]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/controls.i
compilation fix for recent commit
[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
4268f798
RD
58
59// This is the base class for a control or 'widget'.
60//
61// A control is generally a small window which processes user input and/or
62// displays one or more item of data.
7bf85405
RD
63class wxControl : public wxWindow {
64public:
4268f798
RD
65
66 //
9b3d3bc4
RD
67 wxControl(wxWindow *parent,
68 wxWindowID id,
b68dc582
RD
69 const wxPoint& pos=wxDefaultPosition,
70 const wxSize& size=wxDefaultSize,
9b3d3bc4 71 long style=0,
b68dc582 72 const wxValidator& validator=wxDefaultValidator,
9b3d3bc4 73 const char* name="control");
4268f798
RD
74
75 //
09f3d4e6
RD
76 %name(wxPreControl)wxControl();
77
4268f798 78 //
09f3d4e6
RD
79 bool Create(wxWindow *parent,
80 wxWindowID id,
81 const wxPoint& pos=wxDefaultPosition,
82 const wxSize& size=wxDefaultSize,
83 long style=0,
84 const wxValidator& validator=wxDefaultValidator,
85 const char* name="control");
9b3d3bc4 86
0122b7e3 87 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
17c0e08c 88 %pragma(python) addtomethod = "wxPreControl:val._setOORInfo(val)"
6999b0d8 89
4268f798
RD
90 // Simulates the effect of the user issuing a command to the item. See
91 // wxCommandEvent.
7bf85405 92 void Command(wxCommandEvent& event);
4268f798
RD
93
94 // Return a control's text.
fb5e0af0 95 wxString GetLabel();
4268f798
RD
96
97 // Sets the item's text.
7bf85405
RD
98 void SetLabel(const wxString& label);
99};
100
6999b0d8 101
7bf85405
RD
102//----------------------------------------------------------------------
103
900d9886
RD
104
105class wxControlWithItems : public wxControl {
106public:
107
108 // void Clear(); ambiguous, redefine below...
4268f798
RD
109
110 // Deletes an item from the control
900d9886
RD
111 void Delete(int n);
112
4268f798 113 // Returns the number of items in the control.
900d9886
RD
114 int GetCount();
115 %pragma(python) addtoclass = "Number = GetCount"
4268f798
RD
116
117 // Returns the string at the given position.
900d9886 118 wxString GetString(int n);
4268f798
RD
119
120 // Sets the string value of an item.
900d9886 121 void SetString(int n, const wxString& s);
4268f798
RD
122
123 // Finds an item matching the given string. Returns the zero-based
124 // position of the item, or -1 if the string was not found.
900d9886
RD
125 int FindString(const wxString& s);
126
4268f798 127 // Select the item at postion n.
900d9886 128 void Select(int n);
4268f798
RD
129
130 // Gets the position of the selected item.
900d9886
RD
131 int GetSelection();
132
4268f798 133 // Gets the current selection as a string.
900d9886
RD
134 wxString GetStringSelection() const;
135
136 // void Append(const wxString& item);
137 // void Append(const wxString& item, char* clientData);
138 // char* GetClientData(const int n);
139 // void SetClientData(const int n, char* data);
4268f798
RD
140
141
900d9886 142 %addmethods {
4268f798
RD
143 // Adds the item to the control, associating the given data with the
144 // item if not None.
900d9886
RD
145 void Append(const wxString& item, PyObject* clientData=NULL) {
146 if (clientData) {
147 wxPyClientData* data = new wxPyClientData(clientData);
148 self->Append(item, data);
149 } else
150 self->Append(item);
151 }
152
4268f798 153 // Returns the client data associated with the given item, (if any.)
900d9886
RD
154 PyObject* GetClientData(int n) {
155 wxPyClientData* data = (wxPyClientData*)self->GetClientObject(n);
156 if (data) {
157 Py_INCREF(data->m_obj);
158 return data->m_obj;
159 } else {
160 Py_INCREF(Py_None);
161 return Py_None;
162 }
163 }
164
4268f798 165 // Associate the given client data with the item at position n.
900d9886
RD
166 void SetClientData(int n, PyObject* clientData) {
167 wxPyClientData* data = new wxPyClientData(clientData);
168 self->SetClientObject(n, data);
169 }
170 }
171
172};
4268f798 173
900d9886
RD
174//----------------------------------------------------------------------
175
4268f798
RD
176// A button is a control that contains a text string, and is one of the most
177// common elements of a GUI. It may be placed on a dialog box or panel, or
178// indeed almost any other window.
179//
180// Styles
181// wxBU_LEFT: Left-justifies the label. WIN32 only.
182// wxBU_TOP: Aligns the label to the top of the button. WIN32 only.
183// wxBU_RIGHT: Right-justifies the bitmap label. WIN32 only.
184// wxBU_BOTTOM: Aligns the label to the bottom of the button. WIN32 only.
185// wxBU_EXACTFIT: Creates the button as small as possible instead of making
186// it of the standard size (which is the default behaviour.)
187//
188// Events
189// EVT_BUTTON(win,id,func):
190// Sent when the button is clicked.
191//
7bf85405
RD
192class wxButton : public wxControl {
193public:
4268f798
RD
194 // Constructor, creating and showing a button.
195 //
196 // parent: Parent window. Must not be None.
197 // id: Button identifier. A value of -1 indicates a default value.
198 // label: The text to be displayed on the button.
199 // pos: The button position on it's parent.
200 // size: Button size. If the default size (-1, -1) is specified then the
201 // button is sized appropriately for the text.
202 // style: Window style. See wxButton.
203 // validator: Window validator.
204 // name: Window name.
7bf85405 205 wxButton(wxWindow* parent, wxWindowID id, const wxString& label,
b68dc582
RD
206 const wxPoint& pos = wxDefaultPosition,
207 const wxSize& size = wxDefaultSize,
7bf85405 208 long style = 0,
b68dc582 209 const wxValidator& validator = wxDefaultValidator,
7bf85405 210 char* name = "button");
4268f798
RD
211
212 // Default constructor
09f3d4e6
RD
213 %name(wxPreButton)wxButton();
214
4268f798 215 // Button creation function for two-step creation.
09f3d4e6
RD
216 bool Create(wxWindow* parent, wxWindowID id, const wxString& label,
217 const wxPoint& pos = wxDefaultPosition,
218 const wxSize& size = wxDefaultSize,
219 long style = 0,
220 const wxValidator& validator = wxDefaultValidator,
221 char* name = "button");
9c039d08 222
0122b7e3 223 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
17c0e08c 224 %pragma(python) addtomethod = "wxPreButton:val._setOORInfo(val)"
9c039d08 225
4268f798
RD
226 // This sets the button to be the default item for the panel or dialog box.
227 //
228 // Under Windows, only dialog box buttons respond to this function. As
229 // normal under Windows and Motif, pressing return causes the default
230 // button to be depressed when the return key is pressed. See also
231 // wxWindow.SetFocus which sets the keyboard focus for windows and text
232 // panel items, and wxPanel.SetDefaultItem.
7bf85405 233 void SetDefault();
4268f798
RD
234
235 //
9b3d3bc4 236 void SetBackgroundColour(const wxColour& colour);
4268f798 237 //
9b3d3bc4 238 void SetForegroundColour(const wxColour& colour);
4268f798 239
059a841c 240#ifdef __WXMSW__
4268f798 241 // show the image in the button in addition to the label
09f3d4e6 242 void SetImageLabel(const wxBitmap& bitmap);
4268f798
RD
243
244 // set the margins around the image
09f3d4e6 245 void SetImageMargins(wxCoord x, wxCoord y);
059a841c 246#endif
4268f798
RD
247
248 // returns the default button size for this platform
09f3d4e6
RD
249 static wxSize GetDefaultSize();
250};
6999b0d8 251
7bf85405
RD
252//----------------------------------------------------------------------
253
254class wxBitmapButton : public wxButton {
255public:
256 wxBitmapButton(wxWindow* parent, wxWindowID id, const wxBitmap& bitmap,
b68dc582
RD
257 const wxPoint& pos = wxDefaultPosition,
258 const wxSize& size = wxDefaultSize,
7bf85405 259 long style = wxBU_AUTODRAW,
b68dc582 260 const wxValidator& validator = wxDefaultValidator,
7bf85405 261 char* name = "button");
09f3d4e6
RD
262 %name(wxPreBitmapButton)wxBitmapButton();
263
264 bool Create(wxWindow* parent, wxWindowID id, const wxBitmap& bitmap,
265 const wxPoint& pos = wxDefaultPosition,
266 const wxSize& size = wxDefaultSize,
267 long style = wxBU_AUTODRAW,
268 const wxValidator& validator = wxDefaultValidator,
269 char* name = "button");
7bf85405 270
0122b7e3 271 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
17c0e08c 272 %pragma(python) addtomethod = "wxPreBitmapButton:val._setOORInfo(val)"
9c039d08 273
c5943253
RD
274 wxBitmap GetBitmapLabel();
275 wxBitmap GetBitmapDisabled();
276 wxBitmap GetBitmapFocus();
277 wxBitmap GetBitmapSelected();
7bf85405
RD
278 void SetBitmapDisabled(const wxBitmap& bitmap);
279 void SetBitmapFocus(const wxBitmap& bitmap);
7bf85405 280 void SetBitmapSelected(const wxBitmap& bitmap);
fb5e0af0 281 void SetBitmapLabel(const wxBitmap& bitmap);
7bf85405 282
f6bcfd97
BP
283 void SetMargins(int x, int y) { m_marginX = x; m_marginY = y; }
284 int GetMarginX() const { return m_marginX; }
285 int GetMarginY() const { return m_marginY; }
7bf85405
RD
286};
287
288//----------------------------------------------------------------------
289
290class wxCheckBox : public wxControl {
291public:
292 wxCheckBox(wxWindow* parent, wxWindowID id, const wxString& label,
b68dc582
RD
293 const wxPoint& pos = wxDefaultPosition,
294 const wxSize& size = wxDefaultSize,
7bf85405 295 long style = 0,
b68dc582 296 const wxValidator& val = wxDefaultValidator,
7bf85405 297 char* name = "checkBox");
09f3d4e6
RD
298 %name(wxPreCheckBox)wxCheckBox();
299
300 bool Create(wxWindow* parent, wxWindowID id, const wxString& label,
301 const wxPoint& pos = wxDefaultPosition,
302 const wxSize& size = wxDefaultSize,
303 long style = 0,
304 const wxValidator& val = wxDefaultValidator,
305 char* name = "checkBox");
7bf85405 306
0122b7e3 307 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
17c0e08c 308 %pragma(python) addtomethod = "wxPreCheckBox:val._setOORInfo(val)"
9c039d08 309
7bf85405
RD
310 bool GetValue();
311 void SetValue(const bool state);
312};
313
314//----------------------------------------------------------------------
315
900d9886 316class wxChoice : public wxControlWithItems {
7bf85405
RD
317public:
318 wxChoice(wxWindow *parent, wxWindowID id,
b68dc582
RD
319 const wxPoint& pos = wxDefaultPosition,
320 const wxSize& size = wxDefaultSize,
eec92d76 321 int LCOUNT=0, wxString* choices=NULL,
7bf85405 322 long style = 0,
b68dc582 323 const wxValidator& validator = wxDefaultValidator,
7bf85405 324 char* name = "choice");
09f3d4e6
RD
325 %name(wxPreChoice)wxChoice();
326
327 bool Create(wxWindow *parent, wxWindowID id,
328 const wxPoint& pos = wxDefaultPosition,
329 const wxSize& size = wxDefaultSize,
330 int LCOUNT=0, wxString* choices=NULL,
331 long style = 0,
332 const wxValidator& validator = wxDefaultValidator,
333 char* name = "choice");
7bf85405 334
0122b7e3 335 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
17c0e08c 336 %pragma(python) addtomethod = "wxPreChoice:val._setOORInfo(val)"
0122b7e3 337
7bf85405 338 void Clear();
900d9886 339
7bf85405 340 int GetColumns();
7bf85405
RD
341 void SetColumns(const int n = 1);
342 void SetSelection(const int n);
343 void SetStringSelection(const wxString& string);
0adbc166
RD
344 void SetString(int n, const wxString& s);
345
346 %pragma(python) addtoclass = "
0adbc166
RD
347 Select = SetSelection
348 "
7bf85405
RD
349};
350
351//----------------------------------------------------------------------
352
c70fd24f
RD
353// wxGTK's wxComboBox doesn't derive from wxChoice like wxMSW, or
354// even wxControlWithItems, so we have to duplicate the methods
355// here... <blech!>
356
357#ifdef __WXGTK__
358class wxComboBox : public wxControl
359{
360public:
361 wxComboBox(wxWindow* parent, wxWindowID id, char* value = "",
362 const wxPoint& pos = wxDefaultPosition,
363 const wxSize& size = wxDefaultSize,
364 int LCOUNT=0, wxString* choices=NULL,
365 long style = 0,
366 const wxValidator& validator = wxDefaultValidator,
367 char* name = "comboBox");
368 %name(wxPreComboBox)wxComboBox();
369
370 bool Create(wxWindow* parent, wxWindowID id, char* value = "",
371 const wxPoint& pos = wxDefaultPosition,
372 const wxSize& size = wxDefaultSize,
373 int LCOUNT=0, wxString* choices=NULL,
374 long style = 0,
375 const wxValidator& validator = wxDefaultValidator,
376 char* name = "comboBox");
377
378 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
379 %pragma(python) addtomethod = "wxPreComboBox:val._setOORInfo(val)"
380
381 void Copy();
382 void Cut();
383 long GetInsertionPoint();
384 long GetLastPosition();
385 wxString GetValue();
386 void Paste();
387 void Replace(long from, long to, const wxString& text);
388 void Remove(long from, long to);
389 void SetInsertionPoint(long pos);
390 void SetInsertionPointEnd();
391 void SetSelection(int n);
392 %name(SetMark)void SetSelection(long from, long to);
393 void SetValue(const wxString& text);
394 void SetEditable(bool editable);
395
396
397 void Clear();
398 void Delete(int n);
399
400 int GetCount();
401 %pragma(python) addtoclass = "Number = GetCount"
402 wxString GetString(int n);
403 int FindString(const wxString& s);
404
405 //void SetString(int n, const wxString& s); *** No equivalent for wxGTK!!!
406
407 // void Select(int n);
408 %pragma(python) addtoclass = "Select = SetSelection"
409
410 int GetSelection();
411 wxString GetStringSelection() const;
412
413 // void Append(const wxString& item);
414 // void Append(const wxString& item, char* clientData);
415 // char* GetClientData(const int n);
416 // void SetClientData(const int n, char* data);
417 %addmethods {
418 void Append(const wxString& item, PyObject* clientData=NULL) {
419 if (clientData) {
420 wxPyClientData* data = new wxPyClientData(clientData);
421 self->Append(item, data);
422 } else
423 self->Append(item);
424 }
425
426 PyObject* GetClientData(int n) {
427 wxPyClientData* data = (wxPyClientData*)self->GetClientObject(n);
428 if (data) {
429 Py_INCREF(data->m_obj);
430 return data->m_obj;
431 } else {
432 Py_INCREF(Py_None);
433 return Py_None;
434 }
435 }
436
437 void SetClientData(int n, PyObject* clientData) {
438 wxPyClientData* data = new wxPyClientData(clientData);
439 self->SetClientObject(n, data);
440 }
441 }
442
443};
444
445
446
447#else // For all but wxGTK
448
449
bb0054cd 450class wxComboBox : public wxChoice {
7bf85405
RD
451public:
452 wxComboBox(wxWindow* parent, wxWindowID id, char* value = "",
b68dc582
RD
453 const wxPoint& pos = wxDefaultPosition,
454 const wxSize& size = wxDefaultSize,
eec92d76 455 int LCOUNT=0, wxString* choices=NULL,
7bf85405 456 long style = 0,
b68dc582 457 const wxValidator& validator = wxDefaultValidator,
7bf85405 458 char* name = "comboBox");
09f3d4e6
RD
459 %name(wxPreComboBox)wxComboBox();
460
461 bool Create(wxWindow* parent, wxWindowID id, char* value = "",
462 const wxPoint& pos = wxDefaultPosition,
463 const wxSize& size = wxDefaultSize,
464 int LCOUNT=0, wxString* choices=NULL,
465 long style = 0,
466 const wxValidator& validator = wxDefaultValidator,
467 char* name = "comboBox");
7bf85405 468
0122b7e3 469 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
17c0e08c 470 %pragma(python) addtomethod = "wxPreComboBox:val._setOORInfo(val)"
9c039d08 471
7bf85405
RD
472 void Copy();
473 void Cut();
7bf85405
RD
474 long GetInsertionPoint();
475 long GetLastPosition();
7bf85405 476 wxString GetValue();
7bf85405
RD
477 void Paste();
478 void Replace(long from, long to, const wxString& text);
479 void Remove(long from, long to);
7bf85405
RD
480 void SetInsertionPoint(long pos);
481 void SetInsertionPointEnd();
1d99702e 482 void SetSelection(int n);
7bf85405
RD
483 %name(SetMark)void SetSelection(long from, long to);
484 void SetValue(const wxString& text);
0adbc166 485 void SetEditable(bool editable);
7bf85405 486};
c70fd24f
RD
487#endif
488
7bf85405
RD
489
490//----------------------------------------------------------------------
491
492class wxGauge : public wxControl {
493public:
494 wxGauge(wxWindow* parent, wxWindowID id, int range,
b68dc582
RD
495 const wxPoint& pos = wxDefaultPosition,
496 const wxSize& size = wxDefaultSize,
7bf85405 497 long style = wxGA_HORIZONTAL,
b68dc582 498 const wxValidator& validator = wxDefaultValidator,
7bf85405 499 char* name = "gauge");
09f3d4e6
RD
500 %name(wxPreGauge)wxGauge();
501
502 bool Create(wxWindow* parent, wxWindowID id, int range,
503 const wxPoint& pos = wxDefaultPosition,
504 const wxSize& size = wxDefaultSize,
505 long style = wxGA_HORIZONTAL,
506 const wxValidator& validator = wxDefaultValidator,
507 char* name = "gauge");
7bf85405 508
0122b7e3 509 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
17c0e08c 510 %pragma(python) addtomethod = "wxPreGauge:val._setOORInfo(val)"
9c039d08 511
7bf85405
RD
512 int GetBezelFace();
513 int GetRange();
514 int GetShadowWidth();
515 int GetValue();
516 void SetBezelFace(int width);
517 void SetRange(int range);
518 void SetShadowWidth(int width);
519 void SetValue(int pos);
520};
521
522//----------------------------------------------------------------------
523
524class wxStaticBox : public wxControl {
525public:
526 wxStaticBox(wxWindow* parent, wxWindowID id, const wxString& label,
b68dc582
RD
527 const wxPoint& pos = wxDefaultPosition,
528 const wxSize& size = wxDefaultSize,
7bf85405
RD
529 long style = 0,
530 char* name = "staticBox");
09f3d4e6
RD
531 %name(wxPreStaticBox)wxStaticBox();
532
533 bool Create(wxWindow* parent, wxWindowID id, const wxString& label,
534 const wxPoint& pos = wxDefaultPosition,
535 const wxSize& size = wxDefaultSize,
536 long style = 0,
537 char* name = "staticBox");
0122b7e3
RD
538
539 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
17c0e08c 540 %pragma(python) addtomethod = "wxPreStaticBox:val._setOORInfo(val)"
7bf85405
RD
541};
542
543
bb0054cd
RD
544//----------------------------------------------------------------------
545
8bf5d46e 546
bb0054cd
RD
547class wxStaticLine : public wxControl {
548public:
549 wxStaticLine( wxWindow *parent, wxWindowID id,
b68dc582
RD
550 const wxPoint &pos = wxDefaultPosition,
551 const wxSize &size = wxDefaultSize,
bb0054cd 552 long style = wxLI_HORIZONTAL,
d24a34bb 553 const char* name = "staticLine" );
09f3d4e6
RD
554 %name(wxPreStaticLine)wxStaticLine();
555
556 bool Create( wxWindow *parent, wxWindowID id,
557 const wxPoint &pos = wxDefaultPosition,
558 const wxSize &size = wxDefaultSize,
559 long style = wxLI_HORIZONTAL,
560 const char* name = "staticLine" );
0122b7e3
RD
561
562 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
17c0e08c 563 %pragma(python) addtomethod = "wxPreStaticLine:val._setOORInfo(val)"
bb0054cd 564};
8bf5d46e 565
bb0054cd 566
7bf85405
RD
567//----------------------------------------------------------------------
568
569class wxStaticText : public wxControl {
570public:
571 wxStaticText(wxWindow* parent, wxWindowID id, const wxString& label,
b68dc582
RD
572 const wxPoint& pos = wxDefaultPosition,
573 const wxSize& size = wxDefaultSize,
7bf85405
RD
574 long style = 0,
575 char* name = "staticText");
09f3d4e6
RD
576 %name(wxPreStaticText)wxStaticText();
577
578 bool Create(wxWindow* parent, wxWindowID id, const wxString& label,
579 const wxPoint& pos = wxDefaultPosition,
580 const wxSize& size = wxDefaultSize,
581 long style = 0,
582 char* name = "staticText");
7bf85405 583
0122b7e3 584 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
17c0e08c 585 %pragma(python) addtomethod = "wxPreStaticText:val._setOORInfo(val)"
9c039d08 586
7bf85405
RD
587 wxString GetLabel();
588 void SetLabel(const wxString& label);
589};
590
591//----------------------------------------------------------------------
592
900d9886 593class wxListBox : public wxControlWithItems {
7bf85405
RD
594public:
595 wxListBox(wxWindow* parent, wxWindowID id,
b68dc582
RD
596 const wxPoint& pos = wxDefaultPosition,
597 const wxSize& size = wxDefaultSize,
eec92d76 598 int LCOUNT, wxString* choices = NULL,
7bf85405 599 long style = 0,
b68dc582 600 const wxValidator& validator = wxDefaultValidator,
7bf85405 601 char* name = "listBox");
09f3d4e6
RD
602 %name(wxPreListBox)wxListBox();
603
604 bool Create(wxWindow* parent, wxWindowID id,
605 const wxPoint& pos = wxDefaultPosition,
606 const wxSize& size = wxDefaultSize,
607 int LCOUNT, wxString* choices = NULL,
608 long style = 0,
609 const wxValidator& validator = wxDefaultValidator,
610 char* name = "listBox");
7bf85405 611
0122b7e3 612 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
17c0e08c 613 %pragma(python) addtomethod = "wxPreListBox:val._setOORInfo(val)"
0122b7e3 614
7bf85405 615 void Clear();
7bf85405 616 void Deselect(int n);
cf694132
RD
617
618 // int GetSelections(int **selections);
619 %addmethods {
620 PyObject* GetSelections() {
621 wxArrayInt lst;
622 self->GetSelections(lst);
623 PyObject *tup = PyTuple_New(lst.GetCount());
f6bcfd97 624 for(size_t i=0; i<lst.GetCount(); i++) {
cf694132
RD
625 PyTuple_SetItem(tup, i, PyInt_FromLong(lst[i]));
626 }
627 return tup;
628 }
629 }
630
900d9886 631
eec92d76 632 void InsertItems(int LCOUNT, wxString* choices, int pos);
2f90df85 633
0adbc166 634 bool IsSelected(const int n);
7bf85405 635 bool Selected(const int n);
eec92d76 636 void Set(int LCOUNT, wxString* choices);
7bf85405
RD
637 void SetFirstItem(int n);
638 %name(SetFirstItemStr)void SetFirstItem(const wxString& string);
639 void SetSelection(int n, bool select = TRUE);
640 void SetString(int n, const wxString& string);
641 void SetStringSelection(const wxString& string, bool select = TRUE);
642};
643
644
9c039d08
RD
645//----------------------------------------------------------------------
646
9c039d08
RD
647class wxCheckListBox : public wxListBox {
648public:
649 wxCheckListBox(wxWindow *parent, wxWindowID id,
b68dc582
RD
650 const wxPoint& pos = wxDefaultPosition,
651 const wxSize& size = wxDefaultSize,
9c039d08 652 int LCOUNT = 0,
eec92d76 653 wxString* choices = NULL,
9c039d08 654 long style = 0,
b68dc582 655 const wxValidator& validator = wxDefaultValidator,
9c039d08 656 char* name = "listBox");
09f3d4e6
RD
657 %name(wxPreCheckListBox)wxCheckListBox();
658
659 bool Create(wxWindow *parent, wxWindowID id,
660 const wxPoint& pos = wxDefaultPosition,
661 const wxSize& size = wxDefaultSize,
662 int LCOUNT = 0,
663 wxString* choices = NULL,
664 long style = 0,
665 const wxValidator& validator = wxDefaultValidator,
666 char* name = "listBox");
9c039d08 667
0122b7e3 668 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
17c0e08c 669 %pragma(python) addtomethod = "wxPreCheckListBox:val._setOORInfo(val)"
9c039d08
RD
670
671 bool IsChecked(int uiIndex);
694759cf 672 void Check(int uiIndex, int bCheck = TRUE);
eec92d76 673 void InsertItems(int LCOUNT, wxString* choices, int pos);
9c039d08 674
e6056257 675#ifndef __WXMAC__
9c039d08 676 int GetItemHeight();
e6056257 677#endif
9c039d08 678};
9c039d08 679
7bf85405
RD
680//----------------------------------------------------------------------
681
d56cebe7
RD
682
683class wxTextAttr
684{
685public:
686 // ctors
687 wxTextAttr(const wxColour& colText = wxNullColour,
688 const wxColour& colBack = wxNullColour,
689 const wxFont& font = wxNullFont);
690 ~wxTextAttr();
691
692 // setters
693 void SetTextColour(const wxColour& colText);
694 void SetBackgroundColour(const wxColour& colBack);
695 void SetFont(const wxFont& font);
696
697 // accessors
698 bool HasTextColour() const;
699 bool HasBackgroundColour() const;
700 bool HasFont() const;
701
c5943253
RD
702 wxColour GetTextColour() const;
703 wxColour GetBackgroundColour() const;
704 wxFont GetFont() const;
98624b49
RD
705
706 // returns false if we have any attributes set, true otherwise
707 bool IsDefault();
2f4e9287
RD
708
709 // return the attribute having the valid font and colours: it uses the
710 // attributes set in attr and falls back first to attrDefault and then to
711 // the text control font/colours for those attributes which are not set
712 static wxTextAttr Combine(const wxTextAttr& attr,
713 const wxTextAttr& attrDef,
714 const wxTextCtrl *text);
d56cebe7
RD
715};
716
717
718
7bf85405
RD
719class wxTextCtrl : public wxControl {
720public:
721 wxTextCtrl(wxWindow* parent, wxWindowID id, char* value = "",
b68dc582
RD
722 const wxPoint& pos = wxDefaultPosition,
723 const wxSize& size = wxDefaultSize,
7bf85405 724 long style = 0,
b68dc582 725 const wxValidator& validator = wxDefaultValidator,
7bf85405 726 char* name = "text");
09f3d4e6
RD
727 %name(wxPreTextCtrl)wxTextCtrl();
728
729 bool Create(wxWindow* parent, wxWindowID id, char* value = "",
730 const wxPoint& pos = wxDefaultPosition,
731 const wxSize& size = wxDefaultSize,
732 long style = 0,
733 const wxValidator& validator = wxDefaultValidator,
734 char* name = "text");
7bf85405 735
0122b7e3 736 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
17c0e08c 737 %pragma(python) addtomethod = "wxPreTextCtrl:val._setOORInfo(val)"
9c039d08 738
98624b49
RD
739
740 wxString GetValue() const;
741 void SetValue(const wxString& value);
742
743 int GetLineLength(long lineNo) const;
744 wxString GetLineText(long lineNo) const;
745 int GetNumberOfLines() const;
746
747 bool IsModified() const;
748 bool IsEditable() const;
749
750 // If the return values from and to are the same, there is no selection.
751 void GetSelection(long* OUTPUT, long* OUTPUT) const;
b78b83ec 752 wxString GetStringSelection();
98624b49 753
7bf85405 754 void Clear();
7bf85405 755 void Replace(long from, long to, const wxString& value);
98624b49
RD
756 void Remove(long from, long to);
757
758 // load/save the controls contents from/to the file
759 bool LoadFile(const wxString& file);
760 bool SaveFile(const wxString& file = wxEmptyString);
761
762 // clears the dirty flag
763 void DiscardEdits();
764
765 // set the max number of characters which may be entered in a single line
766 // text control
767 void SetMaxLength(unsigned long len);
768
769 // writing text inserts it at the current position, appending always
770 // inserts it at the end
7bf85405 771 void WriteText(const wxString& text);
cf694132 772 void AppendText(const wxString& text);
b1462dfa 773
98624b49
RD
774 // text control under some platforms supports the text styles: these
775 // methods allow to apply the given text style to the given selection or to
776 // set/get the style which will be used for all appended text
d56cebe7
RD
777 bool SetStyle(long start, long end, const wxTextAttr& style);
778 bool SetDefaultStyle(const wxTextAttr& style);
779 const wxTextAttr& GetDefaultStyle() const;
780
98624b49
RD
781 // translate between the position (which is just an index in the text ctrl
782 // considering all its contents as a single strings) and (x, y) coordinates
783 // which represent column and line.
784 long XYToPosition(long x, long y) const;
785 bool PositionToXY(long pos, long *OUTPUT, long *OUTPUT) const;
786
787 void ShowPosition(long pos);
788
789 // Clipboard operations
790 void Copy();
791 void Cut();
792 void Paste();
793
794 bool CanCopy() const;
795 bool CanCut() const;
796 bool CanPaste() const;
797
798 // Undo/redo
799 void Undo();
800 void Redo();
801
802 bool CanUndo() const;
803 bool CanRedo() const;
804
805 // Insertion point
806 void SetInsertionPoint(long pos);
807 void SetInsertionPointEnd();
808 long GetInsertionPoint() const;
809 long GetLastPosition() const;
810
811 void SetSelection(long from, long to);
812 void SelectAll();
813 void SetEditable(bool editable);
00b6c4e3 814
b1462dfa
RD
815 %addmethods {
816 void write(const wxString& text) {
d56cebe7 817 self->AppendText(text);
b1462dfa
RD
818 }
819 }
2f4e9287
RD
820
821 // TODO: replace this when the method is really added to wxTextCtrl
822 %addmethods {
823 wxString GetString(long from, long to) {
824 return self->GetValue().Mid(from, to-from);
825 }
826 }
7bf85405
RD
827};
828
829//----------------------------------------------------------------------
830
831class wxScrollBar : public wxControl {
832public:
833 wxScrollBar(wxWindow* parent, wxWindowID id = -1,
b68dc582
RD
834 const wxPoint& pos = wxDefaultPosition,
835 const wxSize& size = wxDefaultSize,
7bf85405 836 long style = wxSB_HORIZONTAL,
b68dc582 837 const wxValidator& validator = wxDefaultValidator,
7bf85405 838 char* name = "scrollBar");
09f3d4e6
RD
839 %name(wxPreScrollBar)wxScrollBar();
840
841 bool Create(wxWindow* parent, wxWindowID id = -1,
842 const wxPoint& pos = wxDefaultPosition,
843 const wxSize& size = wxDefaultSize,
844 long style = wxSB_HORIZONTAL,
845 const wxValidator& validator = wxDefaultValidator,
846 char* name = "scrollBar");
7bf85405 847
0122b7e3 848 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
17c0e08c 849 %pragma(python) addtomethod = "wxPreScrollBar:val._setOORInfo(val)"
9c039d08 850
7bf85405
RD
851 int GetRange();
852 int GetPageSize();
b8b8dda7 853 int GetThumbPosition();
7bf85405 854 int GetThumbSize();
26b9cf27 855 %name(GetThumbLength) int GetThumbSize(); // to match the docs
ebf4302c
RD
856
857 bool IsVertical();
858
b8b8dda7 859 void SetThumbPosition(int viewStart);
7bf85405
RD
860 void SetScrollbar(int position, int thumbSize,
861 int range, int pageSize,
862 bool refresh = TRUE);
863};
864
865//----------------------------------------------------------------------
866
867class wxSpinButton : public wxControl {
868public:
869 wxSpinButton(wxWindow* parent, wxWindowID id = -1,
b68dc582
RD
870 const wxPoint& pos = wxDefaultPosition,
871 const wxSize& size = wxDefaultSize,
7bf85405
RD
872 long style = wxSP_HORIZONTAL,
873 char* name = "spinButton");
09f3d4e6
RD
874 %name(wxPreSpinButton)wxSpinButton();
875
876 bool Create(wxWindow* parent, wxWindowID id = -1,
877 const wxPoint& pos = wxDefaultPosition,
878 const wxSize& size = wxDefaultSize,
879 long style = wxSP_HORIZONTAL,
880 char* name = "spinButton");
7bf85405 881
0122b7e3 882 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
17c0e08c 883 %pragma(python) addtomethod = "wxPreSpinButton:val._setOORInfo(val)"
0122b7e3 884
7bf85405
RD
885 int GetMax();
886 int GetMin();
887 int GetValue();
888 void SetRange(int min, int max);
889 void SetValue(int value);
890};
891
892//----------------------------------------------------------------------
893
894class wxStaticBitmap : public wxControl {
895public:
896 wxStaticBitmap(wxWindow* parent, wxWindowID id,
897 const wxBitmap& bitmap,
b68dc582
RD
898 const wxPoint& pos = wxDefaultPosition,
899 const wxSize& size = wxDefaultSize,
7bf85405
RD
900 long style = 0,
901 char* name = "staticBitmap");
09f3d4e6
RD
902 %name(wxPreStaticBitmap)wxStaticBitmap();
903
904 bool Create(wxWindow* parent, wxWindowID id,
905 const wxBitmap& bitmap,
906 const wxPoint& pos = wxDefaultPosition,
907 const wxSize& size = wxDefaultSize,
908 long style = 0,
909 char* name = "staticBitmap");
7bf85405 910
0122b7e3 911 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
17c0e08c 912 %pragma(python) addtomethod = "wxPreStaticBitmap:val._setOORInfo(val)"
9c039d08 913
c5943253 914 wxBitmap GetBitmap();
7bf85405 915 void SetBitmap(const wxBitmap& bitmap);
8bf5d46e 916 void SetIcon(const wxIcon& icon);
7bf85405
RD
917};
918
919//----------------------------------------------------------------------
920
921class wxRadioBox : public wxControl {
922public:
923 wxRadioBox(wxWindow* parent, wxWindowID id,
924 const wxString& label,
b68dc582
RD
925 const wxPoint& point = wxDefaultPosition,
926 const wxSize& size = wxDefaultSize,
eec92d76 927 int LCOUNT = 0, wxString* choices = NULL,
7bf85405
RD
928 int majorDimension = 0,
929 long style = wxRA_HORIZONTAL,
b68dc582 930 const wxValidator& validator = wxDefaultValidator,
7bf85405 931 char* name = "radioBox");
09f3d4e6
RD
932 %name(wxPreRadioBox)wxRadioBox();
933
934 bool Create(wxWindow* parent, wxWindowID id,
935 const wxString& label,
936 const wxPoint& point = wxDefaultPosition,
937 const wxSize& size = wxDefaultSize,
938 int LCOUNT = 0, wxString* choices = NULL,
939 int majorDimension = 0,
940 long style = wxRA_HORIZONTAL,
941 const wxValidator& validator = wxDefaultValidator,
942 char* name = "radioBox");
7bf85405 943
0122b7e3 944 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
17c0e08c 945 %pragma(python) addtomethod = "wxPreRadioBox:val._setOORInfo(val)"
9c039d08 946
0699c864
RD
947 void Enable(bool enable);
948 %name(EnableItem)void Enable(int n, bool enable);
7bf85405 949 int FindString(const wxString& string);
bb0054cd 950
7bf85405 951 wxString GetString(int n);
2c8a649d 952
e6056257
RD
953#ifdef __WXGTK__
954 %name(GetItemLabel)wxString GetLabel( int item );
955 %name(SetItemLabel)void SetLabel( int item, const wxString& label );
956#else
0adbc166
RD
957 void SetString(int n, const wxString& label);
958 %pragma(python) addtoclass = "
959 GetItemLabel = GetString
960 SetItemLabel = SetString
961 "
2c8a649d
RD
962 int GetColumnCount();
963 int GetRowCount();
2c8a649d
RD
964#endif
965
0adbc166 966 int GetSelection();
7bf85405 967 wxString GetStringSelection();
0adbc166
RD
968 int GetCount();
969 %pragma(python) addtoclass = "Number = GetCount"
970
7bf85405
RD
971 void SetSelection(int n);
972 void SetStringSelection(const wxString& string);
973 void Show(bool show);
974 %name(ShowItem)void Show(int item, bool show);
975};
976
977//----------------------------------------------------------------------
978
979class wxRadioButton : public wxControl {
980public:
981 wxRadioButton(wxWindow* parent, wxWindowID id,
982 const wxString& label,
b68dc582
RD
983 const wxPoint& pos = wxDefaultPosition,
984 const wxSize& size = wxDefaultSize,
7bf85405 985 long style = 0,
b68dc582 986 const wxValidator& validator = wxDefaultValidator,
7bf85405 987 char* name = "radioButton");
09f3d4e6
RD
988 %name(wxPreRadioButton)wxRadioButton();
989
990 bool Create(wxWindow* parent, wxWindowID id,
991 const wxString& label,
992 const wxPoint& pos = wxDefaultPosition,
993 const wxSize& size = wxDefaultSize,
994 long style = 0,
995 const wxValidator& validator = wxDefaultValidator,
996 char* name = "radioButton");
7bf85405 997
0122b7e3 998 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
17c0e08c 999 %pragma(python) addtomethod = "wxPreRadioButton:val._setOORInfo(val)"
9c039d08 1000
7bf85405
RD
1001 bool GetValue();
1002 void SetValue(bool value);
1003};
1004
1005//----------------------------------------------------------------------
1006
1007class wxSlider : public wxControl {
1008public:
1009 wxSlider(wxWindow* parent, wxWindowID id,
1010 int value, int minValue, int maxValue,
b68dc582
RD
1011 const wxPoint& point = wxDefaultPosition,
1012 const wxSize& size = wxDefaultSize,
7bf85405 1013 long style = wxSL_HORIZONTAL,
b68dc582 1014 const wxValidator& validator = wxDefaultValidator,
7bf85405 1015 char* name = "slider");
09f3d4e6
RD
1016 %name(wxPreSlider)wxSlider();
1017
1018 bool Create(wxWindow* parent, wxWindowID id,
1019 int value, int minValue, int maxValue,
1020 const wxPoint& point = wxDefaultPosition,
1021 const wxSize& size = wxDefaultSize,
1022 long style = wxSL_HORIZONTAL,
1023 const wxValidator& validator = wxDefaultValidator,
1024 char* name = "slider");
7bf85405 1025
0122b7e3 1026 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
17c0e08c 1027 %pragma(python) addtomethod = "wxPreSlider:val._setOORInfo(val)"
9c039d08 1028
7bf85405
RD
1029 void ClearSel();
1030 void ClearTicks();
1031 int GetLineSize();
1032 int GetMax();
1033 int GetMin();
1034 int GetPageSize();
1035 int GetSelEnd();
1036 int GetSelStart();
1037 int GetThumbLength();
1038 int GetTickFreq();
1039 int GetValue();
1040 void SetRange(int minValue, int maxValue);
1041 void SetTickFreq(int n, int pos);
1042 void SetLineSize(int lineSize);
1043 void SetPageSize(int pageSize);
1044 void SetSelection(int startPos, int endPos);
1045 void SetThumbLength(int len);
1046 void SetTick(int tickPos);
1047 void SetValue(int value);
1048};
1049
1050
1051//----------------------------------------------------------------------
1052
f6bcfd97
BP
1053class wxSpinCtrl : public wxSpinButton {
1054public:
1055 wxSpinCtrl(wxWindow *parent,
1056 wxWindowID id = -1,
1057 const char* value = "",
b68dc582
RD
1058 const wxPoint& pos = wxDefaultPosition,
1059 const wxSize& size = wxDefaultSize,
f6bcfd97
BP
1060 long style = wxSP_ARROW_KEYS,
1061 int min = 0, int max = 100, int initial = 0,
1062 const char* name = "wxSpinCtrl");
09f3d4e6
RD
1063 %name(wxPreSpinCtrl)wxSpinCtrl();
1064
1065 bool Create(wxWindow *parent,
1066 wxWindowID id = -1,
1067 const char* value = "",
1068 const wxPoint& pos = wxDefaultPosition,
1069 const wxSize& size = wxDefaultSize,
1070 long style = wxSP_ARROW_KEYS,
1071 int min = 0, int max = 100, int initial = 0,
1072 const char* name = "wxSpinCtrl");
f6bcfd97 1073
0122b7e3 1074 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
17c0e08c 1075 %pragma(python) addtomethod = "wxPreSpinCtrl:val._setOORInfo(val)"
f6bcfd97 1076
c368d904
RD
1077 int GetMax();
1078 int GetMin();
1079 int GetValue();
1080 void SetRange(int min, int max);
1081 void SetValue(int value);
1082
f6bcfd97
BP
1083};
1084
1085
1086//----------------------------------------------------------------------
1087
e6056257 1088#ifndef __WXMAC__
d1679124
RD
1089enum { wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, };
1090
1091class wxToggleButton : public wxControl {
1092public:
1093 wxToggleButton(wxWindow *parent,
1094 wxWindowID id,
1095 const wxString& label,
1096 const wxPoint& pos = wxDefaultPosition,
1097 const wxSize& size = wxDefaultSize,
1098 long style = 0,
1099 const wxValidator& validator = wxDefaultValidator,
1100 const char* name = "toggle");
09f3d4e6
RD
1101 %name(wxPreToggleButton)wxToggleButton();
1102
1103 bool Create(wxWindow *parent,
1104 wxWindowID id,
1105 const wxString& label,
1106 const wxPoint& pos = wxDefaultPosition,
1107 const wxSize& size = wxDefaultSize,
1108 long style = 0,
1109 const wxValidator& validator = wxDefaultValidator,
1110 const char* name = "toggle");
d1679124 1111
0122b7e3 1112 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
17c0e08c 1113 %pragma(python) addtomethod = "wxPreToggleButton:val._setOORInfo(val)"
0122b7e3 1114
d1679124
RD
1115 void SetValue(bool value);
1116 bool GetValue() const ;
1117 void SetLabel(const wxString& label);
1118
1119};
1120
e6056257 1121#endif
d1679124
RD
1122//----------------------------------------------------------------------
1123//----------------------------------------------------------------------
1124//----------------------------------------------------------------------
1125
c368d904
RD
1126
1127