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