]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gdicmn.h
Unicode conversion.
[wxWidgets.git] / include / wx / gdicmn.h
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)
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_GDICMNH__
13 #define _WX_GDICMNH__
14
15 #ifdef __GNUG__
16 #pragma interface "gdicmn.h"
17 #endif
18
19 #include "wx/object.h"
20 #include "wx/list.h"
21 #include "wx/hash.h"
22 #include "wx/string.h"
23 #include "wx/setup.h"
24 #include "wx/colour.h"
25
26 // Standard cursors
27 typedef enum {
28 wxCURSOR_NONE = 0,
29 wxCURSOR_ARROW = 1,
30 wxCURSOR_BULLSEYE,
31 wxCURSOR_CHAR,
32 wxCURSOR_CROSS,
33 wxCURSOR_HAND,
34 wxCURSOR_IBEAM,
35 wxCURSOR_LEFT_BUTTON,
36 wxCURSOR_MAGNIFIER,
37 wxCURSOR_MIDDLE_BUTTON,
38 wxCURSOR_NO_ENTRY,
39 wxCURSOR_PAINT_BRUSH,
40 wxCURSOR_PENCIL,
41 wxCURSOR_POINT_LEFT,
42 wxCURSOR_POINT_RIGHT,
43 wxCURSOR_QUESTION_ARROW,
44 wxCURSOR_RIGHT_BUTTON,
45 wxCURSOR_SIZENESW,
46 wxCURSOR_SIZENS,
47 wxCURSOR_SIZENWSE,
48 wxCURSOR_SIZEWE,
49 wxCURSOR_SIZING,
50 wxCURSOR_SPRAYCAN,
51 wxCURSOR_WAIT,
52 wxCURSOR_WATCH,
53 wxCURSOR_BLANK
54 #ifdef __X__
55 /* Not yet implemented for Windows */
56 , wxCURSOR_CROSS_REVERSE,
57 wxCURSOR_DOUBLE_ARROW,
58 wxCURSOR_BASED_ARROW_UP,
59 wxCURSOR_BASED_ARROW_DOWN
60 #endif
61 } wxStockCursor;
62
63 class WXDLLEXPORT wxSize
64 {
65 public:
66 long x;
67 long y;
68 inline wxSize() { x = 0; y = 0; }
69 inline wxSize(long xx, long yy) { x = xx; y = yy; }
70 inline wxSize(const wxSize& sz) { x = sz.x; y = sz.y; }
71 inline void operator = (const wxSize& sz) { x = sz.x; y = sz.y; }
72 inline bool operator == (const wxSize& sz) const { return (x == sz.x && y == sz.y); }
73 inline wxSize operator + (const wxSize& sz) { return wxSize(x + sz.x, y + sz.y); }
74 inline wxSize operator - (const wxSize& sz) { return wxSize(x - sz.x, y - sz.y); }
75 inline void Set(long xx, long yy) { x = xx; y = yy; }
76 inline long GetX() const { return x; }
77 inline long GetY() const { return y; }
78 };
79
80 // Point
81 class WXDLLEXPORT wxRealPoint
82 {
83 public:
84 double x;
85 double y;
86 inline wxRealPoint() { x = 0.0; y = 0.0; };
87 inline wxRealPoint(double _x, double _y) { x = _x; y = _y; };
88 inline wxRealPoint operator + (const wxRealPoint& pt) { return wxRealPoint(x + pt.x, y + pt.y); }
89 inline wxRealPoint operator - (const wxRealPoint& pt) { return wxRealPoint(x - pt.x, y - pt.y); }
90
91 inline void operator = (const wxRealPoint& pt) { x = pt.x; y = pt.y; }
92 inline bool operator == (const wxRealPoint& pt) const { return (x == pt.x && y == pt.y); }
93 };
94
95 class WXDLLEXPORT wxPoint
96 {
97 public:
98 #if defined(__WXMSW__) && !defined(__WIN32__)
99 int x;
100 int y;
101 #else
102 long x;
103 long y;
104 #endif
105
106 inline wxPoint() { x = 0; y = 0; };
107 wxPoint(long the_x, long the_y) { x = the_x; y = the_y; };
108 wxPoint(const wxPoint& pt) { x = pt.x; y = pt.y; };
109
110 inline void operator = (const wxPoint& pt) { x = pt.x; y = pt.y; }
111 inline bool operator == (const wxPoint& pt) const { return (x == pt.x && y == pt.y); }
112 inline wxPoint operator + (const wxPoint& pt) { return wxPoint(x + pt.x, y + pt.y); }
113 inline wxPoint operator - (const wxPoint& pt) { return wxPoint(x - pt.x, y - pt.y); }
114 };
115
116 #if WXWIN_COMPATIBILITY
117 #define wxIntPoint wxPoint
118 #define wxRectangle wxRect
119 #endif
120
121 class WXDLLEXPORT wxRect
122 {
123 public:
124 wxRect() ;
125 wxRect(long x, long y, long w, long h);
126 wxRect(const wxPoint& topLeft, const wxPoint& bottomRight);
127 wxRect(const wxPoint& pos, const wxSize& size);
128 wxRect(const wxRect& rect);
129
130 inline long GetX() const { return x; }
131 inline void SetX(long X) { x = X; }
132 inline long GetY() const { return y; }
133 inline void SetY(long Y) { y = Y; }
134 inline long GetWidth() const { return width; }
135 inline void SetWidth(long w) { width = w; }
136 inline long GetHeight() const { return height; }
137 inline void SetHeight(long h) { height = h; }
138
139 inline wxPoint GetPosition() { return wxPoint(x, y); }
140 inline wxSize GetSize() { return wxSize(width, height); }
141
142 inline long GetLeft() const { return x; }
143 inline long GetTop() const { return y; }
144 inline long GetBottom() const { return y + height; }
145 inline long GetRight() const { return x + width; }
146
147 wxRect& operator = (const wxRect& rect);
148 bool operator == (const wxRect& rect);
149 bool operator != (const wxRect& rect);
150 public:
151 long x, y, width, height;
152 };
153
154 class WXDLLEXPORT wxBrush;
155 class WXDLLEXPORT wxPen;
156 class WXDLLEXPORT wxBitmap;
157 class WXDLLEXPORT wxIcon;
158 class WXDLLEXPORT wxCursor;
159 class WXDLLEXPORT wxFont;
160 class WXDLLEXPORT wxPalette;
161 class WXDLLEXPORT wxPalette;
162 class WXDLLEXPORT wxRegion;
163
164 /*
165 * Bitmap flags
166 */
167
168 // Hint to indicate filetype
169 #define wxBITMAP_TYPE_BMP 1
170 #define wxBITMAP_TYPE_BMP_RESOURCE 2
171 #define wxBITMAP_TYPE_ICO 3
172 #define wxBITMAP_TYPE_ICO_RESOURCE 4
173 #define wxBITMAP_TYPE_CUR 5
174 #define wxBITMAP_TYPE_CUR_RESOURCE 6
175 #define wxBITMAP_TYPE_XBM 7
176 #define wxBITMAP_TYPE_XBM_DATA 8
177 #define wxBITMAP_TYPE_XPM 9
178 #define wxBITMAP_TYPE_XPM_DATA 10
179 #define wxBITMAP_TYPE_TIF 11
180 #define wxBITMAP_TYPE_TIF_RESOURCE 12
181 #define wxBITMAP_TYPE_GIF 13
182 #define wxBITMAP_TYPE_GIF_RESOURCE 14
183 #define wxBITMAP_TYPE_PNG 15
184 #define wxBITMAP_TYPE_PNG_RESOURCE 16
185 #define wxBITMAP_TYPE_JPEG 17
186 #define wxBITMAP_TYPE_JPEG_RESOURCE 18
187 #define wxBITMAP_TYPE_ANY 50
188
189 #define wxBITMAP_TYPE_RESOURCE wxBITMAP_TYPE_BMP_RESOURCE
190
191 class WXDLLEXPORT wxBitmap;
192 class WXDLLEXPORT wxCursor;
193 class WXDLLEXPORT wxIcon;
194 class WXDLLEXPORT wxColour;
195 class WXDLLEXPORT wxString;
196
197 // Management of pens, brushes and fonts
198 class WXDLLEXPORT wxPenList: public wxList
199 {
200 DECLARE_DYNAMIC_CLASS(wxPenList)
201 public:
202 inline wxPenList()
203 { }
204 ~wxPenList();
205 void AddPen(wxPen *pen);
206 void RemovePen(wxPen *pen);
207 wxPen *FindOrCreatePen(const wxColour& colour, int width, int style);
208 };
209
210 class WXDLLEXPORT wxBrushList: public wxList
211 {
212 DECLARE_DYNAMIC_CLASS(wxBrushList)
213 public:
214 inline wxBrushList()
215 { }
216 ~wxBrushList();
217 void AddBrush(wxBrush *brush);
218 void RemoveBrush(wxBrush *brush);
219 wxBrush *FindOrCreateBrush(const wxColour& colour, int style);
220 };
221
222 WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString;
223
224 class WXDLLEXPORT wxFontList: public wxList
225 {
226 DECLARE_DYNAMIC_CLASS(wxFontList)
227 public:
228 inline wxFontList()
229 { }
230 ~wxFontList();
231 void AddFont(wxFont *font);
232 void RemoveFont(wxFont *font);
233 wxFont *FindOrCreateFont(int pointSize, int family, int style, int weight,
234 bool underline = FALSE, const wxString& face = wxEmptyString);
235 };
236
237 class WXDLLEXPORT wxColourDatabase: public wxList
238 {
239 DECLARE_CLASS(wxColourDatabase)
240 public:
241 wxColourDatabase(int type);
242 ~wxColourDatabase() ;
243 // Not const because it may add a name to the database
244 wxColour *FindColour(const wxString& colour) ;
245 wxString FindName(const wxColour& colour) const;
246 void Initialize();
247 };
248
249 class WXDLLEXPORT wxBitmapList: public wxList
250 {
251 DECLARE_DYNAMIC_CLASS(wxBitmapList)
252 public:
253 wxBitmapList();
254 ~wxBitmapList();
255
256 void AddBitmap(wxBitmap *bitmap);
257 void RemoveBitmap(wxBitmap *bitmap);
258 };
259
260 // Lists of GDI objects
261 WXDLLEXPORT_DATA(extern wxPenList*) wxThePenList;
262 WXDLLEXPORT_DATA(extern wxBrushList*) wxTheBrushList;
263 WXDLLEXPORT_DATA(extern wxFontList*) wxTheFontList;
264 WXDLLEXPORT_DATA(extern wxBitmapList*) wxTheBitmapList;
265
266 // Stock objects
267 WXDLLEXPORT_DATA(extern wxFont*) wxNORMAL_FONT;
268 WXDLLEXPORT_DATA(extern wxFont*) wxSMALL_FONT;
269 WXDLLEXPORT_DATA(extern wxFont*) wxITALIC_FONT;
270 WXDLLEXPORT_DATA(extern wxFont*) wxSWISS_FONT;
271
272 WXDLLEXPORT_DATA(extern wxPen*) wxRED_PEN;
273 WXDLLEXPORT_DATA(extern wxPen*) wxCYAN_PEN;
274 WXDLLEXPORT_DATA(extern wxPen*) wxGREEN_PEN;
275 WXDLLEXPORT_DATA(extern wxPen*) wxBLACK_PEN;
276 WXDLLEXPORT_DATA(extern wxPen*) wxWHITE_PEN;
277 WXDLLEXPORT_DATA(extern wxPen*) wxTRANSPARENT_PEN;
278 WXDLLEXPORT_DATA(extern wxPen*) wxBLACK_DASHED_PEN;
279 WXDLLEXPORT_DATA(extern wxPen*) wxGREY_PEN;
280 WXDLLEXPORT_DATA(extern wxPen*) wxMEDIUM_GREY_PEN;
281 WXDLLEXPORT_DATA(extern wxPen*) wxLIGHT_GREY_PEN;
282
283 WXDLLEXPORT_DATA(extern wxBrush*) wxBLUE_BRUSH;
284 WXDLLEXPORT_DATA(extern wxBrush*) wxGREEN_BRUSH;
285 WXDLLEXPORT_DATA(extern wxBrush*) wxWHITE_BRUSH;
286 WXDLLEXPORT_DATA(extern wxBrush*) wxBLACK_BRUSH;
287 WXDLLEXPORT_DATA(extern wxBrush*) wxGREY_BRUSH;
288 WXDLLEXPORT_DATA(extern wxBrush*) wxMEDIUM_GREY_BRUSH;
289 WXDLLEXPORT_DATA(extern wxBrush*) wxLIGHT_GREY_BRUSH;
290 WXDLLEXPORT_DATA(extern wxBrush*) wxTRANSPARENT_BRUSH;
291 WXDLLEXPORT_DATA(extern wxBrush*) wxCYAN_BRUSH;
292 WXDLLEXPORT_DATA(extern wxBrush*) wxRED_BRUSH;
293
294 WXDLLEXPORT_DATA(extern wxColour*) wxBLACK;
295 WXDLLEXPORT_DATA(extern wxColour*) wxWHITE;
296 WXDLLEXPORT_DATA(extern wxColour*) wxRED;
297 WXDLLEXPORT_DATA(extern wxColour*) wxBLUE;
298 WXDLLEXPORT_DATA(extern wxColour*) wxGREEN;
299 WXDLLEXPORT_DATA(extern wxColour*) wxCYAN;
300 WXDLLEXPORT_DATA(extern wxColour*) wxLIGHT_GREY;
301
302 // 'Null' objects
303 WXDLLEXPORT_DATA(extern wxBitmap) wxNullBitmap;
304 WXDLLEXPORT_DATA(extern wxIcon) wxNullIcon;
305 WXDLLEXPORT_DATA(extern wxCursor) wxNullCursor;
306 WXDLLEXPORT_DATA(extern wxPen) wxNullPen;
307 WXDLLEXPORT_DATA(extern wxBrush) wxNullBrush;
308 WXDLLEXPORT_DATA(extern wxPalette) wxNullPalette;
309 WXDLLEXPORT_DATA(extern wxFont) wxNullFont;
310 WXDLLEXPORT_DATA(extern wxColour) wxNullColour;
311
312 // Stock cursors types
313 WXDLLEXPORT_DATA(extern wxCursor*) wxSTANDARD_CURSOR;
314 WXDLLEXPORT_DATA(extern wxCursor*) wxHOURGLASS_CURSOR;
315 WXDLLEXPORT_DATA(extern wxCursor*) wxCROSS_CURSOR;
316
317 WXDLLEXPORT_DATA(extern wxColourDatabase*) wxTheColourDatabase;
318 extern void WXDLLEXPORT wxInitializeStockObjects();
319 extern void WXDLLEXPORT wxInitializeStockLists();
320 extern void WXDLLEXPORT wxDeleteStockObjects();
321 extern void WXDLLEXPORT wxDeleteStockLists();
322
323 extern bool WXDLLEXPORT wxColourDisplay();
324
325 // Returns depth of screen
326 extern int WXDLLEXPORT wxDisplayDepth();
327 #define wxGetDisplayDepth wxDisplayDepth
328
329 extern void WXDLLEXPORT wxDisplaySize(int *width, int *height);
330 extern wxSize WXDLLEXPORT wxGetDisplaySize();
331
332 extern void WXDLLEXPORT wxSetCursor(const wxCursor& cursor);
333
334 // Useful macro for creating icons portably
335
336 #ifdef __WXMSW__
337 // Load from a resource
338 # define wxICON(X) wxIcon("" #X "")
339
340 #elif defined(__WXGTK__)
341 // Initialize from an included XPM
342 # define wxICON(X) wxIcon( (const char**) X##_xpm )
343 #elif defined(__WXMOTIF__)
344 // Initialize from an included XPM
345 # define wxICON(X) wxIcon( X##_xpm )
346 #else
347
348 // This will usually mean something on any platform
349 # define wxICON(X) wxIcon("" #X "")
350 #endif
351
352 /*
353 Example:
354 wxIcon *icon = new wxICON(mondrian);
355 expands into:
356 wxIcon *icon = new wxIcon("mondrian"); // On wxMSW
357 wxIcon *icon = new wxIcon(mondrian_xpm); // On wxGTK
358 */
359
360 class WXDLLEXPORT wxResourceCache: public wxList
361 {
362 public:
363 wxResourceCache() { }
364 wxResourceCache(const unsigned int keyType) : wxList(keyType) { }
365 ~wxResourceCache();
366
367 private:
368 DECLARE_DYNAMIC_CLASS(wxResourceCache)
369 };
370
371 #endif
372 // _WX_GDICMNH__