]>
Commit | Line | Data |
---|---|---|
0fc1a713 JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: basicp.h | |
3 | // Purpose: Private OGL classes and definitions | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 12/07/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _OGL_BASICP_H_ | |
13 | #define _OGL_BASICP_H_ | |
14 | ||
15 | #ifdef __GNUG__ | |
16 | #pragma interface "basicp.h" | |
17 | #endif | |
18 | ||
19 | #define CONTROL_POINT_SIZE 6 | |
20 | ||
21 | class wxShapeTextLine: public wxObject | |
22 | { | |
23 | DECLARE_DYNAMIC_CLASS(wxShapeTextLine) | |
24 | public: | |
42cfaf8c | 25 | wxShapeTextLine(double the_x = 0.0, double the_y = 0.0, const wxString& the_line = ""); |
0fc1a713 JS |
26 | ~wxShapeTextLine(); |
27 | ||
42cfaf8c JS |
28 | inline double GetX() const { return m_x; } |
29 | inline double GetY() const { return m_y; } | |
0fc1a713 | 30 | |
42cfaf8c JS |
31 | inline void SetX(double x) { m_x = x; } |
32 | inline void SetY(double y) { m_y = y; } | |
0fc1a713 JS |
33 | |
34 | inline void SetText(const wxString& text) { m_line = text; } | |
35 | inline wxString GetText() const { return m_line; } | |
36 | ||
37 | protected: | |
38 | wxString m_line; | |
42cfaf8c JS |
39 | double m_x; |
40 | double m_y; | |
0fc1a713 JS |
41 | }; |
42 | ||
2bb0cd28 | 43 | class wxShape; |
0fc1a713 JS |
44 | class wxControlPoint: public wxRectangleShape |
45 | { | |
46 | DECLARE_DYNAMIC_CLASS(wxControlPoint) | |
47 | ||
2bb0cd28 JS |
48 | friend class wxShapeEvtHandler; |
49 | friend class wxShape; | |
50 | ||
0fc1a713 | 51 | public: |
42cfaf8c JS |
52 | wxControlPoint(wxShapeCanvas *the_canvas = NULL, wxShape *object = NULL, double size = 0.0, double the_xoffset = 0.0, |
53 | double the_yoffset = 0.0, int the_type = 0); | |
0fc1a713 JS |
54 | ~wxControlPoint(); |
55 | ||
56 | void OnDraw(wxDC& dc); | |
57 | void OnErase(wxDC& dc); | |
58 | void OnDrawContents(wxDC& dc); | |
42cfaf8c JS |
59 | void OnDragLeft(bool draw, double x, double y, int keys=0, int attachment = 0); |
60 | void OnBeginDragLeft(double x, double y, int keys=0, int attachment = 0); | |
61 | void OnEndDragLeft(double x, double y, int keys=0, int attachment = 0); | |
0fc1a713 | 62 | |
42cfaf8c | 63 | bool GetAttachmentPosition(int attachment, double *x, double *y, |
0fc1a713 | 64 | int nth = 0, int no_arcs = 1, wxLineShape *line = NULL); |
6f5f3ca0 | 65 | int GetNumberOfAttachments() const; |
0fc1a713 JS |
66 | |
67 | inline void SetEraseObject(bool er) { m_eraseObject = er; } | |
68 | ||
69 | public: | |
70 | int m_type; | |
42cfaf8c JS |
71 | double m_xoffset; |
72 | double m_yoffset; | |
0fc1a713 JS |
73 | wxShape* m_shape; |
74 | wxCursor* m_oldCursor; | |
75 | bool m_eraseObject; // If TRUE, erases object before dragging handle. | |
76 | ||
2bb0cd28 JS |
77 | /* |
78 | * Store original top-left, bottom-right coordinates | |
79 | * in case we're doing non-vertical resizing. | |
80 | */ | |
f93ce4da JS |
81 | static double sm_controlPointDragStartX; |
82 | static double sm_controlPointDragStartY; | |
83 | static double sm_controlPointDragStartWidth; | |
84 | static double sm_controlPointDragStartHeight; | |
85 | static double sm_controlPointDragEndWidth; | |
86 | static double sm_controlPointDragEndHeight; | |
87 | static double sm_controlPointDragPosX; | |
88 | static double sm_controlPointDragPosY; | |
0fc1a713 JS |
89 | }; |
90 | ||
2bb0cd28 | 91 | class wxPolygonShape; |
0fc1a713 JS |
92 | class wxPolygonControlPoint: public wxControlPoint |
93 | { | |
94 | DECLARE_DYNAMIC_CLASS(wxPolygonControlPoint) | |
2bb0cd28 | 95 | friend class wxPolygonShape; |
0fc1a713 | 96 | public: |
42cfaf8c JS |
97 | wxPolygonControlPoint(wxShapeCanvas *the_canvas = NULL, wxShape *object = NULL, double size = 0.0, wxRealPoint *vertex = NULL, |
98 | double the_xoffset = 0.0, double the_yoffset = 0.0); | |
0fc1a713 JS |
99 | ~wxPolygonControlPoint(); |
100 | ||
42cfaf8c JS |
101 | void OnDragLeft(bool draw, double x, double y, int keys=0, int attachment = 0); |
102 | void OnBeginDragLeft(double x, double y, int keys=0, int attachment = 0); | |
103 | void OnEndDragLeft(double x, double y, int keys=0, int attachment = 0); | |
0fc1a713 | 104 | |
34138703 | 105 | // Calculate what new size would be, at end of resize |
42cfaf8c | 106 | virtual void CalculateNewSize(double x, double y); |
34138703 JS |
107 | |
108 | // Get new size | |
109 | inline wxRealPoint GetNewSize() const { return m_newSize; }; | |
110 | ||
0fc1a713 JS |
111 | public: |
112 | wxRealPoint* m_polygonVertex; | |
113 | wxRealPoint m_originalSize; | |
42cfaf8c | 114 | double m_originalDistance; |
34138703 | 115 | wxRealPoint m_newSize; |
0fc1a713 JS |
116 | }; |
117 | ||
118 | /* | |
119 | * Object regions. | |
120 | * Every shape has one or more text regions with various | |
121 | * properties. Not all of a region's properties will be used | |
122 | * by a shape. | |
123 | * | |
124 | */ | |
125 | ||
126 | class wxShapeRegion: public wxObject | |
127 | { | |
128 | DECLARE_DYNAMIC_CLASS(wxShapeRegion) | |
129 | ||
130 | public: | |
131 | // Constructor | |
132 | wxShapeRegion(); | |
133 | // Copy constructor | |
134 | wxShapeRegion(wxShapeRegion& region); | |
135 | // Destructor | |
136 | ~wxShapeRegion(); | |
137 | ||
138 | // Accessors | |
139 | inline void SetText(const wxString& s) { m_regionText = s; } | |
140 | void SetFont(wxFont *f); | |
42cfaf8c JS |
141 | void SetMinSize(double w, double h); |
142 | void SetSize(double w, double h); | |
143 | void SetPosition(double x, double y); | |
144 | void SetProportions(double x, double y); | |
0fc1a713 JS |
145 | void SetFormatMode(int mode); |
146 | inline void SetName(const wxString& s) { m_regionName = s; }; | |
147 | void SetColour(const wxString& col); // Text colour | |
148 | ||
149 | inline wxString GetText() const { return m_regionText; } | |
150 | inline wxFont *GetFont() const { return m_font; } | |
42cfaf8c JS |
151 | inline void GetMinSize(double *x, double *y) const { *x = m_minWidth; *y = m_minHeight; } |
152 | inline void GetProportion(double *x, double *y) const { *x = m_regionProportionX; *y = m_regionProportionY; } | |
153 | inline void GetSize(double *x, double *y) const { *x = m_width; *y = m_height; } | |
154 | inline void GetPosition(double *xp, double *yp) const { *xp = m_x; *yp = m_y; } | |
0fc1a713 JS |
155 | inline int GetFormatMode() const { return m_formatMode; } |
156 | inline wxString GetName() const { return m_regionName; } | |
157 | inline wxString GetColour() const { return m_textColour; } | |
158 | wxColour *GetActualColourObject(); | |
159 | inline wxList& GetFormattedText() { return m_formattedText; } | |
160 | inline wxString GetPenColour() const { return m_penColour; } | |
161 | inline int GetPenStyle() const { return m_penStyle; } | |
162 | inline void SetPenStyle(int style) { m_penStyle = style; m_actualPenObject = NULL; } | |
163 | void SetPenColour(const wxString& col); | |
164 | wxPen *GetActualPen(); | |
42cfaf8c JS |
165 | inline double GetWidth() const { return m_width; } |
166 | inline double GetHeight() const { return m_height; } | |
0fc1a713 JS |
167 | |
168 | void ClearText(); | |
169 | ||
170 | public: | |
171 | wxString m_regionText; | |
172 | wxList m_formattedText; // List of wxShapeTextLines | |
173 | wxFont* m_font; | |
42cfaf8c JS |
174 | double m_minHeight; // If zero, hide region. |
175 | double m_minWidth; // If zero, hide region. | |
176 | double m_width; | |
177 | double m_height; | |
178 | double m_x; | |
179 | double m_y; | |
180 | ||
181 | double m_regionProportionX; // Proportion of total object size; | |
0fc1a713 | 182 | // -1.0 indicates equal proportion |
42cfaf8c | 183 | double m_regionProportionY; // Proportion of total object size; |
0fc1a713 JS |
184 | // -1.0 indicates equal proportion |
185 | ||
186 | int m_formatMode; // FORMAT_CENTRE_HORIZ | FORMAT_CENTRE_VERT | FORMAT_NONE | |
187 | wxString m_regionName; | |
188 | wxString m_textColour; | |
189 | wxColour* m_actualColourObject; // For speed purposes | |
190 | ||
191 | // New members for specifying divided rectangle division colour/style 30/6/94 | |
192 | wxString m_penColour; | |
193 | int m_penStyle; | |
194 | wxPen* m_actualPenObject; | |
195 | ||
196 | }; | |
197 | ||
198 | /* | |
199 | * User-defined attachment point | |
200 | */ | |
201 | ||
202 | class wxAttachmentPoint: public wxObject | |
203 | { | |
204 | DECLARE_DYNAMIC_CLASS(wxAttachmentPoint) | |
205 | ||
206 | public: | |
207 | inline wxAttachmentPoint() | |
208 | { | |
209 | m_id = 0; m_x = 0.0; m_y = 0.0; | |
210 | } | |
42cfaf8c JS |
211 | inline wxAttachmentPoint(int id, double x, double y) |
212 | { | |
213 | m_id = id; m_x = x; m_y = y; | |
214 | } | |
0fc1a713 JS |
215 | |
216 | public: | |
42cfaf8c JS |
217 | int m_id; // Identifier |
218 | double m_x; // x offset from centre of object | |
219 | double m_y; // y offset from centre of object | |
0fc1a713 JS |
220 | }; |
221 | ||
222 | #endif | |
223 | // _OGL_BASICP_H_ |