]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gdicmn.h
Forgot to add the files.
[wxWidgets.git] / include / wx / gdicmn.h
CommitLineData
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
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,
bcc46c75
SB
71 wxBITMAP_TYPE_PNM,
72 wxBITMAP_TYPE_PNM_RESOURCE,
f03fc89f
VZ
73 wxBITMAP_TYPE_ANY = 50
74};
75
c801d85f 76// Standard cursors
f03fc89f
VZ
77enum 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,
ae53c98c
KB
105#ifdef __WXGTK__
106 wxCURSOR_DEFAULT, // standard X11 cursor
107#endif
c801d85f 108#ifdef __X__
f03fc89f
VZ
109 // Not yet implemented for Windows
110 wxCURSOR_CROSS_REVERSE,
111 wxCURSOR_DOUBLE_ARROW,
112 wxCURSOR_BASED_ARROW_UP,
ea804aad 113 wxCURSOR_BASED_ARROW_DOWN,
f03fc89f
VZ
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 "")
1777b9bb
DW
136#elif defined(__WXPM__)
137 // Load from a resource
138 #define wxICON(X) wxIcon("" #X "")
f03fc89f
VZ
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// ===========================================================================
c801d85f 153
f03fc89f
VZ
154// ---------------------------------------------------------------------------
155// wxSize
156// ---------------------------------------------------------------------------
6a6c0a8b 157class WXDLLEXPORT wxSize
c801d85f
KB
158{
159public:
cc775580
VZ
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)
f03fc89f
VZ
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
f03fc89f
VZ
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
cc775580 177 // accessors
f03fc89f 178 void Set(long xx, long yy) { x = xx; y = yy; }
cc775580
VZ
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; }
f03fc89f 184
cc775580 185 // compatibility
f03fc89f
VZ
186 long GetX() const { return x; }
187 long GetY() const { return y; }
c801d85f
KB
188};
189
f03fc89f
VZ
190// ---------------------------------------------------------------------------
191// Point classes: with real or integer coordinates
192// ---------------------------------------------------------------------------
764a3a49 193
6a6c0a8b 194class WXDLLEXPORT wxRealPoint
c801d85f 195{
f03fc89f
VZ
196public:
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; }
c801d85f
KB
207};
208
6a6c0a8b 209class WXDLLEXPORT wxPoint
c801d85f 210{
f03fc89f 211public:
2049ba38 212#if defined(__WXMSW__) && !defined(__WIN32__)
f03fc89f
VZ
213 int x;
214 int y;
6a6c0a8b 215#else
f03fc89f
VZ
216 long x;
217 long y;
6a6c0a8b
JS
218#endif
219
f03fc89f
VZ
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
6a6c0a8b 224
764a3a49
VZ
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); }
f03fc89f 232
764a3a49
VZ
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; }
c801d85f
KB
235};
236
237#if WXWIN_COMPATIBILITY
f03fc89f
VZ
238 #define wxIntPoint wxPoint
239 #define wxRectangle wxRect
240#endif // WXWIN_COMPATIBILITY
241
242// ---------------------------------------------------------------------------
243// wxRect
244// ---------------------------------------------------------------------------
c801d85f 245
6a6c0a8b
JS
246class WXDLLEXPORT wxRect
247{
c801d85f 248public:
a23fd0e1
VZ
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; }
f03fc89f
VZ
252 wxRect(const wxPoint& topLeft, const wxPoint& bottomRight);
253 wxRect(const wxPoint& pos, const wxSize& size);
a23fd0e1
VZ
254
255 // default copy ctor and assignment operators ok
c801d85f 256
f03fc89f
VZ
257 long GetX() const { return x; }
258 void SetX(long xx) { x = xx; }
c801d85f 259
f03fc89f
VZ
260 long GetY() const { return y; }
261 void SetY(long yy) { y = yy; }
c801d85f 262
f03fc89f
VZ
263 long GetWidth() const { return width; }
264 void SetWidth(long w) { width = w; }
c801d85f 265
f03fc89f
VZ
266 long GetHeight() const { return height; }
267 void SetHeight(long h) { height = h; }
268
dcb44466
JS
269 wxPoint GetPosition() const { return wxPoint(x, y); }
270 wxSize GetSize() const { return wxSize(width, height); }
f03fc89f 271
f3c0f9e7
JS
272 // MFC-like functions
273
f03fc89f
VZ
274 long GetLeft() const { return x; }
275 long GetTop() const { return y; }
f3c0f9e7
JS
276 long GetBottom() const { return y + height - 1; }
277 long GetRight() const { return x + width - 1; }
f03fc89f 278
f3c0f9e7
JS
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; }
dcb44466 283
764a3a49
VZ
284 bool operator==(const wxRect& rect) const;
285 bool operator!=(const wxRect& rect) const { return !(*this == rect); }
f03fc89f 286
7742598f 287 bool Inside(int cx, int cy) const;
dcb44466
JS
288 wxRect operator + (const wxRect& rect) const;
289 const wxRect& operator += (const wxRect& rect);
7742598f 290
f03fc89f
VZ
291public:
292 long x, y, width, height;
293};
c801d85f 294
f03fc89f 295// ---------------------------------------------------------------------------
c801d85f 296// Management of pens, brushes and fonts
f03fc89f
VZ
297// ---------------------------------------------------------------------------
298
299class WXDLLEXPORT wxPenList : public wxList
c801d85f 300{
f03fc89f
VZ
301 DECLARE_DYNAMIC_CLASS(wxPenList)
302
303public:
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);
c801d85f
KB
310};
311
f03fc89f 312class WXDLLEXPORT wxBrushList : public wxList
c801d85f 313{
f03fc89f
VZ
314 DECLARE_DYNAMIC_CLASS(wxBrushList)
315
316public:
317 wxBrushList() { }
318 ~wxBrushList();
319
320 void AddBrush(wxBrush *brush);
321 void RemoveBrush(wxBrush *brush);
322 wxBrush *FindOrCreateBrush(const wxColour& colour, int style);
c801d85f
KB
323};
324
9d2f3c71 325WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString;
c801d85f 326
f03fc89f 327class WXDLLEXPORT wxFontList : public wxList
c801d85f 328{
f03fc89f
VZ
329 DECLARE_DYNAMIC_CLASS(wxFontList)
330
331public:
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);
c801d85f
KB
340};
341
f03fc89f 342class WXDLLEXPORT wxColourDatabase : public wxList
c801d85f 343{
f03fc89f
VZ
344 DECLARE_CLASS(wxColourDatabase)
345
346public:
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();
c801d85f
KB
354};
355
f03fc89f 356class WXDLLEXPORT wxBitmapList : public wxList
c801d85f 357{
f03fc89f 358 DECLARE_DYNAMIC_CLASS(wxBitmapList)
c801d85f 359
f03fc89f
VZ
360public:
361 wxBitmapList();
362 ~wxBitmapList();
363
364 void AddBitmap(wxBitmap *bitmap);
365 void RemoveBitmap(wxBitmap *bitmap);
c801d85f
KB
366};
367
f03fc89f
VZ
368class WXDLLEXPORT wxResourceCache: public wxList
369{
370public:
371 wxResourceCache() { }
372 wxResourceCache(const unsigned int keyType) : wxList(keyType) { }
373 ~wxResourceCache();
374
375private:
376 DECLARE_DYNAMIC_CLASS(wxResourceCache)
377};
378
379// ---------------------------------------------------------------------------
380// global variables
381// ---------------------------------------------------------------------------
382
c801d85f 383// Lists of GDI objects
f03fc89f
VZ
384WXDLLEXPORT_DATA(extern wxPenList*) wxThePenList;
385WXDLLEXPORT_DATA(extern wxBrushList*) wxTheBrushList;
386WXDLLEXPORT_DATA(extern wxFontList*) wxTheFontList;
387WXDLLEXPORT_DATA(extern wxBitmapList*) wxTheBitmapList;
c801d85f
KB
388
389// Stock objects
f03fc89f
VZ
390WXDLLEXPORT_DATA(extern wxFont*) wxNORMAL_FONT;
391WXDLLEXPORT_DATA(extern wxFont*) wxSMALL_FONT;
392WXDLLEXPORT_DATA(extern wxFont*) wxITALIC_FONT;
393WXDLLEXPORT_DATA(extern wxFont*) wxSWISS_FONT;
394
395WXDLLEXPORT_DATA(extern wxPen*) wxRED_PEN;
396WXDLLEXPORT_DATA(extern wxPen*) wxCYAN_PEN;
397WXDLLEXPORT_DATA(extern wxPen*) wxGREEN_PEN;
398WXDLLEXPORT_DATA(extern wxPen*) wxBLACK_PEN;
399WXDLLEXPORT_DATA(extern wxPen*) wxWHITE_PEN;
400WXDLLEXPORT_DATA(extern wxPen*) wxTRANSPARENT_PEN;
401WXDLLEXPORT_DATA(extern wxPen*) wxBLACK_DASHED_PEN;
402WXDLLEXPORT_DATA(extern wxPen*) wxGREY_PEN;
403WXDLLEXPORT_DATA(extern wxPen*) wxMEDIUM_GREY_PEN;
404WXDLLEXPORT_DATA(extern wxPen*) wxLIGHT_GREY_PEN;
405
406WXDLLEXPORT_DATA(extern wxBrush*) wxBLUE_BRUSH;
407WXDLLEXPORT_DATA(extern wxBrush*) wxGREEN_BRUSH;
408WXDLLEXPORT_DATA(extern wxBrush*) wxWHITE_BRUSH;
409WXDLLEXPORT_DATA(extern wxBrush*) wxBLACK_BRUSH;
410WXDLLEXPORT_DATA(extern wxBrush*) wxGREY_BRUSH;
411WXDLLEXPORT_DATA(extern wxBrush*) wxMEDIUM_GREY_BRUSH;
412WXDLLEXPORT_DATA(extern wxBrush*) wxLIGHT_GREY_BRUSH;
413WXDLLEXPORT_DATA(extern wxBrush*) wxTRANSPARENT_BRUSH;
414WXDLLEXPORT_DATA(extern wxBrush*) wxCYAN_BRUSH;
415WXDLLEXPORT_DATA(extern wxBrush*) wxRED_BRUSH;
416
417WXDLLEXPORT_DATA(extern wxColour*) wxBLACK;
418WXDLLEXPORT_DATA(extern wxColour*) wxWHITE;
419WXDLLEXPORT_DATA(extern wxColour*) wxRED;
420WXDLLEXPORT_DATA(extern wxColour*) wxBLUE;
421WXDLLEXPORT_DATA(extern wxColour*) wxGREEN;
422WXDLLEXPORT_DATA(extern wxColour*) wxCYAN;
423WXDLLEXPORT_DATA(extern wxColour*) wxLIGHT_GREY;
c801d85f
KB
424
425// 'Null' objects
f03fc89f
VZ
426WXDLLEXPORT_DATA(extern wxBitmap) wxNullBitmap;
427WXDLLEXPORT_DATA(extern wxIcon) wxNullIcon;
428WXDLLEXPORT_DATA(extern wxCursor) wxNullCursor;
429WXDLLEXPORT_DATA(extern wxPen) wxNullPen;
430WXDLLEXPORT_DATA(extern wxBrush) wxNullBrush;
431WXDLLEXPORT_DATA(extern wxPalette) wxNullPalette;
432WXDLLEXPORT_DATA(extern wxFont) wxNullFont;
433WXDLLEXPORT_DATA(extern wxColour) wxNullColour;
c801d85f
KB
434
435// Stock cursors types
f03fc89f
VZ
436WXDLLEXPORT_DATA(extern wxCursor*) wxSTANDARD_CURSOR;
437WXDLLEXPORT_DATA(extern wxCursor*) wxHOURGLASS_CURSOR;
438WXDLLEXPORT_DATA(extern wxCursor*) wxCROSS_CURSOR;
439
440WXDLLEXPORT_DATA(extern wxColourDatabase*) wxTheColourDatabase;
441
442WXDLLEXPORT_DATA(extern const wxChar*) wxPanelNameStr;
c801d85f 443
f03fc89f
VZ
444WXDLLEXPORT_DATA(extern const wxSize) wxDefaultSize;
445WXDLLEXPORT_DATA(extern const wxPoint) wxDefaultPosition;
446
447// The list of objects which should be deleted
448WXDLLEXPORT_DATA(extern wxList) wxPendingDelete;
449
450// ---------------------------------------------------------------------------
451// global functions
452// ---------------------------------------------------------------------------
453
454// resource management
6a6c0a8b 455extern void WXDLLEXPORT wxInitializeStockObjects();
a3622daa 456extern void WXDLLEXPORT wxInitializeStockLists();
6a6c0a8b 457extern void WXDLLEXPORT wxDeleteStockObjects();
a3622daa 458extern void WXDLLEXPORT wxDeleteStockLists();
c801d85f 459
f03fc89f 460// is the display colour (or monochrome)?
6a6c0a8b 461extern bool WXDLLEXPORT wxColourDisplay();
c801d85f
KB
462
463// Returns depth of screen
6a6c0a8b
JS
464extern int WXDLLEXPORT wxDisplayDepth();
465#define wxGetDisplayDepth wxDisplayDepth
c801d85f 466
f03fc89f 467// get the diaplay size
c801d85f 468extern void WXDLLEXPORT wxDisplaySize(int *width, int *height);
6a6c0a8b 469extern wxSize WXDLLEXPORT wxGetDisplaySize();
c801d85f 470
f03fc89f 471// set global cursor
c801d85f
KB
472extern void WXDLLEXPORT wxSetCursor(const wxCursor& cursor);
473
c801d85f 474#endif
34138703 475 // _WX_GDICMNH__