]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gdicmn.h
Tweaking some of the new wxPython stuff for wxGTK
[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,
519cb848
SC
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,
f03fc89f
VZ
81 wxBITMAP_TYPE_ANY = 50
82};
83
c801d85f 84// Standard cursors
f03fc89f
VZ
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,
ae53c98c
KB
113#ifdef __WXGTK__
114 wxCURSOR_DEFAULT, // standard X11 cursor
115#endif
c801d85f 116#ifdef __X__
f03fc89f
VZ
117 // Not yet implemented for Windows
118 wxCURSOR_CROSS_REVERSE,
119 wxCURSOR_DOUBLE_ARROW,
120 wxCURSOR_BASED_ARROW_UP,
ea804aad 121 wxCURSOR_BASED_ARROW_DOWN,
f03fc89f
VZ
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 "")
1777b9bb
DW
144#elif defined(__WXPM__)
145 // Load from a resource
146 #define wxICON(X) wxIcon("" #X "")
f03fc89f
VZ
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
0c5d3e1c
VZ
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
f03fc89f
VZ
168// ===========================================================================
169// classes
170// ===========================================================================
c801d85f 171
f03fc89f
VZ
172// ---------------------------------------------------------------------------
173// wxSize
174// ---------------------------------------------------------------------------
6a6c0a8b 175class WXDLLEXPORT wxSize
c801d85f
KB
176{
177public:
cc775580
VZ
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)
72cdf4c9 181 int x, y;
f03fc89f
VZ
182
183 // constructors
184 wxSize() { x = y = 0; }
72cdf4c9 185 wxSize(int xx, int yy) { Set(xx, yy); }
f03fc89f
VZ
186
187 // no copy ctor or assignment operator - the defaults are ok
f03fc89f
VZ
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
cc775580 194 // accessors
72cdf4c9
VZ
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; }
cc775580 198
72cdf4c9
VZ
199 int GetWidth() const { return x; }
200 int GetHeight() const { return y; }
f03fc89f 201
cc775580 202 // compatibility
72cdf4c9
VZ
203 int GetX() const { return x; }
204 int GetY() const { return y; }
c801d85f
KB
205};
206
f03fc89f
VZ
207// ---------------------------------------------------------------------------
208// Point classes: with real or integer coordinates
209// ---------------------------------------------------------------------------
764a3a49 210
6a6c0a8b 211class WXDLLEXPORT wxRealPoint
c801d85f 212{
f03fc89f
VZ
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; }
c801d85f
KB
224};
225
6a6c0a8b 226class WXDLLEXPORT wxPoint
c801d85f 227{
f03fc89f 228public:
72cdf4c9 229 int x, y;
6a6c0a8b 230
f03fc89f 231 wxPoint() { x = y = 0; };
72cdf4c9 232 wxPoint(int xx, int yy) { x = xx; y = yy; };
f03fc89f
VZ
233
234 // no copy ctor or assignment operator - the defaults are ok
6a6c0a8b 235
764a3a49
VZ
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); }
f03fc89f 243
764a3a49
VZ
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; }
c801d85f
KB
246};
247
248#if WXWIN_COMPATIBILITY
f03fc89f
VZ
249 #define wxIntPoint wxPoint
250 #define wxRectangle wxRect
251#endif // WXWIN_COMPATIBILITY
252
253// ---------------------------------------------------------------------------
254// wxRect
255// ---------------------------------------------------------------------------
c801d85f 256
6a6c0a8b
JS
257class WXDLLEXPORT wxRect
258{
c801d85f 259public:
a23fd0e1 260 wxRect() { x = y = width = height = 0; }
72cdf4c9 261 wxRect(int xx, int yy, int ww, int hh)
a23fd0e1 262 { x = xx; y = yy; width = ww; height = hh; }
f03fc89f
VZ
263 wxRect(const wxPoint& topLeft, const wxPoint& bottomRight);
264 wxRect(const wxPoint& pos, const wxSize& size);
a23fd0e1
VZ
265
266 // default copy ctor and assignment operators ok
c801d85f 267
72cdf4c9
VZ
268 int GetX() const { return x; }
269 void SetX(int xx) { x = xx; }
c801d85f 270
72cdf4c9
VZ
271 int GetY() const { return y; }
272 void SetY(int yy) { y = yy; }
c801d85f 273
72cdf4c9
VZ
274 int GetWidth() const { return width; }
275 void SetWidth(int w) { width = w; }
c801d85f 276
72cdf4c9
VZ
277 int GetHeight() const { return height; }
278 void SetHeight(int h) { height = h; }
f03fc89f 279
dcb44466
JS
280 wxPoint GetPosition() const { return wxPoint(x, y); }
281 wxSize GetSize() const { return wxSize(width, height); }
f03fc89f 282
f3c0f9e7
JS
283 // MFC-like functions
284
72cdf4c9
VZ
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; }
f03fc89f 289
72cdf4c9
VZ
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; }
dcb44466 294
764a3a49
VZ
295 bool operator==(const wxRect& rect) const;
296 bool operator!=(const wxRect& rect) const { return !(*this == rect); }
f03fc89f 297
7742598f 298 bool Inside(int cx, int cy) const;
dcb44466
JS
299 wxRect operator + (const wxRect& rect) const;
300 const wxRect& operator += (const wxRect& rect);
72cdf4c9 301
f03fc89f 302public:
72cdf4c9 303 int x, y, width, height;
f03fc89f 304};
c801d85f 305
f03fc89f 306// ---------------------------------------------------------------------------
c801d85f 307// Management of pens, brushes and fonts
f03fc89f
VZ
308// ---------------------------------------------------------------------------
309
310class WXDLLEXPORT wxPenList : public wxList
c801d85f 311{
f03fc89f
VZ
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);
c801d85f
KB
321};
322
f03fc89f 323class WXDLLEXPORT wxBrushList : public wxList
c801d85f 324{
f03fc89f
VZ
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);
c801d85f
KB
334};
335
9d2f3c71 336WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString;
c801d85f 337
f03fc89f 338class WXDLLEXPORT wxFontList : public wxList
c801d85f 339{
f03fc89f
VZ
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);
c801d85f
KB
351};
352
f03fc89f 353class WXDLLEXPORT wxColourDatabase : public wxList
c801d85f 354{
f03fc89f
VZ
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();
c801d85f
KB
365};
366
f03fc89f 367class WXDLLEXPORT wxBitmapList : public wxList
c801d85f 368{
f03fc89f 369 DECLARE_DYNAMIC_CLASS(wxBitmapList)
c801d85f 370
f03fc89f
VZ
371public:
372 wxBitmapList();
373 ~wxBitmapList();
374
375 void AddBitmap(wxBitmap *bitmap);
376 void RemoveBitmap(wxBitmap *bitmap);
c801d85f
KB
377};
378
f03fc89f
VZ
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
c801d85f 394// Lists of GDI objects
f03fc89f
VZ
395WXDLLEXPORT_DATA(extern wxPenList*) wxThePenList;
396WXDLLEXPORT_DATA(extern wxBrushList*) wxTheBrushList;
397WXDLLEXPORT_DATA(extern wxFontList*) wxTheFontList;
398WXDLLEXPORT_DATA(extern wxBitmapList*) wxTheBitmapList;
c801d85f
KB
399
400// Stock objects
f03fc89f
VZ
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;
c801d85f
KB
435
436// 'Null' objects
f03fc89f
VZ
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;
c801d85f
KB
445
446// Stock cursors types
f03fc89f
VZ
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;
c801d85f 454
f03fc89f
VZ
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
6a6c0a8b 466extern void WXDLLEXPORT wxInitializeStockObjects();
a3622daa 467extern void WXDLLEXPORT wxInitializeStockLists();
6a6c0a8b 468extern void WXDLLEXPORT wxDeleteStockObjects();
a3622daa 469extern void WXDLLEXPORT wxDeleteStockLists();
c801d85f 470
f03fc89f 471// is the display colour (or monochrome)?
6a6c0a8b 472extern bool WXDLLEXPORT wxColourDisplay();
c801d85f
KB
473
474// Returns depth of screen
6a6c0a8b
JS
475extern int WXDLLEXPORT wxDisplayDepth();
476#define wxGetDisplayDepth wxDisplayDepth
c801d85f 477
f03fc89f 478// get the diaplay size
c801d85f 479extern void WXDLLEXPORT wxDisplaySize(int *width, int *height);
6a6c0a8b 480extern wxSize WXDLLEXPORT wxGetDisplaySize();
c801d85f 481
f03fc89f 482// set global cursor
c801d85f
KB
483extern void WXDLLEXPORT wxSetCursor(const wxCursor& cursor);
484
c801d85f 485#endif
34138703 486 // _WX_GDICMNH__