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