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