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