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