]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/stattool.i
Make scrollbars appear.
[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 wxString& label = wxEmptyString,
98 // const wxBitmap& bmpNormal = wxNullBitmap,
99 // const wxBitmap& bmpDisabled = wxNullBitmap,
100 // wxItemKind kind = wxITEM_NORMAL,
101 // wxObject *clientData = (wxObject *) NULL,
102 // const wxString& shortHelpString = wxEmptyString,
103 // const wxString& longHelpString = wxEmptyString)
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 wxItemKind GetKind();
116 bool IsEnabled();
117 bool IsToggled();
118 bool CanBeToggled();
119 const wxBitmap& GetNormalBitmap();
120 const wxBitmap& GetDisabledBitmap();
121 wxBitmap GetBitmap();
122 wxString GetLabel();
123 wxString GetShortHelp();
124 wxString GetLongHelp();
125 bool Enable(bool enable);
126 void Toggle();
127 bool SetToggle(bool toggle);
128 bool SetShortHelp(const wxString& help);
129 bool SetLongHelp(const wxString& help);
130 void SetNormalBitmap(const wxBitmap& bmp);
131 void SetDisabledBitmap(const wxBitmap& bmp);
132 void SetLabel(const wxString& label);
133 void Detach();
134 void Attach(wxToolBarBase *tbar);
135
136 //wxObject *GetClientData();
137 %addmethods {
138 // convert the ClientData back to a PyObject
139 PyObject* GetClientData() {
140 wxPyUserData* udata = (wxPyUserData*)self->GetClientData();
141 if (udata) {
142 Py_INCREF(udata->m_obj);
143 return udata->m_obj;
144 } else {
145 Py_INCREF(Py_None);
146 return Py_None;
147 }
148 }
149
150 void SetClientData(PyObject* clientData) {
151 self->SetClientData(new wxPyUserData(clientData));
152 }
153 }
154
155 %pragma(python) addtoclass="
156 GetBitmap1 = GetNormalBitmap
157 GetBitmap2 = GetDisabledBitmap
158 SetBitmap1 = SetNormalBitmap
159 SetBitmap2 = SetDisabledBitmap
160 "
161 };
162
163
164
165 class wxToolBarBase : public wxControl {
166 public:
167
168 // This is an Abstract Base Class
169
170 %addmethods {
171
172 // the full AddTool() function
173 //
174 // If bmpDisabled is wxNullBitmap, a shadowed version of the normal bitmap
175 // is created and used as the disabled image.
176 wxToolBarToolBase *AddTool(int id,
177 const wxString& label,
178 const wxBitmap& bitmap,
179 const wxBitmap& bmpDisabled,
180 wxItemKind kind = wxITEM_NORMAL,
181 const wxString& shortHelp = wxPyEmptyString,
182 const wxString& longHelp = wxPyEmptyString,
183 PyObject *clientData = NULL)
184 {
185 wxPyUserData* udata = NULL;
186 if (clientData)
187 udata = new wxPyUserData(clientData);
188 return self->AddTool(id, label, bitmap, bmpDisabled, kind,
189 shortHelp, longHelp, udata);
190 }
191
192 // The most common version of AddTool
193 wxToolBarToolBase *AddSimpleTool(int id,
194 const wxString& label,
195 const wxBitmap& bitmap,
196 const wxString& shortHelp = wxPyEmptyString,
197 const wxString& longHelp = wxPyEmptyString,
198 wxItemKind kind = wxITEM_NORMAL)
199 {
200 return self->AddTool(id, label, bitmap, wxNullBitmap, kind,
201 shortHelp, longHelp, NULL);
202 }
203
204 // add a check tool, i.e. a tool which can be toggled
205 wxToolBarToolBase *AddCheckTool(int id,
206 const wxString& label,
207 const wxBitmap& bitmap,
208 const wxBitmap& bmpDisabled = wxNullBitmap,
209 const wxString& shortHelp = wxPyEmptyString,
210 const wxString& longHelp = wxPyEmptyString,
211 PyObject *clientData = NULL)
212 {
213 wxPyUserData* udata = NULL;
214 if (clientData)
215 udata = new wxPyUserData(clientData);
216 return self->AddCheckTool(id, label, bitmap, bmpDisabled,
217 shortHelp, longHelp, udata);
218 }
219
220 // add a radio tool, i.e. a tool which can be toggled and releases any
221 // other toggled radio tools in the same group when it happens
222 wxToolBarToolBase *AddRadioTool(int id,
223 const wxString& label,
224 const wxBitmap& bitmap,
225 const wxBitmap& bmpDisabled = wxNullBitmap,
226 const wxString& shortHelp = wxPyEmptyString,
227 const wxString& longHelp = wxPyEmptyString,
228 PyObject *clientData = NULL)
229 {
230 wxPyUserData* udata = NULL;
231 if (clientData)
232 udata = new wxPyUserData(clientData);
233 return self->AddRadioTool(id, label, bitmap, bmpDisabled,
234 shortHelp, longHelp, udata);
235 }
236
237 // insert the new tool at the given position, if pos == GetToolsCount(), it
238 // is equivalent to AddTool()
239 wxToolBarToolBase *InsertTool(size_t pos,
240 int id,
241 const wxString& label,
242 const wxBitmap& bitmap,
243 const wxBitmap& bmpDisabled = wxNullBitmap,
244 wxItemKind kind = wxITEM_NORMAL,
245 const wxString& shortHelp = wxPyEmptyString,
246 const wxString& longHelp = wxPyEmptyString,
247 PyObject *clientData = NULL)
248 {
249 wxPyUserData* udata = NULL;
250 if (clientData)
251 udata = new wxPyUserData(clientData);
252 return self->InsertTool(pos, id, label, bitmap, bmpDisabled, kind,
253 shortHelp, longHelp, udata);
254 }
255
256 // A simpler InsertTool
257 wxToolBarToolBase *InsertSimpleTool(size_t pos,
258 int id,
259 const wxString& label,
260 const wxBitmap& bitmap,
261 wxItemKind kind = wxITEM_NORMAL,
262 const wxString& shortHelp = wxPyEmptyString,
263 const wxString& longHelp = wxPyEmptyString)
264 {
265 return self->InsertTool(pos, id, label, bitmap, wxNullBitmap, kind,
266 shortHelp, longHelp);
267 }
268 }
269
270
271 wxToolBarToolBase *AddControl(wxControl *control);
272 wxToolBarToolBase *InsertControl(size_t pos, wxControl *control);
273
274 wxToolBarToolBase *AddSeparator();
275 wxToolBarToolBase *InsertSeparator(size_t pos);
276
277 wxToolBarToolBase *RemoveTool(int id);
278
279 bool DeleteToolByPos(size_t pos);
280 bool DeleteTool(int id);
281 void ClearTools();
282 bool Realize();
283
284 void EnableTool(int id, bool enable);
285 void ToggleTool(int id, bool toggle);
286 void SetToggle(int id, bool toggle);
287
288
289 %addmethods {
290 // convert the ClientData back to a PyObject
291 PyObject* GetToolClientData(int id) {
292 wxPyUserData* udata = (wxPyUserData*)self->GetToolClientData(id);
293 if (udata) {
294 Py_INCREF(udata->m_obj);
295 return udata->m_obj;
296 } else {
297 Py_INCREF(Py_None);
298 return Py_None;
299 }
300 }
301
302 void SetToolClientData(int id, PyObject* clientData) {
303 self->SetToolClientData(id, new wxPyUserData(clientData));
304 }
305 }
306
307
308 bool GetToolState(int id);
309 bool GetToolEnabled(int id);
310 void SetToolShortHelp(int id, const wxString& helpString);
311 wxString GetToolShortHelp(int id);
312 void SetToolLongHelp(int id, const wxString& helpString);
313 wxString GetToolLongHelp(int id);
314
315 %name(SetMarginsXY) void SetMargins(int x, int y);
316 void SetMargins(const wxSize& size);
317 void SetToolPacking(int packing);
318 void SetToolSeparation(int separation);
319 wxSize GetToolMargins();
320 wxSize GetMargins();
321 int GetToolPacking();
322 int GetToolSeparation();
323
324 void SetRows(int nRows);
325 void SetMaxRowsCols(int rows, int cols);
326 int GetMaxRows();
327 int GetMaxCols();
328
329 void SetToolBitmapSize(const wxSize& size);
330 wxSize GetToolBitmapSize();
331 wxSize GetToolSize();
332
333 // returns a (non separator) tool containing the point (x, y) or NULL if
334 // there is no tool at this point (corrdinates are client)
335 wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
336
337 // return TRUE if this is a vertical toolbar, otherwise FALSE
338 bool IsVertical();
339 };
340
341
342
343
344 class wxToolBar : public wxToolBarBase {
345 public:
346 wxToolBar(wxWindow *parent,
347 wxWindowID id,
348 const wxPoint& pos = wxDefaultPosition,
349 const wxSize& size = wxDefaultSize,
350 long style = wxNO_BORDER | wxTB_HORIZONTAL,
351 const wxString& name = wxPyToolBarNameStr);
352 %name(wxPreToolBar)wxToolBar();
353
354 bool Create(wxWindow *parent,
355 wxWindowID id,
356 const wxPoint& pos = wxDefaultPosition,
357 const wxSize& size = wxDefaultSize,
358 long style = wxNO_BORDER | wxTB_HORIZONTAL,
359 const wxString& name = wxPyToolBarNameStr);
360
361 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
362 %pragma(python) addtomethod = "wxPreToolBar:val._setOORInfo(val)"
363
364 wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
365 };
366
367
368
369
370 class wxToolBarSimple : public wxToolBarBase {
371 public:
372 wxToolBarSimple(wxWindow *parent,
373 wxWindowID id,
374 const wxPoint& pos = wxDefaultPosition,
375 const wxSize& size = wxDefaultSize,
376 long style = wxNO_BORDER | wxTB_HORIZONTAL,
377 const wxString& name = wxPyToolBarNameStr);
378 %name(wxPreToolBarSimple)wxToolBarSimple();
379
380 bool Create(wxWindow *parent,
381 wxWindowID id,
382 const wxPoint& pos = wxDefaultPosition,
383 const wxSize& size = wxDefaultSize,
384 long style = wxNO_BORDER | wxTB_HORIZONTAL,
385 const wxString& name = wxPyToolBarNameStr);
386
387 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
388 %pragma(python) addtomethod = "wxPreToolBarSimple:val._setOORInfo(val)"
389
390 wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y);
391 };
392
393 //---------------------------------------------------------------------------
394 //---------------------------------------------------------------------------
395