Stroika Library 3.0d18
 
Loading...
Searching...
No Matches
LedItServerItem.cpp
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4
5#include "Stroika/Foundation/StroikaPreComp.h"
6
7#include "LedItControlItem.h"
8#include "LedItDocument.h"
9
10#include "LedItServerItem.h"
11
12using namespace Stroika::Foundation;
13using namespace Stroika::Frameworks::Led;
14using namespace Stroika::Frameworks::Led::Platform;
15using namespace Stroika::Frameworks::Led::StyledTextIO;
16
17/*
18 ********************************************************************************
19 ******************************** LedItServerItem *******************************
20 ********************************************************************************
21 */
22IMPLEMENT_DYNAMIC (LedItServerItem, COleServerItem)
23
24LedItServerItem::LedItServerItem (LedItDocument* pContainerDoc)
25 : COleServerItem (pContainerDoc, TRUE)
26{
27 // TODO: add one-time construction code here
28 // (eg, adding additional clipboard formats to the item's data source)
29}
30
31LedItServerItem::~LedItServerItem ()
32{
33}
34
35void LedItServerItem::Serialize (CArchive& ar)
36{
37 // LedItServerItem::Serialize will be called by the framework if
38 // the item is copied to the clipboard. This can happen automatically
39 // through the OLE callback OnGetClipboardData. A good default for
40 // the embedded item is simply to delegate to the document's Serialize
41 // function. If you support links, then you will want to serialize
42 // just a portion of the document.
43 if (!IsLinkedItem ()) {
44 LedItDocument* pDoc = GetDocument ();
45 ASSERT_VALID (pDoc);
46 pDoc->Serialize (ar);
47 }
48}
49
50BOOL LedItServerItem::OnGetExtent (DVASPECT dwDrawAspect, CSize& rSize)
51{
52 // Most applications, like this one, only handle drawing the content
53 // aspect of the item. If you wish to support other aspects, such
54 // as DVASPECT_THUMBNAIL (by overriding OnDrawEx), then this
55 // implementation of OnGetExtent should be modified to handle the
56 // additional aspect(s).
57
58 if (dwDrawAspect != DVASPECT_CONTENT) {
59 return COleServerItem::OnGetExtent (dwDrawAspect, rSize);
60 }
61
62 // LedItServerItem::OnGetExtent is called to get the extent in
63 // HIMETRIC units of the entire item. The default implementation
64 // here simply returns a hard-coded number of units.
65
66 [[maybe_unused]] LedItDocument* pDoc = GetDocument ();
67 ASSERT_VALID (pDoc);
68
69 // TODO: replace this arbitrary size
70
71 rSize = CSize (3000, 3000); // 3000 x 3000 HIMETRIC units
72
73 return TRUE;
74}
75
76BOOL LedItServerItem::OnDraw (CDC* pDC, CSize& /*rSize*/)
77{
78 LedItDocument* pDoc = GetDocument ();
79 ASSERT_VALID (pDoc);
80
81 // TODO: set mapping mode and extent
82 // (The extent is usually the same as the size returned from OnGetExtent)
83 pDC->SetMapMode (MM_ANISOTROPIC);
84 pDC->SetWindowOrg (0, 0);
85 pDC->SetWindowExt (3000, 3000);
86
87 // TODO: add drawing code here. Optionally, fill in the HIMETRIC extent.
88 // All drawing takes place in the metafile device context (pDC).
89
90 // TODO: also draw embedded LedItControlItem objects.
91
92 // The following code draws the first item at an arbitrary position.
93
94 // TODO: remove this code when your real drawing code is complete
95
96 POSITION pos = pDoc->GetStartPosition ();
97 LedItControlItem* pItem = (LedItControlItem*)pDoc->GetNextClientItem (pos);
98 if (pItem != NULL) {
99 pItem->Draw (pDC, CRect (10, 10, 1010, 1010));
100 }
101 return TRUE;
102}
103
104#ifdef _DEBUG
105void LedItServerItem::AssertValid () const
106{
107 COleServerItem::AssertValid ();
108}
109
110void LedItServerItem::Dump (CDumpContext& dc) const
111{
112 COleServerItem::Dump (dc);
113}
114#endif