]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gdicmn.h
adding command key accelerator
[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
8efb2907
WS
232 void Scale(float xscale, float yscale)
233 { x = (int)(x*xscale); y = (int)(y*yscale); }
234
eddf46fe
JS
235 // accessors
236 void Set(int xx, int yy) { x = xx; y = yy; }
72cdf4c9
VZ
237 void SetWidth(int w) { x = w; }
238 void SetHeight(int h) { y = h; }
cc775580 239
72cdf4c9
VZ
240 int GetWidth() const { return x; }
241 int GetHeight() const { return y; }
f03fc89f 242
5d3e7b52 243 bool IsFullySpecified() const { return x != wxDefaultCoord && y != wxDefaultCoord; }
706f1421
VZ
244
245 // combine this size with the other one replacing the default (i.e. equal
5d3e7b52 246 // to wxDefaultCoord) components of this object with those of the other
706f1421
VZ
247 void SetDefaults(const wxSize& size)
248 {
5d3e7b52 249 if ( x == wxDefaultCoord )
706f1421 250 x = size.x;
5d3e7b52 251 if ( y == wxDefaultCoord )
706f1421
VZ
252 y = size.y;
253 }
254
cc775580 255 // compatibility
72cdf4c9
VZ
256 int GetX() const { return x; }
257 int GetY() const { return y; }
c801d85f
KB
258};
259
f03fc89f
VZ
260// ---------------------------------------------------------------------------
261// Point classes: with real or integer coordinates
262// ---------------------------------------------------------------------------
764a3a49 263
6a6c0a8b 264class WXDLLEXPORT wxRealPoint
c801d85f 265{
f03fc89f
VZ
266public:
267 double x;
268 double y;
269
7ee31b00
GD
270 wxRealPoint() : x(0.0), y(0.0) { }
271 wxRealPoint(double xx, double yy) : x(xx), y(yy) { }
f03fc89f 272
f6bcfd97
BP
273 wxRealPoint operator+(const wxRealPoint& pt) const { return wxRealPoint(x + pt.x, y + pt.y); }
274 wxRealPoint operator-(const wxRealPoint& pt) const { return wxRealPoint(x - pt.x, y - pt.y); }
f03fc89f 275
bc14c8b2
VZ
276 bool operator==(const wxRealPoint& pt) const
277 {
278 return wxIsSameDouble(x, pt.x) && wxIsSameDouble(y, pt.y);
279 }
280 bool operator!=(const wxRealPoint& pt) const { return !(*this == pt); }
c801d85f
KB
281};
282
bc14c8b2 283
6a6c0a8b 284class WXDLLEXPORT wxPoint
c801d85f 285{
f03fc89f 286public:
72cdf4c9 287 int x, y;
6a6c0a8b 288
7ee31b00
GD
289 wxPoint() : x(0), y(0) { }
290 wxPoint(int xx, int yy) : x(xx), y(yy) { }
f03fc89f
VZ
291
292 // no copy ctor or assignment operator - the defaults are ok
6a6c0a8b 293
764a3a49
VZ
294 // comparison
295 bool operator==(const wxPoint& p) const { return x == p.x && y == p.y; }
296 bool operator!=(const wxPoint& p) const { return !(*this == p); }
297
298 // arithmetic operations (component wise)
f6bcfd97
BP
299 wxPoint operator+(const wxPoint& p) const { return wxPoint(x + p.x, y + p.y); }
300 wxPoint operator-(const wxPoint& p) const { return wxPoint(x - p.x, y - p.y); }
f03fc89f 301
764a3a49
VZ
302 wxPoint& operator+=(const wxPoint& p) { x += p.x; y += p.y; return *this; }
303 wxPoint& operator-=(const wxPoint& p) { x -= p.x; y -= p.y; return *this; }
d02bc4c8
JS
304
305 wxPoint& operator+=(const wxSize& s) { x += s.GetWidth(); y += s.GetHeight(); return *this; }
306 wxPoint& operator-=(const wxSize& s) { x -= s.GetWidth(); y -= s.GetHeight(); return *this; }
307
308 wxPoint operator+(const wxSize& s) const { return wxPoint(x + s.GetWidth(), y + s.GetHeight()); }
309 wxPoint operator-(const wxSize& s) const { return wxPoint(x - s.GetWidth(), y - s.GetHeight()); }
c801d85f
KB
310};
311
f03fc89f
VZ
312// ---------------------------------------------------------------------------
313// wxRect
314// ---------------------------------------------------------------------------
c801d85f 315
6a6c0a8b
JS
316class WXDLLEXPORT wxRect
317{
c801d85f 318public:
7ee31b00
GD
319 wxRect()
320 : x(0), y(0), width(0), height(0)
321 { }
72cdf4c9 322 wxRect(int xx, int yy, int ww, int hh)
7ee31b00
GD
323 : x(xx), y(yy), width(ww), height(hh)
324 { }
f03fc89f 325 wxRect(const wxPoint& topLeft, const wxPoint& bottomRight);
df83b840
VZ
326 wxRect(const wxPoint& pt, const wxSize& size)
327 : x(pt.x), y(pt.y), width(size.x), height(size.y)
328 { }
329 wxRect(const wxSize& size)
330 : x(0), y(0), width(size.x), height(size.y)
331 { }
a23fd0e1
VZ
332
333 // default copy ctor and assignment operators ok
c801d85f 334
72cdf4c9
VZ
335 int GetX() const { return x; }
336 void SetX(int xx) { x = xx; }
c801d85f 337
72cdf4c9
VZ
338 int GetY() const { return y; }
339 void SetY(int yy) { y = yy; }
c801d85f 340
72cdf4c9
VZ
341 int GetWidth() const { return width; }
342 void SetWidth(int w) { width = w; }
c801d85f 343
72cdf4c9
VZ
344 int GetHeight() const { return height; }
345 void SetHeight(int h) { height = h; }
f03fc89f 346
dcb44466 347 wxPoint GetPosition() const { return wxPoint(x, y); }
4aa0010b
RL
348 void SetPosition( const wxPoint &p ) { x = p.x; y = p.y; }
349
dcb44466 350 wxSize GetSize() const { return wxSize(width, height); }
4aa0010b 351 void SetSize( const wxSize &s ) { width = s.GetWidth(); height = s.GetHeight(); }
f03fc89f 352
b737ad10
RR
353 bool IsEmpty() const { return (width <= 0) || (height <= 0); }
354
355a5e2b
JS
355 wxPoint GetTopLeft() const { return GetPosition(); }
356 wxPoint GetLeftTop() const { return GetTopLeft(); }
357 void SetTopLeft(const wxPoint &p) { SetPosition(p); }
358 void SetLeftTop(const wxPoint &p) { SetTopLeft(p); }
359
360 wxPoint GetBottomRight() const { return wxPoint(GetRight(), GetBottom()); }
361 wxPoint GetRightBottom() const { return GetBottomRight(); }
362 void SetBottomRight(const wxPoint &p) { SetRight(p.x); SetBottom(p.y); }
363 void SetRightBottom(const wxPoint &p) { SetBottomRight(p); }
364
72cdf4c9
VZ
365 int GetLeft() const { return x; }
366 int GetTop() const { return y; }
367 int GetBottom() const { return y + height - 1; }
368 int GetRight() const { return x + width - 1; }
f03fc89f 369
72cdf4c9
VZ
370 void SetLeft(int left) { x = left; }
371 void SetRight(int right) { width = right - x + 1; }
372 void SetTop(int top) { y = top; }
373 void SetBottom(int bottom) { height = bottom - y + 1; }
dcb44466 374
1e6feb95
VZ
375 // operations with rect
376 wxRect& Inflate(wxCoord dx, wxCoord dy);
377 wxRect& Inflate(wxCoord d) { return Inflate(d, d); }
378 wxRect Inflate(wxCoord dx, wxCoord dy) const
379 {
380 wxRect r = *this;
381 r.Inflate(dx, dy);
382 return r;
383 }
384
385 wxRect& Deflate(wxCoord dx, wxCoord dy) { return Inflate(-dx, -dy); }
386 wxRect& Deflate(wxCoord d) { return Inflate(-d); }
387 wxRect Deflate(wxCoord dx, wxCoord dy) const
388 {
389 wxRect r = *this;
390 r.Deflate(dx, dy);
391 return r;
392 }
393
394 void Offset(wxCoord dx, wxCoord dy) { x += dx; y += dy; }
395 void Offset(const wxPoint& pt) { Offset(pt.x, pt.y); }
396
397 wxRect& Intersect(const wxRect& rect);
398 wxRect Intersect(const wxRect& rect) const
45816ddd 399 {
1e6feb95
VZ
400 wxRect r = *this;
401 r.Intersect(rect);
402 return r;
45816ddd
VZ
403 }
404
df83b840
VZ
405 wxRect& Union(const wxRect& rect);
406 wxRect Union(const wxRect& rect) const
407 {
408 wxRect r = *this;
409 r.Union(rect);
410 return r;
411 }
45816ddd 412
1e6feb95 413 // compare rectangles
764a3a49
VZ
414 bool operator==(const wxRect& rect) const;
415 bool operator!=(const wxRect& rect) const { return !(*this == rect); }
f03fc89f 416
5d3e7b52 417 // return true if the point is (not strcitly) inside the rect
1e6feb95 418 bool Inside(int x, int y) const;
59a12e90 419 bool Inside(const wxPoint& pt) const { return Inside(pt.x, pt.y); }
869b59fc
VS
420 // return true if the rectangle is (not strcitly) inside the rect
421 bool Inside(const wxRect& rect) const;
1e6feb95 422
5d3e7b52 423 // return true if the rectangles have a non empty intersection
1e6feb95 424 bool Intersects(const wxRect& rect) const;
72cdf4c9 425
df83b840
VZ
426
427 // these are like Union() but don't ignore empty rectangles
428 wxRect operator+(const wxRect& rect) const;
3ea9aa8f 429 wxRect& operator+=(const wxRect& rect)
df83b840
VZ
430 {
431 *this = *this + rect;
432 return *this;
433 }
434
435
1bfb73b8
VZ
436 // centre this rectangle in the given (usually, but not necessarily,
437 // larger) one
438 wxRect CentreIn(const wxRect& r, int dir = wxBOTH) const
439 {
440 return wxRect(dir & wxHORIZONTAL ? r.x + (r.width - width)/2 : x,
441 dir & wxVERTICAL ? r.y + (r.height - height)/2 : y,
442 width, height);
443 }
444
445 wxRect CenterIn(const wxRect& r, int dir = wxBOTH) const
446 {
447 return CentreIn(r, dir);
448 }
449
f03fc89f 450public:
72cdf4c9 451 int x, y, width, height;
f03fc89f 452};
c801d85f 453
f03fc89f 454// ---------------------------------------------------------------------------
c801d85f 455// Management of pens, brushes and fonts
f03fc89f
VZ
456// ---------------------------------------------------------------------------
457
236a9de3
RL
458typedef wxInt8 wxDash;
459
1de8d512 460class WXDLLIMPEXP_CORE wxGDIObjListBase {
f03fc89f 461public:
1de8d512
VZ
462 wxGDIObjListBase();
463 ~wxGDIObjListBase();
f03fc89f 464
1de8d512
VZ
465protected:
466 wxList list;
c801d85f
KB
467};
468
1de8d512 469class WXDLLIMPEXP_CORE wxPenList: public wxGDIObjListBase
c801d85f 470{
f03fc89f 471public:
1de8d512
VZ
472 wxPen *FindOrCreatePen(const wxColour& colour, int width, int style);
473#if WXWIN_COMPATIBILITY_2_6
474 wxDEPRECATED( void AddPen(wxPen*) );
475 wxDEPRECATED( void RemovePen(wxPen*) );
476#endif
477};
f03fc89f 478
1de8d512
VZ
479class WXDLLIMPEXP_CORE wxBrushList: public wxGDIObjListBase
480{
481public:
cf000528 482 wxBrush *FindOrCreateBrush(const wxColour& colour, int style = wxSOLID);
1de8d512
VZ
483#if WXWIN_COMPATIBILITY_2_6
484 wxDEPRECATED( void AddBrush(wxBrush*) );
485 wxDEPRECATED( void RemoveBrush(wxBrush*) );
486#endif
c801d85f
KB
487};
488
1de8d512 489class WXDLLIMPEXP_CORE wxFontList: public wxGDIObjListBase
c801d85f 490{
f03fc89f 491public:
f03fc89f 492 wxFont *FindOrCreateFont(int pointSize, int family, int style, int weight,
5d3e7b52 493 bool underline = false,
37bebc11
RD
494 const wxString& face = wxEmptyString,
495 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
1de8d512
VZ
496#if WXWIN_COMPATIBILITY_2_6
497 wxDEPRECATED( void AddFont(wxFont*) );
498 wxDEPRECATED( void RemoveFont(wxFont*) );
499#endif
c801d85f
KB
500};
501
f79f1604
PC
502WX_DECLARE_STRING_HASH_MAP(wxColour*, wxStringToColourHashMap);
503
222ed1d6 504class WXDLLEXPORT wxColourDatabase
c801d85f 505{
f03fc89f 506public:
222ed1d6 507 wxColourDatabase();
c50f92d0 508 ~wxColourDatabase();
f03fc89f 509
c50f92d0
VZ
510 // find colour by name or name for the given colour
511 wxColour Find(const wxString& name) const;
f03fc89f 512 wxString FindName(const wxColour& colour) const;
c50f92d0
VZ
513
514 // add a new colour to the database
515 void AddColour(const wxString& name, const wxColour& colour);
516
ca3e85cf 517#if WXWIN_COMPATIBILITY_2_6
492e2a5b
VZ
518 // deprecated, use Find() instead
519 wxDEPRECATED( wxColour *FindColour(const wxString& name) );
ca3e85cf 520#endif // WXWIN_COMPATIBILITY_2_6
c50f92d0
VZ
521
522
19bf0c69
DW
523#ifdef __WXPM__
524 // PM keeps its own type of colour table
525 long* m_palTable;
526 size_t m_nSize;
527#endif
c50f92d0 528
222ed1d6 529private:
c50f92d0
VZ
530 // load the database with the built in colour values when called for the
531 // first time, do nothing after this
532 void Initialize();
222ed1d6 533
c50f92d0 534 wxStringToColourHashMap *m_map;
c801d85f
KB
535};
536
f03fc89f
VZ
537class WXDLLEXPORT wxResourceCache: public wxList
538{
539public:
540 wxResourceCache() { }
222ed1d6 541#if !wxUSE_STL
f03fc89f 542 wxResourceCache(const unsigned int keyType) : wxList(keyType) { }
222ed1d6 543#endif
9b51403d 544 ~wxResourceCache();
f03fc89f
VZ
545};
546
547// ---------------------------------------------------------------------------
548// global variables
549// ---------------------------------------------------------------------------
550
c801d85f 551// Lists of GDI objects
16cba29d
WS
552extern WXDLLEXPORT_DATA(wxPenList*) wxThePenList;
553extern WXDLLEXPORT_DATA(wxBrushList*) wxTheBrushList;
554extern WXDLLEXPORT_DATA(wxFontList*) wxTheFontList;
c801d85f 555
f516d986
VZ
556/* Stock objects
557
558 wxStockGDI creates the stock GDI objects on demand. Pointers to the
559 created objects are stored in the ms_stockObject array, which is indexed
560 by the Item enum values. Platorm-specific fonts can be created by
561 implementing a derived class with an override for the GetFont function.
562 wxStockGDI operates as a singleton, accessed through the ms_instance
563 pointer. By default this pointer is set to an instance of wxStockGDI.
564 A derived class must arrange to set this pointer to an instance of itself.
565*/
566class WXDLLIMPEXP_CORE wxStockGDI
567{
568public:
569 enum Item {
570 BRUSH_BLACK,
571 BRUSH_BLUE,
572 BRUSH_CYAN,
573 BRUSH_GREEN,
574 BRUSH_GREY,
575 BRUSH_LIGHTGREY,
576 BRUSH_MEDIUMGREY,
577 BRUSH_RED,
578 BRUSH_TRANSPARENT,
579 BRUSH_WHITE,
580 COLOUR_BLACK,
581 COLOUR_BLUE,
582 COLOUR_CYAN,
583 COLOUR_GREEN,
584 COLOUR_LIGHTGREY,
585 COLOUR_RED,
586 COLOUR_WHITE,
587 CURSOR_CROSS,
588 CURSOR_HOURGLASS,
589 CURSOR_STANDARD,
590 FONT_ITALIC,
591 FONT_NORMAL,
592 FONT_SMALL,
593 FONT_SWISS,
594 PEN_BLACK,
595 PEN_BLACKDASHED,
596 PEN_CYAN,
597 PEN_GREEN,
598 PEN_GREY,
599 PEN_LIGHTGREY,
600 PEN_MEDIUMGREY,
601 PEN_RED,
602 PEN_TRANSPARENT,
603 PEN_WHITE,
604 ITEMCOUNT
605 };
606
607 wxStockGDI();
608 virtual ~wxStockGDI();
609 static void DeleteAll();
610
611 static wxStockGDI& instance() { return *ms_instance; }
612
613 static const wxBrush* GetBrush(Item item);
614 static const wxColour* GetColour(Item item);
615 static const wxCursor* GetCursor(Item item);
616 // Can be overridden by platform-specific derived classes
617 virtual const wxFont* GetFont(Item item);
618 static const wxPen* GetPen(Item item);
619
620protected:
621 static wxStockGDI* ms_instance;
622
623 static wxObject* ms_stockObject[ITEMCOUNT];
624
625 DECLARE_NO_COPY_CLASS(wxStockGDI)
626};
627
628#define wxITALIC_FONT wxStockGDI::instance().GetFont(wxStockGDI::FONT_ITALIC)
629#define wxNORMAL_FONT wxStockGDI::instance().GetFont(wxStockGDI::FONT_NORMAL)
630#define wxSMALL_FONT wxStockGDI::instance().GetFont(wxStockGDI::FONT_SMALL)
631#define wxSWISS_FONT wxStockGDI::instance().GetFont(wxStockGDI::FONT_SWISS)
632
633#define wxBLACK_DASHED_PEN wxStockGDI::GetPen(wxStockGDI::PEN_BLACKDASHED)
634#define wxBLACK_PEN wxStockGDI::GetPen(wxStockGDI::PEN_BLACK)
635#define wxCYAN_PEN wxStockGDI::GetPen(wxStockGDI::PEN_CYAN)
636#define wxGREEN_PEN wxStockGDI::GetPen(wxStockGDI::PEN_GREEN)
637#define wxGREY_PEN wxStockGDI::GetPen(wxStockGDI::PEN_GREY)
638#define wxLIGHT_GREY_PEN wxStockGDI::GetPen(wxStockGDI::PEN_LIGHTGREY)
639#define wxMEDIUM_GREY_PEN wxStockGDI::GetPen(wxStockGDI::PEN_MEDIUMGREY)
640#define wxRED_PEN wxStockGDI::GetPen(wxStockGDI::PEN_RED)
641#define wxTRANSPARENT_PEN wxStockGDI::GetPen(wxStockGDI::PEN_TRANSPARENT)
642#define wxWHITE_PEN wxStockGDI::GetPen(wxStockGDI::PEN_WHITE)
643
644#define wxBLACK_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_BLACK)
645#define wxBLUE_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_BLUE)
646#define wxCYAN_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_CYAN)
647#define wxGREEN_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_GREEN)
648#define wxGREY_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_GREY)
649#define wxLIGHT_GREY_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_LIGHTGREY)
650#define wxMEDIUM_GREY_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_MEDIUMGREY)
651#define wxRED_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_RED)
652#define wxTRANSPARENT_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_TRANSPARENT)
653#define wxWHITE_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_WHITE)
654
655#define wxBLACK wxStockGDI::GetColour(wxStockGDI::COLOUR_BLACK)
656#define wxBLUE wxStockGDI::GetColour(wxStockGDI::COLOUR_BLUE)
657#define wxCYAN wxStockGDI::GetColour(wxStockGDI::COLOUR_CYAN)
658#define wxGREEN wxStockGDI::GetColour(wxStockGDI::COLOUR_GREEN)
659#define wxLIGHT_GREY wxStockGDI::GetColour(wxStockGDI::COLOUR_LIGHTGREY)
660#define wxRED wxStockGDI::GetColour(wxStockGDI::COLOUR_RED)
661#define wxWHITE wxStockGDI::GetColour(wxStockGDI::COLOUR_WHITE)
662
663#define wxCROSS_CURSOR wxStockGDI::GetCursor(wxStockGDI::CURSOR_CROSS)
664#define wxHOURGLASS_CURSOR wxStockGDI::GetCursor(wxStockGDI::CURSOR_HOURGLASS)
665#define wxSTANDARD_CURSOR wxStockGDI::GetCursor(wxStockGDI::CURSOR_STANDARD)
c801d85f
KB
666
667// 'Null' objects
16cba29d
WS
668extern WXDLLEXPORT_DATA(wxBitmap) wxNullBitmap;
669extern WXDLLEXPORT_DATA(wxIcon) wxNullIcon;
670extern WXDLLEXPORT_DATA(wxCursor) wxNullCursor;
671extern WXDLLEXPORT_DATA(wxPen) wxNullPen;
672extern WXDLLEXPORT_DATA(wxBrush) wxNullBrush;
673extern WXDLLEXPORT_DATA(wxPalette) wxNullPalette;
674extern WXDLLEXPORT_DATA(wxFont) wxNullFont;
675extern WXDLLEXPORT_DATA(wxColour) wxNullColour;
c801d85f 676
16cba29d 677extern WXDLLEXPORT_DATA(wxColourDatabase*) wxTheColourDatabase;
f03fc89f 678
63ec432b 679extern WXDLLEXPORT_DATA(const wxChar) wxPanelNameStr[];
c801d85f 680
16cba29d
WS
681extern WXDLLEXPORT_DATA(const wxSize) wxDefaultSize;
682extern WXDLLEXPORT_DATA(const wxPoint) wxDefaultPosition;
f03fc89f 683
f03fc89f
VZ
684// ---------------------------------------------------------------------------
685// global functions
686// ---------------------------------------------------------------------------
687
688// resource management
a3622daa 689extern void WXDLLEXPORT wxInitializeStockLists();
a3622daa 690extern void WXDLLEXPORT wxDeleteStockLists();
c801d85f 691
f03fc89f 692// is the display colour (or monochrome)?
6a6c0a8b 693extern bool WXDLLEXPORT wxColourDisplay();
c801d85f
KB
694
695// Returns depth of screen
6a6c0a8b
JS
696extern int WXDLLEXPORT wxDisplayDepth();
697#define wxGetDisplayDepth wxDisplayDepth
c801d85f 698
904a68b6 699// get the display size
c801d85f 700extern void WXDLLEXPORT wxDisplaySize(int *width, int *height);
6a6c0a8b 701extern wxSize WXDLLEXPORT wxGetDisplaySize();
904a68b6
RL
702extern void WXDLLEXPORT wxDisplaySizeMM(int *width, int *height);
703extern wxSize WXDLLEXPORT wxGetDisplaySizeMM();
c801d85f 704
ec5d7799
RD
705// Get position and size of the display workarea
706extern void WXDLLEXPORT wxClientDisplayRect(int *x, int *y, int *width, int *height);
707extern wxRect WXDLLEXPORT wxGetClientDisplayRect();
708
f03fc89f 709// set global cursor
c801d85f
KB
710extern void WXDLLEXPORT wxSetCursor(const wxCursor& cursor);
711
c801d85f 712#endif
34138703 713 // _WX_GDICMNH__