]> git.saurik.com Git - wxWidgets.git/blame - utils/wxPython/src/controls.i
some dist helpers for wxPython
[wxWidgets.git] / utils / 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>
cf694132 19#include <wx/dynarray.h>
fb5e0af0
RD
20
21#ifdef __WXMSW__
9c039d08
RD
22#if wxUSE_OWNER_DRAWN
23#include <wx/checklst.h>
24#endif
fb5e0af0 25#endif
c95e68d8
RD
26
27#ifdef __WXGTK__
28#include <wx/checklst.h>
bb0054cd 29#include <wx/statline.h>
c95e68d8 30#endif
bb0054cd 31
7bf85405
RD
32%}
33
34//----------------------------------------------------------------------
35
36%include typemaps.i
37%include my_typemaps.i
38
39// Import some definitions of other classes, etc.
40%import _defs.i
41%import misc.i
42%import windows.i
43%import gdi.i
44%import events.i
45
b8b8dda7 46%pragma(python) code = "import wx"
9c039d08 47
7bf85405
RD
48//----------------------------------------------------------------------
49
50%{
51wxValidator wxPyDefaultValidator; // Non-const default because of SWIG
52%}
53
54//----------------------------------------------------------------------
55
56class wxControl : public wxWindow {
57public:
58 void Command(wxCommandEvent& event);
fb5e0af0 59 wxString GetLabel();
7bf85405
RD
60 void SetLabel(const wxString& label);
61};
62
63//----------------------------------------------------------------------
64
65class wxButton : public wxControl {
66public:
67 wxButton(wxWindow* parent, wxWindowID id, const wxString& label,
68 const wxPoint& pos = wxPyDefaultPosition,
69 const wxSize& size = wxPyDefaultSize,
70 long style = 0,
71 const wxValidator& validator = wxPyDefaultValidator,
72 char* name = "button");
9c039d08 73
b8b8dda7 74 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
9c039d08 75
7bf85405
RD
76 void SetDefault();
77};
78
79//----------------------------------------------------------------------
80
81class wxBitmapButton : public wxButton {
82public:
83 wxBitmapButton(wxWindow* parent, wxWindowID id, const wxBitmap& bitmap,
84 const wxPoint& pos = wxPyDefaultPosition,
85 const wxSize& size = wxPyDefaultSize,
86 long style = wxBU_AUTODRAW,
87 const wxValidator& validator = wxPyDefaultValidator,
88 char* name = "button");
89
b8b8dda7 90 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
9c039d08 91
fb5e0af0 92 wxBitmap& GetBitmapLabel();
7bf85405
RD
93 wxBitmap& GetBitmapDisabled();
94 wxBitmap& GetBitmapFocus();
7bf85405
RD
95 wxBitmap& GetBitmapSelected();
96 void SetBitmapDisabled(const wxBitmap& bitmap);
97 void SetBitmapFocus(const wxBitmap& bitmap);
7bf85405 98 void SetBitmapSelected(const wxBitmap& bitmap);
fb5e0af0 99 void SetBitmapLabel(const wxBitmap& bitmap);
7bf85405
RD
100
101};
102
103//----------------------------------------------------------------------
104
105class wxCheckBox : public wxControl {
106public:
107 wxCheckBox(wxWindow* parent, wxWindowID id, const wxString& label,
108 const wxPoint& pos = wxPyDefaultPosition,
109 const wxSize& size = wxPyDefaultSize,
110 long style = 0,
111 const wxValidator& val = wxPyDefaultValidator,
112 char* name = "checkBox");
113
b8b8dda7 114 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
9c039d08 115
7bf85405
RD
116 bool GetValue();
117 void SetValue(const bool state);
118};
119
120//----------------------------------------------------------------------
121
122class wxChoice : public wxControl {
123public:
124 wxChoice(wxWindow *parent, wxWindowID id,
125 const wxPoint& pos = wxPyDefaultPosition,
126 const wxSize& size = wxPyDefaultSize,
127 int LCOUNT=0, wxString* LIST=NULL,
128 long style = 0,
129 const wxValidator& validator = wxPyDefaultValidator,
130 char* name = "choice");
131
b8b8dda7 132 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
9c039d08 133
7bf85405
RD
134 void Append(const wxString& item);
135 void Clear();
136 int FindString(const wxString& string);
137 int GetColumns();
138 int GetSelection();
139 wxString GetString(const int n);
140 wxString GetStringSelection();
141 int Number();
142 void SetColumns(const int n = 1);
143 void SetSelection(const int n);
144 void SetStringSelection(const wxString& string);
145};
146
147//----------------------------------------------------------------------
148
bb0054cd 149class wxComboBox : public wxChoice {
7bf85405
RD
150public:
151 wxComboBox(wxWindow* parent, wxWindowID id, char* value = "",
152 const wxPoint& pos = wxPyDefaultPosition,
153 const wxSize& size = wxPyDefaultSize,
154 int LCOUNT=0, wxString* LIST=NULL,
155 long style = 0,
156 const wxValidator& validator = wxPyDefaultValidator,
157 char* name = "comboBox");
158
b8b8dda7 159 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
9c039d08 160
7bf85405
RD
161 void Append(const wxString& item);
162 // TODO: void Append(const wxString& item, char* clientData);
163 void Clear();
164 void Copy();
165 void Cut();
166 void Delete(int n);
167 // NotMember??: void Deselect(int n);
168 int FindString(const wxString& string);
169 // TODO: char* GetClientData(const int n);
170 long GetInsertionPoint();
171 long GetLastPosition();
172 int GetSelection();
173 wxString GetString(int n);
174 wxString GetStringSelection();
175 wxString GetValue();
176 int Number();
177 void Paste();
178 void Replace(long from, long to, const wxString& text);
179 void Remove(long from, long to);
180 // TODO: void SetClientData(const int n, char* data);
181 void SetInsertionPoint(long pos);
182 void SetInsertionPointEnd();
bb0054cd 183 //void SetSelection(int n, int select = TRUE); **** Just use the one in wxChoice
7bf85405
RD
184 %name(SetMark)void SetSelection(long from, long to);
185 void SetValue(const wxString& text);
186};
187
188//----------------------------------------------------------------------
189
190class wxGauge : public wxControl {
191public:
192 wxGauge(wxWindow* parent, wxWindowID id, int range,
193 const wxPoint& pos = wxPyDefaultPosition,
194 const wxSize& size = wxPyDefaultSize,
195 long style = wxGA_HORIZONTAL,
196 const wxValidator& validator = wxPyDefaultValidator,
197 char* name = "gauge");
198
b8b8dda7 199 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
9c039d08 200
7bf85405
RD
201 int GetBezelFace();
202 int GetRange();
203 int GetShadowWidth();
204 int GetValue();
205 void SetBezelFace(int width);
206 void SetRange(int range);
207 void SetShadowWidth(int width);
208 void SetValue(int pos);
209};
210
211//----------------------------------------------------------------------
212
213class wxStaticBox : public wxControl {
214public:
215 wxStaticBox(wxWindow* parent, wxWindowID id, const wxString& label,
216 const wxPoint& pos = wxPyDefaultPosition,
217 const wxSize& size = wxPyDefaultSize,
218 long style = 0,
219 char* name = "staticBox");
220};
221
222
bb0054cd
RD
223//----------------------------------------------------------------------
224
225#ifdef __WXGTK__
226class wxStaticLine : public wxControl {
227public:
228 wxStaticLine( wxWindow *parent, wxWindowID id,
229 const wxPoint &pos = wxPyDefaultPosition,
230 const wxSize &size = wxPyDefaultSize,
231 long style = wxLI_HORIZONTAL,
d24a34bb 232 const char* name = "staticLine" );
bb0054cd
RD
233};
234#endif
235
7bf85405
RD
236//----------------------------------------------------------------------
237
238class wxStaticText : public wxControl {
239public:
240 wxStaticText(wxWindow* parent, wxWindowID id, const wxString& label,
241 const wxPoint& pos = wxPyDefaultPosition,
242 const wxSize& size = wxPyDefaultSize,
243 long style = 0,
244 char* name = "staticText");
245
b8b8dda7 246 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
9c039d08 247
7bf85405
RD
248 wxString GetLabel();
249 void SetLabel(const wxString& label);
250};
251
252//----------------------------------------------------------------------
253
254class wxListBox : public wxControl {
255public:
256 wxListBox(wxWindow* parent, wxWindowID id,
257 const wxPoint& pos = wxPyDefaultPosition,
258 const wxSize& size = wxPyDefaultSize,
259 int LCOUNT, wxString* LIST = NULL,
260 long style = 0,
261 const wxValidator& validator = wxPyDefaultValidator,
262 char* name = "listBox");
263
b8b8dda7 264 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
9c039d08 265
7bf85405
RD
266 void Append(const wxString& item);
267 // TODO: void Append(const wxString& item, char* clientData);
268 void Clear();
269 void Delete(int n);
270 void Deselect(int n);
271 int FindString(const wxString& string);
272 // TODO: char* GetClientData(const int n);
273 int GetSelection();
cf694132
RD
274
275 // int GetSelections(int **selections);
276 %addmethods {
277 PyObject* GetSelections() {
278 wxArrayInt lst;
279 self->GetSelections(lst);
280 PyObject *tup = PyTuple_New(lst.GetCount());
281 for(int i=0; i<lst.GetCount(); i++) {
282 PyTuple_SetItem(tup, i, PyInt_FromLong(lst[i]));
283 }
284 return tup;
285 }
286 }
287
7bf85405
RD
288 wxString GetString(int n);
289 wxString GetStringSelection();
290 int Number();
291 bool Selected(const int n);
292 void Set(int LCOUNT, wxString* LIST);
293 // TODO: void SetClientData(const int n, char* data);
294 void SetFirstItem(int n);
295 %name(SetFirstItemStr)void SetFirstItem(const wxString& string);
296 void SetSelection(int n, bool select = TRUE);
297 void SetString(int n, const wxString& string);
298 void SetStringSelection(const wxString& string, bool select = TRUE);
299};
300
301
9c039d08
RD
302//----------------------------------------------------------------------
303
9c039d08
RD
304class wxCheckListBox : public wxListBox {
305public:
306 wxCheckListBox(wxWindow *parent, wxWindowID id,
307 const wxPoint& pos = wxPyDefaultPosition,
308 const wxSize& size = wxPyDefaultSize,
309 int LCOUNT = 0,
310 wxString* LIST = NULL,
311 long style = 0,
312 const wxValidator& validator = wxPyDefaultValidator,
313 char* name = "listBox");
314
b8b8dda7 315 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
9c039d08
RD
316
317 bool IsChecked(int uiIndex);
318 void Check(int uiIndex, bool bCheck = TRUE);
319
320 int GetItemHeight();
321};
9c039d08 322
7bf85405
RD
323//----------------------------------------------------------------------
324
325class wxTextCtrl : public wxControl {
326public:
327 wxTextCtrl(wxWindow* parent, wxWindowID id, char* value = "",
328 const wxPoint& pos = wxPyDefaultPosition,
329 const wxSize& size = wxPyDefaultSize,
330 long style = 0,
331 const wxValidator& validator = wxPyDefaultValidator,
332 char* name = "text");
333
b8b8dda7 334 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
9c039d08 335
7bf85405
RD
336 void Clear();
337 void Copy();
338 void Cut();
339 void DiscardEdits();
340 long GetInsertionPoint();
341 long GetLastPosition();
342 int GetLineLength(long lineNo);
343 wxString GetLineText(long lineNo);
344 int GetNumberOfLines();
345 wxString GetValue();
346 bool IsModified();
347 bool LoadFile(const wxString& filename);
348 void Paste();
349 void PositionToXY(long pos, long *OUTPUT, long *OUTPUT);
350 void Remove(long from, long to);
351 void Replace(long from, long to, const wxString& value);
352 bool SaveFile(const wxString& filename);
353 void SetEditable(bool editable);
354 void SetInsertionPoint(long pos);
355 void SetInsertionPointEnd();
356 void SetSelection(long from, long to);
357 void SetValue(const wxString& value);
358 void ShowPosition(long pos);
359 void WriteText(const wxString& text);
cf694132 360 void AppendText(const wxString& text);
7bf85405 361 long XYToPosition(long x, long y);
d403febc
RD
362
363 bool CanCopy();
364 bool CanCut();
365 bool CanPaste();
366 bool CanRedo();
367 bool CanUndo();
368 void GetSelection(long* OUTPUT, long* OUTPUT);
369 bool IsEditable();
7bf85405
RD
370};
371
372//----------------------------------------------------------------------
373
374class wxScrollBar : public wxControl {
375public:
376 wxScrollBar(wxWindow* parent, wxWindowID id = -1,
377 const wxPoint& pos = wxPyDefaultPosition,
378 const wxSize& size = wxPyDefaultSize,
379 long style = wxSB_HORIZONTAL,
380 const wxValidator& validator = wxPyDefaultValidator,
381 char* name = "scrollBar");
382
b8b8dda7 383 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
9c039d08 384
7bf85405
RD
385 int GetRange();
386 int GetPageSize();
b8b8dda7 387 int GetThumbPosition();
7bf85405 388 int GetThumbSize();
b8b8dda7 389 void SetThumbPosition(int viewStart);
7bf85405
RD
390 void SetScrollbar(int position, int thumbSize,
391 int range, int pageSize,
392 bool refresh = TRUE);
393};
394
395//----------------------------------------------------------------------
396
397class wxSpinButton : public wxControl {
398public:
399 wxSpinButton(wxWindow* parent, wxWindowID id = -1,
400 const wxPoint& pos = wxPyDefaultPosition,
401 const wxSize& size = wxPyDefaultSize,
402 long style = wxSP_HORIZONTAL,
403 char* name = "spinButton");
404
405 int GetMax();
406 int GetMin();
407 int GetValue();
408 void SetRange(int min, int max);
409 void SetValue(int value);
410};
411
412//----------------------------------------------------------------------
413
414class wxStaticBitmap : public wxControl {
415public:
416 wxStaticBitmap(wxWindow* parent, wxWindowID id,
417 const wxBitmap& bitmap,
418 const wxPoint& pos = wxPyDefaultPosition,
419 const wxSize& size = wxPyDefaultSize,
420 long style = 0,
421 char* name = "staticBitmap");
422
b8b8dda7 423 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
9c039d08 424
cf694132 425 const wxBitmap& GetBitmap();
7bf85405
RD
426 void SetBitmap(const wxBitmap& bitmap);
427};
428
429//----------------------------------------------------------------------
430
431class wxRadioBox : public wxControl {
432public:
433 wxRadioBox(wxWindow* parent, wxWindowID id,
434 const wxString& label,
435 const wxPoint& point = wxPyDefaultPosition,
436 const wxSize& size = wxPyDefaultSize,
437 int LCOUNT = 0, wxString* LIST = NULL,
438 int majorDimension = 0,
439 long style = wxRA_HORIZONTAL,
440 const wxValidator& validator = wxPyDefaultValidator,
441 char* name = "radioBox");
442
b8b8dda7 443 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
9c039d08 444
0699c864
RD
445 void Enable(bool enable);
446 %name(EnableItem)void Enable(int n, bool enable);
7bf85405 447 int FindString(const wxString& string);
bb0054cd
RD
448
449//*** wxString GetLabel();
450//*** void SetLabel(const wxString& label);
451
0699c864 452 %name(GetItemLabel)wxString GetLabel(int n);
7bf85405
RD
453 int GetSelection();
454 wxString GetString(int n);
455 wxString GetStringSelection();
456 int Number();
0699c864 457 %name(SetItemLabel)void SetLabel(int n, const wxString& label);
7bf85405
RD
458 void SetSelection(int n);
459 void SetStringSelection(const wxString& string);
460 void Show(bool show);
461 %name(ShowItem)void Show(int item, bool show);
462};
463
464//----------------------------------------------------------------------
465
466class wxRadioButton : public wxControl {
467public:
468 wxRadioButton(wxWindow* parent, wxWindowID id,
469 const wxString& label,
470 const wxPoint& pos = wxPyDefaultPosition,
471 const wxSize& size = wxPyDefaultSize,
472 long style = 0,
473 const wxValidator& validator = wxPyDefaultValidator,
474 char* name = "radioButton");
475
b8b8dda7 476 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
9c039d08 477
7bf85405
RD
478 bool GetValue();
479 void SetValue(bool value);
480};
481
482//----------------------------------------------------------------------
483
484class wxSlider : public wxControl {
485public:
486 wxSlider(wxWindow* parent, wxWindowID id,
487 int value, int minValue, int maxValue,
488 const wxPoint& point = wxPyDefaultPosition,
489 const wxSize& size = wxPyDefaultSize,
490 long style = wxSL_HORIZONTAL,
491 const wxValidator& validator = wxPyDefaultValidator,
492 char* name = "slider");
493
b8b8dda7 494 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
9c039d08 495
7bf85405
RD
496 void ClearSel();
497 void ClearTicks();
498 int GetLineSize();
499 int GetMax();
500 int GetMin();
501 int GetPageSize();
502 int GetSelEnd();
503 int GetSelStart();
504 int GetThumbLength();
505 int GetTickFreq();
506 int GetValue();
507 void SetRange(int minValue, int maxValue);
508 void SetTickFreq(int n, int pos);
509 void SetLineSize(int lineSize);
510 void SetPageSize(int pageSize);
511 void SetSelection(int startPos, int endPos);
512 void SetThumbLength(int len);
513 void SetTick(int tickPos);
514 void SetValue(int value);
515};
516
517
518//----------------------------------------------------------------------
519
520
521/////////////////////////////////////////////////////////////////////////////
522//
523// $Log$
d24a34bb
RD
524// Revision 1.15 1999/06/22 17:45:18 RD
525// wxPython 2.1b1: Very minor changes needed for wxGTK
526//
bb0054cd 527// Revision 1.14 1999/06/22 07:03:02 RD
d24a34bb 528//
bb0054cd
RD
529// wxPython 2.1b1 for wxMSW (wxGTK coming soon)
530// Lots of changes, see the README.txt for details...
531//
d403febc 532// Revision 1.13 1999/04/30 21:13:43 RD
bb0054cd 533//
d403febc
RD
534// wxPython 2.0b9, first phase (win32)
535// Added gobs of stuff, see wxPython/README.txt for details
536//
cf694132 537// Revision 1.12 1999/04/30 03:29:18 RD
d403febc 538//
cf694132
RD
539// wxPython 2.0b9, first phase (win32)
540// Added gobs of stuff, see wxPython/README.txt for details
541//
542// Revision 1.11.4.1 1999/03/27 23:29:14 RD
543//
544// wxPython 2.0b8
545// Python thread support
546// various minor additions
547// various minor fixes
548//
0699c864 549// Revision 1.11 1999/02/25 07:08:30 RD
cf694132 550//
0699c864
RD
551// wxPython version 2.0b5
552//
c95e68d8 553// Revision 1.10 1998/12/17 17:52:19 RD
0699c864 554//
c95e68d8
RD
555// wxPython 0.5.2
556// Minor fixes and SWIG code generation for RR's changes. MSW and GTK
557// versions are much closer now!
558//
4f22cf8d 559// Revision 1.9 1998/12/17 14:07:29 RR
c95e68d8 560//
4f22cf8d
RR
561// Removed minor differences between wxMSW and wxGTK
562//
b8b8dda7
RD
563// Revision 1.8 1998/12/15 20:41:15 RD
564// Changed the import semantics from "from wxPython import *" to "from
565// wxPython.wx import *" This is for people who are worried about
566// namespace pollution, they can use "from wxPython import wx" and then
567// prefix all the wxPython identifiers with "wx."
568//
569// Added wxTaskbarIcon for wxMSW.
570//
571// Made the events work for wxGrid.
572//
573// Added wxConfig.
574//
575// Added wxMiniFrame for wxGTK, (untested.)
576//
577// Changed many of the args and return values that were pointers to gdi
578// objects to references to reflect changes in the wxWindows API.
579//
580// Other assorted fixes and additions.
581//
62bd0874
RD
582// Revision 1.7 1998/11/16 00:00:53 RD
583// Generic treectrl for wxPython/GTK compiles...
584//
faf3cb35
RD
585// Revision 1.6 1998/11/15 23:03:43 RD
586// Removing some ifdef's for wxGTK
587//
b26e2dc4
RD
588// Revision 1.5 1998/10/07 07:34:32 RD
589// Version 0.4.1 for wxGTK
590//
9c039d08 591// Revision 1.4 1998/10/02 06:40:35 RD
b26e2dc4 592//
9c039d08
RD
593// Version 0.4 of wxPython for MSW.
594//
fb5e0af0
RD
595// Revision 1.3 1998/08/18 19:48:14 RD
596// more wxGTK compatibility things.
597//
598// It builds now but there are serious runtime problems...
599//
03e9bead
RD
600// Revision 1.2 1998/08/15 07:36:28 RD
601// - Moved the header in the .i files out of the code that gets put into
602// the .cpp files. It caused CVS conflicts because of the RCS ID being
603// different each time.
604//
605// - A few minor fixes.
606//
7bf85405
RD
607// Revision 1.1 1998/08/09 08:25:49 RD
608// Initial version
609//
610//
611