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