]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_listbox.i
log wxChoice events in the same format as wxComboBox ones to make it simpler to compa...
[wxWidgets.git] / wxPython / src / _listbox.i
CommitLineData
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
23MAKE_CONST_WXSTRING(ListBoxNameStr);
24
25
d14a1e28
RD
26//---------------------------------------------------------------------------
27%newgroup
28
ab1f7d2a
RD
29MustHaveApp(wxListBox);
30
d14a1e28
RD
31class wxListBox : public wxControlWithItems
32{
33public:
2b9048c5
RD
34 %pythonAppend wxListBox "self._setOORInfo(self)"
35 %pythonAppend wxListBox() ""
d14a1e28 36
d5573410 37 wxListBox(wxWindow* parent, wxWindowID id=-1,
d14a1e28
RD
38 const wxPoint& pos = wxDefaultPosition,
39 const wxSize& size = wxDefaultSize,
699e192b 40 const wxArrayString& choices = wxPyEmptyStringArray,
d14a1e28
RD
41 long style = 0,
42 const wxValidator& validator = wxDefaultValidator,
43 const wxString& name = wxPyListBoxNameStr);
1b8c7ba6 44 %RenameCtor(PreListBox, wxListBox());
d14a1e28 45
d5573410 46 bool Create(wxWindow* parent, wxWindowID id=-1,
699e192b
RD
47 const wxPoint& pos = wxDefaultPosition,
48 const wxSize& size = wxDefaultSize,
699e192b
RD
49 const wxArrayString& choices = wxPyEmptyStringArray,
50 long style = 0,
51 const wxValidator& validator = wxDefaultValidator,
52 const wxString& name = wxPyListBoxNameStr);
d14a1e28
RD
53
54 // all generic methods are in wxControlWithItems...
55
56 %extend {
57 void Insert(const wxString& item, int pos, PyObject* clientData=NULL) {
58 if (clientData) {
59 wxPyClientData* data = new wxPyClientData(clientData);
60 self->Insert(item, pos, data);
61 } else
62 self->Insert(item, pos);
63 }
64 }
65
66 void InsertItems(const wxArrayString& items, int pos);
67 void Set(const wxArrayString& items/*, void **clientData = NULL */);
68
69 // multiple selection logic
70 virtual bool IsSelected(int n) const;
a72f4631 71 virtual void SetSelection(int n, bool select = true);
d14a1e28
RD
72 virtual void Select(int n);
73 void Deselect(int n);
74 void DeselectAll(int itemToLeaveSelected = -1);
75
a72f4631 76 virtual bool SetStringSelection(const wxString& s, bool select = true);
d14a1e28
RD
77
78 // works for single as well as multiple selection listboxes (unlike
79 // GetSelection which only works for listboxes with single selection)
80 //virtual int GetSelections(wxArrayInt& aSelections) const;
81 %extend {
214c4fbe
RD
82 PyObject* GetSelections() {
83 wxArrayInt lst;
84 self->GetSelections(lst);
85 PyObject *tup = PyTuple_New(lst.GetCount());
86 for(size_t i=0; i<lst.GetCount(); i++) {
87 PyTuple_SetItem(tup, i, PyInt_FromLong(lst[i]));
88 }
89 return tup;
90 }
d14a1e28
RD
91 }
92
93 // set the specified item at the first visible item or scroll to max
94 // range.
95 void SetFirstItem(int n);
1b8c7ba6 96 %Rename(SetFirstItemStr, void, SetFirstItem(const wxString& s));
d14a1e28
RD
97
98 // ensures that the given item is visible scrolling the listbox if
99 // necessary
100 virtual void EnsureVisible(int n);
101
102 // a combination of Append() and EnsureVisible(): appends the item to the
103 // listbox and ensures that it is visible i.e. not scrolled out of view
104 void AppendAndEnsureVisible(const wxString& s);
105
dd9f7fea 106 // return True if this listbox is sorted
d14a1e28 107 bool IsSorted() const;
8492b560 108
d344366c
RD
109 // return the index of the item at this position or wxNOT_FOUND
110 int HitTest(const wxPoint& pt) const;
8492b560
RD
111
112 %extend {
113 void SetItemForegroundColour(int item, const wxColour& c) {
114 %#ifdef __WXMSW__
115 if (self->GetWindowStyle() & wxLB_OWNERDRAW)
116 self->GetItem(item)->SetTextColour(c);
117 %#endif
118 }
119 void SetItemBackgroundColour(int item, const wxColour& c) {
120 %#ifdef __WXMSW__
121 if (self->GetWindowStyle() & wxLB_OWNERDRAW)
122 self->GetItem(item)->SetBackgroundColour(c);
123 %#endif
124 }
125 void SetItemFont(int item, const wxFont& f) {
126 %#ifdef __WXMSW__
127 if (self->GetWindowStyle() & wxLB_OWNERDRAW)
128 self->GetItem(item)->SetFont(f);
129 %#endif
130 }
131 }
174051f6
RD
132
133 static wxVisualAttributes
134 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
d14a1e28
RD
135};
136
137
138//---------------------------------------------------------------------------
139%newgroup
140
141
ab1f7d2a
RD
142MustHaveApp(wxCheckListBox);
143
d14a1e28
RD
144// wxCheckListBox: a listbox whose items may be checked
145class wxCheckListBox : public wxListBox
146{
147public:
2b9048c5
RD
148 %pythonAppend wxCheckListBox "self._setOORInfo(self)"
149 %pythonAppend wxCheckListBox() ""
d14a1e28 150
d5573410 151 wxCheckListBox(wxWindow *parent, wxWindowID id=-1,
d14a1e28
RD
152 const wxPoint& pos = wxDefaultPosition,
153 const wxSize& size = wxDefaultSize,
699e192b 154 const wxArrayString& choices = wxPyEmptyStringArray,
d14a1e28
RD
155 long style = 0,
156 const wxValidator& validator = wxDefaultValidator,
157 const wxString& name = wxPyListBoxNameStr);
1b8c7ba6 158 %RenameCtor(PreCheckListBox, wxCheckListBox());
d14a1e28 159
d5573410 160 bool Create(wxWindow *parent, wxWindowID id=-1,
699e192b
RD
161 const wxPoint& pos = wxDefaultPosition,
162 const wxSize& size = wxDefaultSize,
699e192b
RD
163 const wxArrayString& choices = wxPyEmptyStringArray,
164 long style = 0,
165 const wxValidator& validator = wxDefaultValidator,
166 const wxString& name = wxPyListBoxNameStr);
d14a1e28
RD
167
168 bool IsChecked(int index);
a72f4631 169 void Check(int index, int check = true);
d14a1e28 170
8dfc6457 171#if defined(__WXMSW__) || defined(__WXGTK__)
d14a1e28
RD
172 int GetItemHeight();
173#endif
174
d14a1e28
RD
175};
176
177//---------------------------------------------------------------------------