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