]>
Commit | Line | Data |
---|---|---|
c801d85f KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: gdicmn.h | |
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" |
bdcade0a | 23 | #include "wx/hashmap.h" |
bc14c8b2 | 24 | #include "wx/math.h" |
c801d85f | 25 | |
f03fc89f VZ |
26 | // --------------------------------------------------------------------------- |
27 | // forward declarations | |
28 | // --------------------------------------------------------------------------- | |
29 | ||
62a9d04c VS |
30 | class WXDLLIMPEXP_CORE wxBitmap; |
31 | class WXDLLIMPEXP_CORE wxBrush; | |
32 | class WXDLLIMPEXP_CORE wxColour; | |
33 | class WXDLLIMPEXP_CORE wxCursor; | |
34 | class WXDLLIMPEXP_CORE wxFont; | |
35 | class WXDLLIMPEXP_CORE wxIcon; | |
36 | class WXDLLIMPEXP_CORE wxPalette; | |
37 | class WXDLLIMPEXP_CORE wxPen; | |
38 | class WXDLLIMPEXP_CORE wxRegion; | |
39 | class WXDLLIMPEXP_BASE wxString; | |
f03fc89f VZ |
40 | |
41 | // --------------------------------------------------------------------------- | |
42 | // constants | |
43 | // --------------------------------------------------------------------------- | |
44 | ||
45 | // Bitmap flags | |
2aeec9ec | 46 | enum wxBitmapType |
f03fc89f | 47 | { |
6d167489 VZ |
48 | wxBITMAP_TYPE_INVALID, // should be == 0 for compatibility! |
49 | wxBITMAP_TYPE_BMP, | |
f03fc89f VZ |
50 | wxBITMAP_TYPE_BMP_RESOURCE, |
51 | wxBITMAP_TYPE_RESOURCE = wxBITMAP_TYPE_BMP_RESOURCE, | |
52 | wxBITMAP_TYPE_ICO, | |
53 | wxBITMAP_TYPE_ICO_RESOURCE, | |
54 | wxBITMAP_TYPE_CUR, | |
55 | wxBITMAP_TYPE_CUR_RESOURCE, | |
56 | wxBITMAP_TYPE_XBM, | |
57 | wxBITMAP_TYPE_XBM_DATA, | |
58 | wxBITMAP_TYPE_XPM, | |
59 | wxBITMAP_TYPE_XPM_DATA, | |
60 | wxBITMAP_TYPE_TIF, | |
61 | wxBITMAP_TYPE_TIF_RESOURCE, | |
62 | wxBITMAP_TYPE_GIF, | |
63 | wxBITMAP_TYPE_GIF_RESOURCE, | |
64 | wxBITMAP_TYPE_PNG, | |
65 | wxBITMAP_TYPE_PNG_RESOURCE, | |
66 | wxBITMAP_TYPE_JPEG, | |
67 | wxBITMAP_TYPE_JPEG_RESOURCE, | |
bcc46c75 SB |
68 | wxBITMAP_TYPE_PNM, |
69 | wxBITMAP_TYPE_PNM_RESOURCE, | |
6523d119 GRG |
70 | wxBITMAP_TYPE_PCX, |
71 | wxBITMAP_TYPE_PCX_RESOURCE, | |
6d167489 VZ |
72 | wxBITMAP_TYPE_PICT, |
73 | wxBITMAP_TYPE_PICT_RESOURCE, | |
74 | wxBITMAP_TYPE_ICON, | |
75 | wxBITMAP_TYPE_ICON_RESOURCE, | |
658974ae | 76 | wxBITMAP_TYPE_ANI, |
63f8abca | 77 | wxBITMAP_TYPE_IFF, |
6d167489 VZ |
78 | wxBITMAP_TYPE_MACCURSOR, |
79 | wxBITMAP_TYPE_MACCURSOR_RESOURCE, | |
f03fc89f VZ |
80 | wxBITMAP_TYPE_ANY = 50 |
81 | }; | |
82 | ||
c801d85f | 83 | // Standard cursors |
f03fc89f VZ |
84 | enum wxStockCursor |
85 | { | |
86 | wxCURSOR_NONE, // should be 0 | |
87 | wxCURSOR_ARROW, | |
15dadf31 | 88 | wxCURSOR_RIGHT_ARROW, |
f03fc89f VZ |
89 | wxCURSOR_BULLSEYE, |
90 | wxCURSOR_CHAR, | |
91 | wxCURSOR_CROSS, | |
92 | wxCURSOR_HAND, | |
93 | wxCURSOR_IBEAM, | |
94 | wxCURSOR_LEFT_BUTTON, | |
95 | wxCURSOR_MAGNIFIER, | |
96 | wxCURSOR_MIDDLE_BUTTON, | |
97 | wxCURSOR_NO_ENTRY, | |
98 | wxCURSOR_PAINT_BRUSH, | |
99 | wxCURSOR_PENCIL, | |
100 | wxCURSOR_POINT_LEFT, | |
101 | wxCURSOR_POINT_RIGHT, | |
102 | wxCURSOR_QUESTION_ARROW, | |
103 | wxCURSOR_RIGHT_BUTTON, | |
104 | wxCURSOR_SIZENESW, | |
105 | wxCURSOR_SIZENS, | |
106 | wxCURSOR_SIZENWSE, | |
107 | wxCURSOR_SIZEWE, | |
108 | wxCURSOR_SIZING, | |
109 | wxCURSOR_SPRAYCAN, | |
110 | wxCURSOR_WAIT, | |
111 | wxCURSOR_WATCH, | |
112 | wxCURSOR_BLANK, | |
ae53c98c KB |
113 | #ifdef __WXGTK__ |
114 | wxCURSOR_DEFAULT, // standard X11 cursor | |
115 | #endif | |
5f7a6626 | 116 | #ifdef __WXMAC__ |
5d3e7b52 | 117 | wxCURSOR_COPY_ARROW , // MacOS Theme Plus arrow |
5f7a6626 | 118 | #endif |
c801d85f | 119 | #ifdef __X__ |
f03fc89f VZ |
120 | // Not yet implemented for Windows |
121 | wxCURSOR_CROSS_REVERSE, | |
122 | wxCURSOR_DOUBLE_ARROW, | |
123 | wxCURSOR_BASED_ARROW_UP, | |
ea804aad | 124 | wxCURSOR_BASED_ARROW_DOWN, |
f03fc89f VZ |
125 | #endif // X11 |
126 | ||
83f96286 RD |
127 | wxCURSOR_ARROWWAIT, |
128 | ||
f03fc89f VZ |
129 | wxCURSOR_MAX |
130 | }; | |
131 | ||
943d28e4 VZ |
132 | #ifndef __WXGTK__ |
133 | #define wxCURSOR_DEFAULT wxCURSOR_ARROW | |
134 | #endif | |
135 | ||
f03fc89f VZ |
136 | // --------------------------------------------------------------------------- |
137 | // macros | |
138 | // --------------------------------------------------------------------------- | |
139 | ||
140 | /* Useful macro for creating icons portably, for example: | |
141 | ||
142 | wxIcon *icon = new wxICON(mondrian); | |
143 | ||
144 | expands into: | |
145 | ||
146 | wxIcon *icon = new wxIcon("mondrian"); // On wxMSW | |
147 | wxIcon *icon = new wxIcon(mondrian_xpm); // On wxGTK | |
148 | */ | |
149 | ||
150 | #ifdef __WXMSW__ | |
151 | // Load from a resource | |
2b5f62a0 | 152 | #define wxICON(X) wxIcon(wxT(#X)) |
1777b9bb DW |
153 | #elif defined(__WXPM__) |
154 | // Load from a resource | |
2b5f62a0 | 155 | #define wxICON(X) wxIcon(wxT(#X)) |
1e6feb95 | 156 | #elif defined(__WXMGL__) |
1d965e2f VS |
157 | // Initialize from an included XPM |
158 | #define wxICON(X) wxIcon( (const char**) X##_xpm ) | |
f03fc89f VZ |
159 | #elif defined(__WXGTK__) |
160 | // Initialize from an included XPM | |
161 | #define wxICON(X) wxIcon( (const char**) X##_xpm ) | |
0532484d GD |
162 | #elif defined(__WXMAC__) |
163 | // Initialize from an included XPM | |
164 | #define wxICON(X) wxIcon( (const char**) X##_xpm ) | |
f03fc89f VZ |
165 | #elif defined(__WXMOTIF__) |
166 | // Initialize from an included XPM | |
167 | #define wxICON(X) wxIcon( X##_xpm ) | |
83df96d6 JS |
168 | #elif defined(__WXX11__) |
169 | // Initialize from an included XPM | |
170 | #define wxICON(X) wxIcon( X##_xpm ) | |
f03fc89f VZ |
171 | #else |
172 | // This will usually mean something on any platform | |
2b5f62a0 | 173 | #define wxICON(X) wxIcon(wxT(#X)) |
f03fc89f VZ |
174 | #endif // platform |
175 | ||
0c5d3e1c VZ |
176 | /* Another macro: this one is for portable creation of bitmaps. We assume that |
177 | under Unix bitmaps live in XPMs and under Windows they're in ressources. | |
178 | */ | |
179 | ||
1d965e2f | 180 | #if defined(__WXMSW__) || defined(__WXPM__) |
2b5f62a0 | 181 | #define wxBITMAP(name) wxBitmap(wxT(#name), wxBITMAP_TYPE_RESOURCE) |
d22004c4 WS |
182 | #elif defined(__WXGTK__) || \ |
183 | defined(__WXMOTIF__) || \ | |
184 | defined(__WXX11__) || \ | |
185 | defined(__WXMAC__) || \ | |
186 | defined(__WXMGL__) || \ | |
187 | defined(__WXCOCOA__) | |
bab537dc VS |
188 | // Initialize from an included XPM |
189 | #define wxBITMAP(name) wxBitmap( (const char**) name##_xpm ) | |
b8aa1680 | 190 | #else // other platforms |
0c5d3e1c VZ |
191 | #define wxBITMAP(name) wxBitmap(name##_xpm, wxBITMAP_TYPE_XPM) |
192 | #endif // platform | |
193 | ||
f03fc89f VZ |
194 | // =========================================================================== |
195 | // classes | |
196 | // =========================================================================== | |
c801d85f | 197 | |
f03fc89f VZ |
198 | // --------------------------------------------------------------------------- |
199 | // wxSize | |
200 | // --------------------------------------------------------------------------- | |
1e6feb95 | 201 | |
6a6c0a8b | 202 | class WXDLLEXPORT wxSize |
c801d85f KB |
203 | { |
204 | public: | |
e6c96a7c | 205 | // members are public for compatibility, don't use them directly. |
72cdf4c9 | 206 | int x, y; |
f03fc89f VZ |
207 | |
208 | // constructors | |
7ee31b00 GD |
209 | wxSize() : x(0), y(0) { } |
210 | wxSize(int xx, int yy) : x(xx), y(yy) { } | |
f03fc89f VZ |
211 | |
212 | // no copy ctor or assignment operator - the defaults are ok | |
1e6feb95 | 213 | |
f03fc89f | 214 | bool operator==(const wxSize& sz) const { return x == sz.x && y == sz.y; } |
1e6feb95 | 215 | bool operator!=(const wxSize& sz) const { return x != sz.x || y != sz.y; } |
f03fc89f | 216 | |
fbfb8bcc VZ |
217 | wxSize operator+(const wxSize& sz) const { return wxSize(x + sz.x, y + sz.y); } |
218 | wxSize operator-(const wxSize& sz) const { return wxSize(x - sz.x, y - sz.y); } | |
219 | wxSize operator/(int i) const { return wxSize(x / i, y / i); } | |
220 | wxSize operator*(int i) const { return wxSize(x * i, y * i); } | |
fc84bd05 WS |
221 | |
222 | wxSize& operator+=(const wxSize& sz) { x += sz.x; y += sz.y; return *this; } | |
223 | wxSize& operator-=(const wxSize& sz) { x -= sz.x; y -= sz.y; return *this; } | |
224 | wxSize& operator/=(const int i) { x /= i; y /= i; return *this; } | |
225 | wxSize& operator*=(const int i) { x *= i; y *= i; return *this; } | |
706f1421 | 226 | |
5b087ae2 VZ |
227 | void IncTo(const wxSize& sz) |
228 | { if ( sz.x > x ) x = sz.x; if ( sz.y > y ) y = sz.y; } | |
229 | void DecTo(const wxSize& sz) | |
230 | { if ( sz.x < x ) x = sz.x; if ( sz.y < y ) y = sz.y; } | |
f03fc89f | 231 | |
eddf46fe JS |
232 | // accessors |
233 | void Set(int xx, int yy) { x = xx; y = yy; } | |
72cdf4c9 VZ |
234 | void SetWidth(int w) { x = w; } |
235 | void SetHeight(int h) { y = h; } | |
cc775580 | 236 | |
72cdf4c9 VZ |
237 | int GetWidth() const { return x; } |
238 | int GetHeight() const { return y; } | |
f03fc89f | 239 | |
5d3e7b52 | 240 | bool IsFullySpecified() const { return x != wxDefaultCoord && y != wxDefaultCoord; } |
706f1421 VZ |
241 | |
242 | // combine this size with the other one replacing the default (i.e. equal | |
5d3e7b52 | 243 | // to wxDefaultCoord) components of this object with those of the other |
706f1421 VZ |
244 | void SetDefaults(const wxSize& size) |
245 | { | |
5d3e7b52 | 246 | if ( x == wxDefaultCoord ) |
706f1421 | 247 | x = size.x; |
5d3e7b52 | 248 | if ( y == wxDefaultCoord ) |
706f1421 VZ |
249 | y = size.y; |
250 | } | |
251 | ||
cc775580 | 252 | // compatibility |
72cdf4c9 VZ |
253 | int GetX() const { return x; } |
254 | int GetY() const { return y; } | |
c801d85f KB |
255 | }; |
256 | ||
f03fc89f VZ |
257 | // --------------------------------------------------------------------------- |
258 | // Point classes: with real or integer coordinates | |
259 | // --------------------------------------------------------------------------- | |
764a3a49 | 260 | |
6a6c0a8b | 261 | class WXDLLEXPORT wxRealPoint |
c801d85f | 262 | { |
f03fc89f VZ |
263 | public: |
264 | double x; | |
265 | double y; | |
266 | ||
7ee31b00 GD |
267 | wxRealPoint() : x(0.0), y(0.0) { } |
268 | wxRealPoint(double xx, double yy) : x(xx), y(yy) { } | |
f03fc89f | 269 | |
f6bcfd97 BP |
270 | wxRealPoint operator+(const wxRealPoint& pt) const { return wxRealPoint(x + pt.x, y + pt.y); } |
271 | wxRealPoint operator-(const wxRealPoint& pt) const { return wxRealPoint(x - pt.x, y - pt.y); } | |
f03fc89f | 272 | |
bc14c8b2 VZ |
273 | bool operator==(const wxRealPoint& pt) const |
274 | { | |
275 | return wxIsSameDouble(x, pt.x) && wxIsSameDouble(y, pt.y); | |
276 | } | |
277 | bool operator!=(const wxRealPoint& pt) const { return !(*this == pt); } | |
c801d85f KB |
278 | }; |
279 | ||
bc14c8b2 | 280 | |
6a6c0a8b | 281 | class WXDLLEXPORT wxPoint |
c801d85f | 282 | { |
f03fc89f | 283 | public: |
72cdf4c9 | 284 | int x, y; |
6a6c0a8b | 285 | |
7ee31b00 GD |
286 | wxPoint() : x(0), y(0) { } |
287 | wxPoint(int xx, int yy) : x(xx), y(yy) { } | |
f03fc89f VZ |
288 | |
289 | // no copy ctor or assignment operator - the defaults are ok | |
6a6c0a8b | 290 | |
764a3a49 VZ |
291 | // comparison |
292 | bool operator==(const wxPoint& p) const { return x == p.x && y == p.y; } | |
293 | bool operator!=(const wxPoint& p) const { return !(*this == p); } | |
294 | ||
295 | // arithmetic operations (component wise) | |
f6bcfd97 BP |
296 | wxPoint operator+(const wxPoint& p) const { return wxPoint(x + p.x, y + p.y); } |
297 | wxPoint operator-(const wxPoint& p) const { return wxPoint(x - p.x, y - p.y); } | |
f03fc89f | 298 | |
764a3a49 VZ |
299 | wxPoint& operator+=(const wxPoint& p) { x += p.x; y += p.y; return *this; } |
300 | wxPoint& operator-=(const wxPoint& p) { x -= p.x; y -= p.y; return *this; } | |
d02bc4c8 JS |
301 | |
302 | wxPoint& operator+=(const wxSize& s) { x += s.GetWidth(); y += s.GetHeight(); return *this; } | |
303 | wxPoint& operator-=(const wxSize& s) { x -= s.GetWidth(); y -= s.GetHeight(); return *this; } | |
304 | ||
305 | wxPoint operator+(const wxSize& s) const { return wxPoint(x + s.GetWidth(), y + s.GetHeight()); } | |
306 | wxPoint operator-(const wxSize& s) const { return wxPoint(x - s.GetWidth(), y - s.GetHeight()); } | |
c801d85f KB |
307 | }; |
308 | ||
f03fc89f VZ |
309 | // --------------------------------------------------------------------------- |
310 | // wxRect | |
311 | // --------------------------------------------------------------------------- | |
c801d85f | 312 | |
6a6c0a8b JS |
313 | class WXDLLEXPORT wxRect |
314 | { | |
c801d85f | 315 | public: |
7ee31b00 GD |
316 | wxRect() |
317 | : x(0), y(0), width(0), height(0) | |
318 | { } | |
72cdf4c9 | 319 | wxRect(int xx, int yy, int ww, int hh) |
7ee31b00 GD |
320 | : x(xx), y(yy), width(ww), height(hh) |
321 | { } | |
f03fc89f | 322 | wxRect(const wxPoint& topLeft, const wxPoint& bottomRight); |
df83b840 VZ |
323 | wxRect(const wxPoint& pt, const wxSize& size) |
324 | : x(pt.x), y(pt.y), width(size.x), height(size.y) | |
325 | { } | |
326 | wxRect(const wxSize& size) | |
327 | : x(0), y(0), width(size.x), height(size.y) | |
328 | { } | |
a23fd0e1 VZ |
329 | |
330 | // default copy ctor and assignment operators ok | |
c801d85f | 331 | |
72cdf4c9 VZ |
332 | int GetX() const { return x; } |
333 | void SetX(int xx) { x = xx; } | |
c801d85f | 334 | |
72cdf4c9 VZ |
335 | int GetY() const { return y; } |
336 | void SetY(int yy) { y = yy; } | |
c801d85f | 337 | |
72cdf4c9 VZ |
338 | int GetWidth() const { return width; } |
339 | void SetWidth(int w) { width = w; } | |
c801d85f | 340 | |
72cdf4c9 VZ |
341 | int GetHeight() const { return height; } |
342 | void SetHeight(int h) { height = h; } | |
f03fc89f | 343 | |
dcb44466 | 344 | wxPoint GetPosition() const { return wxPoint(x, y); } |
4aa0010b RL |
345 | void SetPosition( const wxPoint &p ) { x = p.x; y = p.y; } |
346 | ||
dcb44466 | 347 | wxSize GetSize() const { return wxSize(width, height); } |
4aa0010b | 348 | void SetSize( const wxSize &s ) { width = s.GetWidth(); height = s.GetHeight(); } |
f03fc89f | 349 | |
b737ad10 RR |
350 | bool IsEmpty() const { return (width <= 0) || (height <= 0); } |
351 | ||
355a5e2b JS |
352 | wxPoint GetTopLeft() const { return GetPosition(); } |
353 | wxPoint GetLeftTop() const { return GetTopLeft(); } | |
354 | void SetTopLeft(const wxPoint &p) { SetPosition(p); } | |
355 | void SetLeftTop(const wxPoint &p) { SetTopLeft(p); } | |
356 | ||
357 | wxPoint GetBottomRight() const { return wxPoint(GetRight(), GetBottom()); } | |
358 | wxPoint GetRightBottom() const { return GetBottomRight(); } | |
359 | void SetBottomRight(const wxPoint &p) { SetRight(p.x); SetBottom(p.y); } | |
360 | void SetRightBottom(const wxPoint &p) { SetBottomRight(p); } | |
361 | ||
72cdf4c9 VZ |
362 | int GetLeft() const { return x; } |
363 | int GetTop() const { return y; } | |
364 | int GetBottom() const { return y + height - 1; } | |
365 | int GetRight() const { return x + width - 1; } | |
f03fc89f | 366 | |
72cdf4c9 VZ |
367 | void SetLeft(int left) { x = left; } |
368 | void SetRight(int right) { width = right - x + 1; } | |
369 | void SetTop(int top) { y = top; } | |
370 | void SetBottom(int bottom) { height = bottom - y + 1; } | |
dcb44466 | 371 | |
1e6feb95 VZ |
372 | // operations with rect |
373 | wxRect& Inflate(wxCoord dx, wxCoord dy); | |
374 | wxRect& Inflate(wxCoord d) { return Inflate(d, d); } | |
375 | wxRect Inflate(wxCoord dx, wxCoord dy) const | |
376 | { | |
377 | wxRect r = *this; | |
378 | r.Inflate(dx, dy); | |
379 | return r; | |
380 | } | |
381 | ||
382 | wxRect& Deflate(wxCoord dx, wxCoord dy) { return Inflate(-dx, -dy); } | |
383 | wxRect& Deflate(wxCoord d) { return Inflate(-d); } | |
384 | wxRect Deflate(wxCoord dx, wxCoord dy) const | |
385 | { | |
386 | wxRect r = *this; | |
387 | r.Deflate(dx, dy); | |
388 | return r; | |
389 | } | |
390 | ||
391 | void Offset(wxCoord dx, wxCoord dy) { x += dx; y += dy; } | |
392 | void Offset(const wxPoint& pt) { Offset(pt.x, pt.y); } | |
393 | ||
394 | wxRect& Intersect(const wxRect& rect); | |
395 | wxRect Intersect(const wxRect& rect) const | |
45816ddd | 396 | { |
1e6feb95 VZ |
397 | wxRect r = *this; |
398 | r.Intersect(rect); | |
399 | return r; | |
45816ddd VZ |
400 | } |
401 | ||
df83b840 VZ |
402 | wxRect& Union(const wxRect& rect); |
403 | wxRect Union(const wxRect& rect) const | |
404 | { | |
405 | wxRect r = *this; | |
406 | r.Union(rect); | |
407 | return r; | |
408 | } | |
45816ddd | 409 | |
1e6feb95 | 410 | // compare rectangles |
764a3a49 VZ |
411 | bool operator==(const wxRect& rect) const; |
412 | bool operator!=(const wxRect& rect) const { return !(*this == rect); } | |
f03fc89f | 413 | |
5d3e7b52 | 414 | // return true if the point is (not strcitly) inside the rect |
1e6feb95 | 415 | bool Inside(int x, int y) const; |
59a12e90 | 416 | bool Inside(const wxPoint& pt) const { return Inside(pt.x, pt.y); } |
1e6feb95 | 417 | |
5d3e7b52 | 418 | // return true if the rectangles have a non empty intersection |
1e6feb95 | 419 | bool Intersects(const wxRect& rect) const; |
72cdf4c9 | 420 | |
df83b840 VZ |
421 | |
422 | // these are like Union() but don't ignore empty rectangles | |
423 | wxRect operator+(const wxRect& rect) const; | |
3ea9aa8f | 424 | wxRect& operator+=(const wxRect& rect) |
df83b840 VZ |
425 | { |
426 | *this = *this + rect; | |
427 | return *this; | |
428 | } | |
429 | ||
430 | ||
1bfb73b8 VZ |
431 | // centre this rectangle in the given (usually, but not necessarily, |
432 | // larger) one | |
433 | wxRect CentreIn(const wxRect& r, int dir = wxBOTH) const | |
434 | { | |
435 | return wxRect(dir & wxHORIZONTAL ? r.x + (r.width - width)/2 : x, | |
436 | dir & wxVERTICAL ? r.y + (r.height - height)/2 : y, | |
437 | width, height); | |
438 | } | |
439 | ||
440 | wxRect CenterIn(const wxRect& r, int dir = wxBOTH) const | |
441 | { | |
442 | return CentreIn(r, dir); | |
443 | } | |
444 | ||
f03fc89f | 445 | public: |
72cdf4c9 | 446 | int x, y, width, height; |
f03fc89f | 447 | }; |
c801d85f | 448 | |
f03fc89f | 449 | // --------------------------------------------------------------------------- |
c801d85f | 450 | // Management of pens, brushes and fonts |
f03fc89f VZ |
451 | // --------------------------------------------------------------------------- |
452 | ||
236a9de3 RL |
453 | typedef wxInt8 wxDash; |
454 | ||
f03fc89f | 455 | class WXDLLEXPORT wxPenList : public wxList |
c801d85f | 456 | { |
f03fc89f VZ |
457 | public: |
458 | wxPenList() { } | |
9b51403d | 459 | ~wxPenList(); |
f03fc89f VZ |
460 | |
461 | void AddPen(wxPen *pen); | |
462 | void RemovePen(wxPen *pen); | |
463 | wxPen *FindOrCreatePen(const wxColour& colour, int width, int style); | |
c801d85f KB |
464 | }; |
465 | ||
f03fc89f | 466 | class WXDLLEXPORT wxBrushList : public wxList |
c801d85f | 467 | { |
f03fc89f VZ |
468 | public: |
469 | wxBrushList() { } | |
9b51403d | 470 | ~wxBrushList(); |
f03fc89f VZ |
471 | |
472 | void AddBrush(wxBrush *brush); | |
473 | void RemoveBrush(wxBrush *brush); | |
cf000528 | 474 | wxBrush *FindOrCreateBrush(const wxColour& colour, int style = wxSOLID); |
c801d85f KB |
475 | }; |
476 | ||
f03fc89f | 477 | class WXDLLEXPORT wxFontList : public wxList |
c801d85f | 478 | { |
f03fc89f VZ |
479 | public: |
480 | wxFontList() { } | |
9b51403d | 481 | ~wxFontList(); |
f03fc89f VZ |
482 | |
483 | void AddFont(wxFont *font); | |
484 | void RemoveFont(wxFont *font); | |
485 | wxFont *FindOrCreateFont(int pointSize, int family, int style, int weight, | |
5d3e7b52 | 486 | bool underline = false, |
37bebc11 RD |
487 | const wxString& face = wxEmptyString, |
488 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT); | |
c801d85f KB |
489 | }; |
490 | ||
3f5c62f9 | 491 | WX_DECLARE_STRING_HASH_MAP( wxColour *, wxStringToColourHashMap ); |
222ed1d6 MB |
492 | |
493 | class WXDLLEXPORT wxColourDatabase | |
c801d85f | 494 | { |
f03fc89f | 495 | public: |
222ed1d6 | 496 | wxColourDatabase(); |
c50f92d0 | 497 | ~wxColourDatabase(); |
f03fc89f | 498 | |
c50f92d0 VZ |
499 | // find colour by name or name for the given colour |
500 | wxColour Find(const wxString& name) const; | |
f03fc89f | 501 | wxString FindName(const wxColour& colour) const; |
c50f92d0 VZ |
502 | |
503 | // add a new colour to the database | |
504 | void AddColour(const wxString& name, const wxColour& colour); | |
505 | ||
492e2a5b VZ |
506 | // deprecated, use Find() instead |
507 | wxDEPRECATED( wxColour *FindColour(const wxString& name) ); | |
c50f92d0 VZ |
508 | |
509 | ||
19bf0c69 DW |
510 | #ifdef __WXPM__ |
511 | // PM keeps its own type of colour table | |
512 | long* m_palTable; | |
513 | size_t m_nSize; | |
514 | #endif | |
c50f92d0 | 515 | |
222ed1d6 | 516 | private: |
c50f92d0 VZ |
517 | // load the database with the built in colour values when called for the |
518 | // first time, do nothing after this | |
519 | void Initialize(); | |
222ed1d6 | 520 | |
c50f92d0 | 521 | wxStringToColourHashMap *m_map; |
c801d85f KB |
522 | }; |
523 | ||
f03fc89f | 524 | class WXDLLEXPORT wxBitmapList : public wxList |
c801d85f | 525 | { |
f03fc89f | 526 | public: |
1b941f2d | 527 | wxBitmapList(){} |
9b51403d | 528 | ~wxBitmapList(); |
f03fc89f VZ |
529 | |
530 | void AddBitmap(wxBitmap *bitmap); | |
531 | void RemoveBitmap(wxBitmap *bitmap); | |
c801d85f KB |
532 | }; |
533 | ||
f03fc89f VZ |
534 | class WXDLLEXPORT wxResourceCache: public wxList |
535 | { | |
536 | public: | |
537 | wxResourceCache() { } | |
222ed1d6 | 538 | #if !wxUSE_STL |
f03fc89f | 539 | wxResourceCache(const unsigned int keyType) : wxList(keyType) { } |
222ed1d6 | 540 | #endif |
9b51403d | 541 | ~wxResourceCache(); |
f03fc89f VZ |
542 | }; |
543 | ||
544 | // --------------------------------------------------------------------------- | |
545 | // global variables | |
546 | // --------------------------------------------------------------------------- | |
547 | ||
c801d85f | 548 | // Lists of GDI objects |
16cba29d WS |
549 | extern WXDLLEXPORT_DATA(wxPenList*) wxThePenList; |
550 | extern WXDLLEXPORT_DATA(wxBrushList*) wxTheBrushList; | |
551 | extern WXDLLEXPORT_DATA(wxFontList*) wxTheFontList; | |
552 | extern WXDLLEXPORT_DATA(wxBitmapList*) wxTheBitmapList; | |
c801d85f KB |
553 | |
554 | // Stock objects | |
16cba29d WS |
555 | extern WXDLLEXPORT_DATA(wxFont*) wxNORMAL_FONT; |
556 | extern WXDLLEXPORT_DATA(wxFont*) wxSMALL_FONT; | |
557 | extern WXDLLEXPORT_DATA(wxFont*) wxITALIC_FONT; | |
558 | extern WXDLLEXPORT_DATA(wxFont*) wxSWISS_FONT; | |
559 | ||
560 | extern WXDLLEXPORT_DATA(wxPen*) wxRED_PEN; | |
561 | extern WXDLLEXPORT_DATA(wxPen*) wxCYAN_PEN; | |
562 | extern WXDLLEXPORT_DATA(wxPen*) wxGREEN_PEN; | |
563 | extern WXDLLEXPORT_DATA(wxPen*) wxBLACK_PEN; | |
564 | extern WXDLLEXPORT_DATA(wxPen*) wxWHITE_PEN; | |
565 | extern WXDLLEXPORT_DATA(wxPen*) wxTRANSPARENT_PEN; | |
566 | extern WXDLLEXPORT_DATA(wxPen*) wxBLACK_DASHED_PEN; | |
567 | extern WXDLLEXPORT_DATA(wxPen*) wxGREY_PEN; | |
568 | extern WXDLLEXPORT_DATA(wxPen*) wxMEDIUM_GREY_PEN; | |
569 | extern WXDLLEXPORT_DATA(wxPen*) wxLIGHT_GREY_PEN; | |
570 | ||
571 | extern WXDLLEXPORT_DATA(wxBrush*) wxBLUE_BRUSH; | |
572 | extern WXDLLEXPORT_DATA(wxBrush*) wxGREEN_BRUSH; | |
573 | extern WXDLLEXPORT_DATA(wxBrush*) wxWHITE_BRUSH; | |
574 | extern WXDLLEXPORT_DATA(wxBrush*) wxBLACK_BRUSH; | |
575 | extern WXDLLEXPORT_DATA(wxBrush*) wxGREY_BRUSH; | |
576 | extern WXDLLEXPORT_DATA(wxBrush*) wxMEDIUM_GREY_BRUSH; | |
577 | extern WXDLLEXPORT_DATA(wxBrush*) wxLIGHT_GREY_BRUSH; | |
578 | extern WXDLLEXPORT_DATA(wxBrush*) wxTRANSPARENT_BRUSH; | |
579 | extern WXDLLEXPORT_DATA(wxBrush*) wxCYAN_BRUSH; | |
580 | extern WXDLLEXPORT_DATA(wxBrush*) wxRED_BRUSH; | |
581 | ||
582 | extern WXDLLEXPORT_DATA(wxColour*) wxBLACK; | |
583 | extern WXDLLEXPORT_DATA(wxColour*) wxWHITE; | |
584 | extern WXDLLEXPORT_DATA(wxColour*) wxRED; | |
585 | extern WXDLLEXPORT_DATA(wxColour*) wxBLUE; | |
586 | extern WXDLLEXPORT_DATA(wxColour*) wxGREEN; | |
587 | extern WXDLLEXPORT_DATA(wxColour*) wxCYAN; | |
588 | extern WXDLLEXPORT_DATA(wxColour*) wxLIGHT_GREY; | |
c801d85f KB |
589 | |
590 | // 'Null' objects | |
16cba29d WS |
591 | extern WXDLLEXPORT_DATA(wxBitmap) wxNullBitmap; |
592 | extern WXDLLEXPORT_DATA(wxIcon) wxNullIcon; | |
593 | extern WXDLLEXPORT_DATA(wxCursor) wxNullCursor; | |
594 | extern WXDLLEXPORT_DATA(wxPen) wxNullPen; | |
595 | extern WXDLLEXPORT_DATA(wxBrush) wxNullBrush; | |
596 | extern WXDLLEXPORT_DATA(wxPalette) wxNullPalette; | |
597 | extern WXDLLEXPORT_DATA(wxFont) wxNullFont; | |
598 | extern WXDLLEXPORT_DATA(wxColour) wxNullColour; | |
c801d85f KB |
599 | |
600 | // Stock cursors types | |
16cba29d WS |
601 | extern WXDLLEXPORT_DATA(wxCursor*) wxSTANDARD_CURSOR; |
602 | extern WXDLLEXPORT_DATA(wxCursor*) wxHOURGLASS_CURSOR; | |
603 | extern WXDLLEXPORT_DATA(wxCursor*) wxCROSS_CURSOR; | |
f03fc89f | 604 | |
16cba29d | 605 | extern WXDLLEXPORT_DATA(wxColourDatabase*) wxTheColourDatabase; |
f03fc89f | 606 | |
63ec432b | 607 | extern WXDLLEXPORT_DATA(const wxChar) wxPanelNameStr[]; |
c801d85f | 608 | |
16cba29d WS |
609 | extern WXDLLEXPORT_DATA(const wxSize) wxDefaultSize; |
610 | extern WXDLLEXPORT_DATA(const wxPoint) wxDefaultPosition; | |
f03fc89f VZ |
611 | |
612 | // The list of objects which should be deleted | |
16cba29d | 613 | extern WXDLLEXPORT_DATA(wxList) wxPendingDelete; |
f03fc89f VZ |
614 | |
615 | // --------------------------------------------------------------------------- | |
616 | // global functions | |
617 | // --------------------------------------------------------------------------- | |
618 | ||
619 | // resource management | |
6a6c0a8b | 620 | extern void WXDLLEXPORT wxInitializeStockObjects(); |
a3622daa | 621 | extern void WXDLLEXPORT wxInitializeStockLists(); |
6a6c0a8b | 622 | extern void WXDLLEXPORT wxDeleteStockObjects(); |
a3622daa | 623 | extern void WXDLLEXPORT wxDeleteStockLists(); |
c801d85f | 624 | |
f03fc89f | 625 | // is the display colour (or monochrome)? |
6a6c0a8b | 626 | extern bool WXDLLEXPORT wxColourDisplay(); |
c801d85f KB |
627 | |
628 | // Returns depth of screen | |
6a6c0a8b JS |
629 | extern int WXDLLEXPORT wxDisplayDepth(); |
630 | #define wxGetDisplayDepth wxDisplayDepth | |
c801d85f | 631 | |
904a68b6 | 632 | // get the display size |
c801d85f | 633 | extern void WXDLLEXPORT wxDisplaySize(int *width, int *height); |
6a6c0a8b | 634 | extern wxSize WXDLLEXPORT wxGetDisplaySize(); |
904a68b6 RL |
635 | extern void WXDLLEXPORT wxDisplaySizeMM(int *width, int *height); |
636 | extern wxSize WXDLLEXPORT wxGetDisplaySizeMM(); | |
c801d85f | 637 | |
ec5d7799 RD |
638 | // Get position and size of the display workarea |
639 | extern void WXDLLEXPORT wxClientDisplayRect(int *x, int *y, int *width, int *height); | |
640 | extern wxRect WXDLLEXPORT wxGetClientDisplayRect(); | |
641 | ||
f03fc89f | 642 | // set global cursor |
c801d85f KB |
643 | extern void WXDLLEXPORT wxSetCursor(const wxCursor& cursor); |
644 | ||
c801d85f | 645 | #endif |
34138703 | 646 | // _WX_GDICMNH__ |