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