]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/controls.i
documented fs_zip bugfix
[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>
6999b0d8 22//#include <wx/toggbutt.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
6999b0d8
RD
128//----------------------------------------------------------------------
129
130// class wxToggleButton : public wxControl {
131// public:
132// wxToggleButton(wxWindow *parent, wxWindowID id, const wxString& label,
b68dc582
RD
133// const wxPoint& pos = wxDefaultPosition,
134// const wxSize& size = wxDefaultSize, long style = 0,
135// const wxValidator& validator = wxDefaultValidator,
6999b0d8
RD
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,
b68dc582
RD
145// const wxPoint& pos = wxDefaultPosition,
146// const wxSize& size = wxDefaultSize, long style = 0,
147// const wxValidator& validator = wxDefaultValidator,
6999b0d8
RD
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,
b68dc582
RD
158 const wxPoint& pos = wxDefaultPosition,
159 const wxSize& size = wxDefaultSize,
7bf85405 160 long style = 0,
b68dc582 161 const wxValidator& val = wxDefaultValidator,
7bf85405
RD
162 char* name = "checkBox");
163
f6bcfd97 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,
b68dc582
RD
175 const wxPoint& pos = wxDefaultPosition,
176 const wxSize& size = wxDefaultSize,
eec92d76 177 int LCOUNT=0, wxString* choices=NULL,
7bf85405 178 long style = 0,
b68dc582 179 const wxValidator& validator = wxDefaultValidator,
7bf85405
RD
180 char* name = "choice");
181
f6bcfd97 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 = "",
b68dc582
RD
202 const wxPoint& pos = wxDefaultPosition,
203 const wxSize& size = wxDefaultSize,
eec92d76 204 int LCOUNT=0, wxString* choices=NULL,
7bf85405 205 long style = 0,
b68dc582 206 const wxValidator& validator = wxDefaultValidator,
7bf85405
RD
207 char* name = "comboBox");
208
f6bcfd97 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,
b68dc582
RD
243 const wxPoint& pos = wxDefaultPosition,
244 const wxSize& size = wxDefaultSize,
7bf85405 245 long style = wxGA_HORIZONTAL,
b68dc582 246 const wxValidator& validator = wxDefaultValidator,
7bf85405
RD
247 char* name = "gauge");
248
f6bcfd97 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,
b68dc582
RD
266 const wxPoint& pos = wxDefaultPosition,
267 const wxSize& size = wxDefaultSize,
7bf85405
RD
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,
b68dc582
RD
279 const wxPoint &pos = wxDefaultPosition,
280 const wxSize &size = wxDefaultSize,
bb0054cd 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,
b68dc582
RD
291 const wxPoint& pos = wxDefaultPosition,
292 const wxSize& size = wxDefaultSize,
7bf85405
RD
293 long style = 0,
294 char* name = "staticText");
295
f6bcfd97 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,
b68dc582
RD
307 const wxPoint& pos = wxDefaultPosition,
308 const wxSize& size = wxDefaultSize,
eec92d76 309 int LCOUNT, wxString* choices = NULL,
7bf85405 310 long style = 0,
b68dc582 311 const wxValidator& validator = wxDefaultValidator,
7bf85405
RD
312 char* name = "listBox");
313
f6bcfd97 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());
f6bcfd97 331 for(size_t i=0; i<lst.GetCount(); i++) {
cf694132
RD
332 PyTuple_SetItem(tup, i, PyInt_FromLong(lst[i]));
333 }
334 return tup;
335 }
336 }
337
eec92d76 338 void InsertItems(int LCOUNT, wxString* choices, int pos);
2f90df85 339
7bf85405
RD
340 wxString GetString(int n);
341 wxString GetStringSelection();
342 int Number();
343 bool Selected(const int n);
eec92d76 344 void Set(int LCOUNT, wxString* choices);
7bf85405
RD
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,
b68dc582
RD
359 const wxPoint& pos = wxDefaultPosition,
360 const wxSize& size = wxDefaultSize,
9c039d08 361 int LCOUNT = 0,
eec92d76 362 wxString* choices = NULL,
9c039d08 363 long style = 0,
b68dc582 364 const wxValidator& validator = wxDefaultValidator,
9c039d08
RD
365 char* name = "listBox");
366
f6bcfd97 367 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
9c039d08
RD
368
369 bool IsChecked(int uiIndex);
694759cf 370 void Check(int uiIndex, int bCheck = TRUE);
eec92d76 371 void InsertItems(int LCOUNT, wxString* choices, 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 = "",
b68dc582
RD
381 const wxPoint& pos = wxDefaultPosition,
382 const wxSize& size = wxDefaultSize,
7bf85405 383 long style = 0,
b68dc582 384 const wxValidator& validator = wxDefaultValidator,
7bf85405
RD
385 char* name = "text");
386
f6bcfd97 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,
b68dc582
RD
438 const wxPoint& pos = wxDefaultPosition,
439 const wxSize& size = wxDefaultSize,
7bf85405 440 long style = wxSB_HORIZONTAL,
b68dc582 441 const wxValidator& validator = wxDefaultValidator,
7bf85405
RD
442 char* name = "scrollBar");
443
f6bcfd97 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();
26b9cf27 450 %name(GetThumbLength) int GetThumbSize(); // to match the docs
b8b8dda7 451 void SetThumbPosition(int viewStart);
7bf85405
RD
452 void SetScrollbar(int position, int thumbSize,
453 int range, int pageSize,
454 bool refresh = TRUE);
455};
456
457//----------------------------------------------------------------------
458
459class wxSpinButton : public wxControl {
460public:
461 wxSpinButton(wxWindow* parent, wxWindowID id = -1,
b68dc582
RD
462 const wxPoint& pos = wxDefaultPosition,
463 const wxSize& size = wxDefaultSize,
7bf85405
RD
464 long style = wxSP_HORIZONTAL,
465 char* name = "spinButton");
466
467 int GetMax();
468 int GetMin();
469 int GetValue();
470 void SetRange(int min, int max);
471 void SetValue(int value);
472};
473
474//----------------------------------------------------------------------
475
476class wxStaticBitmap : public wxControl {
477public:
478 wxStaticBitmap(wxWindow* parent, wxWindowID id,
479 const wxBitmap& bitmap,
b68dc582
RD
480 const wxPoint& pos = wxDefaultPosition,
481 const wxSize& size = wxDefaultSize,
7bf85405
RD
482 long style = 0,
483 char* name = "staticBitmap");
484
f6bcfd97 485 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
9c039d08 486
cf694132 487 const wxBitmap& GetBitmap();
7bf85405 488 void SetBitmap(const wxBitmap& bitmap);
8bf5d46e 489 void SetIcon(const wxIcon& icon);
7bf85405
RD
490};
491
492//----------------------------------------------------------------------
493
494class wxRadioBox : public wxControl {
495public:
496 wxRadioBox(wxWindow* parent, wxWindowID id,
497 const wxString& label,
b68dc582
RD
498 const wxPoint& point = wxDefaultPosition,
499 const wxSize& size = wxDefaultSize,
eec92d76 500 int LCOUNT = 0, wxString* choices = NULL,
7bf85405
RD
501 int majorDimension = 0,
502 long style = wxRA_HORIZONTAL,
b68dc582 503 const wxValidator& validator = wxDefaultValidator,
7bf85405
RD
504 char* name = "radioBox");
505
f6bcfd97 506 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
9c039d08 507
0699c864
RD
508 void Enable(bool enable);
509 %name(EnableItem)void Enable(int n, bool enable);
7bf85405 510 int FindString(const wxString& string);
bb0054cd
RD
511
512//*** wxString GetLabel();
513//*** void SetLabel(const wxString& label);
514
0699c864 515 %name(GetItemLabel)wxString GetLabel(int n);
7bf85405
RD
516 int GetSelection();
517 wxString GetString(int n);
518 wxString GetStringSelection();
519 int Number();
0699c864 520 %name(SetItemLabel)void SetLabel(int n, const wxString& label);
7bf85405
RD
521 void SetSelection(int n);
522 void SetStringSelection(const wxString& string);
523 void Show(bool show);
524 %name(ShowItem)void Show(int item, bool show);
525};
526
527//----------------------------------------------------------------------
528
529class wxRadioButton : public wxControl {
530public:
531 wxRadioButton(wxWindow* parent, wxWindowID id,
532 const wxString& label,
b68dc582
RD
533 const wxPoint& pos = wxDefaultPosition,
534 const wxSize& size = wxDefaultSize,
7bf85405 535 long style = 0,
b68dc582 536 const wxValidator& validator = wxDefaultValidator,
7bf85405
RD
537 char* name = "radioButton");
538
f6bcfd97 539 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
9c039d08 540
7bf85405
RD
541 bool GetValue();
542 void SetValue(bool value);
543};
544
545//----------------------------------------------------------------------
546
547class wxSlider : public wxControl {
548public:
549 wxSlider(wxWindow* parent, wxWindowID id,
550 int value, int minValue, int maxValue,
b68dc582
RD
551 const wxPoint& point = wxDefaultPosition,
552 const wxSize& size = wxDefaultSize,
7bf85405 553 long style = wxSL_HORIZONTAL,
b68dc582 554 const wxValidator& validator = wxDefaultValidator,
7bf85405
RD
555 char* name = "slider");
556
f6bcfd97 557 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
9c039d08 558
7bf85405
RD
559 void ClearSel();
560 void ClearTicks();
561 int GetLineSize();
562 int GetMax();
563 int GetMin();
564 int GetPageSize();
565 int GetSelEnd();
566 int GetSelStart();
567 int GetThumbLength();
568 int GetTickFreq();
569 int GetValue();
570 void SetRange(int minValue, int maxValue);
571 void SetTickFreq(int n, int pos);
572 void SetLineSize(int lineSize);
573 void SetPageSize(int pageSize);
574 void SetSelection(int startPos, int endPos);
575 void SetThumbLength(int len);
576 void SetTick(int tickPos);
577 void SetValue(int value);
578};
579
580
581//----------------------------------------------------------------------
582
f6bcfd97
BP
583class wxSpinCtrl : public wxSpinButton {
584public:
585 wxSpinCtrl(wxWindow *parent,
586 wxWindowID id = -1,
587 const char* value = "",
b68dc582
RD
588 const wxPoint& pos = wxDefaultPosition,
589 const wxSize& size = wxDefaultSize,
f6bcfd97
BP
590 long style = wxSP_ARROW_KEYS,
591 int min = 0, int max = 100, int initial = 0,
592 const char* name = "wxSpinCtrl");
593
594
c368d904
RD
595 int GetMax();
596 int GetMin();
597 int GetValue();
598 void SetRange(int min, int max);
599 void SetValue(int value);
600
f6bcfd97
BP
601};
602
603
604//----------------------------------------------------------------------
605
c368d904
RD
606
607