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