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