]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gdicmn.h
Implement wx-prefixed macros versions of DECLARE/IMPLEMENT_APP_* macros.
[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
89efaf2b
FM
88// Polygon filling mode
89enum wxPolygonFillMode
90{
91 wxODDEVEN_RULE = 1,
92 wxWINDING_RULE
93};
94
c801d85f 95// Standard cursors
f03fc89f
VZ
96enum wxStockCursor
97{
98 wxCURSOR_NONE, // should be 0
99 wxCURSOR_ARROW,
15dadf31 100 wxCURSOR_RIGHT_ARROW,
f03fc89f
VZ
101 wxCURSOR_BULLSEYE,
102 wxCURSOR_CHAR,
103 wxCURSOR_CROSS,
104 wxCURSOR_HAND,
105 wxCURSOR_IBEAM,
106 wxCURSOR_LEFT_BUTTON,
107 wxCURSOR_MAGNIFIER,
108 wxCURSOR_MIDDLE_BUTTON,
109 wxCURSOR_NO_ENTRY,
110 wxCURSOR_PAINT_BRUSH,
111 wxCURSOR_PENCIL,
112 wxCURSOR_POINT_LEFT,
113 wxCURSOR_POINT_RIGHT,
114 wxCURSOR_QUESTION_ARROW,
115 wxCURSOR_RIGHT_BUTTON,
116 wxCURSOR_SIZENESW,
117 wxCURSOR_SIZENS,
118 wxCURSOR_SIZENWSE,
119 wxCURSOR_SIZEWE,
120 wxCURSOR_SIZING,
121 wxCURSOR_SPRAYCAN,
122 wxCURSOR_WAIT,
123 wxCURSOR_WATCH,
124 wxCURSOR_BLANK,
ae53c98c
KB
125#ifdef __WXGTK__
126 wxCURSOR_DEFAULT, // standard X11 cursor
127#endif
5f7a6626 128#ifdef __WXMAC__
5d3e7b52 129 wxCURSOR_COPY_ARROW , // MacOS Theme Plus arrow
5f7a6626 130#endif
c801d85f 131#ifdef __X__
f03fc89f
VZ
132 // Not yet implemented for Windows
133 wxCURSOR_CROSS_REVERSE,
134 wxCURSOR_DOUBLE_ARROW,
135 wxCURSOR_BASED_ARROW_UP,
ea804aad 136 wxCURSOR_BASED_ARROW_DOWN,
f03fc89f 137#endif // X11
83f96286 138 wxCURSOR_ARROWWAIT,
ca91e1eb 139#ifdef __WXMAC__
87315ea2
FM
140 wxCURSOR_OPEN_HAND,
141 wxCURSOR_CLOSED_HAND,
ca91e1eb 142#endif
83f96286 143
f03fc89f
VZ
144 wxCURSOR_MAX
145};
146
943d28e4 147#ifndef __WXGTK__
87315ea2 148 #define wxCURSOR_DEFAULT wxCURSOR_ARROW
943d28e4
VZ
149#endif
150
ca91e1eb
SC
151#ifndef __WXMAC__
152 // TODO CS supply openhand and closedhand cursors
87315ea2
FM
153 #define wxCURSOR_OPEN_HAND wxCURSOR_HAND
154 #define wxCURSOR_CLOSED_HAND wxCURSOR_HAND
ca91e1eb
SC
155#endif
156
f03fc89f
VZ
157// ---------------------------------------------------------------------------
158// macros
159// ---------------------------------------------------------------------------
160
161/* Useful macro for creating icons portably, for example:
162
163 wxIcon *icon = new wxICON(mondrian);
164
165 expands into:
166
167 wxIcon *icon = new wxIcon("mondrian"); // On wxMSW
168 wxIcon *icon = new wxIcon(mondrian_xpm); // On wxGTK
169 */
170
171#ifdef __WXMSW__
172 // Load from a resource
2b5f62a0 173 #define wxICON(X) wxIcon(wxT(#X))
1777b9bb
DW
174#elif defined(__WXPM__)
175 // Load from a resource
2b5f62a0 176 #define wxICON(X) wxIcon(wxT(#X))
1e6feb95 177#elif defined(__WXMGL__)
1d965e2f 178 // Initialize from an included XPM
e45080c1 179 #define wxICON(X) wxIcon( X##_xpm )
d8bfd727
VS
180#elif defined(__WXDFB__)
181 // Initialize from an included XPM
e45080c1 182 #define wxICON(X) wxIcon( X##_xpm )
f03fc89f
VZ
183#elif defined(__WXGTK__)
184 // Initialize from an included XPM
e45080c1 185 #define wxICON(X) wxIcon( X##_xpm )
0532484d
GD
186#elif defined(__WXMAC__)
187 // Initialize from an included XPM
e45080c1 188 #define wxICON(X) wxIcon( X##_xpm )
f03fc89f
VZ
189#elif defined(__WXMOTIF__)
190 // Initialize from an included XPM
191 #define wxICON(X) wxIcon( X##_xpm )
83df96d6
JS
192#elif defined(__WXX11__)
193 // Initialize from an included XPM
194 #define wxICON(X) wxIcon( X##_xpm )
f03fc89f
VZ
195#else
196 // This will usually mean something on any platform
2b5f62a0 197 #define wxICON(X) wxIcon(wxT(#X))
f03fc89f
VZ
198#endif // platform
199
0c5d3e1c
VZ
200/* Another macro: this one is for portable creation of bitmaps. We assume that
201 under Unix bitmaps live in XPMs and under Windows they're in ressources.
202 */
203
1d965e2f 204#if defined(__WXMSW__) || defined(__WXPM__)
2b5f62a0 205 #define wxBITMAP(name) wxBitmap(wxT(#name), wxBITMAP_TYPE_RESOURCE)
d22004c4
WS
206#elif defined(__WXGTK__) || \
207 defined(__WXMOTIF__) || \
208 defined(__WXX11__) || \
209 defined(__WXMAC__) || \
210 defined(__WXMGL__) || \
d8bfd727 211 defined(__WXDFB__) || \
d22004c4 212 defined(__WXCOCOA__)
bab537dc 213 // Initialize from an included XPM
e45080c1 214 #define wxBITMAP(name) wxBitmap(name##_xpm)
b8aa1680 215#else // other platforms
0c5d3e1c
VZ
216 #define wxBITMAP(name) wxBitmap(name##_xpm, wxBITMAP_TYPE_XPM)
217#endif // platform
218
f03fc89f
VZ
219// ===========================================================================
220// classes
221// ===========================================================================
c801d85f 222
f03fc89f
VZ
223// ---------------------------------------------------------------------------
224// wxSize
225// ---------------------------------------------------------------------------
1e6feb95 226
53a2db12 227class WXDLLIMPEXP_CORE wxSize
c801d85f
KB
228{
229public:
e6c96a7c 230 // members are public for compatibility, don't use them directly.
72cdf4c9 231 int x, y;
f03fc89f
VZ
232
233 // constructors
7ee31b00
GD
234 wxSize() : x(0), y(0) { }
235 wxSize(int xx, int yy) : x(xx), y(yy) { }
f03fc89f
VZ
236
237 // no copy ctor or assignment operator - the defaults are ok
1e6feb95 238
fc84bd05
WS
239 wxSize& operator+=(const wxSize& sz) { x += sz.x; y += sz.y; return *this; }
240 wxSize& operator-=(const wxSize& sz) { x -= sz.x; y -= sz.y; return *this; }
bc5e942b
VZ
241 wxSize& operator/=(int i) { x /= i; y /= i; return *this; }
242 wxSize& operator*=(int i) { x *= i; y *= i; return *this; }
06d7b217
FM
243 wxSize& operator/=(unsigned int i) { x /= i; y /= i; return *this; }
244 wxSize& operator*=(unsigned int i) { x *= i; y *= i; return *this; }
245 wxSize& operator/=(long i) { x /= i; y /= i; return *this; }
246 wxSize& operator*=(long i) { x *= i; y *= i; return *this; }
247 wxSize& operator/=(unsigned long i) { x /= i; y /= i; return *this; }
248 wxSize& operator*=(unsigned long i) { x *= i; y *= i; return *this; }
ee08bdb5
FM
249 wxSize& operator/=(double i) { x = int(x/i); y = int(y/i); return *this; }
250 wxSize& operator*=(double i) { x = int(x*i); y = int(y*i); return *this; }
706f1421 251
5b087ae2
VZ
252 void IncTo(const wxSize& sz)
253 { if ( sz.x > x ) x = sz.x; if ( sz.y > y ) y = sz.y; }
254 void DecTo(const wxSize& sz)
255 { if ( sz.x < x ) x = sz.x; if ( sz.y < y ) y = sz.y; }
f03fc89f 256
23359747
VZ
257 void IncBy(int dx, int dy) { x += dx; y += dy; }
258 void IncBy(const wxSize& sz) { IncBy(sz.x, sz.y); }
259 void IncBy(int d) { IncBy(d, d); }
260
261 void DecBy(int dx, int dy) { IncBy(-dx, -dy); }
262 void DecBy(const wxSize& sz) { DecBy(sz.x, sz.y); }
263 void DecBy(int d) { DecBy(d, d); }
264
265
c5bad604
RR
266 wxSize& Scale(float xscale, float yscale)
267 { x = (int)(x*xscale); y = (int)(y*yscale); return *this; }
8efb2907 268
eddf46fe
JS
269 // accessors
270 void Set(int xx, int yy) { x = xx; y = yy; }
72cdf4c9
VZ
271 void SetWidth(int w) { x = w; }
272 void SetHeight(int h) { y = h; }
cc775580 273
72cdf4c9
VZ
274 int GetWidth() const { return x; }
275 int GetHeight() const { return y; }
f03fc89f 276
5d3e7b52 277 bool IsFullySpecified() const { return x != wxDefaultCoord && y != wxDefaultCoord; }
706f1421
VZ
278
279 // combine this size with the other one replacing the default (i.e. equal
5d3e7b52 280 // to wxDefaultCoord) components of this object with those of the other
706f1421
VZ
281 void SetDefaults(const wxSize& size)
282 {
5d3e7b52 283 if ( x == wxDefaultCoord )
706f1421 284 x = size.x;
5d3e7b52 285 if ( y == wxDefaultCoord )
706f1421
VZ
286 y = size.y;
287 }
288
cc775580 289 // compatibility
72cdf4c9
VZ
290 int GetX() const { return x; }
291 int GetY() const { return y; }
c801d85f
KB
292};
293
bc5e942b
VZ
294inline bool operator==(const wxSize& s1, const wxSize& s2)
295{
296 return s1.x == s2.x && s1.y == s2.y;
297}
298
299inline bool operator!=(const wxSize& s1, const wxSize& s2)
300{
301 return s1.x != s2.x || s1.y != s2.y;
302}
303
bc5e942b
VZ
304inline wxSize operator+(const wxSize& s1, const wxSize& s2)
305{
306 return wxSize(s1.x + s2.x, s1.y + s2.y);
307}
308
bc5e942b
VZ
309inline wxSize operator-(const wxSize& s1, const wxSize& s2)
310{
311 return wxSize(s1.x - s2.x, s1.y - s2.y);
312}
313
bc5e942b
VZ
314inline wxSize operator/(const wxSize& s, int i)
315{
316 return wxSize(s.x / i, s.y / i);
317}
318
bc5e942b
VZ
319inline wxSize operator*(const wxSize& s, int i)
320{
321 return wxSize(s.x * i, s.y * i);
322}
323
bc5e942b
VZ
324inline wxSize operator*(int i, const wxSize& s)
325{
326 return wxSize(s.x * i, s.y * i);
327}
328
06d7b217
FM
329inline wxSize operator/(const wxSize& s, unsigned int i)
330{
331 return wxSize(s.x / i, s.y / i);
332}
333
334inline wxSize operator*(const wxSize& s, unsigned int i)
335{
336 return wxSize(s.x * i, s.y * i);
337}
338
339inline wxSize operator*(unsigned int i, const wxSize& s)
340{
341 return wxSize(s.x * i, s.y * i);
342}
343
344inline wxSize operator/(const wxSize& s, long i)
345{
346 return wxSize(s.x / i, s.y / i);
347}
348
349inline wxSize operator*(const wxSize& s, long i)
350{
351 return wxSize(s.x * i, s.y * i);
352}
353
354inline wxSize operator*(long i, const wxSize& s)
355{
356 return wxSize(s.x * i, s.y * i);
357}
358
359inline wxSize operator/(const wxSize& s, unsigned long i)
360{
361 return wxSize(s.x / i, s.y / i);
362}
363
364inline wxSize operator*(const wxSize& s, unsigned long i)
365{
366 return wxSize(s.x * i, s.y * i);
367}
368
369inline wxSize operator*(unsigned long i, const wxSize& s)
370{
371 return wxSize(s.x * i, s.y * i);
372}
373
91743643
FM
374inline wxSize operator*(const wxSize& s, double i)
375{
ee08bdb5 376 return wxSize(int(s.x * i), int(s.y * i));
91743643
FM
377}
378
379inline wxSize operator*(double i, const wxSize& s)
380{
ee08bdb5 381 return wxSize(int(s.x * i), int(s.y * i));
91743643 382}
bc5e942b
VZ
383
384
385
f03fc89f
VZ
386// ---------------------------------------------------------------------------
387// Point classes: with real or integer coordinates
388// ---------------------------------------------------------------------------
764a3a49 389
53a2db12 390class WXDLLIMPEXP_CORE wxRealPoint
c801d85f 391{
f03fc89f
VZ
392public:
393 double x;
394 double y;
395
7ee31b00
GD
396 wxRealPoint() : x(0.0), y(0.0) { }
397 wxRealPoint(double xx, double yy) : x(xx), y(yy) { }
bc5e942b 398};
f03fc89f 399
f03fc89f 400
bc5e942b
VZ
401inline bool operator==(const wxRealPoint& p1, const wxRealPoint& p2)
402{
403 return wxIsSameDouble(p1.x, p2.x) && wxIsSameDouble(p1.y, p2.y);
404}
405
bc5e942b
VZ
406inline bool operator!=(const wxRealPoint& p1, const wxRealPoint& p2)
407{
408 return !(p1 == p2);
409}
410
bc5e942b
VZ
411inline wxRealPoint operator+(const wxRealPoint& p1, const wxRealPoint& p2)
412{
413 return wxRealPoint(p1.x + p2.x, p1.y + p2.y);
414}
415
416
417inline wxRealPoint operator-(const wxRealPoint& p1, const wxRealPoint& p2)
418{
419 return wxRealPoint(p1.x - p2.x, p1.y - p2.y);
420}
c801d85f 421
bc14c8b2 422
8b655c80
FM
423inline wxRealPoint operator/(const wxRealPoint& s, int i)
424{
425 return wxRealPoint(s.x / i, s.y / i);
426}
427
428inline wxRealPoint operator*(const wxRealPoint& s, int i)
429{
430 return wxRealPoint(s.x * i, s.y * i);
431}
432
433inline wxRealPoint operator*(int i, const wxRealPoint& s)
434{
435 return wxRealPoint(s.x * i, s.y * i);
436}
437
438inline wxRealPoint operator/(const wxRealPoint& s, unsigned int i)
439{
440 return wxRealPoint(s.x / i, s.y / i);
441}
442
443inline wxRealPoint operator*(const wxRealPoint& s, unsigned int i)
444{
445 return wxRealPoint(s.x * i, s.y * i);
446}
447
448inline wxRealPoint operator*(unsigned int i, const wxRealPoint& s)
449{
450 return wxRealPoint(s.x * i, s.y * i);
451}
452
453inline wxRealPoint operator/(const wxRealPoint& s, long i)
454{
455 return wxRealPoint(s.x / i, s.y / i);
456}
457
458inline wxRealPoint operator*(const wxRealPoint& s, long i)
459{
460 return wxRealPoint(s.x * i, s.y * i);
461}
462
463inline wxRealPoint operator*(long i, const wxRealPoint& s)
464{
465 return wxRealPoint(s.x * i, s.y * i);
466}
467
468inline wxRealPoint operator/(const wxRealPoint& s, unsigned long i)
469{
470 return wxRealPoint(s.x / i, s.y / i);
471}
472
473inline wxRealPoint operator*(const wxRealPoint& s, unsigned long i)
474{
475 return wxRealPoint(s.x * i, s.y * i);
476}
477
478inline wxRealPoint operator*(unsigned long i, const wxRealPoint& s)
479{
480 return wxRealPoint(s.x * i, s.y * i);
481}
482
483inline wxRealPoint operator*(const wxRealPoint& s, double i)
484{
485 return wxRealPoint(int(s.x * i), int(s.y * i));
486}
487
488inline wxRealPoint operator*(double i, const wxRealPoint& s)
489{
490 return wxRealPoint(int(s.x * i), int(s.y * i));
491}
492
493
bc5e942b
VZ
494// ----------------------------------------------------------------------------
495// wxPoint: 2D point with integer coordinates
496// ----------------------------------------------------------------------------
497
53a2db12 498class WXDLLIMPEXP_CORE wxPoint
c801d85f 499{
f03fc89f 500public:
72cdf4c9 501 int x, y;
6a6c0a8b 502
7ee31b00
GD
503 wxPoint() : x(0), y(0) { }
504 wxPoint(int xx, int yy) : x(xx), y(yy) { }
f03fc89f
VZ
505
506 // no copy ctor or assignment operator - the defaults are ok
6a6c0a8b 507
bc5e942b 508 //assignment operators
764a3a49
VZ
509 wxPoint& operator+=(const wxPoint& p) { x += p.x; y += p.y; return *this; }
510 wxPoint& operator-=(const wxPoint& p) { x -= p.x; y -= p.y; return *this; }
d02bc4c8
JS
511
512 wxPoint& operator+=(const wxSize& s) { x += s.GetWidth(); y += s.GetHeight(); return *this; }
513 wxPoint& operator-=(const wxSize& s) { x -= s.GetWidth(); y -= s.GetHeight(); return *this; }
bc5e942b 514};
d02bc4c8 515
24b800a9 516
bc5e942b
VZ
517// comparison
518inline bool operator==(const wxPoint& p1, const wxPoint& p2)
519{
520 return p1.x == p2.x && p1.y == p2.y;
521}
522
523inline bool operator!=(const wxPoint& p1, const wxPoint& p2)
524{
525 return !(p1 == p2);
526}
527
528
529// arithmetic operations (component wise)
530inline wxPoint operator+(const wxPoint& p1, const wxPoint& p2)
531{
532 return wxPoint(p1.x + p2.x, p1.y + p2.y);
533}
534
535inline wxPoint operator-(const wxPoint& p1, const wxPoint& p2)
536{
537 return wxPoint(p1.x - p2.x, p1.y - p2.y);
538}
539
540inline wxPoint operator+(const wxPoint& p, const wxSize& s)
541{
542 return wxPoint(p.x + s.x, p.y + s.y);
543}
544
545inline wxPoint operator-(const wxPoint& p, const wxSize& s)
546{
547 return wxPoint(p.x - s.x, p.y - s.y);
548}
549
550inline wxPoint operator+(const wxSize& s, const wxPoint& p)
551{
552 return wxPoint(p.x + s.x, p.y + s.y);
553}
554
555inline wxPoint operator-(const wxSize& s, const wxPoint& p)
556{
557 return wxPoint(s.x - p.x, s.y - p.y);
558}
559
560inline wxPoint operator-(const wxPoint& p)
561{
562 return wxPoint(-p.x, -p.y);
563}
564
ed0dd9c1
FM
565inline wxPoint operator/(const wxPoint& s, int i)
566{
567 return wxPoint(s.x / i, s.y / i);
568}
569
570inline wxPoint operator*(const wxPoint& s, int i)
571{
572 return wxPoint(s.x * i, s.y * i);
573}
574
575inline wxPoint operator*(int i, const wxPoint& s)
576{
577 return wxPoint(s.x * i, s.y * i);
578}
579
580inline wxPoint operator/(const wxPoint& s, unsigned int i)
581{
582 return wxPoint(s.x / i, s.y / i);
583}
584
585inline wxPoint operator*(const wxPoint& s, unsigned int i)
586{
587 return wxPoint(s.x * i, s.y * i);
588}
589
590inline wxPoint operator*(unsigned int i, const wxPoint& s)
591{
592 return wxPoint(s.x * i, s.y * i);
593}
594
595inline wxPoint operator/(const wxPoint& s, long i)
596{
597 return wxPoint(s.x / i, s.y / i);
598}
599
600inline wxPoint operator*(const wxPoint& s, long i)
601{
602 return wxPoint(s.x * i, s.y * i);
603}
604
605inline wxPoint operator*(long i, const wxPoint& s)
606{
607 return wxPoint(s.x * i, s.y * i);
608}
609
610inline wxPoint operator/(const wxPoint& s, unsigned long i)
611{
612 return wxPoint(s.x / i, s.y / i);
613}
614
615inline wxPoint operator*(const wxPoint& s, unsigned long i)
616{
617 return wxPoint(s.x * i, s.y * i);
618}
619
620inline wxPoint operator*(unsigned long i, const wxPoint& s)
621{
622 return wxPoint(s.x * i, s.y * i);
623}
624
625inline wxPoint operator*(const wxPoint& s, double i)
626{
627 return wxPoint(int(s.x * i), int(s.y * i));
628}
629
630inline wxPoint operator*(double i, const wxPoint& s)
631{
632 return wxPoint(int(s.x * i), int(s.y * i));
633}
634
b0d7707b 635WX_DECLARE_LIST_WITH_DECL(wxPoint, wxPointList, class WXDLLIMPEXP_CORE);
c801d85f 636
f03fc89f
VZ
637// ---------------------------------------------------------------------------
638// wxRect
639// ---------------------------------------------------------------------------
c801d85f 640
53a2db12 641class WXDLLIMPEXP_CORE wxRect
6a6c0a8b 642{
c801d85f 643public:
7ee31b00
GD
644 wxRect()
645 : x(0), y(0), width(0), height(0)
646 { }
72cdf4c9 647 wxRect(int xx, int yy, int ww, int hh)
7ee31b00
GD
648 : x(xx), y(yy), width(ww), height(hh)
649 { }
f03fc89f 650 wxRect(const wxPoint& topLeft, const wxPoint& bottomRight);
df83b840
VZ
651 wxRect(const wxPoint& pt, const wxSize& size)
652 : x(pt.x), y(pt.y), width(size.x), height(size.y)
653 { }
654 wxRect(const wxSize& size)
655 : x(0), y(0), width(size.x), height(size.y)
656 { }
a23fd0e1
VZ
657
658 // default copy ctor and assignment operators ok
c801d85f 659
72cdf4c9
VZ
660 int GetX() const { return x; }
661 void SetX(int xx) { x = xx; }
c801d85f 662
72cdf4c9
VZ
663 int GetY() const { return y; }
664 void SetY(int yy) { y = yy; }
c801d85f 665
72cdf4c9
VZ
666 int GetWidth() const { return width; }
667 void SetWidth(int w) { width = w; }
c801d85f 668
72cdf4c9
VZ
669 int GetHeight() const { return height; }
670 void SetHeight(int h) { height = h; }
f03fc89f 671
dcb44466 672 wxPoint GetPosition() const { return wxPoint(x, y); }
4aa0010b
RL
673 void SetPosition( const wxPoint &p ) { x = p.x; y = p.y; }
674
dcb44466 675 wxSize GetSize() const { return wxSize(width, height); }
4aa0010b 676 void SetSize( const wxSize &s ) { width = s.GetWidth(); height = s.GetHeight(); }
f03fc89f 677
b737ad10
RR
678 bool IsEmpty() const { return (width <= 0) || (height <= 0); }
679
f790ec82
VZ
680 int GetLeft() const { return x; }
681 int GetTop() const { return y; }
682 int GetBottom() const { return y + height - 1; }
683 int GetRight() const { return x + width - 1; }
684
685 void SetLeft(int left) { x = left; }
686 void SetRight(int right) { width = right - x + 1; }
687 void SetTop(int top) { y = top; }
688 void SetBottom(int bottom) { height = bottom - y + 1; }
689
355a5e2b
JS
690 wxPoint GetTopLeft() const { return GetPosition(); }
691 wxPoint GetLeftTop() const { return GetTopLeft(); }
692 void SetTopLeft(const wxPoint &p) { SetPosition(p); }
693 void SetLeftTop(const wxPoint &p) { SetTopLeft(p); }
694
695 wxPoint GetBottomRight() const { return wxPoint(GetRight(), GetBottom()); }
696 wxPoint GetRightBottom() const { return GetBottomRight(); }
697 void SetBottomRight(const wxPoint &p) { SetRight(p.x); SetBottom(p.y); }
698 void SetRightBottom(const wxPoint &p) { SetBottomRight(p); }
699
f790ec82
VZ
700 wxPoint GetTopRight() const { return wxPoint(GetRight(), GetTop()); }
701 wxPoint GetRightTop() const { return GetTopRight(); }
702 void SetTopRight(const wxPoint &p) { SetRight(p.x); SetTop(p.y); }
703 void SetRightTop(const wxPoint &p) { SetTopLeft(p); }
f03fc89f 704
f790ec82
VZ
705 wxPoint GetBottomLeft() const { return wxPoint(GetLeft(), GetBottom()); }
706 wxPoint GetLeftBottom() const { return GetBottomLeft(); }
707 void SetBottomLeft(const wxPoint &p) { SetLeft(p.x); SetBottom(p.y); }
708 void SetLeftBottom(const wxPoint &p) { SetBottomLeft(p); }
dcb44466 709
1e6feb95
VZ
710 // operations with rect
711 wxRect& Inflate(wxCoord dx, wxCoord dy);
c2c4d939 712 wxRect& Inflate(const wxSize& d) { return Inflate(d.x, d.y); }
1e6feb95
VZ
713 wxRect& Inflate(wxCoord d) { return Inflate(d, d); }
714 wxRect Inflate(wxCoord dx, wxCoord dy) const
715 {
716 wxRect r = *this;
717 r.Inflate(dx, dy);
718 return r;
719 }
720
721 wxRect& Deflate(wxCoord dx, wxCoord dy) { return Inflate(-dx, -dy); }
c2c4d939 722 wxRect& Deflate(const wxSize& d) { return Inflate(-d.x, -d.y); }
1e6feb95
VZ
723 wxRect& Deflate(wxCoord d) { return Inflate(-d); }
724 wxRect Deflate(wxCoord dx, wxCoord dy) const
725 {
726 wxRect r = *this;
727 r.Deflate(dx, dy);
728 return r;
729 }
730
731 void Offset(wxCoord dx, wxCoord dy) { x += dx; y += dy; }
732 void Offset(const wxPoint& pt) { Offset(pt.x, pt.y); }
733
734 wxRect& Intersect(const wxRect& rect);
735 wxRect Intersect(const wxRect& rect) const
45816ddd 736 {
1e6feb95
VZ
737 wxRect r = *this;
738 r.Intersect(rect);
739 return r;
45816ddd
VZ
740 }
741
df83b840
VZ
742 wxRect& Union(const wxRect& rect);
743 wxRect Union(const wxRect& rect) const
744 {
745 wxRect r = *this;
746 r.Union(rect);
747 return r;
748 }
45816ddd 749
5d3e7b52 750 // return true if the point is (not strcitly) inside the rect
22a35096
VS
751 bool Contains(int x, int y) const;
752 bool Contains(const wxPoint& pt) const { return Contains(pt.x, pt.y); }
fc01e9b3 753 // return true if the rectangle 'rect' is (not strictly) inside this rect
22a35096
VS
754 bool Contains(const wxRect& rect) const;
755
756#if WXWIN_COMPATIBILITY_2_6
757 // use Contains() instead
758 wxDEPRECATED( bool Inside(int x, int y) const );
759 wxDEPRECATED( bool Inside(const wxPoint& pt) const );
760 wxDEPRECATED( bool Inside(const wxRect& rect) const );
761#endif // WXWIN_COMPATIBILITY_2_6
1e6feb95 762
5d3e7b52 763 // return true if the rectangles have a non empty intersection
1e6feb95 764 bool Intersects(const wxRect& rect) const;
72cdf4c9 765
bc5e942b
VZ
766 // like Union() but don't ignore empty rectangles
767 wxRect& operator+=(const wxRect& rect);
df83b840 768
bc5e942b
VZ
769 // intersections of two rectrangles not testing for empty rectangles
770 wxRect& operator*=(const wxRect& rect);
df83b840 771
1bfb73b8
VZ
772 // centre this rectangle in the given (usually, but not necessarily,
773 // larger) one
774 wxRect CentreIn(const wxRect& r, int dir = wxBOTH) const
775 {
776 return wxRect(dir & wxHORIZONTAL ? r.x + (r.width - width)/2 : x,
777 dir & wxVERTICAL ? r.y + (r.height - height)/2 : y,
778 width, height);
779 }
780
781 wxRect CenterIn(const wxRect& r, int dir = wxBOTH) const
782 {
783 return CentreIn(r, dir);
784 }
785
f03fc89f 786public:
72cdf4c9 787 int x, y, width, height;
f03fc89f 788};
c801d85f 789
bc5e942b
VZ
790
791// compare rectangles
792inline bool operator==(const wxRect& r1, const wxRect& r2)
793{
794 return (r1.x == r2.x) && (r1.y == r2.y) &&
795 (r1.width == r2.width) && (r1.height == r2.height);
796}
797
798inline bool operator!=(const wxRect& r1, const wxRect& r2)
799{
800 return !(r1 == r2);
801}
802
803// like Union() but don't treat empty rectangles specially
804WXDLLIMPEXP_CORE wxRect operator+(const wxRect& r1, const wxRect& r2);
805
806// intersections of two rectangles
807WXDLLIMPEXP_CORE wxRect operator*(const wxRect& r1, const wxRect& r2);
808
809
810
811
22a35096 812#if WXWIN_COMPATIBILITY_2_6
3e69f6e5 813inline bool wxRect::Inside(int cx, int cy) const { return Contains(cx, cy); }
22a35096
VS
814inline bool wxRect::Inside(const wxPoint& pt) const { return Contains(pt); }
815inline bool wxRect::Inside(const wxRect& rect) const { return Contains(rect); }
816#endif // WXWIN_COMPATIBILITY_2_6
817
818
f03fc89f 819// ---------------------------------------------------------------------------
c801d85f 820// Management of pens, brushes and fonts
f03fc89f
VZ
821// ---------------------------------------------------------------------------
822
236a9de3
RL
823typedef wxInt8 wxDash;
824
1de8d512 825class WXDLLIMPEXP_CORE wxGDIObjListBase {
f03fc89f 826public:
1de8d512
VZ
827 wxGDIObjListBase();
828 ~wxGDIObjListBase();
f03fc89f 829
1de8d512
VZ
830protected:
831 wxList list;
c801d85f
KB
832};
833
f79f1604
PC
834WX_DECLARE_STRING_HASH_MAP(wxColour*, wxStringToColourHashMap);
835
53a2db12 836class WXDLLIMPEXP_CORE wxColourDatabase
c801d85f 837{
f03fc89f 838public:
222ed1d6 839 wxColourDatabase();
c50f92d0 840 ~wxColourDatabase();
f03fc89f 841
c50f92d0
VZ
842 // find colour by name or name for the given colour
843 wxColour Find(const wxString& name) const;
f03fc89f 844 wxString FindName(const wxColour& colour) const;
c50f92d0
VZ
845
846 // add a new colour to the database
847 void AddColour(const wxString& name, const wxColour& colour);
848
ca3e85cf 849#if WXWIN_COMPATIBILITY_2_6
492e2a5b
VZ
850 // deprecated, use Find() instead
851 wxDEPRECATED( wxColour *FindColour(const wxString& name) );
ca3e85cf 852#endif // WXWIN_COMPATIBILITY_2_6
c50f92d0
VZ
853
854
19bf0c69
DW
855#ifdef __WXPM__
856 // PM keeps its own type of colour table
857 long* m_palTable;
858 size_t m_nSize;
859#endif
c50f92d0 860
222ed1d6 861private:
c50f92d0
VZ
862 // load the database with the built in colour values when called for the
863 // first time, do nothing after this
864 void Initialize();
222ed1d6 865
c50f92d0 866 wxStringToColourHashMap *m_map;
c801d85f
KB
867};
868
53a2db12 869class WXDLLIMPEXP_CORE wxResourceCache: public wxList
f03fc89f
VZ
870{
871public:
872 wxResourceCache() { }
222ed1d6 873#if !wxUSE_STL
f03fc89f 874 wxResourceCache(const unsigned int keyType) : wxList(keyType) { }
222ed1d6 875#endif
d3c7fc99 876 virtual ~wxResourceCache();
f03fc89f
VZ
877};
878
879// ---------------------------------------------------------------------------
880// global variables
881// ---------------------------------------------------------------------------
882
c801d85f 883
f516d986
VZ
884/* Stock objects
885
886 wxStockGDI creates the stock GDI objects on demand. Pointers to the
887 created objects are stored in the ms_stockObject array, which is indexed
888 by the Item enum values. Platorm-specific fonts can be created by
889 implementing a derived class with an override for the GetFont function.
890 wxStockGDI operates as a singleton, accessed through the ms_instance
891 pointer. By default this pointer is set to an instance of wxStockGDI.
892 A derived class must arrange to set this pointer to an instance of itself.
893*/
894class WXDLLIMPEXP_CORE wxStockGDI
895{
896public:
897 enum Item {
898 BRUSH_BLACK,
899 BRUSH_BLUE,
900 BRUSH_CYAN,
901 BRUSH_GREEN,
86028025 902 BRUSH_YELLOW,
f516d986
VZ
903 BRUSH_GREY,
904 BRUSH_LIGHTGREY,
905 BRUSH_MEDIUMGREY,
906 BRUSH_RED,
907 BRUSH_TRANSPARENT,
908 BRUSH_WHITE,
909 COLOUR_BLACK,
910 COLOUR_BLUE,
911 COLOUR_CYAN,
912 COLOUR_GREEN,
86028025 913 COLOUR_YELLOW,
f516d986
VZ
914 COLOUR_LIGHTGREY,
915 COLOUR_RED,
916 COLOUR_WHITE,
917 CURSOR_CROSS,
918 CURSOR_HOURGLASS,
919 CURSOR_STANDARD,
920 FONT_ITALIC,
921 FONT_NORMAL,
922 FONT_SMALL,
923 FONT_SWISS,
924 PEN_BLACK,
925 PEN_BLACKDASHED,
d8184587 926 PEN_BLUE,
f516d986
VZ
927 PEN_CYAN,
928 PEN_GREEN,
86028025 929 PEN_YELLOW,
f516d986
VZ
930 PEN_GREY,
931 PEN_LIGHTGREY,
932 PEN_MEDIUMGREY,
933 PEN_RED,
934 PEN_TRANSPARENT,
935 PEN_WHITE,
936 ITEMCOUNT
937 };
938
939 wxStockGDI();
940 virtual ~wxStockGDI();
941 static void DeleteAll();
942
943 static wxStockGDI& instance() { return *ms_instance; }
944
945 static const wxBrush* GetBrush(Item item);
946 static const wxColour* GetColour(Item item);
947 static const wxCursor* GetCursor(Item item);
948 // Can be overridden by platform-specific derived classes
949 virtual const wxFont* GetFont(Item item);
950 static const wxPen* GetPen(Item item);
951
952protected:
953 static wxStockGDI* ms_instance;
954
955 static wxObject* ms_stockObject[ITEMCOUNT];
956
c0c133e1 957 wxDECLARE_NO_COPY_CLASS(wxStockGDI);
f516d986
VZ
958};
959
960#define wxITALIC_FONT wxStockGDI::instance().GetFont(wxStockGDI::FONT_ITALIC)
961#define wxNORMAL_FONT wxStockGDI::instance().GetFont(wxStockGDI::FONT_NORMAL)
962#define wxSMALL_FONT wxStockGDI::instance().GetFont(wxStockGDI::FONT_SMALL)
963#define wxSWISS_FONT wxStockGDI::instance().GetFont(wxStockGDI::FONT_SWISS)
964
965#define wxBLACK_DASHED_PEN wxStockGDI::GetPen(wxStockGDI::PEN_BLACKDASHED)
966#define wxBLACK_PEN wxStockGDI::GetPen(wxStockGDI::PEN_BLACK)
d8184587 967#define wxBLUE_PEN wxStockGDI::GetPen(wxStockGDI::PEN_BLUE)
f516d986
VZ
968#define wxCYAN_PEN wxStockGDI::GetPen(wxStockGDI::PEN_CYAN)
969#define wxGREEN_PEN wxStockGDI::GetPen(wxStockGDI::PEN_GREEN)
86028025 970#define wxYELLOW_PEN wxStockGDI::GetPen(wxStockGDI::PEN_YELLOW)
f516d986
VZ
971#define wxGREY_PEN wxStockGDI::GetPen(wxStockGDI::PEN_GREY)
972#define wxLIGHT_GREY_PEN wxStockGDI::GetPen(wxStockGDI::PEN_LIGHTGREY)
973#define wxMEDIUM_GREY_PEN wxStockGDI::GetPen(wxStockGDI::PEN_MEDIUMGREY)
974#define wxRED_PEN wxStockGDI::GetPen(wxStockGDI::PEN_RED)
975#define wxTRANSPARENT_PEN wxStockGDI::GetPen(wxStockGDI::PEN_TRANSPARENT)
976#define wxWHITE_PEN wxStockGDI::GetPen(wxStockGDI::PEN_WHITE)
977
978#define wxBLACK_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_BLACK)
979#define wxBLUE_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_BLUE)
980#define wxCYAN_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_CYAN)
981#define wxGREEN_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_GREEN)
86028025 982#define wxYELLOW_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_YELLOW)
f516d986
VZ
983#define wxGREY_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_GREY)
984#define wxLIGHT_GREY_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_LIGHTGREY)
985#define wxMEDIUM_GREY_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_MEDIUMGREY)
986#define wxRED_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_RED)
987#define wxTRANSPARENT_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_TRANSPARENT)
988#define wxWHITE_BRUSH wxStockGDI::GetBrush(wxStockGDI::BRUSH_WHITE)
989
990#define wxBLACK wxStockGDI::GetColour(wxStockGDI::COLOUR_BLACK)
991#define wxBLUE wxStockGDI::GetColour(wxStockGDI::COLOUR_BLUE)
992#define wxCYAN wxStockGDI::GetColour(wxStockGDI::COLOUR_CYAN)
993#define wxGREEN wxStockGDI::GetColour(wxStockGDI::COLOUR_GREEN)
86028025 994#define wxYELLOW wxStockGDI::GetColour(wxStockGDI::COLOUR_YELLOW)
f516d986
VZ
995#define wxLIGHT_GREY wxStockGDI::GetColour(wxStockGDI::COLOUR_LIGHTGREY)
996#define wxRED wxStockGDI::GetColour(wxStockGDI::COLOUR_RED)
997#define wxWHITE wxStockGDI::GetColour(wxStockGDI::COLOUR_WHITE)
998
999#define wxCROSS_CURSOR wxStockGDI::GetCursor(wxStockGDI::CURSOR_CROSS)
1000#define wxHOURGLASS_CURSOR wxStockGDI::GetCursor(wxStockGDI::CURSOR_HOURGLASS)
1001#define wxSTANDARD_CURSOR wxStockGDI::GetCursor(wxStockGDI::CURSOR_STANDARD)
c801d85f
KB
1002
1003// 'Null' objects
53a2db12
FM
1004extern WXDLLIMPEXP_DATA_CORE(wxBitmap) wxNullBitmap;
1005extern WXDLLIMPEXP_DATA_CORE(wxIcon) wxNullIcon;
1006extern WXDLLIMPEXP_DATA_CORE(wxCursor) wxNullCursor;
1007extern WXDLLIMPEXP_DATA_CORE(wxPen) wxNullPen;
1008extern WXDLLIMPEXP_DATA_CORE(wxBrush) wxNullBrush;
1009extern WXDLLIMPEXP_DATA_CORE(wxPalette) wxNullPalette;
1010extern WXDLLIMPEXP_DATA_CORE(wxFont) wxNullFont;
1011extern WXDLLIMPEXP_DATA_CORE(wxColour) wxNullColour;
1012extern WXDLLIMPEXP_DATA_CORE(wxIconBundle) wxNullIconBundle;
c801d85f 1013
53a2db12 1014extern WXDLLIMPEXP_DATA_CORE(wxColourDatabase*) wxTheColourDatabase;
f03fc89f 1015
53a2db12 1016extern WXDLLIMPEXP_DATA_CORE(const char) wxPanelNameStr[];
c801d85f 1017
53a2db12
FM
1018extern WXDLLIMPEXP_DATA_CORE(const wxSize) wxDefaultSize;
1019extern WXDLLIMPEXP_DATA_CORE(const wxPoint) wxDefaultPosition;
f03fc89f 1020
f03fc89f
VZ
1021// ---------------------------------------------------------------------------
1022// global functions
1023// ---------------------------------------------------------------------------
1024
1025// resource management
53a2db12
FM
1026extern void WXDLLIMPEXP_CORE wxInitializeStockLists();
1027extern void WXDLLIMPEXP_CORE wxDeleteStockLists();
c801d85f 1028
f03fc89f 1029// is the display colour (or monochrome)?
53a2db12 1030extern bool WXDLLIMPEXP_CORE wxColourDisplay();
c801d85f
KB
1031
1032// Returns depth of screen
53a2db12 1033extern int WXDLLIMPEXP_CORE wxDisplayDepth();
6a6c0a8b 1034#define wxGetDisplayDepth wxDisplayDepth
c801d85f 1035
904a68b6 1036// get the display size
53a2db12
FM
1037extern void WXDLLIMPEXP_CORE wxDisplaySize(int *width, int *height);
1038extern wxSize WXDLLIMPEXP_CORE wxGetDisplaySize();
1039extern void WXDLLIMPEXP_CORE wxDisplaySizeMM(int *width, int *height);
1040extern wxSize WXDLLIMPEXP_CORE wxGetDisplaySizeMM();
40fcf546 1041extern wxSize WXDLLIMPEXP_CORE wxGetDisplayPPI();
c801d85f 1042
ec5d7799 1043// Get position and size of the display workarea
53a2db12
FM
1044extern void WXDLLIMPEXP_CORE wxClientDisplayRect(int *x, int *y, int *width, int *height);
1045extern wxRect WXDLLIMPEXP_CORE wxGetClientDisplayRect();
ec5d7799 1046
f03fc89f 1047// set global cursor
53a2db12 1048extern void WXDLLIMPEXP_CORE wxSetCursor(const wxCursor& cursor);
c801d85f 1049
c801d85f 1050#endif
34138703 1051 // _WX_GDICMNH__