]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/controls.i
Made a couple Number() to GetCount() changes
[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
d56cebe7
RD
353
354class wxTextAttr
355{
356public:
357 // ctors
358 wxTextAttr(const wxColour& colText = wxNullColour,
359 const wxColour& colBack = wxNullColour,
360 const wxFont& font = wxNullFont);
361 ~wxTextAttr();
362
363 // setters
364 void SetTextColour(const wxColour& colText);
365 void SetBackgroundColour(const wxColour& colBack);
366 void SetFont(const wxFont& font);
367
368 // accessors
369 bool HasTextColour() const;
370 bool HasBackgroundColour() const;
371 bool HasFont() const;
372
373 const wxColour& GetTextColour() const;
374 const wxColour& GetBackgroundColour() const;
375 const wxFont& GetFont() const;
376};
377
378
379
7bf85405
RD
380class wxTextCtrl : public wxControl {
381public:
382 wxTextCtrl(wxWindow* parent, wxWindowID id, char* value = "",
b68dc582
RD
383 const wxPoint& pos = wxDefaultPosition,
384 const wxSize& size = wxDefaultSize,
7bf85405 385 long style = 0,
b68dc582 386 const wxValidator& validator = wxDefaultValidator,
7bf85405
RD
387 char* name = "text");
388
f6bcfd97 389 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
9c039d08 390
7bf85405
RD
391 void Clear();
392 void Copy();
393 void Cut();
394 void DiscardEdits();
395 long GetInsertionPoint();
396 long GetLastPosition();
397 int GetLineLength(long lineNo);
398 wxString GetLineText(long lineNo);
399 int GetNumberOfLines();
400 wxString GetValue();
401 bool IsModified();
402 bool LoadFile(const wxString& filename);
403 void Paste();
404 void PositionToXY(long pos, long *OUTPUT, long *OUTPUT);
405 void Remove(long from, long to);
406 void Replace(long from, long to, const wxString& value);
407 bool SaveFile(const wxString& filename);
408 void SetEditable(bool editable);
409 void SetInsertionPoint(long pos);
410 void SetInsertionPointEnd();
411 void SetSelection(long from, long to);
412 void SetValue(const wxString& value);
413 void ShowPosition(long pos);
414 void WriteText(const wxString& text);
cf694132 415 void AppendText(const wxString& text);
7bf85405 416 long XYToPosition(long x, long y);
d403febc
RD
417
418 bool CanCopy();
419 bool CanCut();
420 bool CanPaste();
421 bool CanRedo();
422 bool CanUndo();
423 void GetSelection(long* OUTPUT, long* OUTPUT);
424 bool IsEditable();
b1462dfa
RD
425 void Undo();
426 void Redo();
427
d56cebe7
RD
428 bool SetStyle(long start, long end, const wxTextAttr& style);
429 bool SetDefaultStyle(const wxTextAttr& style);
430 const wxTextAttr& GetDefaultStyle() const;
431
b1462dfa
RD
432 %addmethods {
433 void write(const wxString& text) {
d56cebe7 434 self->AppendText(text);
b1462dfa
RD
435 }
436 }
7bf85405
RD
437};
438
439//----------------------------------------------------------------------
440
441class wxScrollBar : public wxControl {
442public:
443 wxScrollBar(wxWindow* parent, wxWindowID id = -1,
b68dc582
RD
444 const wxPoint& pos = wxDefaultPosition,
445 const wxSize& size = wxDefaultSize,
7bf85405 446 long style = wxSB_HORIZONTAL,
b68dc582 447 const wxValidator& validator = wxDefaultValidator,
7bf85405
RD
448 char* name = "scrollBar");
449
f6bcfd97 450 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
9c039d08 451
7bf85405
RD
452 int GetRange();
453 int GetPageSize();
b8b8dda7 454 int GetThumbPosition();
7bf85405 455 int GetThumbSize();
26b9cf27 456 %name(GetThumbLength) int GetThumbSize(); // to match the docs
b8b8dda7 457 void SetThumbPosition(int viewStart);
7bf85405
RD
458 void SetScrollbar(int position, int thumbSize,
459 int range, int pageSize,
460 bool refresh = TRUE);
461};
462
463//----------------------------------------------------------------------
464
465class wxSpinButton : public wxControl {
466public:
467 wxSpinButton(wxWindow* parent, wxWindowID id = -1,
b68dc582
RD
468 const wxPoint& pos = wxDefaultPosition,
469 const wxSize& size = wxDefaultSize,
7bf85405
RD
470 long style = wxSP_HORIZONTAL,
471 char* name = "spinButton");
472
473 int GetMax();
474 int GetMin();
475 int GetValue();
476 void SetRange(int min, int max);
477 void SetValue(int value);
478};
479
480//----------------------------------------------------------------------
481
482class wxStaticBitmap : public wxControl {
483public:
484 wxStaticBitmap(wxWindow* parent, wxWindowID id,
485 const wxBitmap& bitmap,
b68dc582
RD
486 const wxPoint& pos = wxDefaultPosition,
487 const wxSize& size = wxDefaultSize,
7bf85405
RD
488 long style = 0,
489 char* name = "staticBitmap");
490
f6bcfd97 491 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
9c039d08 492
cf694132 493 const wxBitmap& GetBitmap();
7bf85405 494 void SetBitmap(const wxBitmap& bitmap);
8bf5d46e 495 void SetIcon(const wxIcon& icon);
7bf85405
RD
496};
497
498//----------------------------------------------------------------------
499
500class wxRadioBox : public wxControl {
501public:
502 wxRadioBox(wxWindow* parent, wxWindowID id,
503 const wxString& label,
b68dc582
RD
504 const wxPoint& point = wxDefaultPosition,
505 const wxSize& size = wxDefaultSize,
eec92d76 506 int LCOUNT = 0, wxString* choices = NULL,
7bf85405
RD
507 int majorDimension = 0,
508 long style = wxRA_HORIZONTAL,
b68dc582 509 const wxValidator& validator = wxDefaultValidator,
7bf85405
RD
510 char* name = "radioBox");
511
f6bcfd97 512 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
9c039d08 513
0699c864
RD
514 void Enable(bool enable);
515 %name(EnableItem)void Enable(int n, bool enable);
7bf85405 516 int FindString(const wxString& string);
bb0054cd
RD
517
518//*** wxString GetLabel();
519//*** void SetLabel(const wxString& label);
520
0699c864 521 %name(GetItemLabel)wxString GetLabel(int n);
7bf85405
RD
522 int GetSelection();
523 wxString GetString(int n);
524 wxString GetStringSelection();
525 int Number();
0699c864 526 %name(SetItemLabel)void SetLabel(int n, const wxString& label);
7bf85405
RD
527 void SetSelection(int n);
528 void SetStringSelection(const wxString& string);
529 void Show(bool show);
530 %name(ShowItem)void Show(int item, bool show);
531};
532
533//----------------------------------------------------------------------
534
535class wxRadioButton : public wxControl {
536public:
537 wxRadioButton(wxWindow* parent, wxWindowID id,
538 const wxString& label,
b68dc582
RD
539 const wxPoint& pos = wxDefaultPosition,
540 const wxSize& size = wxDefaultSize,
7bf85405 541 long style = 0,
b68dc582 542 const wxValidator& validator = wxDefaultValidator,
7bf85405
RD
543 char* name = "radioButton");
544
f6bcfd97 545 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
9c039d08 546
7bf85405
RD
547 bool GetValue();
548 void SetValue(bool value);
549};
550
551//----------------------------------------------------------------------
552
553class wxSlider : public wxControl {
554public:
555 wxSlider(wxWindow* parent, wxWindowID id,
556 int value, int minValue, int maxValue,
b68dc582
RD
557 const wxPoint& point = wxDefaultPosition,
558 const wxSize& size = wxDefaultSize,
7bf85405 559 long style = wxSL_HORIZONTAL,
b68dc582 560 const wxValidator& validator = wxDefaultValidator,
7bf85405
RD
561 char* name = "slider");
562
f6bcfd97 563 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
9c039d08 564
7bf85405
RD
565 void ClearSel();
566 void ClearTicks();
567 int GetLineSize();
568 int GetMax();
569 int GetMin();
570 int GetPageSize();
571 int GetSelEnd();
572 int GetSelStart();
573 int GetThumbLength();
574 int GetTickFreq();
575 int GetValue();
576 void SetRange(int minValue, int maxValue);
577 void SetTickFreq(int n, int pos);
578 void SetLineSize(int lineSize);
579 void SetPageSize(int pageSize);
580 void SetSelection(int startPos, int endPos);
581 void SetThumbLength(int len);
582 void SetTick(int tickPos);
583 void SetValue(int value);
584};
585
586
587//----------------------------------------------------------------------
588
f6bcfd97
BP
589class wxSpinCtrl : public wxSpinButton {
590public:
591 wxSpinCtrl(wxWindow *parent,
592 wxWindowID id = -1,
593 const char* value = "",
b68dc582
RD
594 const wxPoint& pos = wxDefaultPosition,
595 const wxSize& size = wxDefaultSize,
f6bcfd97
BP
596 long style = wxSP_ARROW_KEYS,
597 int min = 0, int max = 100, int initial = 0,
598 const char* name = "wxSpinCtrl");
599
600
c368d904
RD
601 int GetMax();
602 int GetMin();
603 int GetValue();
604 void SetRange(int min, int max);
605 void SetValue(int value);
606
f6bcfd97
BP
607};
608
609
610//----------------------------------------------------------------------
611
d1679124
RD
612enum { wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, };
613
614class wxToggleButton : public wxControl {
615public:
616 wxToggleButton(wxWindow *parent,
617 wxWindowID id,
618 const wxString& label,
619 const wxPoint& pos = wxDefaultPosition,
620 const wxSize& size = wxDefaultSize,
621 long style = 0,
622 const wxValidator& validator = wxDefaultValidator,
623 const char* name = "toggle");
624
625 void SetValue(bool value);
626 bool GetValue() const ;
627 void SetLabel(const wxString& label);
628
629};
630
631//----------------------------------------------------------------------
632//----------------------------------------------------------------------
633//----------------------------------------------------------------------
634
c368d904
RD
635
636