]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_stockobjs.i
Use %rename("%(wxpy)s")
[wxWidgets.git] / wxPython / src / _stockobjs.i
CommitLineData
d14a1e28
RD
1/////////////////////////////////////////////////////////////////////////////
2// Name: _stockobjs.i
3// Purpose: SWIG interface defining "stock" GDI objects
4//
5// Author: Robin Dunn
6//
7// Created: 13-Sept-2003
8// RCS-ID: $Id$
9// Copyright: (c) 2003 by Total Control Software
10// Licence: wxWindows license
11/////////////////////////////////////////////////////////////////////////////
12
13// Not a %module
14
15
16//---------------------------------------------------------------------------
17%newgroup
18
19
99a001dd
RD
20class wxStockGDI
21{
22public:
23 enum Item {
24 BRUSH_BLACK,
25 BRUSH_BLUE,
26 BRUSH_CYAN,
27 BRUSH_GREEN,
28 BRUSH_GREY,
29 BRUSH_LIGHTGREY,
30 BRUSH_MEDIUMGREY,
31 BRUSH_RED,
32 BRUSH_TRANSPARENT,
33 BRUSH_WHITE,
34 COLOUR_BLACK,
35 COLOUR_BLUE,
36 COLOUR_CYAN,
37 COLOUR_GREEN,
38 COLOUR_LIGHTGREY,
39 COLOUR_RED,
40 COLOUR_WHITE,
41 CURSOR_CROSS,
42 CURSOR_HOURGLASS,
43 CURSOR_STANDARD,
44 FONT_ITALIC,
45 FONT_NORMAL,
46 FONT_SMALL,
47 FONT_SWISS,
48 PEN_BLACK,
49 PEN_BLACKDASHED,
50 PEN_CYAN,
51 PEN_GREEN,
52 PEN_GREY,
53 PEN_LIGHTGREY,
54 PEN_MEDIUMGREY,
55 PEN_RED,
56 PEN_TRANSPARENT,
57 PEN_WHITE,
58 ITEMCOUNT
59 };
60
61 wxStockGDI();
62 virtual ~wxStockGDI();
63 static void DeleteAll();
64
65 static wxStockGDI& instance();
66
67 static const wxBrush* GetBrush(Item item);
68 static const wxColour* GetColour(Item item);
69 static const wxCursor* GetCursor(Item item);
70 static const wxPen* GetPen(Item item);
71
72 virtual const wxFont* GetFont(Item item);
99a001dd 73
57ffa585
RD
74 %pythoncode {
75 def _initStockObjects():
76 import wx
77 wx.ITALIC_FONT = StockGDI.instance().GetFont(StockGDI.FONT_ITALIC)
78 wx.NORMAL_FONT = StockGDI.instance().GetFont(StockGDI.FONT_NORMAL)
79 wx.SMALL_FONT = StockGDI.instance().GetFont(StockGDI.FONT_SMALL)
80 wx.SWISS_FONT = StockGDI.instance().GetFont(StockGDI.FONT_SWISS)
99a001dd 81
57ffa585
RD
82 wx.BLACK_DASHED_PEN = StockGDI.GetPen(StockGDI.PEN_BLACKDASHED)
83 wx.BLACK_PEN = StockGDI.GetPen(StockGDI.PEN_BLACK)
84 wx.CYAN_PEN = StockGDI.GetPen(StockGDI.PEN_CYAN)
85 wx.GREEN_PEN = StockGDI.GetPen(StockGDI.PEN_GREEN)
86 wx.GREY_PEN = StockGDI.GetPen(StockGDI.PEN_GREY)
87 wx.LIGHT_GREY_PEN = StockGDI.GetPen(StockGDI.PEN_LIGHTGREY)
88 wx.MEDIUM_GREY_PEN = StockGDI.GetPen(StockGDI.PEN_MEDIUMGREY)
89 wx.RED_PEN = StockGDI.GetPen(StockGDI.PEN_RED)
90 wx.TRANSPARENT_PEN = StockGDI.GetPen(StockGDI.PEN_TRANSPARENT)
91 wx.WHITE_PEN = StockGDI.GetPen(StockGDI.PEN_WHITE)
92
93 wx.BLACK_BRUSH = StockGDI.GetBrush(StockGDI.BRUSH_BLACK)
94 wx.BLUE_BRUSH = StockGDI.GetBrush(StockGDI.BRUSH_BLUE)
95 wx.CYAN_BRUSH = StockGDI.GetBrush(StockGDI.BRUSH_CYAN)
96 wx.GREEN_BRUSH = StockGDI.GetBrush(StockGDI.BRUSH_GREEN)
97 wx.GREY_BRUSH = StockGDI.GetBrush(StockGDI.BRUSH_GREY)
98 wx.LIGHT_GREY_BRUSH = StockGDI.GetBrush(StockGDI.BRUSH_LIGHTGREY)
99 wx.MEDIUM_GREY_BRUSH = StockGDI.GetBrush(StockGDI.BRUSH_MEDIUMGREY)
100 wx.RED_BRUSH = StockGDI.GetBrush(StockGDI.BRUSH_RED)
101 wx.TRANSPARENT_BRUSH = StockGDI.GetBrush(StockGDI.BRUSH_TRANSPARENT)
102 wx.WHITE_BRUSH = StockGDI.GetBrush(StockGDI.BRUSH_WHITE)
103
104 wx.BLACK = StockGDI.GetColour(StockGDI.COLOUR_BLACK)
105 wx.BLUE = StockGDI.GetColour(StockGDI.COLOUR_BLUE)
106 wx.CYAN = StockGDI.GetColour(StockGDI.COLOUR_CYAN)
107 wx.GREEN = StockGDI.GetColour(StockGDI.COLOUR_GREEN)
108 wx.LIGHT_GREY = StockGDI.GetColour(StockGDI.COLOUR_LIGHTGREY)
109 wx.RED = StockGDI.GetColour(StockGDI.COLOUR_RED)
110 wx.WHITE = StockGDI.GetColour(StockGDI.COLOUR_WHITE)
99a001dd 111
57ffa585
RD
112 wx.CROSS_CURSOR = StockGDI.GetCursor(StockGDI.CURSOR_CROSS)
113 wx.HOURGLASS_CURSOR = StockGDI.GetCursor(StockGDI.CURSOR_HOURGLASS)
114 wx.STANDARD_CURSOR = StockGDI.GetCursor(StockGDI.CURSOR_STANDARD)
115
116 _initStockObjects = staticmethod(_initStockObjects)
117 }
118};
2b9048c5 119
99a001dd
RD
120
121
122%immutable;
123%threadWrapperOff;
124
2b9048c5
RD
125const wxBitmap wxNullBitmap;
126const wxIcon wxNullIcon;
127const wxCursor wxNullCursor;
128const wxPen wxNullPen;
129const wxBrush wxNullBrush;
130const wxPalette wxNullPalette;
131const wxFont wxNullFont;
132const wxColour wxNullColour;
133
214c4fbe 134%threadWrapperOn;
2b9048c5
RD
135%mutable;
136
137
138//---------------------------------------------------------------------------
139
99a001dd
RD
140
141class wxGDIObjListBase {
142public:
143 wxGDIObjListBase();
144 ~wxGDIObjListBase();
145};
146
147
148class wxPenList : public wxGDIObjListBase {
d14a1e28
RD
149public:
150
d14a1e28 151 wxPen* FindOrCreatePen(const wxColour& colour, int width, int style);
d14a1e28 152
99a001dd
RD
153 void AddPen(wxPen* pen);
154 void RemovePen(wxPen* pen);
155 %pythoncode {
156 AddPen = wx._deprecated(AddPen)
157 RemovePen = wx._deprecated(RemovePen)
158 }
159// int GetCount();
d14a1e28
RD
160};
161
162
99a001dd 163class wxBrushList : public wxGDIObjListBase {
d14a1e28
RD
164public:
165
4f58a958 166 wxBrush * FindOrCreateBrush(const wxColour& colour, int style=wxSOLID);
99a001dd
RD
167
168 void AddBrush(wxBrush *brush);
d14a1e28 169 void RemoveBrush(wxBrush *brush);
99a001dd
RD
170 %pythoncode {
171 AddBrush = wx._deprecated(AddBrush)
172 RemoveBrush = wx._deprecated(RemoveBrush)
173 }
174// int GetCount();
175};
176
177
178class wxFontList : public wxGDIObjListBase {
179public:
180
181 wxFont * FindOrCreateFont(int point_size, int family, int style, int weight,
182 bool underline = false,
183 const wxString& facename = wxPyEmptyString,
184 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
d14a1e28 185
99a001dd
RD
186 void AddFont(wxFont* font);
187 void RemoveFont(wxFont *font);
188 %pythoncode {
189 AddFont = wx._deprecated(AddFont)
190 RemoveFont = wx._deprecated(RemoveFont)
191 }
192
193// int GetCount();
d14a1e28
RD
194};
195
196//---------------------------------------------------------------------------
197
ab1f7d2a
RD
198MustHaveApp(wxColourDatabase);
199
99a001dd 200class wxColourDatabase {
d14a1e28
RD
201public:
202 wxColourDatabase();
203 ~wxColourDatabase();
204
205 // find colour by name or name for the given colour
206 wxColour Find(const wxString& name) const;
207 wxString FindName(const wxColour& colour) const;
208 %pythoncode { FindColour = Find }
209
210 // add a new colour to the database
211 void AddColour(const wxString& name, const wxColour& colour);
212
213 %extend {
214 void Append(const wxString& name, int red, int green, int blue) {
215 self->AddColour(name, wxColour(red, green, blue));
216 }
217 }
218};
219
d14a1e28
RD
220
221//---------------------------------------------------------------------------
222%newgroup
223
99a001dd
RD
224%inline {
225 wxFontList* _wxPyInitTheFontList() { return wxTheFontList; }
226 wxPenList* _wxPyInitThePenList() { return wxThePenList; }
227 wxBrushList* _wxPyInitTheBrushList() { return wxTheBrushList; }
228 wxColourDatabase* _wxPyInitTheColourDatabase() { return wxTheColourDatabase; }
229}
230
231%pythoncode {
57ffa585
RD
232%# This function makes a class used to do delayed initialization of some
233%# stock wx objects. When they are used the first time then an init function
234%# is called to make the real instance, which is then used to replace the
235%# original instance and class seen by the programmer.
236def _wxPyMakeDelayedInitWrapper(initFunc):
237 class _wxPyStockObjectWrapper(object):
238 def __init__(self, *args):
239 self._args = args
240 def __getattr__(self, name):
241 obj = initFunc(*self._args)
242 self.__class__ = obj.__class__
243 self.__dict__ = obj.__dict__
244 return getattr(self, name)
245 def __str__(self):
246 return self.__getattr__("__str__")()
247 def __repr__(self):
248 return self.__getattr__("__repr__")()
249 return _wxPyStockObjectWrapper
250
99a001dd
RD
251wxTheFontList = _wxPyMakeDelayedInitWrapper(_wxPyInitTheFontList)()
252wxThePenList = _wxPyMakeDelayedInitWrapper(_wxPyInitThePenList)()
253wxTheBrushList = _wxPyMakeDelayedInitWrapper(_wxPyInitTheBrushList)()
254wxTheColourDatabase = _wxPyMakeDelayedInitWrapper(_wxPyInitTheColourDatabase)()
255}
d14a1e28
RD
256
257//---------------------------------------------------------------------------
258
2b9048c5
RD
259%pythoncode { NullColor = NullColour }
260
261
262
263