]>
Commit | Line | Data |
---|---|---|
d14a1e28 RD |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: _listbox.i | |
3 | // Purpose: SWIG interface defs for wxListBox and wxCheckListBox | |
4 | // | |
5 | // Author: Robin Dunn | |
6 | // | |
7 | // Created: 10-June-1998 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) 2003 by Total Control Software | |
10 | // Licence: wxWindows license | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | // Not a %module | |
14 | ||
15 | ||
16 | //--------------------------------------------------------------------------- | |
17 | ||
18 | %{ | |
19 | #include <wx/checklst.h> | |
20 | ||
d14a1e28 RD |
21 | %} |
22 | ||
b2dc1044 RD |
23 | MAKE_CONST_WXSTRING(ListBoxNameStr); |
24 | ||
25 | ||
d14a1e28 RD |
26 | //--------------------------------------------------------------------------- |
27 | %newgroup | |
28 | ||
29 | class wxListBox : public wxControlWithItems | |
30 | { | |
31 | public: | |
32 | %addtofunc wxListBox "self._setOORInfo(self)" | |
33 | %addtofunc wxListBox() "" | |
34 | ||
35 | wxListBox(wxWindow* parent, wxWindowID id, | |
36 | const wxPoint& pos = wxDefaultPosition, | |
37 | const wxSize& size = wxDefaultSize, | |
38 | int choices=0, wxString* choices_array = NULL, | |
39 | long style = 0, | |
40 | const wxValidator& validator = wxDefaultValidator, | |
41 | const wxString& name = wxPyListBoxNameStr); | |
42 | %name(PreListBox)wxListBox(); | |
43 | ||
44 | bool Create(wxWindow* parent, wxWindowID id, | |
45 | const wxPoint& pos = wxDefaultPosition, | |
46 | const wxSize& size = wxDefaultSize, | |
47 | int choices=0, wxString* choices_array = NULL, | |
48 | long style = 0, | |
49 | const wxValidator& validator = wxDefaultValidator, | |
50 | const wxString& name = wxPyListBoxNameStr); | |
51 | ||
52 | // all generic methods are in wxControlWithItems... | |
53 | ||
54 | %extend { | |
55 | void Insert(const wxString& item, int pos, PyObject* clientData=NULL) { | |
56 | if (clientData) { | |
57 | wxPyClientData* data = new wxPyClientData(clientData); | |
58 | self->Insert(item, pos, data); | |
59 | } else | |
60 | self->Insert(item, pos); | |
61 | } | |
62 | } | |
63 | ||
64 | void InsertItems(const wxArrayString& items, int pos); | |
65 | void Set(const wxArrayString& items/*, void **clientData = NULL */); | |
66 | ||
67 | // multiple selection logic | |
68 | virtual bool IsSelected(int n) const; | |
dd9f7fea | 69 | virtual void SetSelection(int n, bool select = True); |
d14a1e28 RD |
70 | virtual void Select(int n); |
71 | void Deselect(int n); | |
72 | void DeselectAll(int itemToLeaveSelected = -1); | |
73 | ||
dd9f7fea | 74 | virtual bool SetStringSelection(const wxString& s, bool select = True); |
d14a1e28 RD |
75 | |
76 | // works for single as well as multiple selection listboxes (unlike | |
77 | // GetSelection which only works for listboxes with single selection) | |
78 | //virtual int GetSelections(wxArrayInt& aSelections) const; | |
79 | %extend { | |
80 | PyObject* GetSelections() { | |
81 | wxArrayInt lst; | |
82 | self->GetSelections(lst); | |
83 | PyObject *tup = PyTuple_New(lst.GetCount()); | |
84 | for(size_t i=0; i<lst.GetCount(); i++) { | |
85 | PyTuple_SetItem(tup, i, PyInt_FromLong(lst[i])); | |
86 | } | |
87 | return tup; | |
88 | } | |
89 | } | |
90 | ||
91 | // set the specified item at the first visible item or scroll to max | |
92 | // range. | |
93 | void SetFirstItem(int n); | |
94 | %name(SetFirstItemStr) void SetFirstItem(const wxString& s); | |
95 | ||
96 | // ensures that the given item is visible scrolling the listbox if | |
97 | // necessary | |
98 | virtual void EnsureVisible(int n); | |
99 | ||
100 | // a combination of Append() and EnsureVisible(): appends the item to the | |
101 | // listbox and ensures that it is visible i.e. not scrolled out of view | |
102 | void AppendAndEnsureVisible(const wxString& s); | |
103 | ||
dd9f7fea | 104 | // return True if this listbox is sorted |
d14a1e28 RD |
105 | bool IsSorted() const; |
106 | }; | |
107 | ||
108 | ||
109 | //--------------------------------------------------------------------------- | |
110 | %newgroup | |
111 | ||
112 | ||
113 | // wxCheckListBox: a listbox whose items may be checked | |
114 | class wxCheckListBox : public wxListBox | |
115 | { | |
116 | public: | |
117 | %addtofunc wxListBox "self._setOORInfo(self)" | |
118 | %addtofunc wxListBox() "" | |
119 | ||
120 | wxCheckListBox(wxWindow *parent, wxWindowID id, | |
121 | const wxPoint& pos = wxDefaultPosition, | |
122 | const wxSize& size = wxDefaultSize, | |
123 | int choices = 0, wxString* choices_array = NULL, | |
124 | long style = 0, | |
125 | const wxValidator& validator = wxDefaultValidator, | |
126 | const wxString& name = wxPyListBoxNameStr); | |
127 | %name(PreCheckListBox)wxCheckListBox(); | |
128 | ||
129 | bool Create(wxWindow *parent, wxWindowID id, | |
130 | const wxPoint& pos = wxDefaultPosition, | |
131 | const wxSize& size = wxDefaultSize, | |
132 | int choices = 0, wxString* choices_array = NULL, | |
133 | long style = 0, | |
134 | const wxValidator& validator = wxDefaultValidator, | |
135 | const wxString& name = wxPyListBoxNameStr); | |
136 | ||
137 | bool IsChecked(int index); | |
dd9f7fea | 138 | void Check(int index, int check = True); |
d14a1e28 RD |
139 | |
140 | #ifndef __WXMAC__ | |
141 | int GetItemHeight(); | |
142 | #endif | |
143 | ||
144 | // return the index of the item at this position or wxNOT_FOUND | |
145 | int HitTest(const wxPoint& pt) const; | |
146 | %name(HitTestXY)int HitTest(wxCoord x, wxCoord y) const; | |
147 | }; | |
148 | ||
149 | //--------------------------------------------------------------------------- |