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