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