]>
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$ | |
8 | // Copyright: (c) | |
f03fc89f | 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 | ||
c801d85f | 19 | #ifdef __GNUG__ |
f03fc89f | 20 | #pragma interface "gdicmn.h" |
c801d85f KB |
21 | #endif |
22 | ||
23 | #include "wx/object.h" | |
24 | #include "wx/list.h" | |
25 | #include "wx/hash.h" | |
34138703 | 26 | #include "wx/string.h" |
c801d85f | 27 | #include "wx/setup.h" |
34138703 | 28 | #include "wx/colour.h" |
c801d85f | 29 | |
f03fc89f VZ |
30 | // --------------------------------------------------------------------------- |
31 | // forward declarations | |
32 | // --------------------------------------------------------------------------- | |
33 | ||
34 | class WXDLLEXPORT wxBitmap; | |
35 | class WXDLLEXPORT wxBrush; | |
36 | class WXDLLEXPORT wxColour; | |
37 | class WXDLLEXPORT wxCursor; | |
38 | class WXDLLEXPORT wxFont; | |
39 | class WXDLLEXPORT wxIcon; | |
40 | class WXDLLEXPORT wxPalette; | |
41 | class WXDLLEXPORT wxPen; | |
42 | class WXDLLEXPORT wxRegion; | |
43 | class WXDLLEXPORT wxString; | |
44 | ||
45 | // --------------------------------------------------------------------------- | |
46 | // constants | |
47 | // --------------------------------------------------------------------------- | |
48 | ||
49 | // Bitmap flags | |
50 | enum | |
51 | { | |
52 | wxBITMAP_TYPE_BMP = 1, | |
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, | |
71 | wxBITMAP_TYPE_ANY = 50 | |
72 | }; | |
73 | ||
c801d85f | 74 | // Standard cursors |
f03fc89f VZ |
75 | enum wxStockCursor |
76 | { | |
77 | wxCURSOR_NONE, // should be 0 | |
78 | wxCURSOR_ARROW, | |
79 | wxCURSOR_BULLSEYE, | |
80 | wxCURSOR_CHAR, | |
81 | wxCURSOR_CROSS, | |
82 | wxCURSOR_HAND, | |
83 | wxCURSOR_IBEAM, | |
84 | wxCURSOR_LEFT_BUTTON, | |
85 | wxCURSOR_MAGNIFIER, | |
86 | wxCURSOR_MIDDLE_BUTTON, | |
87 | wxCURSOR_NO_ENTRY, | |
88 | wxCURSOR_PAINT_BRUSH, | |
89 | wxCURSOR_PENCIL, | |
90 | wxCURSOR_POINT_LEFT, | |
91 | wxCURSOR_POINT_RIGHT, | |
92 | wxCURSOR_QUESTION_ARROW, | |
93 | wxCURSOR_RIGHT_BUTTON, | |
94 | wxCURSOR_SIZENESW, | |
95 | wxCURSOR_SIZENS, | |
96 | wxCURSOR_SIZENWSE, | |
97 | wxCURSOR_SIZEWE, | |
98 | wxCURSOR_SIZING, | |
99 | wxCURSOR_SPRAYCAN, | |
100 | wxCURSOR_WAIT, | |
101 | wxCURSOR_WATCH, | |
102 | wxCURSOR_BLANK, | |
c801d85f | 103 | #ifdef __X__ |
f03fc89f VZ |
104 | // Not yet implemented for Windows |
105 | wxCURSOR_CROSS_REVERSE, | |
106 | wxCURSOR_DOUBLE_ARROW, | |
107 | wxCURSOR_BASED_ARROW_UP, | |
ea804aad | 108 | wxCURSOR_BASED_ARROW_DOWN, |
f03fc89f VZ |
109 | #endif // X11 |
110 | ||
111 | wxCURSOR_MAX | |
112 | }; | |
113 | ||
114 | // --------------------------------------------------------------------------- | |
115 | // macros | |
116 | // --------------------------------------------------------------------------- | |
117 | ||
118 | /* Useful macro for creating icons portably, for example: | |
119 | ||
120 | wxIcon *icon = new wxICON(mondrian); | |
121 | ||
122 | expands into: | |
123 | ||
124 | wxIcon *icon = new wxIcon("mondrian"); // On wxMSW | |
125 | wxIcon *icon = new wxIcon(mondrian_xpm); // On wxGTK | |
126 | */ | |
127 | ||
128 | #ifdef __WXMSW__ | |
129 | // Load from a resource | |
130 | #define wxICON(X) wxIcon("" #X "") | |
131 | #elif defined(__WXGTK__) | |
132 | // Initialize from an included XPM | |
133 | #define wxICON(X) wxIcon( (const char**) X##_xpm ) | |
134 | #elif defined(__WXMOTIF__) | |
135 | // Initialize from an included XPM | |
136 | #define wxICON(X) wxIcon( X##_xpm ) | |
137 | #else | |
138 | // This will usually mean something on any platform | |
139 | #define wxICON(X) wxIcon("" #X "") | |
140 | #endif // platform | |
141 | ||
142 | // =========================================================================== | |
143 | // classes | |
144 | // =========================================================================== | |
c801d85f | 145 | |
f03fc89f VZ |
146 | // --------------------------------------------------------------------------- |
147 | // wxSize | |
148 | // --------------------------------------------------------------------------- | |
6a6c0a8b | 149 | class WXDLLEXPORT wxSize |
c801d85f KB |
150 | { |
151 | public: | |
f03fc89f VZ |
152 | // members are public for compatibility |
153 | long x; | |
154 | long y; | |
155 | ||
156 | // constructors | |
157 | wxSize() { x = y = 0; } | |
158 | wxSize(long xx, long yy) { Set(xx, yy); } | |
159 | ||
160 | // no copy ctor or assignment operator - the defaults are ok | |
161 | ||
162 | bool operator==(const wxSize& sz) const { return x == sz.x && y == sz.y; } | |
163 | ||
164 | // FIXME are these really useful? If they're, we should have += &c as well | |
165 | wxSize operator+(const wxSize& sz) { return wxSize(x + sz.x, y + sz.y); } | |
166 | wxSize operator-(const wxSize& sz) { return wxSize(x - sz.x, y - sz.y); } | |
167 | ||
168 | void Set(long xx, long yy) { x = xx; y = yy; } | |
169 | ||
170 | long GetX() const { return x; } | |
171 | long GetY() const { return y; } | |
c801d85f KB |
172 | }; |
173 | ||
f03fc89f VZ |
174 | // --------------------------------------------------------------------------- |
175 | // Point classes: with real or integer coordinates | |
176 | // --------------------------------------------------------------------------- | |
6a6c0a8b | 177 | class WXDLLEXPORT wxRealPoint |
c801d85f | 178 | { |
f03fc89f VZ |
179 | public: |
180 | double x; | |
181 | double y; | |
182 | ||
183 | wxRealPoint() { x = y = 0.0; }; | |
184 | wxRealPoint(double xx, double yy) { x = xx; y = yy; }; | |
185 | ||
186 | wxRealPoint operator+(const wxRealPoint& pt) { return wxRealPoint(x + pt.x, y + pt.y); } | |
187 | wxRealPoint operator-(const wxRealPoint& pt) { return wxRealPoint(x - pt.x, y - pt.y); } | |
188 | ||
189 | bool operator==(const wxRealPoint& pt) const { return x == pt.x && y == pt.y; } | |
c801d85f KB |
190 | }; |
191 | ||
6a6c0a8b | 192 | class WXDLLEXPORT wxPoint |
c801d85f | 193 | { |
f03fc89f | 194 | public: |
2049ba38 | 195 | #if defined(__WXMSW__) && !defined(__WIN32__) |
f03fc89f VZ |
196 | int x; |
197 | int y; | |
6a6c0a8b | 198 | #else |
f03fc89f VZ |
199 | long x; |
200 | long y; | |
6a6c0a8b JS |
201 | #endif |
202 | ||
f03fc89f VZ |
203 | wxPoint() { x = y = 0; }; |
204 | wxPoint(long xx, long yy) { x = xx; y = yy; }; | |
205 | ||
206 | // no copy ctor or assignment operator - the defaults are ok | |
6a6c0a8b | 207 | |
f03fc89f VZ |
208 | bool operator==(const wxPoint& pt) const { return x == pt.x && y == pt.y; } |
209 | ||
210 | wxPoint operator + (const wxPoint& pt) { return wxPoint(x + pt.x, y + pt.y); } | |
211 | wxPoint operator - (const wxPoint& pt) { return wxPoint(x - pt.x, y - pt.y); } | |
c801d85f KB |
212 | }; |
213 | ||
214 | #if WXWIN_COMPATIBILITY | |
f03fc89f VZ |
215 | #define wxIntPoint wxPoint |
216 | #define wxRectangle wxRect | |
217 | #endif // WXWIN_COMPATIBILITY | |
218 | ||
219 | // --------------------------------------------------------------------------- | |
220 | // wxRect | |
221 | // --------------------------------------------------------------------------- | |
c801d85f | 222 | |
6a6c0a8b JS |
223 | class WXDLLEXPORT wxRect |
224 | { | |
c801d85f | 225 | public: |
a23fd0e1 VZ |
226 | wxRect() { x = y = width = height = 0; } |
227 | wxRect(long xx, long yy, long ww, long hh) | |
228 | { x = xx; y = yy; width = ww; height = hh; } | |
f03fc89f VZ |
229 | wxRect(const wxPoint& topLeft, const wxPoint& bottomRight); |
230 | wxRect(const wxPoint& pos, const wxSize& size); | |
a23fd0e1 VZ |
231 | |
232 | // default copy ctor and assignment operators ok | |
c801d85f | 233 | |
f03fc89f VZ |
234 | long GetX() const { return x; } |
235 | void SetX(long xx) { x = xx; } | |
c801d85f | 236 | |
f03fc89f VZ |
237 | long GetY() const { return y; } |
238 | void SetY(long yy) { y = yy; } | |
c801d85f | 239 | |
f03fc89f VZ |
240 | long GetWidth() const { return width; } |
241 | void SetWidth(long w) { width = w; } | |
c801d85f | 242 | |
f03fc89f VZ |
243 | long GetHeight() const { return height; } |
244 | void SetHeight(long h) { height = h; } | |
245 | ||
246 | wxPoint GetPosition() { return wxPoint(x, y); } | |
247 | wxSize GetSize() { return wxSize(width, height); } | |
248 | ||
249 | long GetLeft() const { return x; } | |
250 | long GetTop() const { return y; } | |
251 | long GetBottom() const { return y + height; } | |
252 | long GetRight() const { return x + width; } | |
253 | ||
a23fd0e1 VZ |
254 | bool operator == (const wxRect& rect) const; |
255 | bool operator != (const wxRect& rect) const { return !(*this == rect); } | |
f03fc89f VZ |
256 | |
257 | public: | |
258 | long x, y, width, height; | |
259 | }; | |
c801d85f | 260 | |
f03fc89f | 261 | // --------------------------------------------------------------------------- |
c801d85f | 262 | // Management of pens, brushes and fonts |
f03fc89f VZ |
263 | // --------------------------------------------------------------------------- |
264 | ||
265 | class WXDLLEXPORT wxPenList : public wxList | |
c801d85f | 266 | { |
f03fc89f VZ |
267 | DECLARE_DYNAMIC_CLASS(wxPenList) |
268 | ||
269 | public: | |
270 | wxPenList() { } | |
271 | ~wxPenList(); | |
272 | ||
273 | void AddPen(wxPen *pen); | |
274 | void RemovePen(wxPen *pen); | |
275 | wxPen *FindOrCreatePen(const wxColour& colour, int width, int style); | |
c801d85f KB |
276 | }; |
277 | ||
f03fc89f | 278 | class WXDLLEXPORT wxBrushList : public wxList |
c801d85f | 279 | { |
f03fc89f VZ |
280 | DECLARE_DYNAMIC_CLASS(wxBrushList) |
281 | ||
282 | public: | |
283 | wxBrushList() { } | |
284 | ~wxBrushList(); | |
285 | ||
286 | void AddBrush(wxBrush *brush); | |
287 | void RemoveBrush(wxBrush *brush); | |
288 | wxBrush *FindOrCreateBrush(const wxColour& colour, int style); | |
c801d85f KB |
289 | }; |
290 | ||
9d2f3c71 | 291 | WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString; |
c801d85f | 292 | |
f03fc89f | 293 | class WXDLLEXPORT wxFontList : public wxList |
c801d85f | 294 | { |
f03fc89f VZ |
295 | DECLARE_DYNAMIC_CLASS(wxFontList) |
296 | ||
297 | public: | |
298 | wxFontList() { } | |
299 | ~wxFontList(); | |
300 | ||
301 | void AddFont(wxFont *font); | |
302 | void RemoveFont(wxFont *font); | |
303 | wxFont *FindOrCreateFont(int pointSize, int family, int style, int weight, | |
304 | bool underline = FALSE, | |
305 | const wxString& face = wxEmptyString); | |
c801d85f KB |
306 | }; |
307 | ||
f03fc89f | 308 | class WXDLLEXPORT wxColourDatabase : public wxList |
c801d85f | 309 | { |
f03fc89f VZ |
310 | DECLARE_CLASS(wxColourDatabase) |
311 | ||
312 | public: | |
313 | wxColourDatabase(int type); | |
314 | ~wxColourDatabase() ; | |
315 | ||
316 | // Not const because it may add a name to the database | |
317 | wxColour *FindColour(const wxString& colour) ; | |
318 | wxString FindName(const wxColour& colour) const; | |
319 | void Initialize(); | |
c801d85f KB |
320 | }; |
321 | ||
f03fc89f | 322 | class WXDLLEXPORT wxBitmapList : public wxList |
c801d85f | 323 | { |
f03fc89f | 324 | DECLARE_DYNAMIC_CLASS(wxBitmapList) |
c801d85f | 325 | |
f03fc89f VZ |
326 | public: |
327 | wxBitmapList(); | |
328 | ~wxBitmapList(); | |
329 | ||
330 | void AddBitmap(wxBitmap *bitmap); | |
331 | void RemoveBitmap(wxBitmap *bitmap); | |
c801d85f KB |
332 | }; |
333 | ||
f03fc89f VZ |
334 | class WXDLLEXPORT wxResourceCache: public wxList |
335 | { | |
336 | public: | |
337 | wxResourceCache() { } | |
338 | wxResourceCache(const unsigned int keyType) : wxList(keyType) { } | |
339 | ~wxResourceCache(); | |
340 | ||
341 | private: | |
342 | DECLARE_DYNAMIC_CLASS(wxResourceCache) | |
343 | }; | |
344 | ||
345 | // --------------------------------------------------------------------------- | |
346 | // global variables | |
347 | // --------------------------------------------------------------------------- | |
348 | ||
c801d85f | 349 | // Lists of GDI objects |
f03fc89f VZ |
350 | WXDLLEXPORT_DATA(extern wxPenList*) wxThePenList; |
351 | WXDLLEXPORT_DATA(extern wxBrushList*) wxTheBrushList; | |
352 | WXDLLEXPORT_DATA(extern wxFontList*) wxTheFontList; | |
353 | WXDLLEXPORT_DATA(extern wxBitmapList*) wxTheBitmapList; | |
c801d85f KB |
354 | |
355 | // Stock objects | |
f03fc89f VZ |
356 | WXDLLEXPORT_DATA(extern wxFont*) wxNORMAL_FONT; |
357 | WXDLLEXPORT_DATA(extern wxFont*) wxSMALL_FONT; | |
358 | WXDLLEXPORT_DATA(extern wxFont*) wxITALIC_FONT; | |
359 | WXDLLEXPORT_DATA(extern wxFont*) wxSWISS_FONT; | |
360 | ||
361 | WXDLLEXPORT_DATA(extern wxPen*) wxRED_PEN; | |
362 | WXDLLEXPORT_DATA(extern wxPen*) wxCYAN_PEN; | |
363 | WXDLLEXPORT_DATA(extern wxPen*) wxGREEN_PEN; | |
364 | WXDLLEXPORT_DATA(extern wxPen*) wxBLACK_PEN; | |
365 | WXDLLEXPORT_DATA(extern wxPen*) wxWHITE_PEN; | |
366 | WXDLLEXPORT_DATA(extern wxPen*) wxTRANSPARENT_PEN; | |
367 | WXDLLEXPORT_DATA(extern wxPen*) wxBLACK_DASHED_PEN; | |
368 | WXDLLEXPORT_DATA(extern wxPen*) wxGREY_PEN; | |
369 | WXDLLEXPORT_DATA(extern wxPen*) wxMEDIUM_GREY_PEN; | |
370 | WXDLLEXPORT_DATA(extern wxPen*) wxLIGHT_GREY_PEN; | |
371 | ||
372 | WXDLLEXPORT_DATA(extern wxBrush*) wxBLUE_BRUSH; | |
373 | WXDLLEXPORT_DATA(extern wxBrush*) wxGREEN_BRUSH; | |
374 | WXDLLEXPORT_DATA(extern wxBrush*) wxWHITE_BRUSH; | |
375 | WXDLLEXPORT_DATA(extern wxBrush*) wxBLACK_BRUSH; | |
376 | WXDLLEXPORT_DATA(extern wxBrush*) wxGREY_BRUSH; | |
377 | WXDLLEXPORT_DATA(extern wxBrush*) wxMEDIUM_GREY_BRUSH; | |
378 | WXDLLEXPORT_DATA(extern wxBrush*) wxLIGHT_GREY_BRUSH; | |
379 | WXDLLEXPORT_DATA(extern wxBrush*) wxTRANSPARENT_BRUSH; | |
380 | WXDLLEXPORT_DATA(extern wxBrush*) wxCYAN_BRUSH; | |
381 | WXDLLEXPORT_DATA(extern wxBrush*) wxRED_BRUSH; | |
382 | ||
383 | WXDLLEXPORT_DATA(extern wxColour*) wxBLACK; | |
384 | WXDLLEXPORT_DATA(extern wxColour*) wxWHITE; | |
385 | WXDLLEXPORT_DATA(extern wxColour*) wxRED; | |
386 | WXDLLEXPORT_DATA(extern wxColour*) wxBLUE; | |
387 | WXDLLEXPORT_DATA(extern wxColour*) wxGREEN; | |
388 | WXDLLEXPORT_DATA(extern wxColour*) wxCYAN; | |
389 | WXDLLEXPORT_DATA(extern wxColour*) wxLIGHT_GREY; | |
c801d85f KB |
390 | |
391 | // 'Null' objects | |
f03fc89f VZ |
392 | WXDLLEXPORT_DATA(extern wxBitmap) wxNullBitmap; |
393 | WXDLLEXPORT_DATA(extern wxIcon) wxNullIcon; | |
394 | WXDLLEXPORT_DATA(extern wxCursor) wxNullCursor; | |
395 | WXDLLEXPORT_DATA(extern wxPen) wxNullPen; | |
396 | WXDLLEXPORT_DATA(extern wxBrush) wxNullBrush; | |
397 | WXDLLEXPORT_DATA(extern wxPalette) wxNullPalette; | |
398 | WXDLLEXPORT_DATA(extern wxFont) wxNullFont; | |
399 | WXDLLEXPORT_DATA(extern wxColour) wxNullColour; | |
c801d85f KB |
400 | |
401 | // Stock cursors types | |
f03fc89f VZ |
402 | WXDLLEXPORT_DATA(extern wxCursor*) wxSTANDARD_CURSOR; |
403 | WXDLLEXPORT_DATA(extern wxCursor*) wxHOURGLASS_CURSOR; | |
404 | WXDLLEXPORT_DATA(extern wxCursor*) wxCROSS_CURSOR; | |
405 | ||
406 | WXDLLEXPORT_DATA(extern wxColourDatabase*) wxTheColourDatabase; | |
407 | ||
408 | WXDLLEXPORT_DATA(extern const wxChar*) wxPanelNameStr; | |
c801d85f | 409 | |
f03fc89f VZ |
410 | WXDLLEXPORT_DATA(extern const wxSize) wxDefaultSize; |
411 | WXDLLEXPORT_DATA(extern const wxPoint) wxDefaultPosition; | |
412 | ||
413 | // The list of objects which should be deleted | |
414 | WXDLLEXPORT_DATA(extern wxList) wxPendingDelete; | |
415 | ||
416 | // --------------------------------------------------------------------------- | |
417 | // global functions | |
418 | // --------------------------------------------------------------------------- | |
419 | ||
420 | // resource management | |
6a6c0a8b | 421 | extern void WXDLLEXPORT wxInitializeStockObjects(); |
a3622daa | 422 | extern void WXDLLEXPORT wxInitializeStockLists(); |
6a6c0a8b | 423 | extern void WXDLLEXPORT wxDeleteStockObjects(); |
a3622daa | 424 | extern void WXDLLEXPORT wxDeleteStockLists(); |
c801d85f | 425 | |
f03fc89f | 426 | // is the display colour (or monochrome)? |
6a6c0a8b | 427 | extern bool WXDLLEXPORT wxColourDisplay(); |
c801d85f KB |
428 | |
429 | // Returns depth of screen | |
6a6c0a8b JS |
430 | extern int WXDLLEXPORT wxDisplayDepth(); |
431 | #define wxGetDisplayDepth wxDisplayDepth | |
c801d85f | 432 | |
f03fc89f | 433 | // get the diaplay size |
c801d85f | 434 | extern void WXDLLEXPORT wxDisplaySize(int *width, int *height); |
6a6c0a8b | 435 | extern wxSize WXDLLEXPORT wxGetDisplaySize(); |
c801d85f | 436 | |
f03fc89f | 437 | // set global cursor |
c801d85f KB |
438 | extern void WXDLLEXPORT wxSetCursor(const wxCursor& cursor); |
439 | ||
c801d85f | 440 | #endif |
34138703 | 441 | // _WX_GDICMNH__ |