]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_stockobjs.i
3 parameter wx.ImageList.Replace is now available everywhere
[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);
73};
2b9048c5 74
99a001dd
RD
75
76%pythoncode {
77%# This function makes a class used to do delayed initialization of some
78%# stock wx objects. When they are used the first time then an init function
79%# is called to make the real instance, which is then used to replace the
80%# original instance and class seen by the programmer.
81def _wxPyMakeDelayedInitWrapper(initFunc):
82 class _wxPyStockObjectWrapper(object):
83 def __init__(self, *args):
84 self._args = args
85 def __getattr__(self, name):
86 obj = initFunc(*self._args)
87 self.__class__ = obj.__class__
88 self.__dict__ = obj.__dict__
89 return getattr(self, name)
90 def __str__(self):
91 return self.__getattr__("__str__")()
92 def __repr__(self):
93 return self.__getattr__("__repr__")()
94 return _wxPyStockObjectWrapper
95
96def _wxPyFontInit(id):
97 return StockGDI.instance().GetFont(id)
98
99_wxPyStockPen = _wxPyMakeDelayedInitWrapper(StockGDI.GetPen)
100_wxPyStockBrush = _wxPyMakeDelayedInitWrapper(StockGDI.GetBrush)
101_wxPyStockCursor = _wxPyMakeDelayedInitWrapper(StockGDI.GetCursor)
102_wxPyStockColour = _wxPyMakeDelayedInitWrapper(StockGDI.GetColour)
103_wxPyStockFont = _wxPyMakeDelayedInitWrapper(_wxPyFontInit)
104
105
106ITALIC_FONT = _wxPyStockCursor(StockGDI.FONT_ITALIC)
107NORMAL_FONT = _wxPyStockCursor(StockGDI.FONT_NORMAL)
108SMALL_FONT = _wxPyStockCursor(StockGDI.FONT_SMALL)
109SWISS_FONT = _wxPyStockCursor(StockGDI.FONT_SWISS)
110
111BLACK_DASHED_PEN = _wxPyStockPen(StockGDI.PEN_BLACKDASHED)
112BLACK_PEN = _wxPyStockPen(StockGDI.PEN_BLACK)
113CYAN_PEN = _wxPyStockPen(StockGDI.PEN_CYAN)
114GREEN_PEN = _wxPyStockPen(StockGDI.PEN_GREEN)
115GREY_PEN = _wxPyStockPen(StockGDI.PEN_GREY)
116LIGHT_GREY_PEN = _wxPyStockPen(StockGDI.PEN_LIGHTGREY)
117MEDIUM_GREY_PEN = _wxPyStockPen(StockGDI.PEN_MEDIUMGREY)
118RED_PEN = _wxPyStockPen(StockGDI.PEN_RED)
119TRANSPARENT_PEN = _wxPyStockPen(StockGDI.PEN_TRANSPARENT)
120WHITE_PEN = _wxPyStockPen(StockGDI.PEN_WHITE)
121
122BLACK_BRUSH = _wxPyStockBrush(StockGDI.BRUSH_BLACK)
123BLUE_BRUSH = _wxPyStockBrush(StockGDI.BRUSH_BLUE)
124CYAN_BRUSH = _wxPyStockBrush(StockGDI.BRUSH_CYAN)
125GREEN_BRUSH = _wxPyStockBrush(StockGDI.BRUSH_GREEN)
126GREY_BRUSH = _wxPyStockBrush(StockGDI.BRUSH_GREY)
127LIGHT_GREY_BRUSH = _wxPyStockBrush(StockGDI.BRUSH_LIGHTGREY)
128MEDIUM_GREY_BRUSH = _wxPyStockBrush(StockGDI.BRUSH_MEDIUMGREY)
129RED_BRUSH = _wxPyStockBrush(StockGDI.BRUSH_RED)
130TRANSPARENT_BRUSH = _wxPyStockBrush(StockGDI.BRUSH_TRANSPARENT)
131WHITE_BRUSH = _wxPyStockBrush(StockGDI.BRUSH_WHITE)
132
133BLACK = _wxPyStockColour(StockGDI.COLOUR_BLACK)
134BLUE = _wxPyStockColour(StockGDI.COLOUR_BLUE)
135CYAN = _wxPyStockColour(StockGDI.COLOUR_CYAN)
136GREEN = _wxPyStockColour(StockGDI.COLOUR_GREEN)
137LIGHT_GREY = _wxPyStockColour(StockGDI.COLOUR_LIGHTGREY)
138RED = _wxPyStockColour(StockGDI.COLOUR_RED)
139WHITE = _wxPyStockColour(StockGDI.COLOUR_WHITE)
140
141CROSS_CURSOR = _wxPyStockCursor(StockGDI.CURSOR_CROSS)
142HOURGLASS_CURSOR = _wxPyStockCursor(StockGDI.CURSOR_HOURGLASS)
143STANDARD_CURSOR = _wxPyStockCursor(StockGDI.CURSOR_STANDARD)
144
145}
2b9048c5
RD
146
147
99a001dd
RD
148
149
150%immutable;
151%threadWrapperOff;
152
2b9048c5
RD
153const wxBitmap wxNullBitmap;
154const wxIcon wxNullIcon;
155const wxCursor wxNullCursor;
156const wxPen wxNullPen;
157const wxBrush wxNullBrush;
158const wxPalette wxNullPalette;
159const wxFont wxNullFont;
160const wxColour wxNullColour;
161
214c4fbe 162%threadWrapperOn;
2b9048c5
RD
163%mutable;
164
165
99a001dd
RD
166// %inline {
167// const wxBitmap& _wxPyInitNullBitmap() { return wxNullBitmap; }
168// const wxIcon& _wxPyInitNullIcon() { return wxNullIcon; }
169// const wxCursor& _wxPyInitNullCursor() { return wxNullCursor; }
170// const wxPen& _wxPyInitNullPen() { return wxNullPen; }
171// const wxBrush& _wxPyInitNullBrush() { return wxNullBrush; }
172// const wxPalette& _wxPyInitNullPalette() { return wxNullPalette; }
173// const wxFont& _wxPyInitNullFont() { return wxNullFont; }
174// const wxColour& _wxPyInitNullColour() { return wxNullColour; }
175// }
176
177// %pythoncode {
178// NullBitmap = _wxPyMakeDelayedInitWrapper(_wxPyInitNullBitmap)()
179// NullIcon = _wxPyMakeDelayedInitWrapper(_wxPyInitNullIcon)()
180// NullCursor = _wxPyMakeDelayedInitWrapper(_wxPyInitNullCursor)()
181// NullPen = _wxPyMakeDelayedInitWrapper(_wxPyInitNullPen)()
182// NullBrush = _wxPyMakeDelayedInitWrapper(_wxPyInitNullBrush)()
183// NullPalette = _wxPyMakeDelayedInitWrapper(_wxPyInitNullPalette)()
184// NullFont = _wxPyMakeDelayedInitWrapper(_wxPyInitNullFont)()
185// NullColour = _wxPyMakeDelayedInitWrapper(_wxPyInitNullColour)()
186// }
187
188
2b9048c5
RD
189//---------------------------------------------------------------------------
190
99a001dd
RD
191
192class wxGDIObjListBase {
193public:
194 wxGDIObjListBase();
195 ~wxGDIObjListBase();
196};
197
198
199class wxPenList : public wxGDIObjListBase {
d14a1e28
RD
200public:
201
d14a1e28 202 wxPen* FindOrCreatePen(const wxColour& colour, int width, int style);
d14a1e28 203
99a001dd
RD
204 void AddPen(wxPen* pen);
205 void RemovePen(wxPen* pen);
206 %pythoncode {
207 AddPen = wx._deprecated(AddPen)
208 RemovePen = wx._deprecated(RemovePen)
209 }
210// int GetCount();
d14a1e28
RD
211};
212
213
99a001dd 214class wxBrushList : public wxGDIObjListBase {
d14a1e28
RD
215public:
216
4f58a958 217 wxBrush * FindOrCreateBrush(const wxColour& colour, int style=wxSOLID);
99a001dd
RD
218
219 void AddBrush(wxBrush *brush);
d14a1e28 220 void RemoveBrush(wxBrush *brush);
99a001dd
RD
221 %pythoncode {
222 AddBrush = wx._deprecated(AddBrush)
223 RemoveBrush = wx._deprecated(RemoveBrush)
224 }
225// int GetCount();
226};
227
228
229class wxFontList : public wxGDIObjListBase {
230public:
231
232 wxFont * FindOrCreateFont(int point_size, int family, int style, int weight,
233 bool underline = false,
234 const wxString& facename = wxPyEmptyString,
235 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
d14a1e28 236
99a001dd
RD
237 void AddFont(wxFont* font);
238 void RemoveFont(wxFont *font);
239 %pythoncode {
240 AddFont = wx._deprecated(AddFont)
241 RemoveFont = wx._deprecated(RemoveFont)
242 }
243
244// int GetCount();
d14a1e28
RD
245};
246
247//---------------------------------------------------------------------------
248
ab1f7d2a
RD
249MustHaveApp(wxColourDatabase);
250
99a001dd 251class wxColourDatabase {
d14a1e28
RD
252public:
253 wxColourDatabase();
254 ~wxColourDatabase();
255
256 // find colour by name or name for the given colour
257 wxColour Find(const wxString& name) const;
258 wxString FindName(const wxColour& colour) const;
259 %pythoncode { FindColour = Find }
260
261 // add a new colour to the database
262 void AddColour(const wxString& name, const wxColour& colour);
263
264 %extend {
265 void Append(const wxString& name, int red, int green, int blue) {
266 self->AddColour(name, wxColour(red, green, blue));
267 }
268 }
269};
270
d14a1e28
RD
271
272//---------------------------------------------------------------------------
273%newgroup
274
99a001dd
RD
275%inline {
276 wxFontList* _wxPyInitTheFontList() { return wxTheFontList; }
277 wxPenList* _wxPyInitThePenList() { return wxThePenList; }
278 wxBrushList* _wxPyInitTheBrushList() { return wxTheBrushList; }
279 wxColourDatabase* _wxPyInitTheColourDatabase() { return wxTheColourDatabase; }
280}
281
282%pythoncode {
283wxTheFontList = _wxPyMakeDelayedInitWrapper(_wxPyInitTheFontList)()
284wxThePenList = _wxPyMakeDelayedInitWrapper(_wxPyInitThePenList)()
285wxTheBrushList = _wxPyMakeDelayedInitWrapper(_wxPyInitTheBrushList)()
286wxTheColourDatabase = _wxPyMakeDelayedInitWrapper(_wxPyInitTheColourDatabase)()
287}
d14a1e28
RD
288
289//---------------------------------------------------------------------------
290
2b9048c5
RD
291%pythoncode { NullColor = NullColour }
292
293
294
295