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