-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDRAWOBJ.H
257 lines (194 loc) · 6.97 KB
/
DRAWOBJ.H
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
// drawobj.h - interface for CDrawObj and derivatives
//
// This is a part of the Microsoft Foundation Classes C++ library.
// Copyright (C) 1992-1993 Microsoft Corporation
// All rights reserved.
//
// This source code is only intended as a supplement to the
// Microsoft Foundation Classes Reference and Microsoft
// QuickHelp and/or WinHelp documentation provided with the library.
// See these sources for detailed information regarding the
// Microsoft Foundation Classes product.
#ifndef __DRAWOBJ_H__
#define __DRAWOBJ_H__
class CBaseView;
class CDrawDoc;
#include "mconnect.h"
class AFX_CLASS_EXPORT CNamedObject : public CObject
{
protected:
DECLARE_SERIAL(CNamedObject);
CNamedObject() { m_pObj = NULL; }
public:
~CNamedObject() {}
CString GetName() { return m_sName; }
CObject* GetObj() { return m_pObj; }
void SetObjAndName(CString n, CObject* pObj) {
ASSERT_VALID(pObj);
m_sName = n;
m_pObj = pObj;
}
protected:
CObject* m_pObj;
CString m_sName;
};
/////////////////////////////////////////////////////////////////////////////
// CDrawObj - base class for all 'drawable objects'
class AFX_CLASS_EXPORT CDrawObj : public CMConnect
{
protected:
DECLARE_SERIAL(CDrawObj);
CDrawObj();
// Constructors
public:
CDrawObj(const CRect& position);
// Attributes
enum NetzTyp { Knoten, Kante, KeinNetz };
NetzTyp Netz;
void SetView(CBaseView* p);
void AddViewList(CObList* pList);
void UpDateViews();
void RemoveView(CBaseView* p);
CBaseView* FindHomeView();
CBaseView* FindActiveView();
POSITION FindView(CBaseView* pView);
CObList* GetViewList();
CPoint GetPos(const CRect& rect);
// Übernimmt Fang - Umrechnung
void SetRect(const CRect& rect);
void SetFang(const int f) { Fang = f; };
int GetFang() { return Fang; };
CRect GetRect() { return m_position; };
virtual CRect GetClientRect(CDrawObj* pObj);
CRect InflatedRect(CRect r);
virtual void KillConnections() {};
virtual void SetNumber(const WORD& i) { number = i; };
virtual int GetHandleCount();
virtual CPoint GetHandle(int nHandle);
CRect GetHandleRect(int nHandleID, CBaseView* pView);
virtual HCURSOR GetHandleCursor(int nHandle);
virtual void SetLineColor(COLORREF color);
virtual void SetFillColor(COLORREF color);
// Operations
virtual void Draw(CDC* pDC);
virtual void DrawInClient(CDC* pDC);
CRect CalcClientRect();
BOOL IsDrawInClient();
enum TrackerState { normal, selected, active };
virtual void DrawTracker(CDC* pDC, TrackerState state);
virtual void MoveTo(const CRect& positon, BOOL NurSelbst = FALSE);
virtual int HitTest(CPoint point, CBaseView* pView, BOOL bSelected);
virtual BOOL Intersects(const CRect& rect);
virtual void MoveHandleTo(int nHandle, CPoint point);
virtual void OnOpen(CBaseView* pView);
virtual CDrawObj* Clone(CDrawDoc* pDoc);
void Invalidate();
// Overridables
virtual void OnLButtonDown(CBaseView* pView, UINT nFlags, const CPoint& point);
// ? virtual void OnLButtonDblClk(CBaseView* pView, UINT nFlags, const CPoint& point);
virtual void OnLButtonUp(CBaseView* pView, UINT nFlags, const CPoint& point);
virtual void OnMouseMove(CBaseView* pView, UINT nFlags, const CPoint& point);
virtual void OnCancel();
// Implementation
public:
virtual ~CDrawObj();
virtual void Serialize(CArchive& ar);
#ifdef _DEBUG
void AssertValid();
#endif
// implementation data
private:
CRect m_position;
protected:
BOOL m_bPen;
LOGPEN m_logpen;
BOOL m_bBrush;
LOGBRUSH m_logbrush;
int Fang; // Wird benötigt um Objekte in ein Raster zu "fangen".
WORD number;
BOOL numadded;
BOOL m_bDraw;
CObList m_ViewList;
BOOL m_bObjectChanged;
};
////////////////////////////////////////////////////////////////////////
// specialized draw objects
class AFX_CLASS_EXPORT CDrawRect : public CDrawObj
{
protected:
DECLARE_SERIAL(CDrawRect);
CDrawRect();
public:
CDrawRect(const CRect& position);
void KillConnections();
// Implementation
public:
virtual void Serialize(CArchive& ar);
virtual void Draw(CDC* pDC);
virtual int GetHandleCount();
virtual CPoint GetHandle(int nHandle);
virtual HCURSOR GetHandleCursor(int nHandle);
virtual void MoveHandleTo(int nHandle, CPoint point);
virtual BOOL Intersects(const CRect& rect);
virtual CDrawObj* Clone(CDrawDoc* pDoc, CBaseView* pView);
enum Shape {line, rectangle, roundRectangle, ellipse };
protected:
Shape m_nShape;
CPoint m_roundness; // for roundRect corners
friend class CRectTool;
public:
void SetShape(Shape S) { m_nShape = S; }
};
/////////////////////////////////////////////////////////////////////////////
//class CDrawPoly;
class AFX_CLASS_EXPORT CDrawPoly : public CDrawObj
{
protected:
DECLARE_SERIAL(CDrawPoly);
CDrawPoly();
public:
CDrawPoly(const CRect& position);
// Operations
void AddPoint(const CPoint& point);
BOOL RecalcBounds(CObList* pView);
// Implementation
public:
virtual ~CDrawPoly();
virtual void Serialize(CArchive& ar);
virtual void Draw(CDC* pDC);
virtual void MoveTo(const CRect& positon, BOOL NurSelbst = FALSE);
virtual int GetHandleCount();
virtual CPoint GetHandle(int nHandle);
virtual HCURSOR GetHandleCursor(int nHandle);
virtual void MoveHandleTo(int nHandle, CPoint point);
virtual BOOL Intersects(const CRect& rect);
virtual CDrawObj* Clone(CDrawDoc* pDoc, CBaseView* pView);
// static helper for creating arrays of points
static CPoint* NewPoints(int nPoints);
protected:
int m_nPoints;
int m_nAllocPoints;
CPoint* m_points;
CDrawPoly* m_pDrawObj;
friend class CPolyTool;
};
class CDrawItem; // COleClientItem derived class
class AFX_CLASS_EXPORT CDrawOleObj : public CDrawObj
{
protected:
DECLARE_SERIAL(CDrawOleObj);
CDrawOleObj();
public:
CDrawOleObj(const CRect& position);
// Implementation
public:
virtual void Serialize(CArchive& ar);
virtual void Draw(CDC* pDC);
virtual CDrawObj* Clone(CDrawDoc* pDoc, CBaseView* pView);
virtual void OnOpen(CBaseView* pView);
virtual void MoveTo(const CRect& positon, BOOL NurSelbst = FALSE);
static BOOL c_bShowItems;
CDrawItem* m_pClientItem;
CSize m_extent; // current extent is tracked separate from scaled position
};
#endif // __DRAWOBJ_H__