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