]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gdicmn.h
a small cosmetic fix for single choice dialog
[wxWidgets.git] / include / wx / gdicmn.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: gdicmn.h
3 // Purpose: Common GDI classes, types and declarations
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 01/02/97
7 // RCS-ID: $Id$
8 // Copyright: (c)
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_GDICMNH__
13 #define _WX_GDICMNH__
14
15 // ---------------------------------------------------------------------------
16 // headers
17 // ---------------------------------------------------------------------------
18
19 #ifdef __GNUG__
20 #pragma interface "gdicmn.h"
21 #endif
22
23 #include "wx/object.h"
24 #include "wx/list.h"
25 #include "wx/hash.h"
26 #include "wx/string.h"
27 #include "wx/setup.h"
28 #include "wx/colour.h"
29
30 // ---------------------------------------------------------------------------
31 // forward declarations
32 // ---------------------------------------------------------------------------
33
34 class WXDLLEXPORT wxBitmap;
35 class WXDLLEXPORT wxBrush;
36 class WXDLLEXPORT wxColour;
37 class WXDLLEXPORT wxCursor;
38 class WXDLLEXPORT wxFont;
39 class WXDLLEXPORT wxIcon;
40 class WXDLLEXPORT wxPalette;
41 class WXDLLEXPORT wxPen;
42 class WXDLLEXPORT wxRegion;
43 class WXDLLEXPORT wxString;
44
45 // ---------------------------------------------------------------------------
46 // constants
47 // ---------------------------------------------------------------------------
48
49 // Bitmap flags
50 enum
51 {
52 wxBITMAP_TYPE_BMP = 1,
53 wxBITMAP_TYPE_BMP_RESOURCE,
54 wxBITMAP_TYPE_RESOURCE = wxBITMAP_TYPE_BMP_RESOURCE,
55 wxBITMAP_TYPE_ICO,
56 wxBITMAP_TYPE_ICO_RESOURCE,
57 wxBITMAP_TYPE_CUR,
58 wxBITMAP_TYPE_CUR_RESOURCE,
59 wxBITMAP_TYPE_XBM,
60 wxBITMAP_TYPE_XBM_DATA,
61 wxBITMAP_TYPE_XPM,
62 wxBITMAP_TYPE_XPM_DATA,
63 wxBITMAP_TYPE_TIF,
64 wxBITMAP_TYPE_TIF_RESOURCE,
65 wxBITMAP_TYPE_GIF,
66 wxBITMAP_TYPE_GIF_RESOURCE,
67 wxBITMAP_TYPE_PNG,
68 wxBITMAP_TYPE_PNG_RESOURCE,
69 wxBITMAP_TYPE_JPEG,
70 wxBITMAP_TYPE_JPEG_RESOURCE,
71 wxBITMAP_TYPE_ANY = 50
72 };
73
74 // Standard cursors
75 enum wxStockCursor
76 {
77 wxCURSOR_NONE, // should be 0
78 wxCURSOR_ARROW,
79 wxCURSOR_BULLSEYE,
80 wxCURSOR_CHAR,
81 wxCURSOR_CROSS,
82 wxCURSOR_HAND,
83 wxCURSOR_IBEAM,
84 wxCURSOR_LEFT_BUTTON,
85 wxCURSOR_MAGNIFIER,
86 wxCURSOR_MIDDLE_BUTTON,
87 wxCURSOR_NO_ENTRY,
88 wxCURSOR_PAINT_BRUSH,
89 wxCURSOR_PENCIL,
90 wxCURSOR_POINT_LEFT,
91 wxCURSOR_POINT_RIGHT,
92 wxCURSOR_QUESTION_ARROW,
93 wxCURSOR_RIGHT_BUTTON,
94 wxCURSOR_SIZENESW,
95 wxCURSOR_SIZENS,
96 wxCURSOR_SIZENWSE,
97 wxCURSOR_SIZEWE,
98 wxCURSOR_SIZING,
99 wxCURSOR_SPRAYCAN,
100 wxCURSOR_WAIT,
101 wxCURSOR_WATCH,
102 wxCURSOR_BLANK,
103 #ifdef __WXGTK__
104 wxCURSOR_DEFAULT, // standard X11 cursor
105 #endif
106 #ifdef __X__
107 // Not yet implemented for Windows
108 wxCURSOR_CROSS_REVERSE,
109 wxCURSOR_DOUBLE_ARROW,
110 wxCURSOR_BASED_ARROW_UP,
111 wxCURSOR_BASED_ARROW_DOWN,
112 #endif // X11
113
114 wxCURSOR_MAX
115 };
116
117 // ---------------------------------------------------------------------------
118 // macros
119 // ---------------------------------------------------------------------------
120
121 /* Useful macro for creating icons portably, for example:
122
123 wxIcon *icon = new wxICON(mondrian);
124
125 expands into:
126
127 wxIcon *icon = new wxIcon("mondrian"); // On wxMSW
128 wxIcon *icon = new wxIcon(mondrian_xpm); // On wxGTK
129 */
130
131 #ifdef __WXMSW__
132 // Load from a resource
133 #define wxICON(X) wxIcon("" #X "")
134 #elif defined(__WXGTK__)
135 // Initialize from an included XPM
136 #define wxICON(X) wxIcon( (const char**) X##_xpm )
137 #elif defined(__WXMOTIF__)
138 // Initialize from an included XPM
139 #define wxICON(X) wxIcon( X##_xpm )
140 #else
141 // This will usually mean something on any platform
142 #define wxICON(X) wxIcon("" #X "")
143 #endif // platform
144
145 // ===========================================================================
146 // classes
147 // ===========================================================================
148
149 // ---------------------------------------------------------------------------
150 // wxSize
151 // ---------------------------------------------------------------------------
152 class WXDLLEXPORT wxSize
153 {
154 public:
155 // members are public for compatibility (don't use them directly,
156 // especially that there names were chosen very unfortunately - they should
157 // have been called width and height)
158 long x;
159 long y;
160
161 // constructors
162 wxSize() { x = y = 0; }
163 wxSize(long xx, long yy) { Set(xx, yy); }
164
165 // no copy ctor or assignment operator - the defaults are ok
166 bool operator==(const wxSize& sz) const { return x == sz.x && y == sz.y; }
167
168 // FIXME are these really useful? If they're, we should have += &c as well
169 wxSize operator+(const wxSize& sz) { return wxSize(x + sz.x, y + sz.y); }
170 wxSize operator-(const wxSize& sz) { return wxSize(x - sz.x, y - sz.y); }
171
172 // accessors
173 void Set(long xx, long yy) { x = xx; y = yy; }
174 void SetWidth(long w) { x = w; }
175 void SetHeight(long h) { y = h; }
176
177 long GetWidth() const { return x; }
178 long GetHeight() const { return y; }
179
180 // compatibility
181 long GetX() const { return x; }
182 long GetY() const { return y; }
183 };
184
185 // ---------------------------------------------------------------------------
186 // Point classes: with real or integer coordinates
187 // ---------------------------------------------------------------------------
188
189 class WXDLLEXPORT wxRealPoint
190 {
191 public:
192 double x;
193 double y;
194
195 wxRealPoint() { x = y = 0.0; };
196 wxRealPoint(double xx, double yy) { x = xx; y = yy; };
197
198 wxRealPoint operator+(const wxRealPoint& pt) { return wxRealPoint(x + pt.x, y + pt.y); }
199 wxRealPoint operator-(const wxRealPoint& pt) { return wxRealPoint(x - pt.x, y - pt.y); }
200
201 bool operator==(const wxRealPoint& pt) const { return x == pt.x && y == pt.y; }
202 };
203
204 class WXDLLEXPORT wxPoint
205 {
206 public:
207 #if defined(__WXMSW__) && !defined(__WIN32__)
208 int x;
209 int y;
210 #else
211 long x;
212 long y;
213 #endif
214
215 wxPoint() { x = y = 0; };
216 wxPoint(long xx, long yy) { x = xx; y = yy; };
217
218 // no copy ctor or assignment operator - the defaults are ok
219
220 // comparison
221 bool operator==(const wxPoint& p) const { return x == p.x && y == p.y; }
222 bool operator!=(const wxPoint& p) const { return !(*this == p); }
223
224 // arithmetic operations (component wise)
225 wxPoint operator+(const wxPoint& p) { return wxPoint(x + p.x, y + p.y); }
226 wxPoint operator-(const wxPoint& p) { return wxPoint(x - p.x, y - p.y); }
227
228 wxPoint& operator+=(const wxPoint& p) { x += p.x; y += p.y; return *this; }
229 wxPoint& operator-=(const wxPoint& p) { x -= p.x; y -= p.y; return *this; }
230 };
231
232 #if WXWIN_COMPATIBILITY
233 #define wxIntPoint wxPoint
234 #define wxRectangle wxRect
235 #endif // WXWIN_COMPATIBILITY
236
237 // ---------------------------------------------------------------------------
238 // wxRect
239 // ---------------------------------------------------------------------------
240
241 class WXDLLEXPORT wxRect
242 {
243 public:
244 wxRect() { x = y = width = height = 0; }
245 wxRect(long xx, long yy, long ww, long hh)
246 { x = xx; y = yy; width = ww; height = hh; }
247 wxRect(const wxPoint& topLeft, const wxPoint& bottomRight);
248 wxRect(const wxPoint& pos, const wxSize& size);
249
250 // default copy ctor and assignment operators ok
251
252 long GetX() const { return x; }
253 void SetX(long xx) { x = xx; }
254
255 long GetY() const { return y; }
256 void SetY(long yy) { y = yy; }
257
258 long GetWidth() const { return width; }
259 void SetWidth(long w) { width = w; }
260
261 long GetHeight() const { return height; }
262 void SetHeight(long h) { height = h; }
263
264 wxPoint GetPosition() const { return wxPoint(x, y); }
265 wxSize GetSize() const { return wxSize(width, height); }
266
267 long GetLeft() const { return x; }
268 long GetTop() const { return y; }
269 long GetBottom() const { return y + height; }
270 long GetRight() const { return x + width; }
271
272
273 bool operator==(const wxRect& rect) const;
274 bool operator!=(const wxRect& rect) const { return !(*this == rect); }
275
276 bool Inside(int cx, int cy) const;
277 wxRect operator + (const wxRect& rect) const;
278 const wxRect& operator += (const wxRect& rect);
279
280 public:
281 long x, y, width, height;
282 };
283
284 // ---------------------------------------------------------------------------
285 // Management of pens, brushes and fonts
286 // ---------------------------------------------------------------------------
287
288 class WXDLLEXPORT wxPenList : public wxList
289 {
290 DECLARE_DYNAMIC_CLASS(wxPenList)
291
292 public:
293 wxPenList() { }
294 ~wxPenList();
295
296 void AddPen(wxPen *pen);
297 void RemovePen(wxPen *pen);
298 wxPen *FindOrCreatePen(const wxColour& colour, int width, int style);
299 };
300
301 class WXDLLEXPORT wxBrushList : public wxList
302 {
303 DECLARE_DYNAMIC_CLASS(wxBrushList)
304
305 public:
306 wxBrushList() { }
307 ~wxBrushList();
308
309 void AddBrush(wxBrush *brush);
310 void RemoveBrush(wxBrush *brush);
311 wxBrush *FindOrCreateBrush(const wxColour& colour, int style);
312 };
313
314 WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString;
315
316 class WXDLLEXPORT wxFontList : public wxList
317 {
318 DECLARE_DYNAMIC_CLASS(wxFontList)
319
320 public:
321 wxFontList() { }
322 ~wxFontList();
323
324 void AddFont(wxFont *font);
325 void RemoveFont(wxFont *font);
326 wxFont *FindOrCreateFont(int pointSize, int family, int style, int weight,
327 bool underline = FALSE,
328 const wxString& face = wxEmptyString);
329 };
330
331 class WXDLLEXPORT wxColourDatabase : public wxList
332 {
333 DECLARE_CLASS(wxColourDatabase)
334
335 public:
336 wxColourDatabase(int type);
337 ~wxColourDatabase() ;
338
339 // Not const because it may add a name to the database
340 wxColour *FindColour(const wxString& colour) ;
341 wxString FindName(const wxColour& colour) const;
342 void Initialize();
343 };
344
345 class WXDLLEXPORT wxBitmapList : public wxList
346 {
347 DECLARE_DYNAMIC_CLASS(wxBitmapList)
348
349 public:
350 wxBitmapList();
351 ~wxBitmapList();
352
353 void AddBitmap(wxBitmap *bitmap);
354 void RemoveBitmap(wxBitmap *bitmap);
355 };
356
357 class WXDLLEXPORT wxResourceCache: public wxList
358 {
359 public:
360 wxResourceCache() { }
361 wxResourceCache(const unsigned int keyType) : wxList(keyType) { }
362 ~wxResourceCache();
363
364 private:
365 DECLARE_DYNAMIC_CLASS(wxResourceCache)
366 };
367
368 // ---------------------------------------------------------------------------
369 // global variables
370 // ---------------------------------------------------------------------------
371
372 // Lists of GDI objects
373 WXDLLEXPORT_DATA(extern wxPenList*) wxThePenList;
374 WXDLLEXPORT_DATA(extern wxBrushList*) wxTheBrushList;
375 WXDLLEXPORT_DATA(extern wxFontList*) wxTheFontList;
376 WXDLLEXPORT_DATA(extern wxBitmapList*) wxTheBitmapList;
377
378 // Stock objects
379 WXDLLEXPORT_DATA(extern wxFont*) wxNORMAL_FONT;
380 WXDLLEXPORT_DATA(extern wxFont*) wxSMALL_FONT;
381 WXDLLEXPORT_DATA(extern wxFont*) wxITALIC_FONT;
382 WXDLLEXPORT_DATA(extern wxFont*) wxSWISS_FONT;
383
384 WXDLLEXPORT_DATA(extern wxPen*) wxRED_PEN;
385 WXDLLEXPORT_DATA(extern wxPen*) wxCYAN_PEN;
386 WXDLLEXPORT_DATA(extern wxPen*) wxGREEN_PEN;
387 WXDLLEXPORT_DATA(extern wxPen*) wxBLACK_PEN;
388 WXDLLEXPORT_DATA(extern wxPen*) wxWHITE_PEN;
389 WXDLLEXPORT_DATA(extern wxPen*) wxTRANSPARENT_PEN;
390 WXDLLEXPORT_DATA(extern wxPen*) wxBLACK_DASHED_PEN;
391 WXDLLEXPORT_DATA(extern wxPen*) wxGREY_PEN;
392 WXDLLEXPORT_DATA(extern wxPen*) wxMEDIUM_GREY_PEN;
393 WXDLLEXPORT_DATA(extern wxPen*) wxLIGHT_GREY_PEN;
394
395 WXDLLEXPORT_DATA(extern wxBrush*) wxBLUE_BRUSH;
396 WXDLLEXPORT_DATA(extern wxBrush*) wxGREEN_BRUSH;
397 WXDLLEXPORT_DATA(extern wxBrush*) wxWHITE_BRUSH;
398 WXDLLEXPORT_DATA(extern wxBrush*) wxBLACK_BRUSH;
399 WXDLLEXPORT_DATA(extern wxBrush*) wxGREY_BRUSH;
400 WXDLLEXPORT_DATA(extern wxBrush*) wxMEDIUM_GREY_BRUSH;
401 WXDLLEXPORT_DATA(extern wxBrush*) wxLIGHT_GREY_BRUSH;
402 WXDLLEXPORT_DATA(extern wxBrush*) wxTRANSPARENT_BRUSH;
403 WXDLLEXPORT_DATA(extern wxBrush*) wxCYAN_BRUSH;
404 WXDLLEXPORT_DATA(extern wxBrush*) wxRED_BRUSH;
405
406 WXDLLEXPORT_DATA(extern wxColour*) wxBLACK;
407 WXDLLEXPORT_DATA(extern wxColour*) wxWHITE;
408 WXDLLEXPORT_DATA(extern wxColour*) wxRED;
409 WXDLLEXPORT_DATA(extern wxColour*) wxBLUE;
410 WXDLLEXPORT_DATA(extern wxColour*) wxGREEN;
411 WXDLLEXPORT_DATA(extern wxColour*) wxCYAN;
412 WXDLLEXPORT_DATA(extern wxColour*) wxLIGHT_GREY;
413
414 // 'Null' objects
415 WXDLLEXPORT_DATA(extern wxBitmap) wxNullBitmap;
416 WXDLLEXPORT_DATA(extern wxIcon) wxNullIcon;
417 WXDLLEXPORT_DATA(extern wxCursor) wxNullCursor;
418 WXDLLEXPORT_DATA(extern wxPen) wxNullPen;
419 WXDLLEXPORT_DATA(extern wxBrush) wxNullBrush;
420 WXDLLEXPORT_DATA(extern wxPalette) wxNullPalette;
421 WXDLLEXPORT_DATA(extern wxFont) wxNullFont;
422 WXDLLEXPORT_DATA(extern wxColour) wxNullColour;
423
424 // Stock cursors types
425 WXDLLEXPORT_DATA(extern wxCursor*) wxSTANDARD_CURSOR;
426 WXDLLEXPORT_DATA(extern wxCursor*) wxHOURGLASS_CURSOR;
427 WXDLLEXPORT_DATA(extern wxCursor*) wxCROSS_CURSOR;
428
429 WXDLLEXPORT_DATA(extern wxColourDatabase*) wxTheColourDatabase;
430
431 WXDLLEXPORT_DATA(extern const wxChar*) wxPanelNameStr;
432
433 WXDLLEXPORT_DATA(extern const wxSize) wxDefaultSize;
434 WXDLLEXPORT_DATA(extern const wxPoint) wxDefaultPosition;
435
436 // The list of objects which should be deleted
437 WXDLLEXPORT_DATA(extern wxList) wxPendingDelete;
438
439 // ---------------------------------------------------------------------------
440 // global functions
441 // ---------------------------------------------------------------------------
442
443 // resource management
444 extern void WXDLLEXPORT wxInitializeStockObjects();
445 extern void WXDLLEXPORT wxInitializeStockLists();
446 extern void WXDLLEXPORT wxDeleteStockObjects();
447 extern void WXDLLEXPORT wxDeleteStockLists();
448
449 // is the display colour (or monochrome)?
450 extern bool WXDLLEXPORT wxColourDisplay();
451
452 // Returns depth of screen
453 extern int WXDLLEXPORT wxDisplayDepth();
454 #define wxGetDisplayDepth wxDisplayDepth
455
456 // get the diaplay size
457 extern void WXDLLEXPORT wxDisplaySize(int *width, int *height);
458 extern wxSize WXDLLEXPORT wxGetDisplaySize();
459
460 // set global cursor
461 extern void WXDLLEXPORT wxSetCursor(const wxCursor& cursor);
462
463 #endif
464 // _WX_GDICMNH__