]> git.saurik.com Git - wxWidgets.git/blob - utils/ogl/src/basicp.h
OGL fixes; documentation fixes; dialog editor updates
[wxWidgets.git] / utils / ogl / src / basicp.h
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:
25 wxShapeTextLine(float the_x = 0.0, float the_y = 0.0, const wxString& the_line = "");
26 ~wxShapeTextLine();
27
28 inline float GetX() const { return m_x; }
29 inline float GetY() const { return m_y; }
30
31 inline void SetX(float x) { m_x = x; }
32 inline void SetY(float y) { m_y = y; }
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;
39 float m_x;
40 float m_y;
41 };
42
43 class wxShape;
44 class wxControlPoint: public wxRectangleShape
45 {
46 DECLARE_DYNAMIC_CLASS(wxControlPoint)
47
48 friend class wxShapeEvtHandler;
49 friend class wxShape;
50
51 public:
52 wxControlPoint(wxShapeCanvas *the_canvas = NULL, wxShape *object = NULL, float size = 0.0, float the_xoffset = 0.0,
53 float the_yoffset = 0.0, int the_type = 0);
54 ~wxControlPoint();
55
56 void OnDraw(wxDC& dc);
57 void OnErase(wxDC& dc);
58 void OnDrawContents(wxDC& dc);
59 void OnDragLeft(bool draw, float x, float y, int keys=0, int attachment = 0);
60 void OnBeginDragLeft(float x, float y, int keys=0, int attachment = 0);
61 void OnEndDragLeft(float x, float y, int keys=0, int attachment = 0);
62
63 bool GetAttachmentPosition(int attachment, float *x, float *y,
64 int nth = 0, int no_arcs = 1, wxLineShape *line = NULL);
65 int GetNumberOfAttachments();
66
67 inline void SetEraseObject(bool er) { m_eraseObject = er; }
68
69 public:
70 int m_type;
71 float m_xoffset;
72 float m_yoffset;
73 wxShape* m_shape;
74 wxCursor* m_oldCursor;
75 bool m_eraseObject; // If TRUE, erases object before dragging handle.
76
77 /*
78 * Store original top-left, bottom-right coordinates
79 * in case we're doing non-vertical resizing.
80 */
81 static float controlPointDragStartX;
82 static float controlPointDragStartY;
83 static float controlPointDragStartWidth;
84 static float controlPointDragStartHeight;
85 static float controlPointDragEndWidth;
86 static float controlPointDragEndHeight;
87 static float controlPointDragPosX;
88 static float controlPointDragPosY;
89 };
90
91 class wxPolygonShape;
92 class wxPolygonControlPoint: public wxControlPoint
93 {
94 DECLARE_DYNAMIC_CLASS(wxPolygonControlPoint)
95 friend class wxPolygonShape;
96 public:
97 wxPolygonControlPoint(wxShapeCanvas *the_canvas = NULL, wxShape *object = NULL, float size = 0.0, wxRealPoint *vertex = NULL,
98 float the_xoffset = 0.0, float the_yoffset = 0.0);
99 ~wxPolygonControlPoint();
100
101 void OnDragLeft(bool draw, float x, float y, int keys=0, int attachment = 0);
102 void OnBeginDragLeft(float x, float y, int keys=0, int attachment = 0);
103 void OnEndDragLeft(float x, float y, int keys=0, int attachment = 0);
104
105 public:
106 wxRealPoint* m_polygonVertex;
107 wxRealPoint m_originalSize;
108 float m_originalDistance;
109 };
110
111 /*
112 * Object regions.
113 * Every shape has one or more text regions with various
114 * properties. Not all of a region's properties will be used
115 * by a shape.
116 *
117 */
118
119 class wxShapeRegion: public wxObject
120 {
121 DECLARE_DYNAMIC_CLASS(wxShapeRegion)
122
123 public:
124 // Constructor
125 wxShapeRegion();
126 // Copy constructor
127 wxShapeRegion(wxShapeRegion& region);
128 // Destructor
129 ~wxShapeRegion();
130
131 // Accessors
132 inline void SetText(const wxString& s) { m_regionText = s; }
133 void SetFont(wxFont *f);
134 void SetMinSize(float w, float h);
135 void SetSize(float w, float h);
136 void SetPosition(float x, float y);
137 void SetProportions(float x, float y);
138 void SetFormatMode(int mode);
139 inline void SetName(const wxString& s) { m_regionName = s; };
140 void SetColour(const wxString& col); // Text colour
141
142 inline wxString GetText() const { return m_regionText; }
143 inline wxFont *GetFont() const { return m_font; }
144 inline void GetMinSize(float *x, float *y) const { *x = m_minWidth; *y = m_minHeight; }
145 inline void GetProportion(float *x, float *y) const { *x = m_regionProportionX; *y = m_regionProportionY; }
146 inline void GetSize(float *x, float *y) const { *x = m_width; *y = m_height; }
147 inline void GetPosition(float *xp, float *yp) const { *xp = m_x; *yp = m_y; }
148 inline int GetFormatMode() const { return m_formatMode; }
149 inline wxString GetName() const { return m_regionName; }
150 inline wxString GetColour() const { return m_textColour; }
151 wxColour *GetActualColourObject();
152 inline wxList& GetFormattedText() { return m_formattedText; }
153 inline wxString GetPenColour() const { return m_penColour; }
154 inline int GetPenStyle() const { return m_penStyle; }
155 inline void SetPenStyle(int style) { m_penStyle = style; m_actualPenObject = NULL; }
156 void SetPenColour(const wxString& col);
157 wxPen *GetActualPen();
158 inline float GetWidth() const { return m_width; }
159 inline float GetHeight() const { return m_height; }
160
161 void ClearText();
162
163 public:
164 wxString m_regionText;
165 wxList m_formattedText; // List of wxShapeTextLines
166 wxFont* m_font;
167 float m_minHeight; // If zero, hide region.
168 float m_minWidth; // If zero, hide region.
169 float m_width;
170 float m_height;
171 float m_x;
172 float m_y;
173
174 float m_regionProportionX; // Proportion of total object size;
175 // -1.0 indicates equal proportion
176 float m_regionProportionY; // Proportion of total object size;
177 // -1.0 indicates equal proportion
178
179 int m_formatMode; // FORMAT_CENTRE_HORIZ | FORMAT_CENTRE_VERT | FORMAT_NONE
180 wxString m_regionName;
181 wxString m_textColour;
182 wxColour* m_actualColourObject; // For speed purposes
183
184 // New members for specifying divided rectangle division colour/style 30/6/94
185 wxString m_penColour;
186 int m_penStyle;
187 wxPen* m_actualPenObject;
188
189 };
190
191 /*
192 * User-defined attachment point
193 */
194
195 class wxAttachmentPoint: public wxObject
196 {
197 DECLARE_DYNAMIC_CLASS(wxAttachmentPoint)
198
199 public:
200 inline wxAttachmentPoint()
201 {
202 m_id = 0; m_x = 0.0; m_y = 0.0;
203 }
204
205 public:
206 int m_id; // Identifier
207 float m_x; // x offset from centre of object
208 float m_y; // y offset from centre of object
209 };
210
211 #endif
212 // _OGL_BASICP_H_