1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG interface defining "stock" GDI objects
7 // Created: 13-Sept-2003
9 // Copyright: (c) 2003 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
16 //---------------------------------------------------------------------------
62 virtual ~wxStockGDI();
63 static void DeleteAll();
65 static wxStockGDI& instance();
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);
72 virtual const wxFont* GetFont(Item item);
75 def _initStockObjects():
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)
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)
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)
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)
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)
116 _initStockObjects = staticmethod(_initStockObjects)
125 const wxBitmap wxNullBitmap;
126 const wxIcon wxNullIcon;
127 const wxCursor wxNullCursor;
128 const wxPen wxNullPen;
129 const wxBrush wxNullBrush;
130 const wxPalette wxNullPalette;
131 const wxFont wxNullFont;
132 const wxColour wxNullColour;
138 //---------------------------------------------------------------------------
141 class wxGDIObjListBase {
148 class wxPenList : public wxGDIObjListBase {
151 wxPen* FindOrCreatePen(const wxColour& colour, int width, int style);
153 void AddPen(wxPen* pen);
154 void RemovePen(wxPen* pen);
156 AddPen = wx._deprecated(AddPen)
157 RemovePen = wx._deprecated(RemovePen)
163 class wxBrushList : public wxGDIObjListBase {
166 wxBrush * FindOrCreateBrush(const wxColour& colour, int style=wxSOLID);
168 void AddBrush(wxBrush *brush);
169 void RemoveBrush(wxBrush *brush);
171 AddBrush = wx._deprecated(AddBrush)
172 RemoveBrush = wx._deprecated(RemoveBrush)
178 class wxFontList : public wxGDIObjListBase {
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);
186 void AddFont(wxFont* font);
187 void RemoveFont(wxFont *font);
189 AddFont = wx._deprecated(AddFont)
190 RemoveFont = wx._deprecated(RemoveFont)
196 //---------------------------------------------------------------------------
198 MustHaveApp(wxColourDatabase);
200 class wxColourDatabase {
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 }
210 // add a new colour to the database
211 void AddColour(const wxString& name, const wxColour& colour);
214 void Append(const wxString& name, int red, int green, int blue) {
215 self->AddColour(name, wxColour(red, green, blue));
221 //---------------------------------------------------------------------------
225 wxFontList* _wxPyInitTheFontList() { return wxTheFontList; }
226 wxPenList* _wxPyInitThePenList() { return wxThePenList; }
227 wxBrushList* _wxPyInitTheBrushList() { return wxTheBrushList; }
228 wxColourDatabase* _wxPyInitTheColourDatabase() { return wxTheColourDatabase; }
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.
236 def _wxPyMakeDelayedInitWrapper(initFunc):
237 class _wxPyStockObjectWrapper(object):
238 def __init__(self, *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)
246 return self.__getattr__("__str__")()
248 return self.__getattr__("__repr__")()
249 return _wxPyStockObjectWrapper
251 TheFontList = _wxPyMakeDelayedInitWrapper(_wxPyInitTheFontList)()
252 ThePenList = _wxPyMakeDelayedInitWrapper(_wxPyInitThePenList)()
253 TheBrushList = _wxPyMakeDelayedInitWrapper(_wxPyInitTheBrushList)()
254 TheColourDatabase = _wxPyMakeDelayedInitWrapper(_wxPyInitTheColourDatabase)()
257 //---------------------------------------------------------------------------
259 %pythoncode { NullColor = NullColour }