1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Common GDI classes, types and declarations
4 // Author: Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
16 #pragma interface "gdicmn.h"
19 #include "wx/object.h"
22 #include "wx/string.h"
24 #include "wx/colour.h"
37 wxCURSOR_MIDDLE_BUTTON
,
43 wxCURSOR_QUESTION_ARROW
,
44 wxCURSOR_RIGHT_BUTTON
,
55 /* Not yet implemented for Windows */
56 , wxCURSOR_CROSS_REVERSE
,
57 wxCURSOR_DOUBLE_ARROW
,
58 wxCURSOR_BASED_ARROW_UP
,
59 wxCURSOR_BASED_ARROW_DOWN
63 class WXDLLEXPORT wxSize
68 inline wxSize() { x
= 0; y
= 0; }
69 inline wxSize(long xx
, long yy
) { x
= xx
; y
= yy
; }
70 inline wxSize(const wxSize
& sz
) { x
= sz
.x
; y
= sz
.y
; }
71 inline void operator = (const wxSize
& sz
) { x
= sz
.x
; y
= sz
.y
; }
72 inline bool operator == (const wxSize
& sz
) const { return (x
== sz
.x
&& y
== sz
.y
); }
73 inline wxSize
operator + (const wxSize
& sz
) { return wxSize(x
+ sz
.x
, y
+ sz
.y
); }
74 inline wxSize
operator - (const wxSize
& sz
) { return wxSize(x
- sz
.x
, y
- sz
.y
); }
75 inline void Set(long xx
, long yy
) { x
= xx
; y
= yy
; }
76 inline long GetX() const { return x
; }
77 inline long GetY() const { return y
; }
81 class WXDLLEXPORT wxRealPoint
86 inline wxRealPoint() { x
= 0.0; y
= 0.0; };
87 inline wxRealPoint(double _x
, double _y
) { x
= _x
; y
= _y
; };
88 inline wxRealPoint
operator + (const wxRealPoint
& pt
) { return wxRealPoint(x
+ pt
.x
, y
+ pt
.y
); }
89 inline wxRealPoint
operator - (const wxRealPoint
& pt
) { return wxRealPoint(x
- pt
.x
, y
- pt
.y
); }
91 inline void operator = (const wxRealPoint
& pt
) { x
= pt
.x
; y
= pt
.y
; }
92 inline bool operator == (const wxRealPoint
& pt
) const { return (x
== pt
.x
&& y
== pt
.y
); }
95 class WXDLLEXPORT wxPoint
98 #if defined(__WXMSW__) && !defined(__WIN32__)
106 inline wxPoint() { x
= 0; y
= 0; };
107 wxPoint(long the_x
, long the_y
) { x
= the_x
; y
= the_y
; };
108 wxPoint(const wxPoint
& pt
) { x
= pt
.x
; y
= pt
.y
; };
110 inline void operator = (const wxPoint
& pt
) { x
= pt
.x
; y
= pt
.y
; }
111 inline bool operator == (const wxPoint
& pt
) const { return (x
== pt
.x
&& y
== pt
.y
); }
112 inline wxPoint
operator + (const wxPoint
& pt
) { return wxPoint(x
+ pt
.x
, y
+ pt
.y
); }
113 inline wxPoint
operator - (const wxPoint
& pt
) { return wxPoint(x
- pt
.x
, y
- pt
.y
); }
116 #if WXWIN_COMPATIBILITY
117 #define wxIntPoint wxPoint
118 #define wxRectangle wxRect
121 class WXDLLEXPORT wxRect
125 wxRect(long x
, long y
, long w
, long h
);
126 wxRect(const wxPoint
& topLeft
, const wxPoint
& bottomRight
);
127 wxRect(const wxPoint
& pos
, const wxSize
& size
);
128 wxRect(const wxRect
& rect
);
130 inline long GetX() const { return x
; }
131 inline void SetX(long X
) { x
= X
; }
132 inline long GetY() const { return y
; }
133 inline void SetY(long Y
) { y
= Y
; }
134 inline long GetWidth() const { return width
; }
135 inline void SetWidth(long w
) { width
= w
; }
136 inline long GetHeight() const { return height
; }
137 inline void SetHeight(long h
) { height
= h
; }
139 inline wxPoint
GetPosition() { return wxPoint(x
, y
); }
140 inline wxSize
GetSize() { return wxSize(width
, height
); }
142 inline long GetLeft() const { return x
; }
143 inline long GetTop() const { return y
; }
144 inline long GetBottom() const { return y
+ height
; }
145 inline long GetRight() const { return x
+ width
; }
147 wxRect
& operator = (const wxRect
& rect
);
148 bool operator == (const wxRect
& rect
);
149 bool operator != (const wxRect
& rect
);
151 long x
, y
, width
, height
;
154 class WXDLLEXPORT wxBrush
;
155 class WXDLLEXPORT wxPen
;
156 class WXDLLEXPORT wxBitmap
;
157 class WXDLLEXPORT wxIcon
;
158 class WXDLLEXPORT wxCursor
;
159 class WXDLLEXPORT wxFont
;
160 class WXDLLEXPORT wxPalette
;
161 class WXDLLEXPORT wxPalette
;
162 class WXDLLEXPORT wxRegion
;
168 // Hint to indicate filetype
169 #define wxBITMAP_TYPE_BMP 1
170 #define wxBITMAP_TYPE_BMP_RESOURCE 2
171 #define wxBITMAP_TYPE_ICO 3
172 #define wxBITMAP_TYPE_ICO_RESOURCE 4
173 #define wxBITMAP_TYPE_CUR 5
174 #define wxBITMAP_TYPE_CUR_RESOURCE 6
175 #define wxBITMAP_TYPE_XBM 7
176 #define wxBITMAP_TYPE_XBM_DATA 8
177 #define wxBITMAP_TYPE_XPM 9
178 #define wxBITMAP_TYPE_XPM_DATA 10
179 #define wxBITMAP_TYPE_TIF 11
180 #define wxBITMAP_TYPE_TIF_RESOURCE 12
181 #define wxBITMAP_TYPE_GIF 13
182 #define wxBITMAP_TYPE_GIF_RESOURCE 14
183 #define wxBITMAP_TYPE_PNG 15
184 #define wxBITMAP_TYPE_PNG_RESOURCE 16
185 #define wxBITMAP_TYPE_JPEG 17
186 #define wxBITMAP_TYPE_JPEG_RESOURCE 18
187 #define wxBITMAP_TYPE_ANY 50
189 #define wxBITMAP_TYPE_RESOURCE wxBITMAP_TYPE_BMP_RESOURCE
191 class WXDLLEXPORT wxBitmap
;
192 class WXDLLEXPORT wxCursor
;
193 class WXDLLEXPORT wxIcon
;
194 class WXDLLEXPORT wxColour
;
195 class WXDLLEXPORT wxString
;
197 // Management of pens, brushes and fonts
198 class WXDLLEXPORT wxPenList
: public wxList
200 DECLARE_DYNAMIC_CLASS(wxPenList
)
205 void AddPen(wxPen
*pen
);
206 void RemovePen(wxPen
*pen
);
207 wxPen
*FindOrCreatePen(const wxColour
& colour
, int width
, int style
);
210 class WXDLLEXPORT wxBrushList
: public wxList
212 DECLARE_DYNAMIC_CLASS(wxBrushList
)
217 void AddBrush(wxBrush
*brush
);
218 void RemoveBrush(wxBrush
*brush
);
219 wxBrush
*FindOrCreateBrush(const wxColour
& colour
, int style
);
222 WXDLLEXPORT_DATA(extern const wxChar
*) wxEmptyString
;
224 class WXDLLEXPORT wxFontList
: public wxList
226 DECLARE_DYNAMIC_CLASS(wxFontList
)
231 void AddFont(wxFont
*font
);
232 void RemoveFont(wxFont
*font
);
233 wxFont
*FindOrCreateFont(int pointSize
, int family
, int style
, int weight
,
234 bool underline
= FALSE
, const wxString
& face
= wxEmptyString
);
237 class WXDLLEXPORT wxColourDatabase
: public wxList
239 DECLARE_CLASS(wxColourDatabase
)
241 wxColourDatabase(int type
);
242 ~wxColourDatabase() ;
243 // Not const because it may add a name to the database
244 wxColour
*FindColour(const wxString
& colour
) ;
245 wxString
FindName(const wxColour
& colour
) const;
249 class WXDLLEXPORT wxBitmapList
: public wxList
251 DECLARE_DYNAMIC_CLASS(wxBitmapList
)
256 void AddBitmap(wxBitmap
*bitmap
);
257 void RemoveBitmap(wxBitmap
*bitmap
);
260 // Lists of GDI objects
261 WXDLLEXPORT_DATA(extern wxPenList
*) wxThePenList
;
262 WXDLLEXPORT_DATA(extern wxBrushList
*) wxTheBrushList
;
263 WXDLLEXPORT_DATA(extern wxFontList
*) wxTheFontList
;
264 WXDLLEXPORT_DATA(extern wxBitmapList
*) wxTheBitmapList
;
267 WXDLLEXPORT_DATA(extern wxFont
*) wxNORMAL_FONT
;
268 WXDLLEXPORT_DATA(extern wxFont
*) wxSMALL_FONT
;
269 WXDLLEXPORT_DATA(extern wxFont
*) wxITALIC_FONT
;
270 WXDLLEXPORT_DATA(extern wxFont
*) wxSWISS_FONT
;
272 WXDLLEXPORT_DATA(extern wxPen
*) wxRED_PEN
;
273 WXDLLEXPORT_DATA(extern wxPen
*) wxCYAN_PEN
;
274 WXDLLEXPORT_DATA(extern wxPen
*) wxGREEN_PEN
;
275 WXDLLEXPORT_DATA(extern wxPen
*) wxBLACK_PEN
;
276 WXDLLEXPORT_DATA(extern wxPen
*) wxWHITE_PEN
;
277 WXDLLEXPORT_DATA(extern wxPen
*) wxTRANSPARENT_PEN
;
278 WXDLLEXPORT_DATA(extern wxPen
*) wxBLACK_DASHED_PEN
;
279 WXDLLEXPORT_DATA(extern wxPen
*) wxGREY_PEN
;
280 WXDLLEXPORT_DATA(extern wxPen
*) wxMEDIUM_GREY_PEN
;
281 WXDLLEXPORT_DATA(extern wxPen
*) wxLIGHT_GREY_PEN
;
283 WXDLLEXPORT_DATA(extern wxBrush
*) wxBLUE_BRUSH
;
284 WXDLLEXPORT_DATA(extern wxBrush
*) wxGREEN_BRUSH
;
285 WXDLLEXPORT_DATA(extern wxBrush
*) wxWHITE_BRUSH
;
286 WXDLLEXPORT_DATA(extern wxBrush
*) wxBLACK_BRUSH
;
287 WXDLLEXPORT_DATA(extern wxBrush
*) wxGREY_BRUSH
;
288 WXDLLEXPORT_DATA(extern wxBrush
*) wxMEDIUM_GREY_BRUSH
;
289 WXDLLEXPORT_DATA(extern wxBrush
*) wxLIGHT_GREY_BRUSH
;
290 WXDLLEXPORT_DATA(extern wxBrush
*) wxTRANSPARENT_BRUSH
;
291 WXDLLEXPORT_DATA(extern wxBrush
*) wxCYAN_BRUSH
;
292 WXDLLEXPORT_DATA(extern wxBrush
*) wxRED_BRUSH
;
294 WXDLLEXPORT_DATA(extern wxColour
*) wxBLACK
;
295 WXDLLEXPORT_DATA(extern wxColour
*) wxWHITE
;
296 WXDLLEXPORT_DATA(extern wxColour
*) wxRED
;
297 WXDLLEXPORT_DATA(extern wxColour
*) wxBLUE
;
298 WXDLLEXPORT_DATA(extern wxColour
*) wxGREEN
;
299 WXDLLEXPORT_DATA(extern wxColour
*) wxCYAN
;
300 WXDLLEXPORT_DATA(extern wxColour
*) wxLIGHT_GREY
;
303 WXDLLEXPORT_DATA(extern wxBitmap
) wxNullBitmap
;
304 WXDLLEXPORT_DATA(extern wxIcon
) wxNullIcon
;
305 WXDLLEXPORT_DATA(extern wxCursor
) wxNullCursor
;
306 WXDLLEXPORT_DATA(extern wxPen
) wxNullPen
;
307 WXDLLEXPORT_DATA(extern wxBrush
) wxNullBrush
;
308 WXDLLEXPORT_DATA(extern wxPalette
) wxNullPalette
;
309 WXDLLEXPORT_DATA(extern wxFont
) wxNullFont
;
310 WXDLLEXPORT_DATA(extern wxColour
) wxNullColour
;
312 // Stock cursors types
313 WXDLLEXPORT_DATA(extern wxCursor
*) wxSTANDARD_CURSOR
;
314 WXDLLEXPORT_DATA(extern wxCursor
*) wxHOURGLASS_CURSOR
;
315 WXDLLEXPORT_DATA(extern wxCursor
*) wxCROSS_CURSOR
;
317 WXDLLEXPORT_DATA(extern wxColourDatabase
*) wxTheColourDatabase
;
318 extern void WXDLLEXPORT
wxInitializeStockObjects();
319 extern void WXDLLEXPORT
wxInitializeStockLists();
320 extern void WXDLLEXPORT
wxDeleteStockObjects();
321 extern void WXDLLEXPORT
wxDeleteStockLists();
323 extern bool WXDLLEXPORT
wxColourDisplay();
325 // Returns depth of screen
326 extern int WXDLLEXPORT
wxDisplayDepth();
327 #define wxGetDisplayDepth wxDisplayDepth
329 extern void WXDLLEXPORT
wxDisplaySize(int *width
, int *height
);
330 extern wxSize WXDLLEXPORT
wxGetDisplaySize();
332 extern void WXDLLEXPORT
wxSetCursor(const wxCursor
& cursor
);
334 // Useful macro for creating icons portably
337 // Load from a resource
338 # define wxICON(X) wxIcon("" #X "")
340 #elif defined(__WXGTK__)
341 // Initialize from an included XPM
342 # define wxICON(X) wxIcon( (const char**) X##_xpm )
343 #elif defined(__WXMOTIF__)
344 // Initialize from an included XPM
345 # define wxICON(X) wxIcon( X##_xpm )
348 // This will usually mean something on any platform
349 # define wxICON(X) wxIcon("" #X "")
354 wxIcon *icon = new wxICON(mondrian);
356 wxIcon *icon = new wxIcon("mondrian"); // On wxMSW
357 wxIcon *icon = new wxIcon(mondrian_xpm); // On wxGTK
360 class WXDLLEXPORT wxResourceCache
: public wxList
363 wxResourceCache() { }
364 wxResourceCache(const unsigned int keyType
) : wxList(keyType
) { }
368 DECLARE_DYNAMIC_CLASS(wxResourceCache
)