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