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