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