]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gdicmn.h
Added wxNB_LEFT,RIGHT,BOTTOM styles to alter tab placement
[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
152// ===========================================================================
153// classes
154// ===========================================================================
c801d85f 155
f03fc89f
VZ
156// ---------------------------------------------------------------------------
157// wxSize
158// ---------------------------------------------------------------------------
6a6c0a8b 159class WXDLLEXPORT wxSize
c801d85f
KB
160{
161public:
cc775580
VZ
162 // members are public for compatibility (don't use them directly,
163 // especially that there names were chosen very unfortunately - they should
164 // have been called width and height)
f03fc89f
VZ
165 long x;
166 long y;
167
168 // constructors
169 wxSize() { x = y = 0; }
170 wxSize(long xx, long yy) { Set(xx, yy); }
171
172 // no copy ctor or assignment operator - the defaults are ok
f03fc89f
VZ
173 bool operator==(const wxSize& sz) const { return x == sz.x && y == sz.y; }
174
175 // FIXME are these really useful? If they're, we should have += &c as well
176 wxSize operator+(const wxSize& sz) { return wxSize(x + sz.x, y + sz.y); }
177 wxSize operator-(const wxSize& sz) { return wxSize(x - sz.x, y - sz.y); }
178
cc775580 179 // accessors
f03fc89f 180 void Set(long xx, long yy) { x = xx; y = yy; }
cc775580
VZ
181 void SetWidth(long w) { x = w; }
182 void SetHeight(long h) { y = h; }
183
184 long GetWidth() const { return x; }
185 long GetHeight() const { return y; }
f03fc89f 186
cc775580 187 // compatibility
f03fc89f
VZ
188 long GetX() const { return x; }
189 long GetY() const { return y; }
c801d85f
KB
190};
191
f03fc89f
VZ
192// ---------------------------------------------------------------------------
193// Point classes: with real or integer coordinates
194// ---------------------------------------------------------------------------
764a3a49 195
6a6c0a8b 196class WXDLLEXPORT wxRealPoint
c801d85f 197{
f03fc89f
VZ
198public:
199 double x;
200 double y;
201
202 wxRealPoint() { x = y = 0.0; };
203 wxRealPoint(double xx, double yy) { x = xx; y = yy; };
204
205 wxRealPoint operator+(const wxRealPoint& pt) { return wxRealPoint(x + pt.x, y + pt.y); }
206 wxRealPoint operator-(const wxRealPoint& pt) { return wxRealPoint(x - pt.x, y - pt.y); }
207
208 bool operator==(const wxRealPoint& pt) const { return x == pt.x && y == pt.y; }
c801d85f
KB
209};
210
6a6c0a8b 211class WXDLLEXPORT wxPoint
c801d85f 212{
f03fc89f 213public:
2049ba38 214#if defined(__WXMSW__) && !defined(__WIN32__)
f03fc89f
VZ
215 int x;
216 int y;
6a6c0a8b 217#else
f03fc89f
VZ
218 long x;
219 long y;
6a6c0a8b
JS
220#endif
221
f03fc89f
VZ
222 wxPoint() { x = y = 0; };
223 wxPoint(long xx, long yy) { x = xx; y = yy; };
224
225 // no copy ctor or assignment operator - the defaults are ok
6a6c0a8b 226
764a3a49
VZ
227 // comparison
228 bool operator==(const wxPoint& p) const { return x == p.x && y == p.y; }
229 bool operator!=(const wxPoint& p) const { return !(*this == p); }
230
231 // arithmetic operations (component wise)
232 wxPoint operator+(const wxPoint& p) { return wxPoint(x + p.x, y + p.y); }
233 wxPoint operator-(const wxPoint& p) { return wxPoint(x - p.x, y - p.y); }
f03fc89f 234
764a3a49
VZ
235 wxPoint& operator+=(const wxPoint& p) { x += p.x; y += p.y; return *this; }
236 wxPoint& operator-=(const wxPoint& p) { x -= p.x; y -= p.y; return *this; }
c801d85f
KB
237};
238
239#if WXWIN_COMPATIBILITY
f03fc89f
VZ
240 #define wxIntPoint wxPoint
241 #define wxRectangle wxRect
242#endif // WXWIN_COMPATIBILITY
243
244// ---------------------------------------------------------------------------
245// wxRect
246// ---------------------------------------------------------------------------
c801d85f 247
6a6c0a8b
JS
248class WXDLLEXPORT wxRect
249{
c801d85f 250public:
a23fd0e1
VZ
251 wxRect() { x = y = width = height = 0; }
252 wxRect(long xx, long yy, long ww, long hh)
253 { x = xx; y = yy; width = ww; height = hh; }
f03fc89f
VZ
254 wxRect(const wxPoint& topLeft, const wxPoint& bottomRight);
255 wxRect(const wxPoint& pos, const wxSize& size);
a23fd0e1
VZ
256
257 // default copy ctor and assignment operators ok
c801d85f 258
f03fc89f
VZ
259 long GetX() const { return x; }
260 void SetX(long xx) { x = xx; }
c801d85f 261
f03fc89f
VZ
262 long GetY() const { return y; }
263 void SetY(long yy) { y = yy; }
c801d85f 264
f03fc89f
VZ
265 long GetWidth() const { return width; }
266 void SetWidth(long w) { width = w; }
c801d85f 267
f03fc89f
VZ
268 long GetHeight() const { return height; }
269 void SetHeight(long h) { height = h; }
270
dcb44466
JS
271 wxPoint GetPosition() const { return wxPoint(x, y); }
272 wxSize GetSize() const { return wxSize(width, height); }
f03fc89f 273
f3c0f9e7
JS
274 // MFC-like functions
275
f03fc89f
VZ
276 long GetLeft() const { return x; }
277 long GetTop() const { return y; }
f3c0f9e7
JS
278 long GetBottom() const { return y + height - 1; }
279 long GetRight() const { return x + width - 1; }
f03fc89f 280
f3c0f9e7
JS
281 void SetLeft(long left) { x = left; }
282 void SetRight(long right) { width = right - x + 1; }
283 void SetTop(long top) { y = top; }
284 void SetBottom(long bottom) { height = bottom - y + 1; }
dcb44466 285
764a3a49
VZ
286 bool operator==(const wxRect& rect) const;
287 bool operator!=(const wxRect& rect) const { return !(*this == rect); }
f03fc89f 288
7742598f 289 bool Inside(int cx, int cy) const;
dcb44466
JS
290 wxRect operator + (const wxRect& rect) const;
291 const wxRect& operator += (const wxRect& rect);
7742598f 292
f03fc89f
VZ
293public:
294 long x, y, width, height;
295};
c801d85f 296
f03fc89f 297// ---------------------------------------------------------------------------
c801d85f 298// Management of pens, brushes and fonts
f03fc89f
VZ
299// ---------------------------------------------------------------------------
300
301class WXDLLEXPORT wxPenList : public wxList
c801d85f 302{
f03fc89f
VZ
303 DECLARE_DYNAMIC_CLASS(wxPenList)
304
305public:
306 wxPenList() { }
307 ~wxPenList();
308
309 void AddPen(wxPen *pen);
310 void RemovePen(wxPen *pen);
311 wxPen *FindOrCreatePen(const wxColour& colour, int width, int style);
c801d85f
KB
312};
313
f03fc89f 314class WXDLLEXPORT wxBrushList : public wxList
c801d85f 315{
f03fc89f
VZ
316 DECLARE_DYNAMIC_CLASS(wxBrushList)
317
318public:
319 wxBrushList() { }
320 ~wxBrushList();
321
322 void AddBrush(wxBrush *brush);
323 void RemoveBrush(wxBrush *brush);
324 wxBrush *FindOrCreateBrush(const wxColour& colour, int style);
c801d85f
KB
325};
326
9d2f3c71 327WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString;
c801d85f 328
f03fc89f 329class WXDLLEXPORT wxFontList : public wxList
c801d85f 330{
f03fc89f
VZ
331 DECLARE_DYNAMIC_CLASS(wxFontList)
332
333public:
334 wxFontList() { }
335 ~wxFontList();
336
337 void AddFont(wxFont *font);
338 void RemoveFont(wxFont *font);
339 wxFont *FindOrCreateFont(int pointSize, int family, int style, int weight,
340 bool underline = FALSE,
341 const wxString& face = wxEmptyString);
c801d85f
KB
342};
343
f03fc89f 344class WXDLLEXPORT wxColourDatabase : public wxList
c801d85f 345{
f03fc89f
VZ
346 DECLARE_CLASS(wxColourDatabase)
347
348public:
349 wxColourDatabase(int type);
350 ~wxColourDatabase() ;
351
352 // Not const because it may add a name to the database
353 wxColour *FindColour(const wxString& colour) ;
354 wxString FindName(const wxColour& colour) const;
355 void Initialize();
c801d85f
KB
356};
357
f03fc89f 358class WXDLLEXPORT wxBitmapList : public wxList
c801d85f 359{
f03fc89f 360 DECLARE_DYNAMIC_CLASS(wxBitmapList)
c801d85f 361
f03fc89f
VZ
362public:
363 wxBitmapList();
364 ~wxBitmapList();
365
366 void AddBitmap(wxBitmap *bitmap);
367 void RemoveBitmap(wxBitmap *bitmap);
c801d85f
KB
368};
369
f03fc89f
VZ
370class WXDLLEXPORT wxResourceCache: public wxList
371{
372public:
373 wxResourceCache() { }
374 wxResourceCache(const unsigned int keyType) : wxList(keyType) { }
375 ~wxResourceCache();
376
377private:
378 DECLARE_DYNAMIC_CLASS(wxResourceCache)
379};
380
381// ---------------------------------------------------------------------------
382// global variables
383// ---------------------------------------------------------------------------
384
c801d85f 385// Lists of GDI objects
f03fc89f
VZ
386WXDLLEXPORT_DATA(extern wxPenList*) wxThePenList;
387WXDLLEXPORT_DATA(extern wxBrushList*) wxTheBrushList;
388WXDLLEXPORT_DATA(extern wxFontList*) wxTheFontList;
389WXDLLEXPORT_DATA(extern wxBitmapList*) wxTheBitmapList;
c801d85f
KB
390
391// Stock objects
f03fc89f
VZ
392WXDLLEXPORT_DATA(extern wxFont*) wxNORMAL_FONT;
393WXDLLEXPORT_DATA(extern wxFont*) wxSMALL_FONT;
394WXDLLEXPORT_DATA(extern wxFont*) wxITALIC_FONT;
395WXDLLEXPORT_DATA(extern wxFont*) wxSWISS_FONT;
396
397WXDLLEXPORT_DATA(extern wxPen*) wxRED_PEN;
398WXDLLEXPORT_DATA(extern wxPen*) wxCYAN_PEN;
399WXDLLEXPORT_DATA(extern wxPen*) wxGREEN_PEN;
400WXDLLEXPORT_DATA(extern wxPen*) wxBLACK_PEN;
401WXDLLEXPORT_DATA(extern wxPen*) wxWHITE_PEN;
402WXDLLEXPORT_DATA(extern wxPen*) wxTRANSPARENT_PEN;
403WXDLLEXPORT_DATA(extern wxPen*) wxBLACK_DASHED_PEN;
404WXDLLEXPORT_DATA(extern wxPen*) wxGREY_PEN;
405WXDLLEXPORT_DATA(extern wxPen*) wxMEDIUM_GREY_PEN;
406WXDLLEXPORT_DATA(extern wxPen*) wxLIGHT_GREY_PEN;
407
408WXDLLEXPORT_DATA(extern wxBrush*) wxBLUE_BRUSH;
409WXDLLEXPORT_DATA(extern wxBrush*) wxGREEN_BRUSH;
410WXDLLEXPORT_DATA(extern wxBrush*) wxWHITE_BRUSH;
411WXDLLEXPORT_DATA(extern wxBrush*) wxBLACK_BRUSH;
412WXDLLEXPORT_DATA(extern wxBrush*) wxGREY_BRUSH;
413WXDLLEXPORT_DATA(extern wxBrush*) wxMEDIUM_GREY_BRUSH;
414WXDLLEXPORT_DATA(extern wxBrush*) wxLIGHT_GREY_BRUSH;
415WXDLLEXPORT_DATA(extern wxBrush*) wxTRANSPARENT_BRUSH;
416WXDLLEXPORT_DATA(extern wxBrush*) wxCYAN_BRUSH;
417WXDLLEXPORT_DATA(extern wxBrush*) wxRED_BRUSH;
418
419WXDLLEXPORT_DATA(extern wxColour*) wxBLACK;
420WXDLLEXPORT_DATA(extern wxColour*) wxWHITE;
421WXDLLEXPORT_DATA(extern wxColour*) wxRED;
422WXDLLEXPORT_DATA(extern wxColour*) wxBLUE;
423WXDLLEXPORT_DATA(extern wxColour*) wxGREEN;
424WXDLLEXPORT_DATA(extern wxColour*) wxCYAN;
425WXDLLEXPORT_DATA(extern wxColour*) wxLIGHT_GREY;
c801d85f
KB
426
427// 'Null' objects
f03fc89f
VZ
428WXDLLEXPORT_DATA(extern wxBitmap) wxNullBitmap;
429WXDLLEXPORT_DATA(extern wxIcon) wxNullIcon;
430WXDLLEXPORT_DATA(extern wxCursor) wxNullCursor;
431WXDLLEXPORT_DATA(extern wxPen) wxNullPen;
432WXDLLEXPORT_DATA(extern wxBrush) wxNullBrush;
433WXDLLEXPORT_DATA(extern wxPalette) wxNullPalette;
434WXDLLEXPORT_DATA(extern wxFont) wxNullFont;
435WXDLLEXPORT_DATA(extern wxColour) wxNullColour;
c801d85f
KB
436
437// Stock cursors types
f03fc89f
VZ
438WXDLLEXPORT_DATA(extern wxCursor*) wxSTANDARD_CURSOR;
439WXDLLEXPORT_DATA(extern wxCursor*) wxHOURGLASS_CURSOR;
440WXDLLEXPORT_DATA(extern wxCursor*) wxCROSS_CURSOR;
441
442WXDLLEXPORT_DATA(extern wxColourDatabase*) wxTheColourDatabase;
443
444WXDLLEXPORT_DATA(extern const wxChar*) wxPanelNameStr;
c801d85f 445
f03fc89f
VZ
446WXDLLEXPORT_DATA(extern const wxSize) wxDefaultSize;
447WXDLLEXPORT_DATA(extern const wxPoint) wxDefaultPosition;
448
449// The list of objects which should be deleted
450WXDLLEXPORT_DATA(extern wxList) wxPendingDelete;
451
452// ---------------------------------------------------------------------------
453// global functions
454// ---------------------------------------------------------------------------
455
456// resource management
6a6c0a8b 457extern void WXDLLEXPORT wxInitializeStockObjects();
a3622daa 458extern void WXDLLEXPORT wxInitializeStockLists();
6a6c0a8b 459extern void WXDLLEXPORT wxDeleteStockObjects();
a3622daa 460extern void WXDLLEXPORT wxDeleteStockLists();
c801d85f 461
f03fc89f 462// is the display colour (or monochrome)?
6a6c0a8b 463extern bool WXDLLEXPORT wxColourDisplay();
c801d85f
KB
464
465// Returns depth of screen
6a6c0a8b
JS
466extern int WXDLLEXPORT wxDisplayDepth();
467#define wxGetDisplayDepth wxDisplayDepth
c801d85f 468
f03fc89f 469// get the diaplay size
c801d85f 470extern void WXDLLEXPORT wxDisplaySize(int *width, int *height);
6a6c0a8b 471extern wxSize WXDLLEXPORT wxGetDisplaySize();
c801d85f 472
f03fc89f 473// set global cursor
c801d85f
KB
474extern void WXDLLEXPORT wxSetCursor(const wxCursor& cursor);
475
c801d85f 476#endif
34138703 477 // _WX_GDICMNH__