1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Common GDI classes, types and declarations
4 // Author: Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
16 #pragma interface "gdicmn.h"
19 #include "wx/object.h"
22 #include "wx/string.h"
24 #include "wx/colour.h"
37 wxCURSOR_MIDDLE_BUTTON
,
43 wxCURSOR_QUESTION_ARROW
,
44 wxCURSOR_RIGHT_BUTTON
,
55 /* Not yet implemented for Windows */
56 , wxCURSOR_CROSS_REVERSE
,
57 wxCURSOR_DOUBLE_ARROW
,
58 wxCURSOR_BASED_ARROW_UP
,
59 wxCURSOR_BASED_ARROW_DOWN
63 class WXDLLEXPORT wxSize
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 wxSize
operator + (const wxSize
& sz
) { return wxSize(x
+ sz
.x
, y
+ sz
.y
); }
73 inline wxSize
operator - (const wxSize
& sz
) { return wxSize(x
- sz
.x
, y
- sz
.y
); }
74 inline void Set(long xx
, long yy
) { x
= xx
; y
= yy
; }
75 inline long GetX() const { return x
; }
76 inline long GetY() const { return y
; }
80 class WXDLLEXPORT wxRealPoint
85 inline wxRealPoint() { x
= 0.0; y
= 0.0; };
86 inline wxRealPoint(double _x
, double _y
) { x
= _x
; y
= _y
; };
87 inline wxRealPoint
operator + (const wxRealPoint
& pt
) { return wxRealPoint(x
+ pt
.x
, y
+ pt
.y
); }
88 inline wxRealPoint
operator - (const wxRealPoint
& pt
) { return wxRealPoint(x
- pt
.x
, y
- pt
.y
); }
90 inline void operator = (const wxRealPoint
& pt
) { x
= pt
.x
; y
= pt
.y
; }
93 class WXDLLEXPORT wxPoint
96 #if defined(__WXMSW__) && !defined(__WIN32__)
104 inline wxPoint() { x
= 0; y
= 0; };
105 wxPoint(long the_x
, long the_y
) { x
= the_x
; y
= the_y
; };
106 wxPoint(const wxPoint
& pt
) { x
= pt
.x
; y
= pt
.y
; };
108 inline void operator = (const wxPoint
& pt
) { x
= pt
.x
; y
= pt
.y
; }
109 inline wxPoint
operator + (const wxPoint
& pt
) { return wxPoint(x
+ pt
.x
, y
+ pt
.y
); }
110 inline wxPoint
operator - (const wxPoint
& pt
) { return wxPoint(x
- pt
.x
, y
- pt
.y
); }
113 #if WXWIN_COMPATIBILITY
114 #define wxIntPoint wxPoint
115 #define wxRectangle wxRect
118 class WXDLLEXPORT wxRect
122 wxRect(long x
, long y
, long w
, long h
);
123 wxRect(const wxPoint
& topLeft
, const wxPoint
& bottomRight
);
124 wxRect(const wxPoint
& pos
, const wxSize
& size
);
125 wxRect(const wxRect
& rect
);
127 inline long GetX() const { return x
; }
128 inline void SetX(long X
) { x
= X
; }
129 inline long GetY() const { return y
; }
130 inline void SetY(long Y
) { y
= Y
; }
131 inline long GetWidth() const { return width
; }
132 inline void SetWidth(long w
) { width
= w
; }
133 inline long GetHeight() const { return height
; }
134 inline void SetHeight(long h
) { height
= h
; }
136 inline wxPoint
GetPosition() { return wxPoint(x
, y
); }
137 inline wxSize
GetSize() { return wxSize(width
, height
); }
139 inline long GetLeft() const { return x
; }
140 inline long GetTop() const { return y
; }
141 inline long GetBottom() const { return y
+ height
; }
142 inline long GetRight() const { return x
+ width
; }
144 wxRect
& operator = (const wxRect
& rect
);
145 bool operator == (const wxRect
& rect
);
146 bool operator != (const wxRect
& rect
);
148 long x
, y
, width
, height
;
151 class WXDLLEXPORT wxBrush
;
152 class WXDLLEXPORT wxPen
;
153 class WXDLLEXPORT wxBitmap
;
154 class WXDLLEXPORT wxIcon
;
155 class WXDLLEXPORT wxCursor
;
156 class WXDLLEXPORT wxFont
;
157 class WXDLLEXPORT wxPalette
;
158 class WXDLLEXPORT wxPalette
;
159 class WXDLLEXPORT wxRegion
;
165 // Hint to indicate filetype
166 #define wxBITMAP_TYPE_BMP 1
167 #define wxBITMAP_TYPE_BMP_RESOURCE 2
168 #define wxBITMAP_TYPE_ICO 3
169 #define wxBITMAP_TYPE_ICO_RESOURCE 4
170 #define wxBITMAP_TYPE_CUR 5
171 #define wxBITMAP_TYPE_CUR_RESOURCE 6
172 #define wxBITMAP_TYPE_XBM 7
173 #define wxBITMAP_TYPE_XBM_DATA 8
174 #define wxBITMAP_TYPE_XPM 9
175 #define wxBITMAP_TYPE_XPM_DATA 10
176 #define wxBITMAP_TYPE_TIF 11
177 #define wxBITMAP_TYPE_TIF_RESOURCE 12
178 #define wxBITMAP_TYPE_GIF 13
179 #define wxBITMAP_TYPE_GIF_RESOURCE 14
180 #define wxBITMAP_TYPE_PNG 15
181 #define wxBITMAP_TYPE_PNG_RESOURCE 16
182 #define wxBITMAP_TYPE_JPEG 17
183 #define wxBITMAP_TYPE_JPEG_RESOURCE 18
184 #define wxBITMAP_TYPE_ANY 50
186 #define wxBITMAP_TYPE_RESOURCE wxBITMAP_TYPE_BMP_RESOURCE
188 class WXDLLEXPORT wxBitmap
;
189 class WXDLLEXPORT wxCursor
;
190 class WXDLLEXPORT wxIcon
;
191 class WXDLLEXPORT wxColour
;
192 class WXDLLEXPORT wxString
;
194 // Management of pens, brushes and fonts
195 class WXDLLEXPORT wxPenList
: public wxList
197 DECLARE_DYNAMIC_CLASS(wxPenList
)
202 void AddPen(wxPen
*pen
);
203 void RemovePen(wxPen
*pen
);
204 wxPen
*FindOrCreatePen(const wxColour
& colour
, int width
, int style
);
207 class WXDLLEXPORT wxBrushList
: public wxList
209 DECLARE_DYNAMIC_CLASS(wxBrushList
)
214 void AddBrush(wxBrush
*brush
);
215 void RemoveBrush(wxBrush
*brush
);
216 wxBrush
*FindOrCreateBrush(const wxColour
& colour
, int style
);
219 WXDLLEXPORT_DATA(extern const char*) wxEmptyString
;
221 class WXDLLEXPORT wxFontList
: public wxList
223 DECLARE_DYNAMIC_CLASS(wxFontList
)
228 void AddFont(wxFont
*font
);
229 void RemoveFont(wxFont
*font
);
230 wxFont
*FindOrCreateFont(int pointSize
, int family
, int style
, int weight
,
231 bool underline
= FALSE
, const wxString
& face
= wxEmptyString
);
234 class WXDLLEXPORT wxColourDatabase
: public wxList
236 DECLARE_CLASS(wxColourDatabase
)
238 wxColourDatabase(int type
);
239 ~wxColourDatabase() ;
240 // Not const because it may add a name to the database
241 wxColour
*FindColour(const wxString
& colour
) ;
242 wxString
FindName(const wxColour
& colour
) const;
246 class WXDLLEXPORT wxBitmapList
: public wxList
248 DECLARE_DYNAMIC_CLASS(wxBitmapList
)
253 void AddBitmap(wxBitmap
*bitmap
);
254 void RemoveBitmap(wxBitmap
*bitmap
);
257 // Lists of GDI objects
258 WXDLLEXPORT_DATA(extern wxPenList
*) wxThePenList
;
259 WXDLLEXPORT_DATA(extern wxBrushList
*) wxTheBrushList
;
260 WXDLLEXPORT_DATA(extern wxFontList
*) wxTheFontList
;
261 WXDLLEXPORT_DATA(extern wxBitmapList
*) wxTheBitmapList
;
264 WXDLLEXPORT_DATA(extern wxFont
*) wxNORMAL_FONT
;
265 WXDLLEXPORT_DATA(extern wxFont
*) wxSMALL_FONT
;
266 WXDLLEXPORT_DATA(extern wxFont
*) wxITALIC_FONT
;
267 WXDLLEXPORT_DATA(extern wxFont
*) wxSWISS_FONT
;
269 WXDLLEXPORT_DATA(extern wxPen
*) wxRED_PEN
;
270 WXDLLEXPORT_DATA(extern wxPen
*) wxCYAN_PEN
;
271 WXDLLEXPORT_DATA(extern wxPen
*) wxGREEN_PEN
;
272 WXDLLEXPORT_DATA(extern wxPen
*) wxBLACK_PEN
;
273 WXDLLEXPORT_DATA(extern wxPen
*) wxWHITE_PEN
;
274 WXDLLEXPORT_DATA(extern wxPen
*) wxTRANSPARENT_PEN
;
275 WXDLLEXPORT_DATA(extern wxPen
*) wxBLACK_DASHED_PEN
;
276 WXDLLEXPORT_DATA(extern wxPen
*) wxGREY_PEN
;
277 WXDLLEXPORT_DATA(extern wxPen
*) wxMEDIUM_GREY_PEN
;
278 WXDLLEXPORT_DATA(extern wxPen
*) wxLIGHT_GREY_PEN
;
280 WXDLLEXPORT_DATA(extern wxBrush
*) wxBLUE_BRUSH
;
281 WXDLLEXPORT_DATA(extern wxBrush
*) wxGREEN_BRUSH
;
282 WXDLLEXPORT_DATA(extern wxBrush
*) wxWHITE_BRUSH
;
283 WXDLLEXPORT_DATA(extern wxBrush
*) wxBLACK_BRUSH
;
284 WXDLLEXPORT_DATA(extern wxBrush
*) wxGREY_BRUSH
;
285 WXDLLEXPORT_DATA(extern wxBrush
*) wxMEDIUM_GREY_BRUSH
;
286 WXDLLEXPORT_DATA(extern wxBrush
*) wxLIGHT_GREY_BRUSH
;
287 WXDLLEXPORT_DATA(extern wxBrush
*) wxTRANSPARENT_BRUSH
;
288 WXDLLEXPORT_DATA(extern wxBrush
*) wxCYAN_BRUSH
;
289 WXDLLEXPORT_DATA(extern wxBrush
*) wxRED_BRUSH
;
291 WXDLLEXPORT_DATA(extern wxColour
*) wxBLACK
;
292 WXDLLEXPORT_DATA(extern wxColour
*) wxWHITE
;
293 WXDLLEXPORT_DATA(extern wxColour
*) wxRED
;
294 WXDLLEXPORT_DATA(extern wxColour
*) wxBLUE
;
295 WXDLLEXPORT_DATA(extern wxColour
*) wxGREEN
;
296 WXDLLEXPORT_DATA(extern wxColour
*) wxCYAN
;
297 WXDLLEXPORT_DATA(extern wxColour
*) wxLIGHT_GREY
;
300 WXDLLEXPORT_DATA(extern wxBitmap
) wxNullBitmap
;
301 WXDLLEXPORT_DATA(extern wxIcon
) wxNullIcon
;
302 WXDLLEXPORT_DATA(extern wxCursor
) wxNullCursor
;
303 WXDLLEXPORT_DATA(extern wxPen
) wxNullPen
;
304 WXDLLEXPORT_DATA(extern wxBrush
) wxNullBrush
;
305 WXDLLEXPORT_DATA(extern wxPalette
) wxNullPalette
;
306 WXDLLEXPORT_DATA(extern wxFont
) wxNullFont
;
307 WXDLLEXPORT_DATA(extern wxColour
) wxNullColour
;
309 // Stock cursors types
310 WXDLLEXPORT_DATA(extern wxCursor
*) wxSTANDARD_CURSOR
;
311 WXDLLEXPORT_DATA(extern wxCursor
*) wxHOURGLASS_CURSOR
;
312 WXDLLEXPORT_DATA(extern wxCursor
*) wxCROSS_CURSOR
;
314 WXDLLEXPORT_DATA(extern wxColourDatabase
*) wxTheColourDatabase
;
315 extern void WXDLLEXPORT
wxInitializeStockObjects();
316 extern void WXDLLEXPORT
wxInitializeStockLists();
317 extern void WXDLLEXPORT
wxDeleteStockObjects();
318 extern void WXDLLEXPORT
wxDeleteStockLists();
320 extern bool WXDLLEXPORT
wxColourDisplay();
322 // Returns depth of screen
323 extern int WXDLLEXPORT
wxDisplayDepth();
324 #define wxGetDisplayDepth wxDisplayDepth
326 extern void WXDLLEXPORT
wxDisplaySize(int *width
, int *height
);
327 extern wxSize WXDLLEXPORT
wxGetDisplaySize();
329 extern void WXDLLEXPORT
wxSetCursor(const wxCursor
& cursor
);
331 // Useful macro for creating icons portably
334 // Load from a resource
335 # define wxICON(X) wxIcon("" #X "")
337 #elif defined(__WXGTK__)
338 // Initialize from an included XPM
339 # define wxICON(X) wxIcon( (const char**) X##_xpm )
340 #elif defined(__WXMOTIF__)
341 // Initialize from an included XPM
342 # define wxICON(X) wxIcon( X##_xpm )
345 // This will usually mean something on any platform
346 # define wxICON(X) wxIcon("" #X "")
351 wxIcon *icon = new wxICON(mondrian);
353 wxIcon *icon = new wxIcon("mondrian"); // On wxMSW
354 wxIcon *icon = new wxIcon(mondrian_xpm); // On wxGTK
357 class WXDLLEXPORT wxResourceCache
: public wxList
360 wxResourceCache() { }
361 wxResourceCache(const unsigned int keyType
) : wxList(keyType
) { }
365 DECLARE_DYNAMIC_CLASS(wxResourceCache
)