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