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