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>
20 #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 wxp"
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__:wxp._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__:wxp._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__:wxp._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__:wxp._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__:wxp._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__:wxp._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__:wxp._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__:wxp._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__:wxp._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__:wxp._StdWindowCallbacks(self)"
311 long GetInsertionPoint();
312 long GetLastPosition();
314 int GetLineLength(long lineNo);
315 wxString GetLineText(long lineNo);
316 int GetNumberOfLines();
320 bool LoadFile(const wxString& filename);
323 void PositionToXY(long pos, long *OUTPUT, long *OUTPUT);
325 void Remove(long from, long to);
326 void Replace(long from, long to, const wxString& value);
327 bool SaveFile(const wxString& filename);
328 void SetEditable(bool editable);
329 void SetInsertionPoint(long pos);
330 void SetInsertionPointEnd();
331 void SetSelection(long from, long to);
332 void SetValue(const wxString& value);
333 void ShowPosition(long pos);
334 void WriteText(const wxString& text);
336 long XYToPosition(long x, long y);
340 //----------------------------------------------------------------------
342 class wxScrollBar : public wxControl {
344 wxScrollBar(wxWindow* parent, wxWindowID id = -1,
345 const wxPoint& pos = wxPyDefaultPosition,
346 const wxSize& size = wxPyDefaultSize,
347 long style = wxSB_HORIZONTAL,
348 const wxValidator& validator = wxPyDefaultValidator,
349 char* name = "scrollBar");
351 %pragma(python) addtomethod = "__init__:wxp._StdWindowCallbacks(self)"
357 void SetPosition(int viewStart);
358 void SetScrollbar(int position, int thumbSize,
359 int range, int pageSize,
360 bool refresh = TRUE);
363 //----------------------------------------------------------------------
366 class wxSpinButton : public wxControl {
368 wxSpinButton(wxWindow* parent, wxWindowID id = -1,
369 const wxPoint& pos = wxPyDefaultPosition,
370 const wxSize& size = wxPyDefaultSize,
371 long style = wxSP_HORIZONTAL,
372 char* name = "spinButton");
377 void SetRange(int min, int max);
378 void SetValue(int value);
382 //----------------------------------------------------------------------
384 class wxStaticBitmap : public wxControl {
386 wxStaticBitmap(wxWindow* parent, wxWindowID id,
387 const wxBitmap& bitmap,
388 const wxPoint& pos = wxPyDefaultPosition,
389 const wxSize& size = wxPyDefaultSize,
391 char* name = "staticBitmap");
393 %pragma(python) addtomethod = "__init__:wxp._StdWindowCallbacks(self)"
395 wxBitmap& GetBitmap();
396 void SetBitmap(const wxBitmap& bitmap);
399 //----------------------------------------------------------------------
401 class wxRadioBox : public wxControl {
403 wxRadioBox(wxWindow* parent, wxWindowID id,
404 const wxString& label,
405 const wxPoint& point = wxPyDefaultPosition,
406 const wxSize& size = wxPyDefaultSize,
407 int LCOUNT = 0, wxString* LIST = NULL,
408 int majorDimension = 0,
409 long style = wxRA_HORIZONTAL,
410 const wxValidator& validator = wxPyDefaultValidator,
411 char* name = "radioBox");
413 %pragma(python) addtomethod = "__init__:wxp._StdWindowCallbacks(self)"
415 %name(EnableBox)void Enable(bool enable);
416 void Enable(int n, bool enable);
417 int FindString(const wxString& string);
419 %name(GetBoxLabel)wxString GetLabel();
421 wxString GetLabel(int n);
423 wxString GetString(int n);
424 wxString GetStringSelection();
426 %name(SetBoxLabel)void SetLabel(const wxString& label);
427 void SetLabel(int n, const wxString& label);
428 void SetSelection(int n);
429 void SetStringSelection(const wxString& string);
430 void Show(bool show);
431 %name(ShowItem)void Show(int item, bool show);
434 //----------------------------------------------------------------------
436 class wxRadioButton : public wxControl {
438 wxRadioButton(wxWindow* parent, wxWindowID id,
439 const wxString& label,
440 const wxPoint& pos = wxPyDefaultPosition,
441 const wxSize& size = wxPyDefaultSize,
443 const wxValidator& validator = wxPyDefaultValidator,
444 char* name = "radioButton");
446 %pragma(python) addtomethod = "__init__:wxp._StdWindowCallbacks(self)"
449 void SetValue(bool value);
452 //----------------------------------------------------------------------
454 class wxSlider : public wxControl {
456 wxSlider(wxWindow* parent, wxWindowID id,
457 int value, int minValue, int maxValue,
458 const wxPoint& point = wxPyDefaultPosition,
459 const wxSize& size = wxPyDefaultSize,
460 long style = wxSL_HORIZONTAL,
461 const wxValidator& validator = wxPyDefaultValidator,
462 char* name = "slider");
464 %pragma(python) addtomethod = "__init__:wxp._StdWindowCallbacks(self)"
474 int GetThumbLength();
477 void SetRange(int minValue, int maxValue);
478 void SetTickFreq(int n, int pos);
479 void SetLineSize(int lineSize);
480 void SetPageSize(int pageSize);
481 void SetSelection(int startPos, int endPos);
482 void SetThumbLength(int len);
483 void SetTick(int tickPos);
484 void SetValue(int value);
488 //----------------------------------------------------------------------
491 /////////////////////////////////////////////////////////////////////////////
494 // Revision 1.5 1998/10/07 07:34:32 RD
495 // Version 0.4.1 for wxGTK
497 // Revision 1.4 1998/10/02 06:40:35 RD
499 // Version 0.4 of wxPython for MSW.
501 // Revision 1.3 1998/08/18 19:48:14 RD
502 // more wxGTK compatibility things.
504 // It builds now but there are serious runtime problems...
506 // Revision 1.2 1998/08/15 07:36:28 RD
507 // - Moved the header in the .i files out of the code that gets put into
508 // the .cpp files. It caused CVS conflicts because of the RCS ID being
509 // different each time.
511 // - A few minor fixes.
513 // Revision 1.1 1998/08/09 08:25:49 RD