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