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