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