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