]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/stattool.i
More unicode related cleanup and fixes for wxPython
[wxWidgets.git] / wxPython / src / stattool.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: stattool.i
3 // Purpose: SWIG definitions for StatusBar and ToolBar classes
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 08/24/1998
8 // RCS-ID: $Id$
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13
14 %module stattool
15
16 %{
17 #include "helpers.h"
18 #include <wx/toolbar.h>
19 #include <wx/tbarsmpl.h>
20 %}
21
22 //----------------------------------------------------------------------
23
24 %include typemaps.i
25 %include my_typemaps.i
26
27 // Import some definitions of other classes, etc.
28 %import _defs.i
29 %import misc.i
30 %import windows.i
31 %import controls.i
32
33 %pragma(python) code = "import wx"
34
35
36 //----------------------------------------------------------------------
37
38 %{
39 // Put some wx default wxChar* values into wxStrings.
40 DECLARE_DEF_STRING(StatusLineNameStr);
41 DECLARE_DEF_STRING(ToolBarNameStr);
42 static const wxString wxPyEmptyString(wxT(""));
43 %}
44
45 //---------------------------------------------------------------------------
46
47 class wxStatusBar : public wxWindow {
48 public:
49 wxStatusBar(wxWindow* parent, wxWindowID id = -1,
50 long style = wxST_SIZEGRIP,
51 const wxString& name = wxPyStatusLineNameStr);
52 %name(wxPreStatusBar)wxStatusBar();
53
54 bool Create(wxWindow* parent, wxWindowID id,
55 long style = wxST_SIZEGRIP,
56 const wxString& name = wxPyStatusLineNameStr);
57
58 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
59 %pragma(python) addtomethod = "wxPreStatusBar:val._setOORInfo(val)"
60
61 %addmethods {
62 %new wxRect* GetFieldRect(long item) {
63 wxRect* rect= new wxRect;
64 self->GetFieldRect(item, *rect);
65 return rect;
66 }
67 }
68 int GetFieldsCount(void);
69 wxString GetStatusText(int ir = 0);
70 int GetBorderX();
71 int GetBorderY();
72
73 void SetFieldsCount(int number = 1);
74 void SetStatusText(const wxString& text, int i = 0);
75 void SetStatusWidths(int LCOUNT, int* choices);
76 void SetMinHeight(int height);
77 };
78
79
80 //---------------------------------------------------------------------------
81
82 class wxToolBarBase;
83
84 enum wxToolBarToolStyle
85 {
86 wxTOOL_STYLE_BUTTON = 1,
87 wxTOOL_STYLE_SEPARATOR = 2,
88 wxTOOL_STYLE_CONTROL
89 };
90
91
92
93 class wxToolBarToolBase : public wxObject {
94 public:
95 // wxToolBarToolBase(wxToolBarBase *tbar = (wxToolBarBase *)NULL,
96 // int id = wxID_SEPARATOR,
97 // const wxBitmap& bitmap1 = wxNullBitmap,
98 // const wxBitmap& bitmap2 = wxNullBitmap,
99 // bool toggle = FALSE,
100 // wxObject *clientData = (wxObject *) NULL,
101 // const wxString& shortHelpString = wxPyEmptyString,
102 // const wxString& longHelpString = wxPyEmptyString);
103 // wxToolBarToolBase(wxToolBarBase *tbar, wxControl *control);
104 // ~wxToolBarToolBase();
105
106 %addmethods { void Destroy() { delete self; } }
107
108 int GetId();
109 wxControl *GetControl();
110 wxToolBarBase *GetToolBar();
111 int IsButton();
112 int IsControl();
113 int IsSeparator();
114 int GetStyle();
115 bool IsEnabled();
116 bool IsToggled();
117 bool CanBeToggled();
118 const wxBitmap& GetNormalBitmap();
119 const wxBitmap& GetDisabledBitmap();
120 wxBitmap GetBitmap();
121 wxString GetLabel();
122 wxString GetShortHelp();
123 wxString GetLongHelp();
124 bool Enable(bool enable);
125 void Toggle();
126 bool SetToggle(bool toggle);
127 bool SetShortHelp(const wxString& help);
128 bool SetLongHelp(const wxString& help);
129 void SetNormalBitmap(const wxBitmap& bmp);
130 void SetDisabledBitmap(const wxBitmap& bmp);
131 void SetLabel(const wxString& label);
132 void Detach();
133 void Attach(wxToolBarBase *tbar);
134
135 //wxObject *GetClientData();
136 %addmethods {
137 // convert the ClientData back to a PyObject
138 PyObject* GetClientData() {
139 wxPyUserData* udata = (wxPyUserData*)self->GetClientData();
140 if (udata) {
141 Py_INCREF(udata->m_obj);
142 return udata->m_obj;
143 } else {
144 Py_INCREF(Py_None);
145 return Py_None;
146 }
147 }
148
149 void SetClientData(PyObject* clientData) {
150 self->SetClientData(new wxPyUserData(clientData));
151 }
152 }
153
154 %pragma(python) addtoclass="
155 GetBitmap1 = GetNormalBitmap
156 GetBitmap2 = GetDisabledBitmap
157 SetBitmap1 = SetNormalBitmap
158 SetBitmap2 = SetDisabledBitmap
159 "
160 };
161
162
163
164 class wxToolBarBase : public wxControl {
165 public:
166
167 // This is an Abstract Base Class
168
169 %addmethods {
170 // wrap ClientData in a class that knows about PyObjects
171 wxToolBarToolBase *AddTool(int id,
172 const wxBitmap& bitmap,
173 const wxBitmap& pushedBitmap = wxNullBitmap,
174 int isToggle = FALSE,
175 PyObject *clientData = NULL,
176 const wxString& shortHelpString = wxPyEmptyString,
177 const wxString& longHelpString = wxPyEmptyString) {
178 wxPyUserData* udata = NULL;
179 if (clientData)
180 udata = new wxPyUserData(clientData);
181 return self->AddTool(id, bitmap, pushedBitmap, (bool)isToggle,
182 udata, shortHelpString, longHelpString);
183 }
184
185 // This one is easier to use...
186 wxToolBarToolBase *AddSimpleTool(int id,
187 const wxBitmap& bitmap,
188 const wxString& shortHelpString = wxPyEmptyString,
189 const wxString& longHelpString = wxPyEmptyString,
190 int isToggle = FALSE) {
191 return self->AddTool(id, bitmap, wxNullBitmap, isToggle, NULL,
192 shortHelpString, longHelpString);
193 }
194
195
196 // wrap ClientData in a class that knows about PyObjects
197 wxToolBarToolBase *InsertTool(size_t pos,
198 int id,
199 const wxBitmap& bitmap,
200 const wxBitmap& pushedBitmap = wxNullBitmap,
201 int isToggle = FALSE,
202 PyObject *clientData = NULL,
203 const wxString& shortHelpString = wxPyEmptyString,
204 const wxString& longHelpString = wxPyEmptyString) {
205 wxPyUserData* udata = NULL;
206 if (clientData)
207 udata = new wxPyUserData(clientData);
208 return self->InsertTool(pos, id, bitmap, pushedBitmap, (bool)isToggle,
209 udata, shortHelpString, longHelpString);
210 }
211
212 // This one is easier to use...
213 wxToolBarToolBase *InsertSimpleTool(size_t pos,
214 int id,
215 const wxBitmap& bitmap,
216 const wxString& shortHelpString = wxPyEmptyString,
217 const wxString& longHelpString = wxPyEmptyString,
218 int isToggle = FALSE) {
219 return self->InsertTool(pos, id, bitmap, wxNullBitmap, isToggle, NULL,
220 shortHelpString, longHelpString);
221 }
222 }
223
224
225 wxToolBarToolBase *AddControl(wxControl *control);
226 wxToolBarToolBase *InsertControl(size_t pos, wxControl *control);
227
228 wxToolBarToolBase *AddSeparator();
229 wxToolBarToolBase *InsertSeparator(size_t pos);
230
231 wxToolBarToolBase *RemoveTool(int id);
232
233 bool DeleteToolByPos(size_t pos);
234 bool DeleteTool(int id);
235 void ClearTools();
236 bool Realize();
237
238 void EnableTool(int id, bool enable);
239 void ToggleTool(int id, bool toggle);
240 void SetToggle(int id, bool toggle);
241
242
243 %addmethods {
244 // convert the ClientData back to a PyObject
245 PyObject* GetToolClientData(int id) {
246 wxPyUserData* udata = (wxPyUserData*)self->GetToolClientData(id);
247 if (udata) {
248 Py_INCREF(udata->m_obj);
249 return udata->m_obj;
250 } else {
251 Py_INCREF(Py_None);
252 return Py_None;
253 }
254 }
255
256 void SetToolClientData(int id, PyObject* clientData) {
257 self->SetToolClientData(id, new wxPyUserData(clientData));
258 }
259 }
260
261
262 bool GetToolState(int id);
263 bool GetToolEnabled(int id);
264 void SetToolShortHelp(int id, const wxString& helpString);
265 wxString GetToolShortHelp(int id);
266 void SetToolLongHelp(int id, const wxString& helpString);
267 wxString GetToolLongHelp(int id);
268
269 %name(SetMarginsXY) void SetMargins(int x, int y);
270 void SetMargins(const wxSize& size);
271 void SetToolPacking(int packing);
272 void SetToolSeparation(int separation);
273 wxSize GetToolMargins();
274 wxSize GetMargins();
275 int GetToolPacking();
276 int GetToolSeparation();
277
278 void SetRows(int nRows);
279 void SetMaxRowsCols(int rows, int cols);
280 int GetMaxRows();
281 int GetMaxCols();
282
283 void SetToolBitmapSize(const wxSize& size);
284 wxSize GetToolBitmapSize();
285 wxSize GetToolSize();
286
287 // returns a (non separator) tool containing the point (x, y) or NULL if
288 // there is no tool at this point (corrdinates are client)
289 wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
290
291 // return TRUE if this is a vertical toolbar, otherwise FALSE
292 bool IsVertical();
293 };
294
295
296
297
298 class wxToolBar : public wxToolBarBase {
299 public:
300 wxToolBar(wxWindow *parent,
301 wxWindowID id,
302 const wxPoint& pos = wxDefaultPosition,
303 const wxSize& size = wxDefaultSize,
304 long style = wxNO_BORDER | wxTB_HORIZONTAL,
305 const wxString& name = wxPyToolBarNameStr);
306 %name(wxPreToolBar)wxToolBar();
307
308 bool Create(wxWindow *parent,
309 wxWindowID id,
310 const wxPoint& pos = wxDefaultPosition,
311 const wxSize& size = wxDefaultSize,
312 long style = wxNO_BORDER | wxTB_HORIZONTAL,
313 const wxString& name = wxPyToolBarNameStr);
314
315 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
316 %pragma(python) addtomethod = "wxPreToolBar:val._setOORInfo(val)"
317
318 wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
319 };
320
321
322
323
324 class wxToolBarSimple : public wxToolBarBase {
325 public:
326 wxToolBarSimple(wxWindow *parent,
327 wxWindowID id,
328 const wxPoint& pos = wxDefaultPosition,
329 const wxSize& size = wxDefaultSize,
330 long style = wxNO_BORDER | wxTB_HORIZONTAL,
331 const wxString& name = wxPyToolBarNameStr);
332 %name(wxPreToolBarSimple)wxToolBarSimple();
333
334 bool Create(wxWindow *parent,
335 wxWindowID id,
336 const wxPoint& pos = wxDefaultPosition,
337 const wxSize& size = wxDefaultSize,
338 long style = wxNO_BORDER | wxTB_HORIZONTAL,
339 const wxString& name = wxPyToolBarNameStr);
340
341 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
342 %pragma(python) addtomethod = "wxPreToolBarSimple:val._setOORInfo(val)"
343
344 wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
345 };
346
347 //---------------------------------------------------------------------------
348 //---------------------------------------------------------------------------
349