rename Inside(x,y) parameters to avoid gcc warnings about parameters shadowing member...
[wxWidgets.git] / include / wx / gdicmn.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/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) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_GDICMNH__
13 #define _WX_GDICMNH__
14
15 // ---------------------------------------------------------------------------
16 // headers
17 // ---------------------------------------------------------------------------
18
19 #include "wx/defs.h"
20 #include "wx/list.h"
21 #include "wx/string.h"
22 #include "wx/fontenc.h"
23 #include "wx/hashmap.h"
24 #include "wx/math.h"
25
26 // ---------------------------------------------------------------------------
27 // forward declarations
28 // ---------------------------------------------------------------------------
29
30 class WXDLLIMPEXP_CORE wxBitmap;
31 class WXDLLIMPEXP_CORE wxBrush;
32 class WXDLLIMPEXP_CORE wxColour;
33 class WXDLLIMPEXP_CORE wxCursor;
34 class WXDLLIMPEXP_CORE wxFont;
35 class WXDLLIMPEXP_CORE wxIcon;
36 class WXDLLIMPEXP_CORE wxPalette;
37 class WXDLLIMPEXP_CORE wxPen;
38 class WXDLLIMPEXP_CORE wxRegion;
39 class WXDLLIMPEXP_BASE wxString;
40
41 // ---------------------------------------------------------------------------
42 // constants
43 // ---------------------------------------------------------------------------
44
45 // Bitmap flags
46 enum wxBitmapType
47 {
48 wxBITMAP_TYPE_INVALID, // should be == 0 for compatibility!
49 wxBITMAP_TYPE_BMP,
50 wxBITMAP_TYPE_BMP_RESOURCE,
51 wxBITMAP_TYPE_RESOURCE = wxBITMAP_TYPE_BMP_RESOURCE,
52 wxBITMAP_TYPE_ICO,
53 wxBITMAP_TYPE_ICO_RESOURCE,
54 wxBITMAP_TYPE_CUR,
55 wxBITMAP_TYPE_CUR_RESOURCE,
56 wxBITMAP_TYPE_XBM,
57 wxBITMAP_TYPE_XBM_DATA,
58 wxBITMAP_TYPE_XPM,
59 wxBITMAP_TYPE_XPM_DATA,
60 wxBITMAP_TYPE_TIF,
61 wxBITMAP_TYPE_TIF_RESOURCE,
62 wxBITMAP_TYPE_GIF,
63 wxBITMAP_TYPE_GIF_RESOURCE,
64 wxBITMAP_TYPE_PNG,
65 wxBITMAP_TYPE_PNG_RESOURCE,
66 wxBITMAP_TYPE_JPEG,
67 wxBITMAP_TYPE_JPEG_RESOURCE,
68 wxBITMAP_TYPE_PNM,
69 wxBITMAP_TYPE_PNM_RESOURCE,
70 wxBITMAP_TYPE_PCX,
71 wxBITMAP_TYPE_PCX_RESOURCE,
72 wxBITMAP_TYPE_PICT,
73 wxBITMAP_TYPE_PICT_RESOURCE,
74 wxBITMAP_TYPE_ICON,
75 wxBITMAP_TYPE_ICON_RESOURCE,
76 wxBITMAP_TYPE_ANI,
77 wxBITMAP_TYPE_IFF,
78 wxBITMAP_TYPE_TGA,
79 wxBITMAP_TYPE_MACCURSOR,
80 wxBITMAP_TYPE_MACCURSOR_RESOURCE,
81 wxBITMAP_TYPE_ANY = 50
82 };
83
84 // Standard cursors
85 enum wxStockCursor
86 {
87 wxCURSOR_NONE, // should be 0
88 wxCURSOR_ARROW,
89 wxCURSOR_RIGHT_ARROW,
90 wxCURSOR_BULLSEYE,
91 wxCURSOR_CHAR,
92 wxCURSOR_CROSS,
93 wxCURSOR_HAND,
94 wxCURSOR_IBEAM,
95 wxCURSOR_LEFT_BUTTON,
96 wxCURSOR_MAGNIFIER,
97 wxCURSOR_MIDDLE_BUTTON,
98 wxCURSOR_NO_ENTRY,
99 wxCURSOR_PAINT_BRUSH,
100 wxCURSOR_PENCIL,
101 wxCURSOR_POINT_LEFT,
102 wxCURSOR_POINT_RIGHT,
103 wxCURSOR_QUESTION_ARROW,
104 wxCURSOR_RIGHT_BUTTON,
105 wxCURSOR_SIZENESW,
106 wxCURSOR_SIZENS,
107 wxCURSOR_SIZENWSE,
108 wxCURSOR_SIZEWE,
109 wxCURSOR_SIZING,
110 wxCURSOR_SPRAYCAN,
111 wxCURSOR_WAIT,
112 wxCURSOR_WATCH,
113 wxCURSOR_BLANK,
114 #ifdef __WXGTK__
115 wxCURSOR_DEFAULT, // standard X11 cursor
116 #endif
117 #ifdef __WXMAC__
118 wxCURSOR_COPY_ARROW , // MacOS Theme Plus arrow
119 #endif
120 #ifdef __X__
121 // Not yet implemented for Windows
122 wxCURSOR_CROSS_REVERSE,
123 wxCURSOR_DOUBLE_ARROW,
124 wxCURSOR_BASED_ARROW_UP,
125 wxCURSOR_BASED_ARROW_DOWN,
126 #endif // X11
127
128 wxCURSOR_ARROWWAIT,
129
130 wxCURSOR_MAX
131 };
132
133 #ifndef __WXGTK__
134 #define wxCURSOR_DEFAULT wxCURSOR_ARROW
135 #endif
136
137 // ---------------------------------------------------------------------------
138 // macros
139 // ---------------------------------------------------------------------------
140
141 /* Useful macro for creating icons portably, for example:
142
143 wxIcon *icon = new wxICON(mondrian);
144
145 expands into:
146
147 wxIcon *icon = new wxIcon("mondrian"); // On wxMSW
148 wxIcon *icon = new wxIcon(mondrian_xpm); // On wxGTK
149 */
150
151 #ifdef __WXMSW__
152 // Load from a resource
153 #define wxICON(X) wxIcon(wxT(#X))
154 #elif defined(__WXPM__)
155 // Load from a resource
156 #define wxICON(X) wxIcon(wxT(#X))
157 #elif defined(__WXMGL__)
158 // Initialize from an included XPM
159 #define wxICON(X) wxIcon( (const char**) X##_xpm )
160 #elif defined(__WXDFB__)
161 // Initialize from an included XPM
162 #define wxICON(X) wxIcon( (const char**) X##_xpm )
163 #elif defined(__WXGTK__)
164 // Initialize from an included XPM
165 #define wxICON(X) wxIcon( (const char**) X##_xpm )
166 #elif defined(__WXMAC__)
167 // Initialize from an included XPM
168 #define wxICON(X) wxIcon( (const char**) X##_xpm )
169 #elif defined(__WXMOTIF__)
170 // Initialize from an included XPM
171 #define wxICON(X) wxIcon( X##_xpm )
172 #elif defined(__WXX11__)
173 // Initialize from an included XPM
174 #define wxICON(X) wxIcon( X##_xpm )
175 #else
176 // This will usually mean something on any platform
177 #define wxICON(X) wxIcon(wxT(#X))
178 #endif // platform
179
180 /* Another macro: this one is for portable creation of bitmaps. We assume that
181 under Unix bitmaps live in XPMs and under Windows they're in ressources.
182 */
183
184 #if defined(__WXMSW__) || defined(__WXPM__)
185 #define wxBITMAP(name) wxBitmap(wxT(#name), wxBITMAP_TYPE_RESOURCE)
186 #elif defined(__WXGTK__) || \
187 defined(__WXMOTIF__) || \
188 defined(__WXX11__) || \
189 defined(__WXMAC__) || \
190 defined(__WXMGL__) || \
191 defined(__WXDFB__) || \
192 defined(__WXCOCOA__)
193 // Initialize from an included XPM
194 #define wxBITMAP(name) wxBitmap( (const char**) name##_xpm )
195 #else // other platforms
196 #define wxBITMAP(name) wxBitmap(name##_xpm, wxBITMAP_TYPE_XPM)
197 #endif // platform
198
199 // ===========================================================================
200 // classes
201 // ===========================================================================
202
203 // ---------------------------------------------------------------------------
204 // wxSize
205 // ---------------------------------------------------------------------------
206
207 class WXDLLEXPORT wxSize
208 {
209 public:
210 // members are public for compatibility, don't use them directly.
211 int x, y;
212
213 // constructors
214 wxSize() : x(0), y(0) { }
215 wxSize(int xx, int yy) : x(xx), y(yy) { }
216
217 // no copy ctor or assignment operator - the defaults are ok
218
219 bool operator==(const wxSize& sz) const { return x == sz.x && y == sz.y; }
220 bool operator!=(const wxSize& sz) const { return x != sz.x || y != sz.y; }
221
222 wxSize operator+(const wxSize& sz) const { return wxSize(x + sz.x, y + sz.y); }
223 wxSize operator-(const wxSize& sz) const { return wxSize(x - sz.x, y - sz.y); }
224 wxSize operator/(int i) const { return wxSize(x / i, y / i); }
225 wxSize operator*(int i) const { return wxSize(x * i, y * i); }
226
227 wxSize& operator+=(const wxSize& sz) { x += sz.x; y += sz.y; return *this; }
228 wxSize& operator-=(const wxSize& sz) { x -= sz.x; y -= sz.y; return *this; }
229 wxSize& operator/=(const int i) { x /= i; y /= i; return *this; }
230 wxSize& operator*=(const int i) { x *= i; y *= i; return *this; }
231
232 void IncTo(const wxSize& sz)
233 { if ( sz.x > x ) x = sz.x; if ( sz.y > y ) y = sz.y; }
234 void DecTo(const wxSize& sz)
235 { if ( sz.x < x ) x = sz.x; if ( sz.y < y ) y = sz.y; }
236
237 void IncBy(int dx, int dy) { x += dx; y += dy; }
238 void IncBy(const wxSize& sz) { IncBy(sz.x, sz.y); }
239 void IncBy(int d) { IncBy(d, d); }
240
241 void DecBy(int dx, int dy) { IncBy(-dx, -dy); }
242 void DecBy(const wxSize& sz) { DecBy(sz.x, sz.y); }
243 void DecBy(int d) { DecBy(d, d); }
244
245
246 wxSize& Scale(float xscale, float yscale)
247 { x = (int)(x*xscale); y = (int)(y*yscale); return *this; }
248
249 // accessors
250 void Set(int xx, int yy) { x = xx; y = yy; }
251 void SetWidth(int w) { x = w; }
252 void SetHeight(int h) { y = h; }
253
254 int GetWidth() const { return x; }
255 int GetHeight() const { return y; }
256
257 bool IsFullySpecified() const { return x != wxDefaultCoord && y != wxDefaultCoord; }
258
259 // combine this size with the other one replacing the default (i.e. equal
260 // to wxDefaultCoord) components of this object with those of the other
261 void SetDefaults(const wxSize& size)
262 {
263 if ( x == wxDefaultCoord )
264 x = size.x;
265 if ( y == wxDefaultCoord )
266 y = size.y;
267 }
268
269 // compatibility
270 int GetX() const { return x; }
271 int GetY() const { return y; }
272 };
273
274 // ---------------------------------------------------------------------------
275 // Point classes: with real or integer coordinates
276 // ---------------------------------------------------------------------------
277
278 class WXDLLEXPORT wxRealPoint
279 {
280 public:
281 double x;
282 double y;
283
284 wxRealPoint() : x(0.0), y(0.0) { }
285 wxRealPoint(double xx, double yy) : x(xx), y(yy) { }
286
287 wxRealPoint operator+(const wxRealPoint& pt) const { return wxRealPoint(x + pt.x, y + pt.y); }
288 wxRealPoint operator-(const wxRealPoint& pt) const { return wxRealPoint(x - pt.x, y - pt.y); }
289
290 bool operator==(const wxRealPoint& pt) const
291 {
292 return wxIsSameDouble(x, pt.x) && wxIsSameDouble(y, pt.y);
293 }
294 bool operator!=(const wxRealPoint& pt) const { return !(*this == pt); }
295 };
296
297
298 class WXDLLEXPORT wxPoint
299 {
300 public:
301 int x, y;
302
303 wxPoint() : x(0), y(0) { }
304 wxPoint(int xx, int yy) : x(xx), y(yy) { }
305
306 // no copy ctor or assignment operator - the defaults are ok
307
308 // comparison
309 bool operator==(const wxPoint& p) const { return x == p.x && y == p.y; }
310 bool operator!=(const wxPoint& p) const { return !(*this == p); }
311
312 // arithmetic operations (component wise)
313 wxPoint operator+(const wxPoint& p) const { return wxPoint(x + p.x, y + p.y); }
314 wxPoint operator-(const wxPoint& p) const { return wxPoint(x - p.x, y - p.y); }
315
316 wxPoint& operator+=(const wxPoint& p) { x += p.x; y += p.y; return *this; }
317 wxPoint& operator-=(const wxPoint& p) { x -= p.x; y -= p.y; return *this; }
318
319 wxPoint& operator+=(const wxSize& s) { x += s.GetWidth(); y += s.GetHeight(); return *this; }
320 wxPoint& operator-=(const wxSize& s) { x -= s.GetWidth(); y -= s.GetHeight(); return *this; }
321
322 wxPoint operator+(const wxSize& s) const { return wxPoint(x + s.GetWidth(), y + s.GetHeight()); }
323 wxPoint operator-(const wxSize& s) const { return wxPoint(x - s.GetWidth(), y - s.GetHeight()); }
324
325 wxPoint operator-() const { return wxPoint(-x, -y); }
326 };
327
328 // ---------------------------------------------------------------------------
329 // wxRect
330 // ---------------------------------------------------------------------------
331
332 class WXDLLEXPORT wxRect
333 {
334 public:
335 wxRect()
336 : x(0), y(0), width(0), height(0)
337 { }
338 wxRect(int xx, int yy, int ww, int hh)
339 : x(xx), y(yy), width(ww), height(hh)
340 { }
341 wxRect(const wxPoint& topLeft, const wxPoint& bottomRight);
342 wxRect(const wxPoint& pt, const wxSize& size)
343 : x(pt.x), y(pt.y), width(size.x), height(size.y)
344 { }
345 wxRect(const wxSize& size)
346 : x(0), y(0), width(size.x), height(size.y)
347 { }
348
349 // default copy ctor and assignment operators ok
350
351 int GetX() const { return x; }
352 void SetX(int xx) { x = xx; }
353
354 int GetY() const { return y; }
355 void SetY(int yy) { y = yy; }
356
357 int GetWidth() const { return width; }
358 void SetWidth(int w) { width = w; }
359
360 int GetHeight() const { return height; }
361 void SetHeight(int h) { height = h; }
362
363 wxPoint GetPosition() const { return wxPoint(x, y); }
364 void SetPosition( const wxPoint &p ) { x = p.x; y = p.y; }
365
366 wxSize GetSize() const { return wxSize(width, height); }
367 void SetSize( const wxSize &s ) { width = s.GetWidth(); height = s.GetHeight(); }
368
369 bool IsEmpty() const { return (width <= 0) || (height <= 0); }
370
371 int GetLeft() const { return x; }
372 int GetTop() const { return y; }
373 int GetBottom() const { return y + height - 1; }
374 int GetRight() const { return x + width - 1; }
375
376 void SetLeft(int left) { x = left; }
377 void SetRight(int right) { width = right - x + 1; }
378 void SetTop(int top) { y = top; }
379 void SetBottom(int bottom) { height = bottom - y + 1; }
380
381 wxPoint GetTopLeft() const { return GetPosition(); }
382 wxPoint GetLeftTop() const { return GetTopLeft(); }
383 void SetTopLeft(const wxPoint &p) { SetPosition(p); }
384 void SetLeftTop(const wxPoint &p) { SetTopLeft(p); }
385
386 wxPoint GetBottomRight() const { return wxPoint(GetRight(), GetBottom()); }
387 wxPoint GetRightBottom() const { return GetBottomRight(); }
388 void SetBottomRight(const wxPoint &p) { SetRight(p.x); SetBottom(p.y); }
389 void SetRightBottom(const wxPoint &p) { SetBottomRight(p); }
390
391 wxPoint GetTopRight() const { return wxPoint(GetRight(), GetTop()); }
392 wxPoint GetRightTop() const { return GetTopRight(); }
393 void SetTopRight(const wxPoint &p) { SetRight(p.x); SetTop(p.y); }
394 void SetRightTop(const wxPoint &p) { SetTopLeft(p); }
395
396 wxPoint GetBottomLeft() const { return wxPoint(GetLeft(), GetBottom()); }
397 wxPoint GetLeftBottom() const { return GetBottomLeft(); }
398 void SetBottomLeft(const wxPoint &p) { SetLeft(p.x); SetBottom(p.y); }
399 void SetLeftBottom(const wxPoint &p) { SetBottomLeft(p); }
400
401 // operations with rect
402 wxRect& Inflate(wxCoord dx, wxCoord dy);
403 wxRect& Inflate(const wxSize& d) { return Inflate(d.x, d.y); }
404 wxRect& Inflate(wxCoord d) { return Inflate(d, d); }
405 wxRect Inflate(wxCoord dx, wxCoord dy) const
406 {
407 wxRect r = *this;
408 r.Inflate(dx, dy);
409 return r;
410 }
411
412 wxRect& Deflate(wxCoord dx, wxCoord dy) { return Inflate(-dx, -dy); }
413 wxRect& Deflate(const wxSize& d) { return Inflate(-d.x, -d.y); }
414 wxRect& Deflate(wxCoord d) { return Inflate(-d); }
415 wxRect Deflate(wxCoord dx, wxCoord dy) const
416 {
417 wxRect r = *this;
418 r.Deflate(dx, dy);
419 return r;
420 }
421
422 void Offset(wxCoord dx, wxCoord dy) { x += dx; y += dy; }
423 void Offset(const wxPoint& pt) { Offset(pt.x, pt.y); }
424
425 wxRect& Intersect(const wxRect& rect);
426 wxRect Intersect(const wxRect& rect) const
427 {
428 wxRect r = *this;
429 r.Intersect(rect);
430 return r;
431 }
432
433 wxRect& Union(const wxRect& rect);
434 wxRect Union(const wxRect& rect) const
435 {
436 wxRect r = *this;
437 r.Union(rect);
438 return r;
439 }
440
441 // compare rectangles
442 bool operator==(const wxRect& rect) const;
443 bool operator!=(const wxRect& rect) const { return !(*this == rect); }
444
445 // return true if the point is (not strcitly) inside the rect
446 bool Contains(int x, int y) const;
447 bool Contains(const wxPoint& pt) const { return Contains(pt.x, pt.y); }
448 // return true if the rectangle is (not strcitly) inside the rect
449 bool Contains(const wxRect& rect) const;
450
451 #if WXWIN_COMPATIBILITY_2_6
452 // use Contains() instead
453 wxDEPRECATED( bool Inside(int x, int y) const );
454 wxDEPRECATED( bool Inside(const wxPoint& pt) const );
455 wxDEPRECATED( bool Inside(const wxRect& rect) const );
456 #endif // WXWIN_COMPATIBILITY_2_6
457
458 // return true if the rectangles have a non empty intersection
459 bool Intersects(const wxRect& rect) const;
460
461
462 // these are like Union() but don't ignore empty rectangles
463 wxRect operator+(const wxRect& rect) const;
464 wxRect& operator+=(const wxRect& rect)
465 {
466 *this = *this + rect;
467 return *this;
468 }
469
470
471 // centre this rectangle in the given (usually, but not necessarily,
472 // larger) one
473 wxRect CentreIn(const wxRect& r, int dir = wxBOTH) const
474 {
475 return wxRect(dir & wxHORIZONTAL ? r.x + (r.width - width)/2 : x,
476 dir & wxVERTICAL ? r.y + (r.height - height)/2 : y,
477 width, height);
478 }
479
480 wxRect CenterIn(const wxRect& r, int dir = wxBOTH) const
481 {
482 return CentreIn(r, dir);
483 }
484
485 public:
486 int x, y, width, height;
487 };
488
489 #if WXWIN_COMPATIBILITY_2_6
490 inline bool wxRect::Inside(int cx, int cy) const { return Contains(cx, cy); }
491 inline bool wxRect::Inside(const wxPoint& pt) const { return Contains(pt); }
492 inline bool wxRect::Inside(const wxRect& rect) const { return Contains(rect); }
493 #endif // WXWIN_COMPATIBILITY_2_6
494
495
496 // ---------------------------------------------------------------------------
497 // Management of pens, brushes and fonts
498 // ---------------------------------------------------------------------------
499
500 typedef wxInt8 wxDash;
501
502 class WXDLLIMPEXP_CORE wxGDIObjListBase {
503 public:
504 wxGDIObjListBase();
505 ~wxGDIObjListBase();
506
507 protected:
508 wxList list;
509 };
510
511 class WXDLLIMPEXP_CORE wxPenList: public wxGDIObjListBase
512 {
513 public:
514 wxPen *FindOrCreatePen(const wxColour& colour, int width, int style);
515 #if WXWIN_COMPATIBILITY_2_6
516 wxDEPRECATED( void AddPen(wxPen*) );
517 wxDEPRECATED( void RemovePen(wxPen*) );
518 #endif
519 };
520
521 class WXDLLIMPEXP_CORE wxBrushList: public wxGDIObjListBase
522 {
523 public:
524 wxBrush *FindOrCreateBrush(const wxColour& colour, int style = wxSOLID);
525 #if WXWIN_COMPATIBILITY_2_6
526 wxDEPRECATED( void AddBrush(wxBrush*) );
527 wxDEPRECATED( void RemoveBrush(wxBrush*) );
528 #endif
529 };
530
531 class WXDLLIMPEXP_CORE wxFontList: public wxGDIObjListBase
532 {
533 public:
534 wxFont *FindOrCreateFont(int pointSize, int family, int style, int weight,
535 bool underline = false,
536 const wxString& face = wxEmptyString,
537 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
538 #if WXWIN_COMPATIBILITY_2_6
539 wxDEPRECATED( void AddFont(wxFont*) );
540 wxDEPRECATED( void RemoveFont(wxFont*) );
541 #endif
542 };
543
544 WX_DECLARE_STRING_HASH_MAP(wxColour*, wxStringToColourHashMap);
545
546 class WXDLLEXPORT wxColourDatabase
547 {
548 public:
549 wxColourDatabase();
550 ~wxColourDatabase();
551
552 // find colour by name or name for the given colour
553 wxColour Find(const wxString& name) const;
554 wxString FindName(const wxColour& colour) const;
555
556 // add a new colour to the database
557 void AddColour(const wxString& name, const wxColour& colour);
558
559 #if WXWIN_COMPATIBILITY_2_6
560 // deprecated, use Find() instead
561 wxDEPRECATED( wxColour *FindColour(const wxString& name) );
562 #endif // WXWIN_COMPATIBILITY_2_6
563
564
565 #ifdef __WXPM__
566 // PM keeps its own type of colour table
567 long* m_palTable;
568 size_t m_nSize;
569 #endif
570
571 private:
572 // load the database with the built in colour values when called for the
573 // first time, do nothing after this
574 void Initialize();
575
576 wxStringToColourHashMap *m_map;
577 };
578
579 class WXDLLEXPORT wxResourceCache: public wxList
580 {
581 public:
582 wxResourceCache() { }
583 #if !wxUSE_STL
584 wxResourceCache(const unsigned int keyType) : wxList(keyType) { }
585 #endif
586 virtual ~wxResourceCache();
587 };
588
589 // ---------------------------------------------------------------------------
590 // global variables
591 // ---------------------------------------------------------------------------
592
593 // Lists of GDI objects
594 extern WXDLLEXPORT_DATA(wxPenList*) wxThePenList;
595 extern WXDLLEXPORT_DATA(wxBrushList*) wxTheBrushList;
596 extern WXDLLEXPORT_DATA(wxFontList*) wxTheFontList;
597
598 /* Stock objects
599
600 wxStockGDI creates the stock GDI objects on demand. Pointers to the
601 created objects are stored in the ms_stockObject array, which is indexed
602 by the Item enum values. Platorm-specific fonts can be created by
603 implementing a derived class with an override for the GetFont function.
604 wxStockGDI operates as a singleton, accessed through the ms_instance
605 pointer. By default this pointer is set to an instance of wxStockGDI.
606 A derived class must arrange to set this pointer to an instance of itself.
607 */
608 class WXDLLIMPEXP_CORE wxStockGDI
609 {
610 public:
611 enum Item {
612 BRUSH_BLACK,
613 BRUSH_BLUE,
614 BRUSH_CYAN,
615 BRUSH_GREEN,
616 BRUSH_GREY,
617 BRUSH_LIGHTGREY,
618 BRUSH_MEDIUMGREY,
619 BRUSH_RED,
620 BRUSH_TRANSPARENT,
621 BRUSH_WHITE,
622 COLOUR_BLACK,
623 COLOUR_BLUE,
624 COLOUR_CYAN,
625 COLOUR_GREEN,
626 COLOUR_LIGHTGREY,
627 COLOUR_RED,
628 COLOUR_WHITE,
629 CURSOR_CROSS,
630 CURSOR_HOURGLASS,
631 CURSOR_STANDARD,
632 FONT_ITALIC,
633 FONT_NORMAL,
634 FONT_SMALL,
635 FONT_SWISS,
636 PEN_BLACK,
637 PEN_BLACKDASHED,
638 PEN_CYAN,
639 PEN_GREEN,
640 PEN_GREY,
641 PEN_LIGHTGREY,
642 PEN_MEDIUMGREY,
643 PEN_RED,
644 PEN_TRANSPARENT,
645 PEN_WHITE,
646 ITEMCOUNT
647 };
648
649 wxStockGDI();
650 virtual ~wxStockGDI();
651 static void DeleteAll();
652
653 static wxStockGDI& instance() { return *ms_instance; }
654
655 static const wxBrush* GetBrush(Item item);
656 static const wxColour* GetColour(Item item);
657 static const wxCursor* GetCursor(Item item);
658 // Can be overridden by platform-specific derived classes
659 virtual const wxFont* GetFont(Item item);
660 static const wxPen* GetPen(Item item);
661
662 protected:
663 static wxStockGDI* ms_instance;
664
665 static wxObject* ms_stockObject[ITEMCOUNT];
666
667 DECLARE_NO_COPY_CLASS(wxStockGDI)
668 };
669
670 #define wxITALIC_FONT wxStockGDI::instance().GetFont(wxStockGDI::FONT_ITALIC)
671 #define wxNORMAL_FONT wxStockGDI::instance().GetFont(wxStockGDI::FONT_NORMAL)
672 #define wxSMALL_FONT wxStockGDI::instance().GetFont(wxStockGDI::FONT_SMALL)
673 #define wxSWISS_FONT wxStockGDI::instance().GetFont(wxStockGDI::FONT_SWISS)
674
675 #define wxBLACK_DASHED_PEN wxStockGDI::GetPen(wxStockGDI::PEN_BLACKDASHED)
676 #define wxBLACK_PEN wxStockGDI::GetPen(wxStockGDI::PEN_BLACK)
677 #define wxCYAN_PEN wxStockGDI::GetPen(wxStockGDI::PEN_CYAN)
678 #define wxGREEN_PEN wxStockGDI::GetPen(wxStockGDI::PEN_GREEN)
679 #define wxGREY_PEN wxStockGDI::GetPen(wxStockGDI::PEN_GREY)
680 #define wxLIGHT_GREY_PEN wxStockGDI::GetPen(wxStockGDI::PEN_LIGHTGREY)
681 #define wxMEDIUM_GREY_PEN wxStockGDI::GetPen(wxStockGDI::PEN_MEDIUMGREY)
682 #define wxRED_PEN wxStockGDI::GetPen(wxStockGDI::PEN_RED)
683 #define wxTRANSPARENT_PEN wxStockGDI::GetPen(wxStockGDI::PEN_TRANSPARENT)
684 #define wxWHITE_PEN wxStockGDI::GetPen(wxStockGDI::PEN_WHITE)
685
686 #define wxBLACK_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_BLACK)
687 #define wxBLUE_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_BLUE)
688 #define wxCYAN_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_CYAN)
689 #define wxGREEN_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_GREEN)
690 #define wxGREY_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_GREY)
691 #define wxLIGHT_GREY_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_LIGHTGREY)
692 #define wxMEDIUM_GREY_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_MEDIUMGREY)
693 #define wxRED_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_RED)
694 #define wxTRANSPARENT_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_TRANSPARENT)
695 #define wxWHITE_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_WHITE)
696
697 #define wxBLACK wxStockGDI::GetColour(wxStockGDI::COLOUR_BLACK)
698 #define wxBLUE wxStockGDI::GetColour(wxStockGDI::COLOUR_BLUE)
699 #define wxCYAN wxStockGDI::GetColour(wxStockGDI::COLOUR_CYAN)
700 #define wxGREEN wxStockGDI::GetColour(wxStockGDI::COLOUR_GREEN)
701 #define wxLIGHT_GREY wxStockGDI::GetColour(wxStockGDI::COLOUR_LIGHTGREY)
702 #define wxRED wxStockGDI::GetColour(wxStockGDI::COLOUR_RED)
703 #define wxWHITE wxStockGDI::GetColour(wxStockGDI::COLOUR_WHITE)
704
705 #define wxCROSS_CURSOR wxStockGDI::GetCursor(wxStockGDI::CURSOR_CROSS)
706 #define wxHOURGLASS_CURSOR wxStockGDI::GetCursor(wxStockGDI::CURSOR_HOURGLASS)
707 #define wxSTANDARD_CURSOR wxStockGDI::GetCursor(wxStockGDI::CURSOR_STANDARD)
708
709 // 'Null' objects
710 extern WXDLLEXPORT_DATA(wxBitmap) wxNullBitmap;
711 extern WXDLLEXPORT_DATA(wxIcon) wxNullIcon;
712 extern WXDLLEXPORT_DATA(wxCursor) wxNullCursor;
713 extern WXDLLEXPORT_DATA(wxPen) wxNullPen;
714 extern WXDLLEXPORT_DATA(wxBrush) wxNullBrush;
715 extern WXDLLEXPORT_DATA(wxPalette) wxNullPalette;
716 extern WXDLLEXPORT_DATA(wxFont) wxNullFont;
717 extern WXDLLEXPORT_DATA(wxColour) wxNullColour;
718
719 extern WXDLLEXPORT_DATA(wxColourDatabase*) wxTheColourDatabase;
720
721 extern WXDLLEXPORT_DATA(const wxChar) wxPanelNameStr[];
722
723 extern WXDLLEXPORT_DATA(const wxSize) wxDefaultSize;
724 extern WXDLLEXPORT_DATA(const wxPoint) wxDefaultPosition;
725
726 // ---------------------------------------------------------------------------
727 // global functions
728 // ---------------------------------------------------------------------------
729
730 // resource management
731 extern void WXDLLEXPORT wxInitializeStockLists();
732 extern void WXDLLEXPORT wxDeleteStockLists();
733
734 // is the display colour (or monochrome)?
735 extern bool WXDLLEXPORT wxColourDisplay();
736
737 // Returns depth of screen
738 extern int WXDLLEXPORT wxDisplayDepth();
739 #define wxGetDisplayDepth wxDisplayDepth
740
741 // get the display size
742 extern void WXDLLEXPORT wxDisplaySize(int *width, int *height);
743 extern wxSize WXDLLEXPORT wxGetDisplaySize();
744 extern void WXDLLEXPORT wxDisplaySizeMM(int *width, int *height);
745 extern wxSize WXDLLEXPORT wxGetDisplaySizeMM();
746
747 // Get position and size of the display workarea
748 extern void WXDLLEXPORT wxClientDisplayRect(int *x, int *y, int *width, int *height);
749 extern wxRect WXDLLEXPORT wxGetClientDisplayRect();
750
751 // set global cursor
752 extern void WXDLLEXPORT wxSetCursor(const wxCursor& cursor);
753
754 #endif
755 // _WX_GDICMNH__