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