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