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