1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Private OGL classes and definitions
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _OGL_BASICP_H_
13 #define _OGL_BASICP_H_
15 #if defined(__GNUG__) && !defined(__APPLE__)
16 #pragma interface "basicp.h"
20 #define CONTROL_POINT_SIZE 6
22 class WXDLLIMPEXP_OGL wxShapeTextLine
: public wxObject
24 DECLARE_DYNAMIC_CLASS(wxShapeTextLine
)
26 wxShapeTextLine(double the_x
= 0.0, double the_y
= 0.0, const wxString
& the_line
= wxEmptyString
);
29 inline double GetX() const { return m_x
; }
30 inline double GetY() const { return m_y
; }
32 inline void SetX(double x
) { m_x
= x
; }
33 inline void SetY(double y
) { m_y
= y
; }
35 inline void SetText(const wxString
& text
) { m_line
= text
; }
36 inline wxString
GetText() const { return m_line
; }
44 class WXDLLIMPEXP_OGL wxShape
;
45 class WXDLLIMPEXP_OGL wxControlPoint
: public wxRectangleShape
47 DECLARE_DYNAMIC_CLASS(wxControlPoint
)
49 friend class WXDLLIMPEXP_OGL wxShapeEvtHandler
;
50 friend class WXDLLIMPEXP_OGL wxShape
;
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);
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);
64 bool GetAttachmentPosition(int attachment
, double *x
, double *y
,
65 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
66 int GetNumberOfAttachments() const;
68 inline void SetEraseObject(bool er
) { m_eraseObject
= er
; }
75 wxCursor
* m_oldCursor
;
76 bool m_eraseObject
; // If true, erases object before dragging handle.
79 * Store original top-left, bottom-right coordinates
80 * in case we're doing non-vertical resizing.
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
;
92 class WXDLLIMPEXP_OGL wxPolygonShape
;
93 class WXDLLIMPEXP_OGL wxPolygonControlPoint
: public wxControlPoint
95 DECLARE_DYNAMIC_CLASS(wxPolygonControlPoint
)
96 friend class WXDLLIMPEXP_OGL wxPolygonShape
;
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();
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);
106 // Calculate what new size would be, at end of resize
107 virtual void CalculateNewSize(double x
, double y
);
110 inline wxRealPoint
GetNewSize() const { return m_newSize
; };
113 wxRealPoint
* m_polygonVertex
;
114 wxRealPoint m_originalSize
;
115 double m_originalDistance
;
116 wxRealPoint m_newSize
;
121 * Every shape has one or more text regions with various
122 * properties. Not all of a region's properties will be used
127 class WXDLLIMPEXP_OGL wxShapeRegion
: public wxObject
129 DECLARE_DYNAMIC_CLASS(wxShapeRegion
)
135 wxShapeRegion(wxShapeRegion
& region
);
140 inline void SetText(const wxString
& s
)
141 { m_regionText
= 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
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
; }
173 wxString m_regionText
;
174 wxList m_formattedText
; // List of wxShapeTextLines
176 double m_minHeight
; // If zero, hide region.
177 double m_minWidth
; // If zero, hide region.
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
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
193 // New members for specifying divided rectangle division colour/style 30/6/94
194 wxString m_penColour
;
196 wxPen
* m_actualPenObject
;
201 * User-defined attachment point
204 class WXDLLIMPEXP_OGL wxAttachmentPoint
: public wxObject
206 DECLARE_DYNAMIC_CLASS(wxAttachmentPoint
)
209 inline wxAttachmentPoint()
211 m_id
= 0; m_x
= 0.0; m_y
= 0.0;
213 inline wxAttachmentPoint(int id
, double x
, double y
)
215 m_id
= id
; m_x
= x
; m_y
= y
;
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