]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/controls.i
MouseWheel stuff
[wxWidgets.git] / wxPython / src / controls.i
CommitLineData
7bf85405
RD
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
03e9bead 13%module controls
7bf85405 14
03e9bead 15%{
7bf85405
RD
16#include "helpers.h"
17#include <wx/slider.h>
62bd0874 18#include <wx/spinbutt.h>
f6bcfd97 19#include <wx/spinctrl.h>
cf694132 20#include <wx/dynarray.h>
8bf5d46e 21#include <wx/statline.h>
d1679124 22#include <wx/tglbtn.h>
fb5e0af0
RD
23
24#ifdef __WXMSW__
9c039d08
RD
25#if wxUSE_OWNER_DRAWN
26#include <wx/checklst.h>
27#endif
fb5e0af0 28#endif
c95e68d8
RD
29
30#ifdef __WXGTK__
31#include <wx/checklst.h>
32#endif
bb0054cd 33
7bf85405
RD
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
b8b8dda7 48%pragma(python) code = "import wx"
9c039d08 49
7bf85405
RD
50//----------------------------------------------------------------------
51
2f90df85
RD
52%readonly
53wxValidator wxDefaultValidator;
54%readwrite
55
7bf85405
RD
56//----------------------------------------------------------------------
57
58class wxControl : public wxWindow {
59public:
9b3d3bc4
RD
60 wxControl(wxWindow *parent,
61 wxWindowID id,
b68dc582
RD
62 const wxPoint& pos=wxDefaultPosition,
63 const wxSize& size=wxDefaultSize,
9b3d3bc4 64 long style=0,
b68dc582 65 const wxValidator& validator=wxDefaultValidator,
9b3d3bc4
RD
66 const char* name="control");
67
f6bcfd97 68 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
6999b0d8 69
7bf85405 70 void Command(wxCommandEvent& event);
fb5e0af0 71 wxString GetLabel();
7bf85405
RD
72 void SetLabel(const wxString& label);
73};
74
6999b0d8 75
7bf85405
RD
76//----------------------------------------------------------------------
77
78class wxButton : public wxControl {
79public:
80 wxButton(wxWindow* parent, wxWindowID id, const wxString& label,
b68dc582
RD
81 const wxPoint& pos = wxDefaultPosition,
82 const wxSize& size = wxDefaultSize,
7bf85405 83 long style = 0,
b68dc582 84 const wxValidator& validator = wxDefaultValidator,
7bf85405 85 char* name = "button");
9c039d08 86
f6bcfd97 87 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
9c039d08 88
7bf85405 89 void SetDefault();
9b3d3bc4
RD
90 void SetBackgroundColour(const wxColour& colour);
91 void SetForegroundColour(const wxColour& colour);
7bf85405
RD
92};
93
6999b0d8
RD
94
95%inline %{
96 wxSize wxButton_GetDefaultSize() {
97 return wxButton::GetDefaultSize();
98 }
99%}
100
7bf85405
RD
101//----------------------------------------------------------------------
102
103class wxBitmapButton : public wxButton {
104public:
105 wxBitmapButton(wxWindow* parent, wxWindowID id, const wxBitmap& bitmap,
b68dc582
RD
106 const wxPoint& pos = wxDefaultPosition,
107 const wxSize& size = wxDefaultSize,
7bf85405 108 long style = wxBU_AUTODRAW,
b68dc582 109 const wxValidator& validator = wxDefaultValidator,
7bf85405
RD
110 char* name = "button");
111
f6bcfd97 112 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
9c039d08 113
fb5e0af0 114 wxBitmap& GetBitmapLabel();
7bf85405
RD
115 wxBitmap& GetBitmapDisabled();
116 wxBitmap& GetBitmapFocus();
7bf85405
RD
117 wxBitmap& GetBitmapSelected();
118 void SetBitmapDisabled(const wxBitmap& bitmap);
119 void SetBitmapFocus(const wxBitmap& bitmap);
7bf85405 120 void SetBitmapSelected(const wxBitmap& bitmap);
fb5e0af0 121 void SetBitmapLabel(const wxBitmap& bitmap);
7bf85405 122
f6bcfd97
BP
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; }
7bf85405
RD
126};
127
128//----------------------------------------------------------------------
129
130class wxCheckBox : public wxControl {
131public:
132 wxCheckBox(wxWindow* parent, wxWindowID id, const wxString& label,
b68dc582
RD
133 const wxPoint& pos = wxDefaultPosition,
134 const wxSize& size = wxDefaultSize,
7bf85405 135 long style = 0,
b68dc582 136 const wxValidator& val = wxDefaultValidator,
7bf85405
RD
137 char* name = "checkBox");
138
f6bcfd97 139 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
9c039d08 140
7bf85405
RD
141 bool GetValue();
142 void SetValue(const bool state);
143};
144
145//----------------------------------------------------------------------
146
147class wxChoice : public wxControl {
148public:
149 wxChoice(wxWindow *parent, wxWindowID id,
b68dc582
RD
150 const wxPoint& pos = wxDefaultPosition,
151 const wxSize& size = wxDefaultSize,
eec92d76 152 int LCOUNT=0, wxString* choices=NULL,
7bf85405 153 long style = 0,
b68dc582 154 const wxValidator& validator = wxDefaultValidator,
7bf85405
RD
155 char* name = "choice");
156
f6bcfd97 157 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
9c039d08 158
7bf85405
RD
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
bb0054cd 174class wxComboBox : public wxChoice {
7bf85405
RD
175public:
176 wxComboBox(wxWindow* parent, wxWindowID id, char* value = "",
b68dc582
RD
177 const wxPoint& pos = wxDefaultPosition,
178 const wxSize& size = wxDefaultSize,
eec92d76 179 int LCOUNT=0, wxString* choices=NULL,
7bf85405 180 long style = 0,
b68dc582 181 const wxValidator& validator = wxDefaultValidator,
7bf85405
RD
182 char* name = "comboBox");
183
f6bcfd97 184 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
9c039d08 185
7bf85405
RD
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();
1d99702e 208 void SetSelection(int n);
7bf85405
RD
209 %name(SetMark)void SetSelection(long from, long to);
210 void SetValue(const wxString& text);
211};
212
213//----------------------------------------------------------------------
214
215class wxGauge : public wxControl {
216public:
217 wxGauge(wxWindow* parent, wxWindowID id, int range,
b68dc582
RD
218 const wxPoint& pos = wxDefaultPosition,
219 const wxSize& size = wxDefaultSize,
7bf85405 220 long style = wxGA_HORIZONTAL,
b68dc582 221 const wxValidator& validator = wxDefaultValidator,
7bf85405
RD
222 char* name = "gauge");
223
f6bcfd97 224 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
9c039d08 225
7bf85405
RD
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
238class wxStaticBox : public wxControl {
239public:
240 wxStaticBox(wxWindow* parent, wxWindowID id, const wxString& label,
b68dc582
RD
241 const wxPoint& pos = wxDefaultPosition,
242 const wxSize& size = wxDefaultSize,
7bf85405
RD
243 long style = 0,
244 char* name = "staticBox");
245};
246
247
bb0054cd
RD
248//----------------------------------------------------------------------
249
8bf5d46e 250
bb0054cd
RD
251class wxStaticLine : public wxControl {
252public:
253 wxStaticLine( wxWindow *parent, wxWindowID id,
b68dc582
RD
254 const wxPoint &pos = wxDefaultPosition,
255 const wxSize &size = wxDefaultSize,
bb0054cd 256 long style = wxLI_HORIZONTAL,
d24a34bb 257 const char* name = "staticLine" );
bb0054cd 258};
8bf5d46e 259
bb0054cd 260
7bf85405
RD
261//----------------------------------------------------------------------
262
263class wxStaticText : public wxControl {
264public:
265 wxStaticText(wxWindow* parent, wxWindowID id, const wxString& label,
b68dc582
RD
266 const wxPoint& pos = wxDefaultPosition,
267 const wxSize& size = wxDefaultSize,
7bf85405
RD
268 long style = 0,
269 char* name = "staticText");
270
f6bcfd97 271 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
9c039d08 272
7bf85405
RD
273 wxString GetLabel();
274 void SetLabel(const wxString& label);
275};
276
277//----------------------------------------------------------------------
278
279class wxListBox : public wxControl {
280public:
281 wxListBox(wxWindow* parent, wxWindowID id,
b68dc582
RD
282 const wxPoint& pos = wxDefaultPosition,
283 const wxSize& size = wxDefaultSize,
eec92d76 284 int LCOUNT, wxString* choices = NULL,
7bf85405 285 long style = 0,
b68dc582 286 const wxValidator& validator = wxDefaultValidator,
7bf85405
RD
287 char* name = "listBox");
288
f6bcfd97 289 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
9c039d08 290
7bf85405
RD
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();
cf694132
RD
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());
f6bcfd97 306 for(size_t i=0; i<lst.GetCount(); i++) {
cf694132
RD
307 PyTuple_SetItem(tup, i, PyInt_FromLong(lst[i]));
308 }
309 return tup;
310 }
311 }
312
eec92d76 313 void InsertItems(int LCOUNT, wxString* choices, int pos);
2f90df85 314
7bf85405
RD
315 wxString GetString(int n);
316 wxString GetStringSelection();
317 int Number();
318 bool Selected(const int n);
eec92d76 319 void Set(int LCOUNT, wxString* choices);
7bf85405
RD
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
9c039d08
RD
329//----------------------------------------------------------------------
330
9c039d08
RD
331class wxCheckListBox : public wxListBox {
332public:
333 wxCheckListBox(wxWindow *parent, wxWindowID id,
b68dc582
RD
334 const wxPoint& pos = wxDefaultPosition,
335 const wxSize& size = wxDefaultSize,
9c039d08 336 int LCOUNT = 0,
eec92d76 337 wxString* choices = NULL,
9c039d08 338 long style = 0,
b68dc582 339 const wxValidator& validator = wxDefaultValidator,
9c039d08
RD
340 char* name = "listBox");
341
f6bcfd97 342 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
9c039d08
RD
343
344 bool IsChecked(int uiIndex);
694759cf 345 void Check(int uiIndex, int bCheck = TRUE);
eec92d76 346 void InsertItems(int LCOUNT, wxString* choices, int pos);
9c039d08
RD
347
348 int GetItemHeight();
349};
9c039d08 350
7bf85405
RD
351//----------------------------------------------------------------------
352
353class wxTextCtrl : public wxControl {
354public:
355 wxTextCtrl(wxWindow* parent, wxWindowID id, char* value = "",
b68dc582
RD
356 const wxPoint& pos = wxDefaultPosition,
357 const wxSize& size = wxDefaultSize,
7bf85405 358 long style = 0,
b68dc582 359 const wxValidator& validator = wxDefaultValidator,
7bf85405
RD
360 char* name = "text");
361
f6bcfd97 362 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
9c039d08 363
7bf85405
RD
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);
cf694132 388 void AppendText(const wxString& text);
7bf85405 389 long XYToPosition(long x, long y);
d403febc
RD
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();
b1462dfa
RD
398 void Undo();
399 void Redo();
400
401 %addmethods {
402 void write(const wxString& text) {
403 self->AppendText(text + '\n');
404 }
405 }
7bf85405
RD
406};
407
408//----------------------------------------------------------------------
409
410class wxScrollBar : public wxControl {
411public:
412 wxScrollBar(wxWindow* parent, wxWindowID id = -1,
b68dc582
RD
413 const wxPoint& pos = wxDefaultPosition,
414 const wxSize& size = wxDefaultSize,
7bf85405 415 long style = wxSB_HORIZONTAL,
b68dc582 416 const wxValidator& validator = wxDefaultValidator,
7bf85405
RD
417 char* name = "scrollBar");
418
f6bcfd97 419 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
9c039d08 420
7bf85405
RD
421 int GetRange();
422 int GetPageSize();
b8b8dda7 423 int GetThumbPosition();
7bf85405 424 int GetThumbSize();
26b9cf27 425 %name(GetThumbLength) int GetThumbSize(); // to match the docs
b8b8dda7 426 void SetThumbPosition(int viewStart);
7bf85405
RD
427 void SetScrollbar(int position, int thumbSize,
428 int range, int pageSize,
429 bool refresh = TRUE);
430};
431
432//----------------------------------------------------------------------
433
434class wxSpinButton : public wxControl {
435public:
436 wxSpinButton(wxWindow* parent, wxWindowID id = -1,
b68dc582
RD
437 const wxPoint& pos = wxDefaultPosition,
438 const wxSize& size = wxDefaultSize,
7bf85405
RD
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
451class wxStaticBitmap : public wxControl {
452public:
453 wxStaticBitmap(wxWindow* parent, wxWindowID id,
454 const wxBitmap& bitmap,
b68dc582
RD
455 const wxPoint& pos = wxDefaultPosition,
456 const wxSize& size = wxDefaultSize,
7bf85405
RD
457 long style = 0,
458 char* name = "staticBitmap");
459
f6bcfd97 460 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
9c039d08 461
cf694132 462 const wxBitmap& GetBitmap();
7bf85405 463 void SetBitmap(const wxBitmap& bitmap);
8bf5d46e 464 void SetIcon(const wxIcon& icon);
7bf85405
RD
465};
466
467//----------------------------------------------------------------------
468
469class wxRadioBox : public wxControl {
470public:
471 wxRadioBox(wxWindow* parent, wxWindowID id,
472 const wxString& label,
b68dc582
RD
473 const wxPoint& point = wxDefaultPosition,
474 const wxSize& size = wxDefaultSize,
eec92d76 475 int LCOUNT = 0, wxString* choices = NULL,
7bf85405
RD
476 int majorDimension = 0,
477 long style = wxRA_HORIZONTAL,
b68dc582 478 const wxValidator& validator = wxDefaultValidator,
7bf85405
RD
479 char* name = "radioBox");
480
f6bcfd97 481 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
9c039d08 482
0699c864
RD
483 void Enable(bool enable);
484 %name(EnableItem)void Enable(int n, bool enable);
7bf85405 485 int FindString(const wxString& string);
bb0054cd
RD
486
487//*** wxString GetLabel();
488//*** void SetLabel(const wxString& label);
489
0699c864 490 %name(GetItemLabel)wxString GetLabel(int n);
7bf85405
RD
491 int GetSelection();
492 wxString GetString(int n);
493 wxString GetStringSelection();
494 int Number();
0699c864 495 %name(SetItemLabel)void SetLabel(int n, const wxString& label);
7bf85405
RD
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
504class wxRadioButton : public wxControl {
505public:
506 wxRadioButton(wxWindow* parent, wxWindowID id,
507 const wxString& label,
b68dc582
RD
508 const wxPoint& pos = wxDefaultPosition,
509 const wxSize& size = wxDefaultSize,
7bf85405 510 long style = 0,
b68dc582 511 const wxValidator& validator = wxDefaultValidator,
7bf85405
RD
512 char* name = "radioButton");
513
f6bcfd97 514 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
9c039d08 515
7bf85405
RD
516 bool GetValue();
517 void SetValue(bool value);
518};
519
520//----------------------------------------------------------------------
521
522class wxSlider : public wxControl {
523public:
524 wxSlider(wxWindow* parent, wxWindowID id,
525 int value, int minValue, int maxValue,
b68dc582
RD
526 const wxPoint& point = wxDefaultPosition,
527 const wxSize& size = wxDefaultSize,
7bf85405 528 long style = wxSL_HORIZONTAL,
b68dc582 529 const wxValidator& validator = wxDefaultValidator,
7bf85405
RD
530 char* name = "slider");
531
f6bcfd97 532 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
9c039d08 533
7bf85405
RD
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
f6bcfd97
BP
558class wxSpinCtrl : public wxSpinButton {
559public:
560 wxSpinCtrl(wxWindow *parent,
561 wxWindowID id = -1,
562 const char* value = "",
b68dc582
RD
563 const wxPoint& pos = wxDefaultPosition,
564 const wxSize& size = wxDefaultSize,
f6bcfd97
BP
565 long style = wxSP_ARROW_KEYS,
566 int min = 0, int max = 100, int initial = 0,
567 const char* name = "wxSpinCtrl");
568
569
c368d904
RD
570 int GetMax();
571 int GetMin();
572 int GetValue();
573 void SetRange(int min, int max);
574 void SetValue(int value);
575
f6bcfd97
BP
576};
577
578
579//----------------------------------------------------------------------
580
d1679124
RD
581enum { wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, };
582
583class wxToggleButton : public wxControl {
584public:
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
c368d904
RD
604
605