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