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();
87 wxBitmap& GetBitmapDisabled();
88 wxBitmap& GetBitmapFocus();
89 wxBitmap& GetBitmapSelected();
90 void SetBitmapDisabled(const wxBitmap& bitmap);
91 void SetBitmapFocus(const wxBitmap& bitmap);
92 void SetBitmapSelected(const wxBitmap& bitmap);
94 void SetBitmapLabel(const wxBitmap& bitmap);
98 //----------------------------------------------------------------------
100 class wxCheckBox : public wxControl {
102 wxCheckBox(wxWindow* parent, wxWindowID id, const wxString& label,
103 const wxPoint& pos = wxPyDefaultPosition,
104 const wxSize& size = wxPyDefaultSize,
106 const wxValidator& val = wxPyDefaultValidator,
107 char* name = "checkBox");
109 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
112 void SetValue(const bool state);
115 //----------------------------------------------------------------------
117 class wxChoice : public wxControl {
119 wxChoice(wxWindow *parent, wxWindowID id,
120 const wxPoint& pos = wxPyDefaultPosition,
121 const wxSize& size = wxPyDefaultSize,
122 int LCOUNT=0, wxString* LIST=NULL,
124 const wxValidator& validator = wxPyDefaultValidator,
125 char* name = "choice");
127 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
129 void Append(const wxString& item);
131 int FindString(const wxString& string);
134 wxString GetString(const int n);
135 wxString GetStringSelection();
137 void SetColumns(const int n = 1);
138 void SetSelection(const int n);
139 void SetStringSelection(const wxString& string);
142 //----------------------------------------------------------------------
144 class wxComboBox : public wxControl {
146 wxComboBox(wxWindow* parent, wxWindowID id, char* value = "",
147 const wxPoint& pos = wxPyDefaultPosition,
148 const wxSize& size = wxPyDefaultSize,
149 int LCOUNT=0, wxString* LIST=NULL,
151 const wxValidator& validator = wxPyDefaultValidator,
152 char* name = "comboBox");
154 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
156 void Append(const wxString& item);
157 // TODO: void Append(const wxString& item, char* clientData);
162 // NotMember??: void Deselect(int n);
163 int FindString(const wxString& string);
164 // TODO: char* GetClientData(const int n);
165 long GetInsertionPoint();
166 long GetLastPosition();
168 wxString GetString(int n);
169 wxString GetStringSelection();
173 void Replace(long from, long to, const wxString& text);
174 void Remove(long from, long to);
175 // TODO: void SetClientData(const int n, char* data);
176 void SetInsertionPoint(long pos);
177 void SetInsertionPointEnd();
178 void SetSelection(int n, bool select = TRUE);
179 %name(SetMark)void SetSelection(long from, long to);
180 void SetValue(const wxString& text);
183 //----------------------------------------------------------------------
185 class wxGauge : public wxControl {
187 wxGauge(wxWindow* parent, wxWindowID id, int range,
188 const wxPoint& pos = wxPyDefaultPosition,
189 const wxSize& size = wxPyDefaultSize,
190 long style = wxGA_HORIZONTAL,
191 const wxValidator& validator = wxPyDefaultValidator,
192 char* name = "gauge");
194 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
198 int GetShadowWidth();
200 void SetBezelFace(int width);
201 void SetRange(int range);
202 void SetShadowWidth(int width);
203 void SetValue(int pos);
206 //----------------------------------------------------------------------
208 class wxStaticBox : public wxControl {
210 wxStaticBox(wxWindow* parent, wxWindowID id, const wxString& label,
211 const wxPoint& pos = wxPyDefaultPosition,
212 const wxSize& size = wxPyDefaultSize,
214 char* name = "staticBox");
218 //----------------------------------------------------------------------
220 class wxStaticText : public wxControl {
222 wxStaticText(wxWindow* parent, wxWindowID id, const wxString& label,
223 const wxPoint& pos = wxPyDefaultPosition,
224 const wxSize& size = wxPyDefaultSize,
226 char* name = "staticText");
228 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
231 void SetLabel(const wxString& label);
234 //----------------------------------------------------------------------
236 class wxListBox : public wxControl {
238 wxListBox(wxWindow* parent, wxWindowID id,
239 const wxPoint& pos = wxPyDefaultPosition,
240 const wxSize& size = wxPyDefaultSize,
241 int LCOUNT, wxString* LIST = NULL,
243 const wxValidator& validator = wxPyDefaultValidator,
244 char* name = "listBox");
246 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
248 void Append(const wxString& item);
249 // TODO: void Append(const wxString& item, char* clientData);
252 void Deselect(int n);
253 int FindString(const wxString& string);
254 // TODO: char* GetClientData(const int n);
256 // TODO: int GetSelections(int **selections);
257 wxString GetString(int n);
258 wxString GetStringSelection();
260 bool Selected(const int n);
261 void Set(int LCOUNT, wxString* LIST);
262 // TODO: void SetClientData(const int n, char* data);
263 void SetFirstItem(int n);
264 %name(SetFirstItemStr)void SetFirstItem(const wxString& string);
265 void SetSelection(int n, bool select = TRUE);
266 void SetString(int n, const wxString& string);
267 void SetStringSelection(const wxString& string, bool select = TRUE);
271 //----------------------------------------------------------------------
274 class wxCheckListBox : public wxListBox {
276 wxCheckListBox(wxWindow *parent, wxWindowID id,
277 const wxPoint& pos = wxPyDefaultPosition,
278 const wxSize& size = wxPyDefaultSize,
280 wxString* LIST = NULL,
282 const wxValidator& validator = wxPyDefaultValidator,
283 char* name = "listBox");
285 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
287 bool IsChecked(int uiIndex);
288 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.8 1998/12/15 20:41:15 RD
487 // Changed the import semantics from "from wxPython import *" to "from
488 // wxPython.wx import *" This is for people who are worried about
489 // namespace pollution, they can use "from wxPython import wx" and then
490 // prefix all the wxPython identifiers with "wx."
492 // Added wxTaskbarIcon for wxMSW.
494 // Made the events work for wxGrid.
498 // Added wxMiniFrame for wxGTK, (untested.)
500 // Changed many of the args and return values that were pointers to gdi
501 // objects to references to reflect changes in the wxWindows API.
503 // Other assorted fixes and additions.
505 // Revision 1.7 1998/11/16 00:00:53 RD
506 // Generic treectrl for wxPython/GTK compiles...
508 // Revision 1.6 1998/11/15 23:03:43 RD
509 // Removing some ifdef's for wxGTK
511 // Revision 1.5 1998/10/07 07:34:32 RD
512 // Version 0.4.1 for wxGTK
514 // Revision 1.4 1998/10/02 06:40:35 RD
516 // Version 0.4 of wxPython for MSW.
518 // Revision 1.3 1998/08/18 19:48:14 RD
519 // more wxGTK compatibility things.
521 // It builds now but there are serious runtime problems...
523 // Revision 1.2 1998/08/15 07:36:28 RD
524 // - Moved the header in the .i files out of the code that gets put into
525 // the .cpp files. It caused CVS conflicts because of the RCS ID being
526 // different each time.
528 // - A few minor fixes.
530 // Revision 1.1 1998/08/09 08:25:49 RD