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