]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/controls.i
second merge of the 2.2 branch (RL)
[wxWidgets.git] / wxPython / src / controls.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: controls.i
3 // Purpose: Control (widget) classes for wxPython
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 6/10/98
8 // RCS-ID: $Id$
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13 %module controls
14
15 %{
16 #include "helpers.h"
17 #include <wx/slider.h>
18 #include <wx/spinbutt.h>
19 #include <wx/spinctrl.h>
20 #include <wx/dynarray.h>
21 #include <wx/statline.h>
22 //#include <wx/toggbutt.h>
23
24 #ifdef __WXMSW__
25 #if wxUSE_OWNER_DRAWN
26 #include <wx/checklst.h>
27 #endif
28 #endif
29
30 #ifdef __WXGTK__
31 #include <wx/checklst.h>
32 #endif
33
34 %}
35
36 //----------------------------------------------------------------------
37
38 %include typemaps.i
39 %include my_typemaps.i
40
41 // Import some definitions of other classes, etc.
42 %import _defs.i
43 %import misc.i
44 %import windows.i
45 %import gdi.i
46 %import events.i
47
48 %pragma(python) code = "import wx"
49
50 //----------------------------------------------------------------------
51
52 %{
53 wxValidator wxPyDefaultValidator; // Non-const default because of SWIG
54 %}
55
56 %readonly
57 wxValidator wxDefaultValidator;
58 %readwrite
59
60 //----------------------------------------------------------------------
61
62 class wxControl : public wxWindow {
63 public:
64 wxControl(wxWindow *parent,
65 wxWindowID id,
66 const wxPoint& pos=wxPyDefaultPosition,
67 const wxSize& size=wxPyDefaultSize,
68 long style=0,
69 const wxValidator& validator=wxPyDefaultValidator,
70 const char* name="control");
71
72 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
73
74 void Command(wxCommandEvent& event);
75 wxString GetLabel();
76 void SetLabel(const wxString& label);
77 };
78
79
80 //----------------------------------------------------------------------
81
82 class wxButton : public wxControl {
83 public:
84 wxButton(wxWindow* parent, wxWindowID id, const wxString& label,
85 const wxPoint& pos = wxPyDefaultPosition,
86 const wxSize& size = wxPyDefaultSize,
87 long style = 0,
88 const wxValidator& validator = wxPyDefaultValidator,
89 char* name = "button");
90
91 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
92
93 void SetDefault();
94 void SetBackgroundColour(const wxColour& colour);
95 void SetForegroundColour(const wxColour& colour);
96 };
97
98
99 %inline %{
100 wxSize wxButton_GetDefaultSize() {
101 return wxButton::GetDefaultSize();
102 }
103 %}
104
105 //----------------------------------------------------------------------
106
107 class wxBitmapButton : public wxButton {
108 public:
109 wxBitmapButton(wxWindow* parent, wxWindowID id, const wxBitmap& bitmap,
110 const wxPoint& pos = wxPyDefaultPosition,
111 const wxSize& size = wxPyDefaultSize,
112 long style = wxBU_AUTODRAW,
113 const wxValidator& validator = wxPyDefaultValidator,
114 char* name = "button");
115
116 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
117
118 wxBitmap& GetBitmapLabel();
119 wxBitmap& GetBitmapDisabled();
120 wxBitmap& GetBitmapFocus();
121 wxBitmap& GetBitmapSelected();
122 void SetBitmapDisabled(const wxBitmap& bitmap);
123 void SetBitmapFocus(const wxBitmap& bitmap);
124 void SetBitmapSelected(const wxBitmap& bitmap);
125 void SetBitmapLabel(const wxBitmap& bitmap);
126
127 void SetMargins(int x, int y) { m_marginX = x; m_marginY = y; }
128 int GetMarginX() const { return m_marginX; }
129 int GetMarginY() const { return m_marginY; }
130 };
131
132 //----------------------------------------------------------------------
133
134 // class wxToggleButton : public wxControl {
135 // public:
136 // wxToggleButton(wxWindow *parent, wxWindowID id, const wxString& label,
137 // const wxPoint& pos = wxPyDefaultPosition,
138 // const wxSize& size = wxPyDefaultSize, long style = 0,
139 // const wxValidator& validator = wxPyDefaultValidator,
140 // const char* name = "toggle");
141 // void SetValue(bool value);
142 // bool GetValue() const ;
143 // void SetLabel(const wxString& label);
144 // };
145
146 // class wxBitmapToggleButton : public wxToggleButton {
147 // public:
148 // wxBitmapToggleButton(wxWindow *parent, wxWindowID id, const wxBitmap *label,
149 // const wxPoint& pos = wxPyDefaultPosition,
150 // const wxSize& size = wxPyDefaultSize, long style = 0,
151 // const wxValidator& validator = wxPyDefaultValidator,
152 // const char *name = "toggle");
153 // void SetLabel(const wxBitmap& bitmap);
154 // };
155
156
157 //----------------------------------------------------------------------
158
159 class wxCheckBox : public wxControl {
160 public:
161 wxCheckBox(wxWindow* parent, wxWindowID id, const wxString& label,
162 const wxPoint& pos = wxPyDefaultPosition,
163 const wxSize& size = wxPyDefaultSize,
164 long style = 0,
165 const wxValidator& val = wxPyDefaultValidator,
166 char* name = "checkBox");
167
168 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
169
170 bool GetValue();
171 void SetValue(const bool state);
172 };
173
174 //----------------------------------------------------------------------
175
176 class wxChoice : public wxControl {
177 public:
178 wxChoice(wxWindow *parent, wxWindowID id,
179 const wxPoint& pos = wxPyDefaultPosition,
180 const wxSize& size = wxPyDefaultSize,
181 int LCOUNT=0, wxString* choices=NULL,
182 long style = 0,
183 const wxValidator& validator = wxPyDefaultValidator,
184 char* name = "choice");
185
186 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
187
188 void Append(const wxString& item);
189 void Clear();
190 int FindString(const wxString& string);
191 int GetColumns();
192 int GetSelection();
193 wxString GetString(const int n);
194 wxString GetStringSelection();
195 int Number();
196 void SetColumns(const int n = 1);
197 void SetSelection(const int n);
198 void SetStringSelection(const wxString& string);
199 };
200
201 //----------------------------------------------------------------------
202
203 class wxComboBox : public wxChoice {
204 public:
205 wxComboBox(wxWindow* parent, wxWindowID id, char* value = "",
206 const wxPoint& pos = wxPyDefaultPosition,
207 const wxSize& size = wxPyDefaultSize,
208 int LCOUNT=0, wxString* choices=NULL,
209 long style = 0,
210 const wxValidator& validator = wxPyDefaultValidator,
211 char* name = "comboBox");
212
213 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
214
215 void Append(const wxString& item);
216 // TODO: void Append(const wxString& item, char* clientData);
217 void Clear();
218 void Copy();
219 void Cut();
220 void Delete(int n);
221 // NotMember??: void Deselect(int n);
222 int FindString(const wxString& string);
223 // TODO: char* GetClientData(const int n);
224 long GetInsertionPoint();
225 long GetLastPosition();
226 int GetSelection();
227 wxString GetString(int n);
228 wxString GetStringSelection();
229 wxString GetValue();
230 int Number();
231 void Paste();
232 void Replace(long from, long to, const wxString& text);
233 void Remove(long from, long to);
234 // TODO: void SetClientData(const int n, char* data);
235 void SetInsertionPoint(long pos);
236 void SetInsertionPointEnd();
237 void SetSelection(int n);
238 %name(SetMark)void SetSelection(long from, long to);
239 void SetValue(const wxString& text);
240 };
241
242 //----------------------------------------------------------------------
243
244 class wxGauge : public wxControl {
245 public:
246 wxGauge(wxWindow* parent, wxWindowID id, int range,
247 const wxPoint& pos = wxPyDefaultPosition,
248 const wxSize& size = wxPyDefaultSize,
249 long style = wxGA_HORIZONTAL,
250 const wxValidator& validator = wxPyDefaultValidator,
251 char* name = "gauge");
252
253 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
254
255 int GetBezelFace();
256 int GetRange();
257 int GetShadowWidth();
258 int GetValue();
259 void SetBezelFace(int width);
260 void SetRange(int range);
261 void SetShadowWidth(int width);
262 void SetValue(int pos);
263 };
264
265 //----------------------------------------------------------------------
266
267 class wxStaticBox : public wxControl {
268 public:
269 wxStaticBox(wxWindow* parent, wxWindowID id, const wxString& label,
270 const wxPoint& pos = wxPyDefaultPosition,
271 const wxSize& size = wxPyDefaultSize,
272 long style = 0,
273 char* name = "staticBox");
274 };
275
276
277 //----------------------------------------------------------------------
278
279
280 class wxStaticLine : public wxControl {
281 public:
282 wxStaticLine( wxWindow *parent, wxWindowID id,
283 const wxPoint &pos = wxPyDefaultPosition,
284 const wxSize &size = wxPyDefaultSize,
285 long style = wxLI_HORIZONTAL,
286 const char* name = "staticLine" );
287 };
288
289
290 //----------------------------------------------------------------------
291
292 class wxStaticText : public wxControl {
293 public:
294 wxStaticText(wxWindow* parent, wxWindowID id, const wxString& label,
295 const wxPoint& pos = wxPyDefaultPosition,
296 const wxSize& size = wxPyDefaultSize,
297 long style = 0,
298 char* name = "staticText");
299
300 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
301
302 wxString GetLabel();
303 void SetLabel(const wxString& label);
304 };
305
306 //----------------------------------------------------------------------
307
308 class wxListBox : public wxControl {
309 public:
310 wxListBox(wxWindow* parent, wxWindowID id,
311 const wxPoint& pos = wxPyDefaultPosition,
312 const wxSize& size = wxPyDefaultSize,
313 int LCOUNT, wxString* choices = NULL,
314 long style = 0,
315 const wxValidator& validator = wxPyDefaultValidator,
316 char* name = "listBox");
317
318 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
319
320 void Append(const wxString& item);
321 // TODO: void Append(const wxString& item, char* clientData);
322 void Clear();
323 void Delete(int n);
324 void Deselect(int n);
325 int FindString(const wxString& string);
326 // TODO: char* GetClientData(const int n);
327 int GetSelection();
328
329 // int GetSelections(int **selections);
330 %addmethods {
331 PyObject* GetSelections() {
332 wxArrayInt lst;
333 self->GetSelections(lst);
334 PyObject *tup = PyTuple_New(lst.GetCount());
335 for(size_t i=0; i<lst.GetCount(); i++) {
336 PyTuple_SetItem(tup, i, PyInt_FromLong(lst[i]));
337 }
338 return tup;
339 }
340 }
341
342 void InsertItems(int LCOUNT, wxString* choices, int pos);
343
344 wxString GetString(int n);
345 wxString GetStringSelection();
346 int Number();
347 bool Selected(const int n);
348 void Set(int LCOUNT, wxString* choices);
349 // TODO: void SetClientData(const int n, char* data);
350 void SetFirstItem(int n);
351 %name(SetFirstItemStr)void SetFirstItem(const wxString& string);
352 void SetSelection(int n, bool select = TRUE);
353 void SetString(int n, const wxString& string);
354 void SetStringSelection(const wxString& string, bool select = TRUE);
355 };
356
357
358 //----------------------------------------------------------------------
359
360 class wxCheckListBox : public wxListBox {
361 public:
362 wxCheckListBox(wxWindow *parent, wxWindowID id,
363 const wxPoint& pos = wxPyDefaultPosition,
364 const wxSize& size = wxPyDefaultSize,
365 int LCOUNT = 0,
366 wxString* choices = NULL,
367 long style = 0,
368 const wxValidator& validator = wxPyDefaultValidator,
369 char* name = "listBox");
370
371 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
372
373 bool IsChecked(int uiIndex);
374 void Check(int uiIndex, int bCheck = TRUE);
375 void InsertItems(int LCOUNT, wxString* choices, int pos);
376
377 int GetItemHeight();
378 };
379
380 //----------------------------------------------------------------------
381
382 class wxTextCtrl : public wxControl {
383 public:
384 wxTextCtrl(wxWindow* parent, wxWindowID id, char* value = "",
385 const wxPoint& pos = wxPyDefaultPosition,
386 const wxSize& size = wxPyDefaultSize,
387 long style = 0,
388 const wxValidator& validator = wxPyDefaultValidator,
389 char* name = "text");
390
391 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
392
393 void Clear();
394 void Copy();
395 void Cut();
396 void DiscardEdits();
397 long GetInsertionPoint();
398 long GetLastPosition();
399 int GetLineLength(long lineNo);
400 wxString GetLineText(long lineNo);
401 int GetNumberOfLines();
402 wxString GetValue();
403 bool IsModified();
404 bool LoadFile(const wxString& filename);
405 void Paste();
406 void PositionToXY(long pos, long *OUTPUT, long *OUTPUT);
407 void Remove(long from, long to);
408 void Replace(long from, long to, const wxString& value);
409 bool SaveFile(const wxString& filename);
410 void SetEditable(bool editable);
411 void SetInsertionPoint(long pos);
412 void SetInsertionPointEnd();
413 void SetSelection(long from, long to);
414 void SetValue(const wxString& value);
415 void ShowPosition(long pos);
416 void WriteText(const wxString& text);
417 void AppendText(const wxString& text);
418 long XYToPosition(long x, long y);
419
420 bool CanCopy();
421 bool CanCut();
422 bool CanPaste();
423 bool CanRedo();
424 bool CanUndo();
425 void GetSelection(long* OUTPUT, long* OUTPUT);
426 bool IsEditable();
427 void Undo();
428 void Redo();
429
430 %addmethods {
431 void write(const wxString& text) {
432 self->AppendText(text + '\n');
433 }
434 }
435 };
436
437 //----------------------------------------------------------------------
438
439 class wxScrollBar : public wxControl {
440 public:
441 wxScrollBar(wxWindow* parent, wxWindowID id = -1,
442 const wxPoint& pos = wxPyDefaultPosition,
443 const wxSize& size = wxPyDefaultSize,
444 long style = wxSB_HORIZONTAL,
445 const wxValidator& validator = wxPyDefaultValidator,
446 char* name = "scrollBar");
447
448 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
449
450 int GetRange();
451 int GetPageSize();
452 int GetThumbPosition();
453 int GetThumbSize();
454 %name(GetThumbLength) int GetThumbSize(); // to match the docs
455 void SetThumbPosition(int viewStart);
456 void SetScrollbar(int position, int thumbSize,
457 int range, int pageSize,
458 bool refresh = TRUE);
459 };
460
461 //----------------------------------------------------------------------
462
463 class wxSpinButton : public wxControl {
464 public:
465 wxSpinButton(wxWindow* parent, wxWindowID id = -1,
466 const wxPoint& pos = wxPyDefaultPosition,
467 const wxSize& size = wxPyDefaultSize,
468 long style = wxSP_HORIZONTAL,
469 char* name = "spinButton");
470
471 int GetMax();
472 int GetMin();
473 int GetValue();
474 void SetRange(int min, int max);
475 void SetValue(int value);
476 };
477
478 //----------------------------------------------------------------------
479
480 class wxStaticBitmap : public wxControl {
481 public:
482 wxStaticBitmap(wxWindow* parent, wxWindowID id,
483 const wxBitmap& bitmap,
484 const wxPoint& pos = wxPyDefaultPosition,
485 const wxSize& size = wxPyDefaultSize,
486 long style = 0,
487 char* name = "staticBitmap");
488
489 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
490
491 const wxBitmap& GetBitmap();
492 void SetBitmap(const wxBitmap& bitmap);
493 void SetIcon(const wxIcon& icon);
494 };
495
496 //----------------------------------------------------------------------
497
498 class wxRadioBox : public wxControl {
499 public:
500 wxRadioBox(wxWindow* parent, wxWindowID id,
501 const wxString& label,
502 const wxPoint& point = wxPyDefaultPosition,
503 const wxSize& size = wxPyDefaultSize,
504 int LCOUNT = 0, wxString* choices = NULL,
505 int majorDimension = 0,
506 long style = wxRA_HORIZONTAL,
507 const wxValidator& validator = wxPyDefaultValidator,
508 char* name = "radioBox");
509
510 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
511
512 void Enable(bool enable);
513 %name(EnableItem)void Enable(int n, bool enable);
514 int FindString(const wxString& string);
515
516 //*** wxString GetLabel();
517 //*** void SetLabel(const wxString& label);
518
519 %name(GetItemLabel)wxString GetLabel(int n);
520 int GetSelection();
521 wxString GetString(int n);
522 wxString GetStringSelection();
523 int Number();
524 %name(SetItemLabel)void SetLabel(int n, const wxString& label);
525 void SetSelection(int n);
526 void SetStringSelection(const wxString& string);
527 void Show(bool show);
528 %name(ShowItem)void Show(int item, bool show);
529 };
530
531 //----------------------------------------------------------------------
532
533 class wxRadioButton : public wxControl {
534 public:
535 wxRadioButton(wxWindow* parent, wxWindowID id,
536 const wxString& label,
537 const wxPoint& pos = wxPyDefaultPosition,
538 const wxSize& size = wxPyDefaultSize,
539 long style = 0,
540 const wxValidator& validator = wxPyDefaultValidator,
541 char* name = "radioButton");
542
543 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
544
545 bool GetValue();
546 void SetValue(bool value);
547 };
548
549 //----------------------------------------------------------------------
550
551 class wxSlider : public wxControl {
552 public:
553 wxSlider(wxWindow* parent, wxWindowID id,
554 int value, int minValue, int maxValue,
555 const wxPoint& point = wxPyDefaultPosition,
556 const wxSize& size = wxPyDefaultSize,
557 long style = wxSL_HORIZONTAL,
558 const wxValidator& validator = wxPyDefaultValidator,
559 char* name = "slider");
560
561 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
562
563 void ClearSel();
564 void ClearTicks();
565 int GetLineSize();
566 int GetMax();
567 int GetMin();
568 int GetPageSize();
569 int GetSelEnd();
570 int GetSelStart();
571 int GetThumbLength();
572 int GetTickFreq();
573 int GetValue();
574 void SetRange(int minValue, int maxValue);
575 void SetTickFreq(int n, int pos);
576 void SetLineSize(int lineSize);
577 void SetPageSize(int pageSize);
578 void SetSelection(int startPos, int endPos);
579 void SetThumbLength(int len);
580 void SetTick(int tickPos);
581 void SetValue(int value);
582 };
583
584
585 //----------------------------------------------------------------------
586
587 class wxSpinCtrl : public wxSpinButton {
588 public:
589 wxSpinCtrl(wxWindow *parent,
590 wxWindowID id = -1,
591 const char* value = "",
592 const wxPoint& pos = wxPyDefaultPosition,
593 const wxSize& size = wxPyDefaultSize,
594 long style = wxSP_ARROW_KEYS,
595 int min = 0, int max = 100, int initial = 0,
596 const char* name = "wxSpinCtrl");
597
598
599 };
600
601
602 //----------------------------------------------------------------------
603