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