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(__MOTIF__)
27 #include "wx/xt/colour.h"
28 #elif defined(__GTK__)
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
: public wxObject
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
; }
83 class WXDLLEXPORT wxRealPoint
: public wxObject
85 DECLARE_DYNAMIC_CLASS(wxRealPoint
)
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
; };
92 inline void operator = (const wxRealPoint
& pt
) { x
= pt
.x
; y
= pt
.y
; }
95 class WXDLLEXPORT wxPoint
: public wxObject
97 DECLARE_DYNAMIC_CLASS(wxPoint
)
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
; }
106 #if WXWIN_COMPATIBILITY
107 #define wxIntPoint wxPoint
108 #define wxRectangle wxRect
111 class WXDLLEXPORT wxRect
: public wxObject
{
112 DECLARE_DYNAMIC_CLASS(wxRect
)
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
);
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
; }
129 inline wxPoint
GetPosition(void) { return wxPoint(x
, y
); }
130 inline wxSize
GetSize(void) { return wxSize(width
, height
); }
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
; }
137 wxRect
& operator = (const wxRect
& rect
);
138 bool operator == (const wxRect
& rect
);
139 bool operator != (const wxRect
& rect
);
141 long x
, y
, width
, height
;
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
;
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
176 #define wxBITMAP_TYPE_RESOURCE wxBITMAP_TYPE_BMP_RESOURCE
178 class WXDLLEXPORT wxBitmap
;
179 class WXDLLEXPORT wxCursor
;
180 class WXDLLEXPORT wxIcon
;
182 // Management of pens, brushes and fonts
183 class WXDLLEXPORT wxPenList
: public wxList
185 DECLARE_DYNAMIC_CLASS(wxPenList
)
187 inline 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
);
196 class WXDLLEXPORT wxBrushList
: public wxList
198 DECLARE_DYNAMIC_CLASS(wxBrushList
)
200 inline 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
);
209 WXDLLEXPORT_DATA(extern const char*) wxEmptyString
;
211 class WXDLLEXPORT wxFontList
: public wxList
213 DECLARE_DYNAMIC_CLASS(wxFontList
)
215 inline 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
);
224 class WXDLLEXPORT wxColourDatabase
: public wxList
226 DECLARE_CLASS(wxColourDatabase
)
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);
236 class WXDLLEXPORT wxBitmapList
: public wxList
238 DECLARE_DYNAMIC_CLASS(wxBitmapList
)
243 void AddBitmap(wxBitmap
*bitmap
);
244 void RemoveBitmap(wxBitmap
*bitmap
);
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
;
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
;
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
;
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
;
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
;
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
;
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
;
304 WXDLLEXPORT_DATA(extern wxColourDatabase
*) wxTheColourDatabase
;
305 extern void WXDLLEXPORT
wxInitializeStockObjects(void);
306 extern void WXDLLEXPORT
wxDeleteStockObjects(void);
308 extern bool WXDLLEXPORT
wxColourDisplay(void);
310 // Returns depth of screen
311 extern int WXDLLEXPORT
wxDisplayDepth(void);
313 extern void WXDLLEXPORT
wxDisplaySize(int *width
, int *height
);
315 extern void WXDLLEXPORT
wxSetCursor(const wxCursor
& cursor
);
317 // Useful macro for create icons portably
320 # define wxICON(X) wxIcon(X##_icon);
322 # define wxICON(X) wxIcon(X##_bits, X##_width, X##_height);
324 # define wxICON wxIcon
329 #define wxbuild_icon "wxbuild"
331 wxIcon *icon = new wxICON(wxbuild);