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