1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Control (widget) classes for wxPython
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
17 #include <wx/slider.h>
18 #include <wx/spinbutt.h>
22 #include <wx/checklst.h>
27 #include <wx/checklst.h>
31 //----------------------------------------------------------------------
34 %include my_typemaps.i
36 // Import some definitions of other classes, etc.
43 %pragma(python) code = "import wx"
45 //----------------------------------------------------------------------
48 wxValidator wxPyDefaultValidator; // Non-const default because of SWIG
51 //----------------------------------------------------------------------
53 class wxControl : public wxWindow {
55 void Command(wxCommandEvent& event);
57 void SetLabel(const wxString& label);
60 //----------------------------------------------------------------------
62 class wxButton : public wxControl {
64 wxButton(wxWindow* parent, wxWindowID id, const wxString& label,
65 const wxPoint& pos = wxPyDefaultPosition,
66 const wxSize& size = wxPyDefaultSize,
68 const wxValidator& validator = wxPyDefaultValidator,
69 char* name = "button");
71 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
76 //----------------------------------------------------------------------
78 class wxBitmapButton : public wxButton {
80 wxBitmapButton(wxWindow* parent, wxWindowID id, const wxBitmap& bitmap,
81 const wxPoint& pos = wxPyDefaultPosition,
82 const wxSize& size = wxPyDefaultSize,
83 long style = wxBU_AUTODRAW,
84 const wxValidator& validator = wxPyDefaultValidator,
85 char* name = "button");
87 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
89 wxBitmap& GetBitmapLabel();
90 wxBitmap& GetBitmapDisabled();
91 wxBitmap& GetBitmapFocus();
92 wxBitmap& GetBitmapSelected();
93 void SetBitmapDisabled(const wxBitmap& bitmap);
94 void SetBitmapFocus(const wxBitmap& bitmap);
95 void SetBitmapSelected(const wxBitmap& bitmap);
96 void SetBitmapLabel(const wxBitmap& bitmap);
100 //----------------------------------------------------------------------
102 class wxCheckBox : public wxControl {
104 wxCheckBox(wxWindow* parent, wxWindowID id, const wxString& label,
105 const wxPoint& pos = wxPyDefaultPosition,
106 const wxSize& size = wxPyDefaultSize,
108 const wxValidator& val = wxPyDefaultValidator,
109 char* name = "checkBox");
111 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
114 void SetValue(const bool state);
117 //----------------------------------------------------------------------
119 class wxChoice : public wxControl {
121 wxChoice(wxWindow *parent, wxWindowID id,
122 const wxPoint& pos = wxPyDefaultPosition,
123 const wxSize& size = wxPyDefaultSize,
124 int LCOUNT=0, wxString* LIST=NULL,
126 const wxValidator& validator = wxPyDefaultValidator,
127 char* name = "choice");
129 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
131 void Append(const wxString& item);
133 int FindString(const wxString& string);
136 wxString GetString(const int n);
137 wxString GetStringSelection();
139 void SetColumns(const int n = 1);
140 void SetSelection(const int n);
141 void SetStringSelection(const wxString& string);
144 //----------------------------------------------------------------------
146 class wxComboBox : public wxControl {
148 wxComboBox(wxWindow* parent, wxWindowID id, char* value = "",
149 const wxPoint& pos = wxPyDefaultPosition,
150 const wxSize& size = wxPyDefaultSize,
151 int LCOUNT=0, wxString* LIST=NULL,
153 const wxValidator& validator = wxPyDefaultValidator,
154 char* name = "comboBox");
156 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
158 void Append(const wxString& item);
159 // TODO: void Append(const wxString& item, char* clientData);
164 // NotMember??: void Deselect(int n);
165 int FindString(const wxString& string);
166 // TODO: char* GetClientData(const int n);
167 long GetInsertionPoint();
168 long GetLastPosition();
170 wxString GetString(int n);
171 wxString GetStringSelection();
175 void Replace(long from, long to, const wxString& text);
176 void Remove(long from, long to);
177 // TODO: void SetClientData(const int n, char* data);
178 void SetInsertionPoint(long pos);
179 void SetInsertionPointEnd();
180 void SetSelection(int n, bool select = TRUE);
181 %name(SetMark)void SetSelection(long from, long to);
182 void SetValue(const wxString& text);
185 //----------------------------------------------------------------------
187 class wxGauge : public wxControl {
189 wxGauge(wxWindow* parent, wxWindowID id, int range,
190 const wxPoint& pos = wxPyDefaultPosition,
191 const wxSize& size = wxPyDefaultSize,
192 long style = wxGA_HORIZONTAL,
193 const wxValidator& validator = wxPyDefaultValidator,
194 char* name = "gauge");
196 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
200 int GetShadowWidth();
202 void SetBezelFace(int width);
203 void SetRange(int range);
204 void SetShadowWidth(int width);
205 void SetValue(int pos);
208 //----------------------------------------------------------------------
210 class wxStaticBox : public wxControl {
212 wxStaticBox(wxWindow* parent, wxWindowID id, const wxString& label,
213 const wxPoint& pos = wxPyDefaultPosition,
214 const wxSize& size = wxPyDefaultSize,
216 char* name = "staticBox");
220 //----------------------------------------------------------------------
222 class wxStaticText : public wxControl {
224 wxStaticText(wxWindow* parent, wxWindowID id, const wxString& label,
225 const wxPoint& pos = wxPyDefaultPosition,
226 const wxSize& size = wxPyDefaultSize,
228 char* name = "staticText");
230 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
233 void SetLabel(const wxString& label);
236 //----------------------------------------------------------------------
238 class wxListBox : public wxControl {
240 wxListBox(wxWindow* parent, wxWindowID id,
241 const wxPoint& pos = wxPyDefaultPosition,
242 const wxSize& size = wxPyDefaultSize,
243 int LCOUNT, wxString* LIST = NULL,
245 const wxValidator& validator = wxPyDefaultValidator,
246 char* name = "listBox");
248 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
250 void Append(const wxString& item);
251 // TODO: void Append(const wxString& item, char* clientData);
254 void Deselect(int n);
255 int FindString(const wxString& string);
256 // TODO: char* GetClientData(const int n);
258 // TODO: int GetSelections(int **selections);
259 wxString GetString(int n);
260 wxString GetStringSelection();
262 bool Selected(const int n);
263 void Set(int LCOUNT, wxString* LIST);
264 // TODO: void SetClientData(const int n, char* data);
265 void SetFirstItem(int n);
266 %name(SetFirstItemStr)void SetFirstItem(const wxString& string);
267 void SetSelection(int n, bool select = TRUE);
268 void SetString(int n, const wxString& string);
269 void SetStringSelection(const wxString& string, bool select = TRUE);
273 //----------------------------------------------------------------------
275 class wxCheckListBox : public wxListBox {
277 wxCheckListBox(wxWindow *parent, wxWindowID id,
278 const wxPoint& pos = wxPyDefaultPosition,
279 const wxSize& size = wxPyDefaultSize,
281 wxString* LIST = NULL,
283 const wxValidator& validator = wxPyDefaultValidator,
284 char* name = "listBox");
286 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
288 bool IsChecked(int uiIndex);
289 void Check(int uiIndex, bool bCheck = TRUE);
294 //----------------------------------------------------------------------
296 class wxTextCtrl : public wxControl {
298 wxTextCtrl(wxWindow* parent, wxWindowID id, char* value = "",
299 const wxPoint& pos = wxPyDefaultPosition,
300 const wxSize& size = wxPyDefaultSize,
302 const wxValidator& validator = wxPyDefaultValidator,
303 char* name = "text");
305 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
311 long GetInsertionPoint();
312 long GetLastPosition();
313 int GetLineLength(long lineNo);
314 wxString GetLineText(long lineNo);
315 int GetNumberOfLines();
318 bool LoadFile(const wxString& filename);
320 void PositionToXY(long pos, long *OUTPUT, long *OUTPUT);
321 void Remove(long from, long to);
322 void Replace(long from, long to, const wxString& value);
323 bool SaveFile(const wxString& filename);
324 void SetEditable(bool editable);
325 void SetInsertionPoint(long pos);
326 void SetInsertionPointEnd();
327 void SetSelection(long from, long to);
328 void SetValue(const wxString& value);
329 void ShowPosition(long pos);
330 void WriteText(const wxString& text);
331 long XYToPosition(long x, long y);
334 //----------------------------------------------------------------------
336 class wxScrollBar : public wxControl {
338 wxScrollBar(wxWindow* parent, wxWindowID id = -1,
339 const wxPoint& pos = wxPyDefaultPosition,
340 const wxSize& size = wxPyDefaultSize,
341 long style = wxSB_HORIZONTAL,
342 const wxValidator& validator = wxPyDefaultValidator,
343 char* name = "scrollBar");
345 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
349 int GetThumbPosition();
351 void SetThumbPosition(int viewStart);
352 void SetScrollbar(int position, int thumbSize,
353 int range, int pageSize,
354 bool refresh = TRUE);
357 //----------------------------------------------------------------------
359 class wxSpinButton : public wxControl {
361 wxSpinButton(wxWindow* parent, wxWindowID id = -1,
362 const wxPoint& pos = wxPyDefaultPosition,
363 const wxSize& size = wxPyDefaultSize,
364 long style = wxSP_HORIZONTAL,
365 char* name = "spinButton");
370 void SetRange(int min, int max);
371 void SetValue(int value);
374 //----------------------------------------------------------------------
376 class wxStaticBitmap : public wxControl {
378 wxStaticBitmap(wxWindow* parent, wxWindowID id,
379 const wxBitmap& bitmap,
380 const wxPoint& pos = wxPyDefaultPosition,
381 const wxSize& size = wxPyDefaultSize,
383 char* name = "staticBitmap");
385 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
387 wxBitmap& GetBitmap();
388 void SetBitmap(const wxBitmap& bitmap);
391 //----------------------------------------------------------------------
393 class wxRadioBox : public wxControl {
395 wxRadioBox(wxWindow* parent, wxWindowID id,
396 const wxString& label,
397 const wxPoint& point = wxPyDefaultPosition,
398 const wxSize& size = wxPyDefaultSize,
399 int LCOUNT = 0, wxString* LIST = NULL,
400 int majorDimension = 0,
401 long style = wxRA_HORIZONTAL,
402 const wxValidator& validator = wxPyDefaultValidator,
403 char* name = "radioBox");
405 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
407 %name(EnableBox)void Enable(bool enable);
408 void Enable(int n, bool enable);
409 int FindString(const wxString& string);
411 %name(GetBoxLabel)wxString GetLabel();
413 wxString GetLabel(int n);
415 wxString GetString(int n);
416 wxString GetStringSelection();
418 %name(SetBoxLabel)void SetLabel(const wxString& label);
419 void SetLabel(int n, const wxString& label);
420 void SetSelection(int n);
421 void SetStringSelection(const wxString& string);
422 void Show(bool show);
423 %name(ShowItem)void Show(int item, bool show);
426 //----------------------------------------------------------------------
428 class wxRadioButton : public wxControl {
430 wxRadioButton(wxWindow* parent, wxWindowID id,
431 const wxString& label,
432 const wxPoint& pos = wxPyDefaultPosition,
433 const wxSize& size = wxPyDefaultSize,
435 const wxValidator& validator = wxPyDefaultValidator,
436 char* name = "radioButton");
438 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
441 void SetValue(bool value);
444 //----------------------------------------------------------------------
446 class wxSlider : public wxControl {
448 wxSlider(wxWindow* parent, wxWindowID id,
449 int value, int minValue, int maxValue,
450 const wxPoint& point = wxPyDefaultPosition,
451 const wxSize& size = wxPyDefaultSize,
452 long style = wxSL_HORIZONTAL,
453 const wxValidator& validator = wxPyDefaultValidator,
454 char* name = "slider");
456 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
466 int GetThumbLength();
469 void SetRange(int minValue, int maxValue);
470 void SetTickFreq(int n, int pos);
471 void SetLineSize(int lineSize);
472 void SetPageSize(int pageSize);
473 void SetSelection(int startPos, int endPos);
474 void SetThumbLength(int len);
475 void SetTick(int tickPos);
476 void SetValue(int value);
480 //----------------------------------------------------------------------
483 /////////////////////////////////////////////////////////////////////////////
486 // Revision 1.10 1998/12/17 17:52:19 RD
488 // Minor fixes and SWIG code generation for RR's changes. MSW and GTK
489 // versions are much closer now!
491 // Revision 1.9 1998/12/17 14:07:29 RR
493 // Removed minor differences between wxMSW and wxGTK
495 // Revision 1.8 1998/12/15 20:41:15 RD
496 // Changed the import semantics from "from wxPython import *" to "from
497 // wxPython.wx import *" This is for people who are worried about
498 // namespace pollution, they can use "from wxPython import wx" and then
499 // prefix all the wxPython identifiers with "wx."
501 // Added wxTaskbarIcon for wxMSW.
503 // Made the events work for wxGrid.
507 // Added wxMiniFrame for wxGTK, (untested.)
509 // Changed many of the args and return values that were pointers to gdi
510 // objects to references to reflect changes in the wxWindows API.
512 // Other assorted fixes and additions.
514 // Revision 1.7 1998/11/16 00:00:53 RD
515 // Generic treectrl for wxPython/GTK compiles...
517 // Revision 1.6 1998/11/15 23:03:43 RD
518 // Removing some ifdef's for wxGTK
520 // Revision 1.5 1998/10/07 07:34:32 RD
521 // Version 0.4.1 for wxGTK
523 // Revision 1.4 1998/10/02 06:40:35 RD
525 // Version 0.4 of wxPython for MSW.
527 // Revision 1.3 1998/08/18 19:48:14 RD
528 // more wxGTK compatibility things.
530 // It builds now but there are serious runtime problems...
532 // Revision 1.2 1998/08/15 07:36:28 RD
533 // - Moved the header in the .i files out of the code that gets put into
534 // the .cpp files. It caused CVS conflicts because of the RCS ID being
535 // different each time.
537 // - A few minor fixes.
539 // Revision 1.1 1998/08/09 08:25:49 RD