Alientech 0.01
An extendable game engine
C:/Alientech/AlienPlanets/AlienPlanetsDoc.cpp
Go to the documentation of this file.
00001 
00002 // AlienPlanetsDoc.cpp : implementation of the CAlienPlanetsDoc class
00003 //
00004 
00005 #include "stdafx.h"
00006 // SHARED_HANDLERS can be defined in an ATL project implementing preview, thumbnail
00007 // and search filter handlers and allows sharing of document code with that project.
00008 #ifndef SHARED_HANDLERS
00009 #include "AlienPlanets.h"
00010 #endif
00011 
00012 #include "AlienPlanetsDoc.h"
00013 #include "CntrItem.h"
00014 
00015 #include <propkey.h>
00016 
00017 #ifdef _DEBUG
00018 #define new DEBUG_NEW
00019 #endif
00020 
00021 // CAlienPlanetsDoc
00022 
00023 IMPLEMENT_DYNCREATE(CAlienPlanetsDoc, COleDocument)
00024 
00025 BEGIN_MESSAGE_MAP(CAlienPlanetsDoc, COleDocument)
00026         // Enable default OLE container implementation
00027         ON_UPDATE_COMMAND_UI(ID_EDIT_PASTE, &COleDocument::OnUpdatePasteMenu)
00028         ON_UPDATE_COMMAND_UI(ID_EDIT_PASTE_LINK, &COleDocument::OnUpdatePasteLinkMenu)
00029         ON_UPDATE_COMMAND_UI(ID_OLE_EDIT_CONVERT, &COleDocument::OnUpdateObjectVerbMenu)
00030         ON_COMMAND(ID_OLE_EDIT_CONVERT, &COleDocument::OnEditConvert)
00031         ON_UPDATE_COMMAND_UI(ID_OLE_EDIT_LINKS, &COleDocument::OnUpdateEditLinksMenu)
00032         ON_COMMAND(ID_OLE_EDIT_LINKS, &COleDocument::OnEditLinks)
00033         ON_UPDATE_COMMAND_UI_RANGE(ID_OLE_VERB_FIRST, ID_OLE_VERB_LAST, &COleDocument::OnUpdateObjectVerbMenu)
00034 END_MESSAGE_MAP()
00035 
00036 BEGIN_DISPATCH_MAP(CAlienPlanetsDoc, COleDocument)
00037 END_DISPATCH_MAP()
00038 
00039 // Note: we add support for IID_IAlienPlanets to support typesafe binding
00040 //  from VBA.  This IID must match the GUID that is attached to the 
00041 //  dispinterface in the .IDL file.
00042 
00043 // {216325ED-8E12-4F6E-9966-C5E859949A84}
00044 static const IID IID_IAlienPlanets =
00045 { 0x216325ED, 0x8E12, 0x4F6E, { 0x99, 0x66, 0xC5, 0xE8, 0x59, 0x94, 0x9A, 0x84 } };
00046 
00047 BEGIN_INTERFACE_MAP(CAlienPlanetsDoc, COleDocument)
00048         INTERFACE_PART(CAlienPlanetsDoc, IID_IAlienPlanets, Dispatch)
00049 END_INTERFACE_MAP()
00050 
00051 
00052 // CAlienPlanetsDoc construction/destruction
00053 
00054 CAlienPlanetsDoc::CAlienPlanetsDoc()
00055 {
00056         // TODO: add one-time construction code here
00057 
00058         EnableAutomation();
00059 
00060         AfxOleLockApp();
00061 }
00062 
00063 CAlienPlanetsDoc::~CAlienPlanetsDoc()
00064 {
00065         AfxOleUnlockApp();
00066 }
00067 
00068 BOOL CAlienPlanetsDoc::OnNewDocument()
00069 {
00070         if (!COleDocument::OnNewDocument())
00071                 return FALSE;
00072 
00073         // TODO: add reinitialization code here
00074         // (SDI documents will reuse this document)
00075 
00076         return TRUE;
00077 }
00078 
00079 
00080 
00081 
00082 // CAlienPlanetsDoc serialization
00083 
00084 void CAlienPlanetsDoc::Serialize(CArchive& ar)
00085 {
00086         if (ar.IsStoring())
00087         {
00088                 // TODO: add storing code here
00089         }
00090         else
00091         {
00092                 // TODO: add loading code here
00093         }
00094 
00095         // Calling the base class COleDocument enables serialization
00096         //  of the container document's COleClientItem objects.
00097         COleDocument::Serialize(ar);
00098 }
00099 
00100 #ifdef SHARED_HANDLERS
00101 
00102 // Support for thumbnails
00103 void CAlienPlanetsDoc::OnDrawThumbnail(CDC& dc, LPRECT lprcBounds)
00104 {
00105         // Modify this code to draw the document's data
00106         dc.FillSolidRect(lprcBounds, RGB(255, 255, 255));
00107 
00108         CString strText = _T("TODO: implement thumbnail drawing here");
00109         LOGFONT lf;
00110 
00111         CFont* pDefaultGUIFont = CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT));
00112         pDefaultGUIFont->GetLogFont(&lf);
00113         lf.lfHeight = 36;
00114 
00115         CFont fontDraw;
00116         fontDraw.CreateFontIndirect(&lf);
00117 
00118         CFont* pOldFont = dc.SelectObject(&fontDraw);
00119         dc.DrawText(strText, lprcBounds, DT_CENTER | DT_WORDBREAK);
00120         dc.SelectObject(pOldFont);
00121 }
00122 
00123 // Support for Search Handlers
00124 void CAlienPlanetsDoc::InitializeSearchContent()
00125 {
00126         CString strSearchContent;
00127         // Set search contents from document's data. 
00128         // The content parts should be separated by ";"
00129 
00130         // For example:  strSearchContent = _T("point;rectangle;circle;ole object;");
00131         SetSearchContent(strSearchContent);
00132 }
00133 
00134 void CAlienPlanetsDoc::SetSearchContent(const CString& value)
00135 {
00136         if (value.IsEmpty())
00137         {
00138                 RemoveChunk(PKEY_Search_Contents.fmtid, PKEY_Search_Contents.pid);
00139         }
00140         else
00141         {
00142                 CMFCFilterChunkValueImpl *pChunk = NULL;
00143                 ATLTRY(pChunk = new CMFCFilterChunkValueImpl);
00144                 if (pChunk != NULL)
00145                 {
00146                         pChunk->SetTextValue(PKEY_Search_Contents, value, CHUNK_TEXT);
00147                         SetChunkValue(pChunk);
00148                 }
00149         }
00150 }
00151 
00152 #endif // SHARED_HANDLERS
00153 
00154 // CAlienPlanetsDoc diagnostics
00155 
00156 #ifdef _DEBUG
00157 void CAlienPlanetsDoc::AssertValid() const
00158 {
00159         COleDocument::AssertValid();
00160 }
00161 
00162 void CAlienPlanetsDoc::Dump(CDumpContext& dc) const
00163 {
00164         COleDocument::Dump(dc);
00165 }
00166 #endif //_DEBUG
00167 
00168 
00169 // CAlienPlanetsDoc commands