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"
25 #include "wx/msw/colour.h"
26 #elif defined(__WXMOTIF__)
27 #include "wx/xt/colour.h"
28 #elif defined(__WXGTK__)
29 #include "wx/gtk/colour.h"
42 wxCURSOR_MIDDLE_BUTTON
,
48 wxCURSOR_QUESTION_ARROW
,
49 wxCURSOR_RIGHT_BUTTON
,
60 /* Not yet implemented for Windows */
61 , wxCURSOR_CROSS_REVERSE
,
62 wxCURSOR_DOUBLE_ARROW
,
63 wxCURSOR_BASED_ARROW_UP
,
64 wxCURSOR_BASED_ARROW_DOWN
66 } _standard_cursors_t
;
68 class WXDLLEXPORT wxSize
73 inline wxSize() { 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 wxSize
operator + (const wxSize
& sz
) { return wxSize(x
+ sz
.x
, y
+ sz
.y
); }
78 inline wxSize
operator - (const wxSize
& sz
) { return wxSize(x
- sz
.x
, y
- sz
.y
); }
79 inline void Set(long xx
, long yy
) { x
= xx
; y
= yy
; }
80 inline long GetX() const { return x
; }
81 inline long GetY() const { return y
; }
85 class WXDLLEXPORT wxRealPoint
90 inline wxRealPoint() { x
= 0.0; y
= 0.0; };
91 inline wxRealPoint(double _x
, double _y
) { x
= _x
; y
= _y
; };
92 inline wxRealPoint
operator + (const wxRealPoint
& pt
) { return wxRealPoint(x
+ pt
.x
, y
+ pt
.y
); }
93 inline wxRealPoint
operator - (const wxRealPoint
& pt
) { return wxRealPoint(x
- pt
.x
, y
- pt
.y
); }
95 inline void operator = (const wxRealPoint
& pt
) { x
= pt
.x
; y
= pt
.y
; }
98 class WXDLLEXPORT wxPoint
101 #if defined(__WXMSW__) && !defined(__WIN32__)
109 inline wxPoint() { x
= 0; y
= 0; };
110 wxPoint(long the_x
, long the_y
) { x
= the_x
; y
= the_y
; };
111 wxPoint(const wxPoint
& pt
) { x
= pt
.x
; y
= pt
.y
; };
113 inline void operator = (const wxPoint
& pt
) { x
= pt
.x
; y
= pt
.y
; }
114 inline wxPoint
operator + (const wxPoint
& pt
) { return wxPoint(x
+ pt
.x
, y
+ pt
.y
); }
115 inline wxPoint
operator - (const wxPoint
& pt
) { return wxPoint(x
- pt
.x
, y
- pt
.y
); }
118 #if WXWIN_COMPATIBILITY
119 #define wxIntPoint wxPoint
120 #define wxRectangle wxRect
123 class WXDLLEXPORT wxRect
127 wxRect(long x
, long y
, long w
, long h
);
128 wxRect(const wxPoint
& topLeft
, const wxPoint
& bottomRight
);
129 wxRect(const wxPoint
& pos
, const wxSize
& size
);
130 wxRect(const wxRect
& rect
);
132 inline long GetX() const { return x
; }
133 inline void SetX(long X
) { x
= X
; }
134 inline long GetY() const { return y
; }
135 inline void SetY(long Y
) { y
= Y
; }
136 inline long GetWidth() const { return width
; }
137 inline void SetWidth(long w
) { width
= w
; }
138 inline long GetHeight() const { return height
; }
139 inline void SetHeight(long h
) { height
= h
; }
141 inline wxPoint
GetPosition() { return wxPoint(x
, y
); }
142 inline wxSize
GetSize() { return wxSize(width
, height
); }
144 inline long GetLeft() const { return x
; }
145 inline long GetTop() const { return y
; }
146 inline long GetBottom() const { return y
+ height
; }
147 inline long GetRight() const { return x
+ width
; }
149 wxRect
& operator = (const wxRect
& rect
);
150 bool operator == (const wxRect
& rect
);
151 bool operator != (const wxRect
& rect
);
153 long x
, y
, width
, height
;
156 class WXDLLEXPORT wxBrush
;
157 class WXDLLEXPORT wxPen
;
158 class WXDLLEXPORT wxBitmap
;
159 class WXDLLEXPORT wxIcon
;
160 class WXDLLEXPORT wxCursor
;
161 class WXDLLEXPORT wxFont
;
162 class WXDLLEXPORT wxPalette
;
163 class WXDLLEXPORT wxPalette
;
169 // Hint to indicate filetype
170 #define wxBITMAP_TYPE_BMP 1
171 #define wxBITMAP_TYPE_BMP_RESOURCE 2
172 #define wxBITMAP_TYPE_ICO 3
173 #define wxBITMAP_TYPE_ICO_RESOURCE 4
174 #define wxBITMAP_TYPE_CUR 5
175 #define wxBITMAP_TYPE_CUR_RESOURCE 6
176 #define wxBITMAP_TYPE_XBM 7
177 #define wxBITMAP_TYPE_XBM_DATA 8
178 #define wxBITMAP_TYPE_XPM 9
179 #define wxBITMAP_TYPE_XPM_DATA 10
180 #define wxBITMAP_TYPE_TIF 11
181 #define wxBITMAP_TYPE_TIF_RESOURCE 12
182 #define wxBITMAP_TYPE_GIF 13
183 #define wxBITMAP_TYPE_GIF_RESOURCE 14
184 #define wxBITMAP_TYPE_PNG 15
185 #define wxBITMAP_TYPE_PNG_RESOURCE 16
186 #define wxBITMAP_TYPE_ANY 50
188 #define wxBITMAP_TYPE_RESOURCE wxBITMAP_TYPE_BMP_RESOURCE
190 class WXDLLEXPORT wxBitmap
;
191 class WXDLLEXPORT wxCursor
;
192 class WXDLLEXPORT wxIcon
;
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
);
205 wxPen
*FindOrCreatePen(const wxString
& colour
, int width
, int style
);
208 class WXDLLEXPORT wxBrushList
: public wxList
210 DECLARE_DYNAMIC_CLASS(wxBrushList
)
215 void AddBrush(wxBrush
*brush
);
216 void RemoveBrush(wxBrush
*brush
);
217 wxBrush
*FindOrCreateBrush(const wxColour
& colour
, int style
);
218 wxBrush
*FindOrCreateBrush(const wxString
& colour
, int style
);
221 WXDLLEXPORT_DATA(extern const char*) wxEmptyString
;
223 class WXDLLEXPORT wxFontList
: public wxList
225 DECLARE_DYNAMIC_CLASS(wxFontList
)
230 void AddFont(wxFont
*font
);
231 void RemoveFont(wxFont
*font
);
232 wxFont
*FindOrCreateFont(int pointSize
, int family
, int style
, int weight
,
233 bool underline
= FALSE
, const wxString
& face
= wxEmptyString
);
236 class WXDLLEXPORT wxColourDatabase
: public wxList
238 DECLARE_CLASS(wxColourDatabase
)
240 wxColourDatabase(int type
);
241 ~wxColourDatabase() ;
242 // Not const because it may add a name to the database
243 wxColour
*FindColour(const wxString
& colour
) ;
244 wxString
FindName(const wxColour
& colour
) const;
248 class WXDLLEXPORT wxBitmapList
: public wxList
250 DECLARE_DYNAMIC_CLASS(wxBitmapList
)
255 void AddBitmap(wxBitmap
*bitmap
);
256 void RemoveBitmap(wxBitmap
*bitmap
);
259 // Lists of GDI objects
260 WXDLLEXPORT_DATA(extern wxPenList
*) wxThePenList
;
261 WXDLLEXPORT_DATA(extern wxBrushList
*) wxTheBrushList
;
262 WXDLLEXPORT_DATA(extern wxFontList
*) wxTheFontList
;
263 WXDLLEXPORT_DATA(extern wxBitmapList
*) wxTheBitmapList
;
266 WXDLLEXPORT_DATA(extern wxFont
*) wxNORMAL_FONT
;
267 WXDLLEXPORT_DATA(extern wxFont
*) wxSMALL_FONT
;
268 WXDLLEXPORT_DATA(extern wxFont
*) wxITALIC_FONT
;
269 WXDLLEXPORT_DATA(extern wxFont
*) wxSWISS_FONT
;
271 WXDLLEXPORT_DATA(extern wxPen
*) wxRED_PEN
;
272 WXDLLEXPORT_DATA(extern wxPen
*) wxCYAN_PEN
;
273 WXDLLEXPORT_DATA(extern wxPen
*) wxGREEN_PEN
;
274 WXDLLEXPORT_DATA(extern wxPen
*) wxBLACK_PEN
;
275 WXDLLEXPORT_DATA(extern wxPen
*) wxWHITE_PEN
;
276 WXDLLEXPORT_DATA(extern wxPen
*) wxTRANSPARENT_PEN
;
277 WXDLLEXPORT_DATA(extern wxPen
*) wxBLACK_DASHED_PEN
;
278 WXDLLEXPORT_DATA(extern wxPen
*) wxGREY_PEN
;
279 WXDLLEXPORT_DATA(extern wxPen
*) wxMEDIUM_GREY_PEN
;
280 WXDLLEXPORT_DATA(extern wxPen
*) wxLIGHT_GREY_PEN
;
282 WXDLLEXPORT_DATA(extern wxBrush
*) wxBLUE_BRUSH
;
283 WXDLLEXPORT_DATA(extern wxBrush
*) wxGREEN_BRUSH
;
284 WXDLLEXPORT_DATA(extern wxBrush
*) wxWHITE_BRUSH
;
285 WXDLLEXPORT_DATA(extern wxBrush
*) wxBLACK_BRUSH
;
286 WXDLLEXPORT_DATA(extern wxBrush
*) wxGREY_BRUSH
;
287 WXDLLEXPORT_DATA(extern wxBrush
*) wxMEDIUM_GREY_BRUSH
;
288 WXDLLEXPORT_DATA(extern wxBrush
*) wxLIGHT_GREY_BRUSH
;
289 WXDLLEXPORT_DATA(extern wxBrush
*) wxTRANSPARENT_BRUSH
;
290 WXDLLEXPORT_DATA(extern wxBrush
*) wxCYAN_BRUSH
;
291 WXDLLEXPORT_DATA(extern wxBrush
*) wxRED_BRUSH
;
293 WXDLLEXPORT_DATA(extern wxColour
*) wxBLACK
;
294 WXDLLEXPORT_DATA(extern wxColour
*) wxWHITE
;
295 WXDLLEXPORT_DATA(extern wxColour
*) wxRED
;
296 WXDLLEXPORT_DATA(extern wxColour
*) wxBLUE
;
297 WXDLLEXPORT_DATA(extern wxColour
*) wxGREEN
;
298 WXDLLEXPORT_DATA(extern wxColour
*) wxCYAN
;
299 WXDLLEXPORT_DATA(extern wxColour
*) wxLIGHT_GREY
;
302 WXDLLEXPORT_DATA(extern wxBitmap
) wxNullBitmap
;
303 WXDLLEXPORT_DATA(extern wxIcon
) wxNullIcon
;
304 WXDLLEXPORT_DATA(extern wxCursor
) wxNullCursor
;
305 WXDLLEXPORT_DATA(extern wxPen
) wxNullPen
;
306 WXDLLEXPORT_DATA(extern wxBrush
) wxNullBrush
;
307 WXDLLEXPORT_DATA(extern wxPalette
) wxNullPalette
;
308 WXDLLEXPORT_DATA(extern wxFont
) wxNullFont
;
309 WXDLLEXPORT_DATA(extern wxColour
) wxNullColour
;
311 // Stock cursors types
312 WXDLLEXPORT_DATA(extern wxCursor
*) wxSTANDARD_CURSOR
;
313 WXDLLEXPORT_DATA(extern wxCursor
*) wxHOURGLASS_CURSOR
;
314 WXDLLEXPORT_DATA(extern wxCursor
*) wxCROSS_CURSOR
;
316 WXDLLEXPORT_DATA(extern wxColourDatabase
*) wxTheColourDatabase
;
317 extern void WXDLLEXPORT
wxInitializeStockObjects();
318 extern void WXDLLEXPORT
wxDeleteStockObjects();
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 create icons portably
334 # define wxICON(X) wxIcon(X##_icon);
336 # define wxICON(X) wxIcon(X##_bits, X##_width, X##_height);
338 # define wxICON wxIcon
343 #define wxbuild_icon "wxbuild"
345 wxIcon *icon = new wxICON(wxbuild);