Debian Codegraph @

editor/SrvrItem.cpp

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 // SrvrItem.cpp : implementation of the CEditorSrvrItem class
20 //
21
22 #include "stdafx.h"
23 #include "editor.h"
24
25 #include "editorDoc.h"
26 #include "SrvrItem.h"
27
28 #ifdef _DEBUG
29 #define new DEBUG_NEW
30 #undef THIS_FILE
31 static char THIS_FILE[] = __FILE__;
32 #endif
33
34 /////////////////////////////////////////////////////////////////////////////
35 // CEditorSrvrItem implementation
36
37 IMPLEMENT_DYNAMIC(CEditorSrvrItem, COleServerItem)
38
39 CEditorSrvrItem::CEditorSrvrItem(CEditorDoc *pContainerDoc) : COleServerItem(pContainerDoc, TRUE) {
40 // TODO: add one-time construction code here
41 // (eg, adding additional clipboard formats to the item's data source)
42 }
43
44 CEditorSrvrItem::~CEditorSrvrItem() {
45 // TODO: add cleanup code here
46 }
47
48 void CEditorSrvrItem::Serialize(CArchive &ar) {
49 // CEditorSrvrItem::Serialize will be called by the framework if
50 // the item is copied to the clipboard. This can happen automatically
51 // through the OLE callback OnGetClipboardData. A good default for
52 // the embedded item is simply to delegate to the document's Serialize
53 // function. If you support links, then you will want to serialize
54 // just a portion of the document.
55
56 if (!IsLinkedItem()) {
57 CEditorDoc *pDoc = GetDocument();
58 ASSERT_VALID(pDoc);
59 pDoc->Serialize(ar);
60 }
61 }
62
63 BOOL CEditorSrvrItem::OnGetExtent(DVASPECT dwDrawAspect, CSize &rSize) {
64 // Most applications, like this one, only handle drawing the content
65 // aspect of the item. If you wish to support other aspects, such
66 // as DVASPECT_THUMBNAIL (by overriding OnDrawEx), then this
67 // implementation of OnGetExtent should be modified to handle the
68 // additional aspect(s).
69
70 if (dwDrawAspect != DVASPECT_CONTENT)
71 return COleServerItem::OnGetExtent(dwDrawAspect, rSize);
72
73 // CEditorSrvrItem::OnGetExtent is called to get the extent in
74 // HIMETRIC units of the entire item. The default implementation
75 // here simply returns a hard-coded number of units.
76
77 CEditorDoc *pDoc = GetDocument();
78 ASSERT_VALID(pDoc);
79
80 // TODO: replace this arbitrary size
81
82 rSize = CSize(3000, 3000); // 3000 x 3000 HIMETRIC units
83
84 return TRUE;
85 }
86
87 BOOL CEditorSrvrItem::OnDraw(CDC *pDC, CSize &rSize) {
88 // Remove this if you use rSize
89 UNREFERENCED_PARAMETER(rSize);
90
91 CEditorDoc *pDoc = GetDocument();
92 ASSERT_VALID(pDoc);
93
94 // TODO: set mapping mode and extent
95 // (The extent is usually the same as the size returned from OnGetExtent)
96 pDC->SetMapMode(MM_ANISOTROPIC);
97 pDC->SetWindowOrg(0, 0);
98 pDC->SetWindowExt(3000, 3000);
99
100 // TODO: add drawing code here. Optionally, fill in the HIMETRIC extent.
101 // All drawing takes place in the metafile device context (pDC).
102
103 return TRUE;
104 }
105
106 /////////////////////////////////////////////////////////////////////////////
107 // CEditorSrvrItem diagnostics
108
109 #ifdef _DEBUG
110 void CEditorSrvrItem::AssertValid() const { COleServerItem::AssertValid(); }
111
112 void CEditorSrvrItem::Dump(CDumpContext &dc) const { COleServerItem::Dump(dc); }
113 #endif
114
115 /////////////////////////////////////////////////////////////////////////////