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