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