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