home *** CD-ROM | disk | FTP | other *** search
/ Mastering MFC Development / MMD.ISO / samples / c07 / tmpgraph / tgrafdoc.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-20  |  2.2 KB  |  90 lines

  1. // TGrafDoc.cpp : implementation of the CTemperatureGraphDoc class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "TmpGraph.h"
  6.  
  7. #include "TGrafDoc.h"
  8.  
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14.  
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CTemperatureGraphDoc
  17.  
  18. IMPLEMENT_DYNCREATE(CTemperatureGraphDoc, CDocument)
  19.  
  20. BEGIN_MESSAGE_MAP(CTemperatureGraphDoc, CDocument)
  21.     //{{AFX_MSG_MAP(CTemperatureGraphDoc)
  22.         // NOTE - the ClassWizard will add and remove mapping macros here.
  23.         //    DO NOT EDIT what you see in these blocks of generated code!
  24.     //}}AFX_MSG_MAP
  25. END_MESSAGE_MAP()
  26.  
  27. /////////////////////////////////////////////////////////////////////////////
  28. // CTemperatureGraphDoc construction/destruction
  29.  
  30. CTemperatureGraphDoc::CTemperatureGraphDoc()
  31. {
  32. }
  33.  
  34. CTemperatureGraphDoc::~CTemperatureGraphDoc()
  35. {
  36. }
  37.  
  38. BOOL CTemperatureGraphDoc::OnNewDocument()
  39. {
  40.     if (!CDocument::OnNewDocument())
  41.         return FALSE;
  42.     // These are defaults. m_month can be changed from a menu.
  43.     // Changing city and year are left as exercises.
  44.     m_month = "January";
  45.     m_year = 1996;
  46.     m_city = "Seattle";
  47.     temps.SetSize(31);
  48.     for (int i = 0; i < temps.GetSize(); i++)
  49.     {
  50.         temps[i].x = i;
  51.         temps[i].y = DEFAULT_TEMPERATURE;
  52.     }
  53.     return TRUE;
  54. }
  55.  
  56. /////////////////////////////////////////////////////////////////////////////
  57. // CTemperatureGraphDoc serialization
  58.  
  59. void CTemperatureGraphDoc::Serialize(CArchive& ar)
  60. {
  61.     // The three simple data members of the document are serialized
  62.     // using the overloaded insertion and extraction operators...
  63.     if( ar.IsStoring() )
  64.         ar << m_month << m_year << m_city;
  65.     else
  66.         ar >> m_month >> m_year >> m_city;
  67.  
  68.     // and the CArray takes care of itself.
  69.     temps.Serialize(ar);
  70.     return;
  71. }
  72.  
  73. /////////////////////////////////////////////////////////////////////////////
  74. // CTemperatureGraphDoc diagnostics
  75.  
  76. #ifdef _DEBUG
  77. void CTemperatureGraphDoc::AssertValid() const
  78. {
  79.     CDocument::AssertValid();
  80. }
  81.  
  82. void CTemperatureGraphDoc::Dump(CDumpContext& dc) const
  83. {
  84.     CDocument::Dump(dc);
  85. }
  86. #endif //_DEBUG
  87.  
  88. /////////////////////////////////////////////////////////////////////////////
  89. // CTemperatureGraphDoc commands
  90.