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 //----------------------------------------------------------------------
30 %include my_typemaps.i
32 // Import some definitions of other classes, etc.
39 %pragma(python) code = "import wx"
41 //----------------------------------------------------------------------
44 wxValidator wxPyDefaultValidator; // Non-const default because of SWIG
47 //----------------------------------------------------------------------
49 class wxControl : public wxWindow {
51 void Command(wxCommandEvent& event);
53 void SetLabel(const wxString& label);
56 //----------------------------------------------------------------------
58 class wxButton : public wxControl {
60 wxButton(wxWindow* parent, wxWindowID id, const wxString& label,
61 const wxPoint& pos = wxPyDefaultPosition,
62 const wxSize& size = wxPyDefaultSize,
64 const wxValidator& validator = wxPyDefaultValidator,
65 char* name = "button");
67 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
72 //----------------------------------------------------------------------
74 class wxBitmapButton : public wxButton {
76 wxBitmapButton(wxWindow* parent, wxWindowID id, const wxBitmap& bitmap,
77 const wxPoint& pos = wxPyDefaultPosition,
78 const wxSize& size = wxPyDefaultSize,
79 long style = wxBU_AUTODRAW,
80 const wxValidator& validator = wxPyDefaultValidator,
81 char* name = "button");
83 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
85 wxBitmap& GetBitmapLabel();
86 wxBitmap& GetBitmapDisabled();
87 wxBitmap& GetBitmapFocus();
88 wxBitmap& GetBitmapSelected();
89 void SetBitmapDisabled(const wxBitmap& bitmap);
90 void SetBitmapFocus(const wxBitmap& bitmap);
91 void SetBitmapSelected(const wxBitmap& bitmap);
92 void SetBitmapLabel(const wxBitmap& bitmap);
96 //----------------------------------------------------------------------
98 class wxCheckBox : public wxControl {
100 wxCheckBox(wxWindow* parent, wxWindowID id, const wxString& label,
101 const wxPoint& pos = wxPyDefaultPosition,
102 const wxSize& size = wxPyDefaultSize,
104 const wxValidator& val = wxPyDefaultValidator,
105 char* name = "checkBox");
107 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
110 void SetValue(const bool state);
113 //----------------------------------------------------------------------
115 class wxChoice : public wxControl {
117 wxChoice(wxWindow *parent, wxWindowID id,
118 const wxPoint& pos = wxPyDefaultPosition,
119 const wxSize& size = wxPyDefaultSize,
120 int LCOUNT=0, wxString* LIST=NULL,
122 const wxValidator& validator = wxPyDefaultValidator,
123 char* name = "choice");
125 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
127 void Append(const wxString& item);
129 int FindString(const wxString& string);
132 wxString GetString(const int n);
133 wxString GetStringSelection();
135 void SetColumns(const int n = 1);
136 void SetSelection(const int n);
137 void SetStringSelection(const wxString& string);
140 //----------------------------------------------------------------------
142 class wxComboBox : public wxControl {
144 wxComboBox(wxWindow* parent, wxWindowID id, char* value = "",
145 const wxPoint& pos = wxPyDefaultPosition,
146 const wxSize& size = wxPyDefaultSize,
147 int LCOUNT=0, wxString* LIST=NULL,
149 const wxValidator& validator = wxPyDefaultValidator,
150 char* name = "comboBox");
152 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
154 void Append(const wxString& item);
155 // TODO: void Append(const wxString& item, char* clientData);
160 // NotMember??: void Deselect(int n);
161 int FindString(const wxString& string);
162 // TODO: char* GetClientData(const int n);
163 long GetInsertionPoint();
164 long GetLastPosition();
166 wxString GetString(int n);
167 wxString GetStringSelection();
171 void Replace(long from, long to, const wxString& text);
172 void Remove(long from, long to);
173 // TODO: void SetClientData(const int n, char* data);
174 void SetInsertionPoint(long pos);
175 void SetInsertionPointEnd();
176 void SetSelection(int n, bool select = TRUE);
177 %name(SetMark)void SetSelection(long from, long to);
178 void SetValue(const wxString& text);
181 //----------------------------------------------------------------------
183 class wxGauge : public wxControl {
185 wxGauge(wxWindow* parent, wxWindowID id, int range,
186 const wxPoint& pos = wxPyDefaultPosition,
187 const wxSize& size = wxPyDefaultSize,
188 long style = wxGA_HORIZONTAL,
189 const wxValidator& validator = wxPyDefaultValidator,
190 char* name = "gauge");
192 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
196 int GetShadowWidth();
198 void SetBezelFace(int width);
199 void SetRange(int range);
200 void SetShadowWidth(int width);
201 void SetValue(int pos);
204 //----------------------------------------------------------------------
206 class wxStaticBox : public wxControl {
208 wxStaticBox(wxWindow* parent, wxWindowID id, const wxString& label,
209 const wxPoint& pos = wxPyDefaultPosition,
210 const wxSize& size = wxPyDefaultSize,
212 char* name = "staticBox");
216 //----------------------------------------------------------------------
218 class wxStaticText : public wxControl {
220 wxStaticText(wxWindow* parent, wxWindowID id, const wxString& label,
221 const wxPoint& pos = wxPyDefaultPosition,
222 const wxSize& size = wxPyDefaultSize,
224 char* name = "staticText");
226 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
229 void SetLabel(const wxString& label);
232 //----------------------------------------------------------------------
234 class wxListBox : public wxControl {
236 wxListBox(wxWindow* parent, wxWindowID id,
237 const wxPoint& pos = wxPyDefaultPosition,
238 const wxSize& size = wxPyDefaultSize,
239 int LCOUNT, wxString* LIST = NULL,
241 const wxValidator& validator = wxPyDefaultValidator,
242 char* name = "listBox");
244 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
246 void Append(const wxString& item);
247 // TODO: void Append(const wxString& item, char* clientData);
250 void Deselect(int n);
251 int FindString(const wxString& string);
252 // TODO: char* GetClientData(const int n);
254 // TODO: int GetSelections(int **selections);
255 wxString GetString(int n);
256 wxString GetStringSelection();
258 bool Selected(const int n);
259 void Set(int LCOUNT, wxString* LIST);
260 // TODO: void SetClientData(const int n, char* data);
261 void SetFirstItem(int n);
262 %name(SetFirstItemStr)void SetFirstItem(const wxString& string);
263 void SetSelection(int n, bool select = TRUE);
264 void SetString(int n, const wxString& string);
265 void SetStringSelection(const wxString& string, bool select = TRUE);
269 //----------------------------------------------------------------------
271 class wxCheckListBox : public wxListBox {
273 wxCheckListBox(wxWindow *parent, wxWindowID id,
274 const wxPoint& pos = wxPyDefaultPosition,
275 const wxSize& size = wxPyDefaultSize,
277 wxString* LIST = NULL,
279 const wxValidator& validator = wxPyDefaultValidator,
280 char* name = "listBox");
282 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
284 bool IsChecked(int uiIndex);
285 void Check(int uiIndex, bool bCheck = TRUE);
290 //----------------------------------------------------------------------
292 class wxTextCtrl : public wxControl {
294 wxTextCtrl(wxWindow* parent, wxWindowID id, char* value = "",
295 const wxPoint& pos = wxPyDefaultPosition,
296 const wxSize& size = wxPyDefaultSize,
298 const wxValidator& validator = wxPyDefaultValidator,
299 char* name = "text");
301 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
307 long GetInsertionPoint();
308 long GetLastPosition();
309 int GetLineLength(long lineNo);
310 wxString GetLineText(long lineNo);
311 int GetNumberOfLines();
314 bool LoadFile(const wxString& filename);
316 void PositionToXY(long pos, long *OUTPUT, long *OUTPUT);
317 void Remove(long from, long to);
318 void Replace(long from, long to, const wxString& value);
319 bool SaveFile(const wxString& filename);
320 void SetEditable(bool editable);
321 void SetInsertionPoint(long pos);
322 void SetInsertionPointEnd();
323 void SetSelection(long from, long to);
324 void SetValue(const wxString& value);
325 void ShowPosition(long pos);
326 void WriteText(const wxString& text);
327 long XYToPosition(long x, long y);
330 //----------------------------------------------------------------------
332 class wxScrollBar : public wxControl {
334 wxScrollBar(wxWindow* parent, wxWindowID id = -1,
335 const wxPoint& pos = wxPyDefaultPosition,
336 const wxSize& size = wxPyDefaultSize,
337 long style = wxSB_HORIZONTAL,
338 const wxValidator& validator = wxPyDefaultValidator,
339 char* name = "scrollBar");
341 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
345 int GetThumbPosition();
347 void SetThumbPosition(int viewStart);
348 void SetScrollbar(int position, int thumbSize,
349 int range, int pageSize,
350 bool refresh = TRUE);
353 //----------------------------------------------------------------------
355 class wxSpinButton : public wxControl {
357 wxSpinButton(wxWindow* parent, wxWindowID id = -1,
358 const wxPoint& pos = wxPyDefaultPosition,
359 const wxSize& size = wxPyDefaultSize,
360 long style = wxSP_HORIZONTAL,
361 char* name = "spinButton");
366 void SetRange(int min, int max);
367 void SetValue(int value);
370 //----------------------------------------------------------------------
372 class wxStaticBitmap : public wxControl {
374 wxStaticBitmap(wxWindow* parent, wxWindowID id,
375 const wxBitmap& bitmap,
376 const wxPoint& pos = wxPyDefaultPosition,
377 const wxSize& size = wxPyDefaultSize,
379 char* name = "staticBitmap");
381 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
383 wxBitmap& GetBitmap();
384 void SetBitmap(const wxBitmap& bitmap);
387 //----------------------------------------------------------------------
389 class wxRadioBox : public wxControl {
391 wxRadioBox(wxWindow* parent, wxWindowID id,
392 const wxString& label,
393 const wxPoint& point = wxPyDefaultPosition,
394 const wxSize& size = wxPyDefaultSize,
395 int LCOUNT = 0, wxString* LIST = NULL,
396 int majorDimension = 0,
397 long style = wxRA_HORIZONTAL,
398 const wxValidator& validator = wxPyDefaultValidator,
399 char* name = "radioBox");
401 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
403 %name(EnableBox)void Enable(bool enable);
404 void Enable(int n, bool enable);
405 int FindString(const wxString& string);
407 %name(GetBoxLabel)wxString GetLabel();
409 wxString GetLabel(int n);
411 wxString GetString(int n);
412 wxString GetStringSelection();
414 %name(SetBoxLabel)void SetLabel(const wxString& label);
415 void SetLabel(int n, const wxString& label);
416 void SetSelection(int n);
417 void SetStringSelection(const wxString& string);
418 void Show(bool show);
419 %name(ShowItem)void Show(int item, bool show);
422 //----------------------------------------------------------------------
424 class wxRadioButton : public wxControl {
426 wxRadioButton(wxWindow* parent, wxWindowID id,
427 const wxString& label,
428 const wxPoint& pos = wxPyDefaultPosition,
429 const wxSize& size = wxPyDefaultSize,
431 const wxValidator& validator = wxPyDefaultValidator,
432 char* name = "radioButton");
434 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
437 void SetValue(bool value);
440 //----------------------------------------------------------------------
442 class wxSlider : public wxControl {
444 wxSlider(wxWindow* parent, wxWindowID id,
445 int value, int minValue, int maxValue,
446 const wxPoint& point = wxPyDefaultPosition,
447 const wxSize& size = wxPyDefaultSize,
448 long style = wxSL_HORIZONTAL,
449 const wxValidator& validator = wxPyDefaultValidator,
450 char* name = "slider");
452 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
462 int GetThumbLength();
465 void SetRange(int minValue, int maxValue);
466 void SetTickFreq(int n, int pos);
467 void SetLineSize(int lineSize);
468 void SetPageSize(int pageSize);
469 void SetSelection(int startPos, int endPos);
470 void SetThumbLength(int len);
471 void SetTick(int tickPos);
472 void SetValue(int value);
476 //----------------------------------------------------------------------
479 /////////////////////////////////////////////////////////////////////////////
482 // Revision 1.9 1998/12/17 14:07:29 RR
483 // Removed minor differences between wxMSW and wxGTK
485 // Revision 1.8 1998/12/15 20:41:15 RD
486 // Changed the import semantics from "from wxPython import *" to "from
487 // wxPython.wx import *" This is for people who are worried about
488 // namespace pollution, they can use "from wxPython import wx" and then
489 // prefix all the wxPython identifiers with "wx."
491 // Added wxTaskbarIcon for wxMSW.
493 // Made the events work for wxGrid.
497 // Added wxMiniFrame for wxGTK, (untested.)
499 // Changed many of the args and return values that were pointers to gdi
500 // objects to references to reflect changes in the wxWindows API.
502 // Other assorted fixes and additions.
504 // Revision 1.7 1998/11/16 00:00:53 RD
505 // Generic treectrl for wxPython/GTK compiles...
507 // Revision 1.6 1998/11/15 23:03:43 RD
508 // Removing some ifdef's for wxGTK
510 // Revision 1.5 1998/10/07 07:34:32 RD
511 // Version 0.4.1 for wxGTK
513 // Revision 1.4 1998/10/02 06:40:35 RD
515 // Version 0.4 of wxPython for MSW.
517 // Revision 1.3 1998/08/18 19:48:14 RD
518 // more wxGTK compatibility things.
520 // It builds now but there are serious runtime problems...
522 // Revision 1.2 1998/08/15 07:36:28 RD
523 // - Moved the header in the .i files out of the code that gets put into
524 // the .cpp files. It caused CVS conflicts because of the RCS ID being
525 // different each time.
527 // - A few minor fixes.
529 // Revision 1.1 1998/08/09 08:25:49 RD