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