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