1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: More control (widget) classes for wxPython
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
17 #include <wx/listctrl.h>
18 #include <wx/treectrl.h>
20 #include <wx/tabctrl.h>
24 //----------------------------------------------------------------------
27 %include my_typemaps.i
29 // Import some definitions of other classes, etc.
37 %pragma(python) code = "import wxp"
39 //----------------------------------------------------------------------
42 extern wxValidator wxPyDefaultValidator;
45 //----------------------------------------------------------------------
49 long m_mask; // Indicates what fields are valid
50 long m_itemId; // The zero-based item position
51 int m_col; // Zero-based column, if in report mode
52 long m_state; // The state of the item
53 long m_stateMask; // Which flags of m_state are valid (uses same flags)
54 wxString m_text; // The label/header text
55 int m_image; // The zero-based index into an image list
56 long m_data; // App-defined data
57 // wxColour *m_colour; // only wxGLC, not supported by Windows ;->
60 int m_format; // left, right, centre
61 int m_width; // width of column
67 class wxListEvent: public wxCommandEvent {
81 class wxListCtrl : public wxControl {
84 wxListCtrl(wxWindow* parent, wxWindowID id,
85 const wxPoint& pos = wxPyDefaultPosition,
86 const wxSize& size = wxPyDefaultSize,
87 long style = wxLC_ICON,
88 const wxValidator& validator = wxPyDefaultValidator,
89 char* name = "listCtrl");
91 wxListCtrl(wxWindow* parent, wxWindowID id,
92 const wxPoint& pos = wxPyDefaultPosition,
93 const wxSize& size = wxPyDefaultSize,
94 long style = wxLC_ICON,
95 char* name = "listctrl");
98 %pragma(python) addtomethod = "__init__:wxp._StdWindowCallbacks(self)"
100 bool Arrange(int flag = wxLIST_ALIGN_DEFAULT);
101 bool DeleteItem(long item);
102 bool DeleteAllItems();
103 bool DeleteColumn(int col);
105 bool DeleteAllColumns(void);
107 wxTextCtrl* EditLabel(long item);
108 bool EndEditLabel(bool cancel);
110 bool EnsureVisible(long item);
111 long FindItem(long start, const wxString& str, bool partial = FALSE);
112 %name(FindItemData)long FindItem(long start, long data);
113 %name(FindItemAtPos)long FindItem(long start, const wxPoint& pt,
115 bool GetColumn(int col, wxListItem& item);
116 int GetColumnWidth(int col);
117 int GetCountPerPage();
119 wxTextCtrl* GetEditControl();
121 wxImageList* GetImageList(int which);
122 long GetItemData(long item);
125 %new wxListItem* GetItem() {
126 wxListItem* info = new wxListItem;
127 self->GetItem(*info);
130 %new wxPoint* GetItemPosition(long item) {
131 wxPoint* pos = new wxPoint;
132 self->GetItemPosition(item, *pos);
135 %new wxRect* GetItemRect(long item, int code = wxLIST_RECT_BOUNDS) {
136 wxRect* rect= new wxRect;
137 self->GetItemRect(item, *rect, code);
142 int GetItemState(long item, long stateMask);
144 int GetItemSpacing(bool isSmall);
145 wxString GetItemText(long item);
146 long GetNextItem(long item,
147 int geometry = wxLIST_NEXT_ALL,
148 int state = wxLIST_STATE_DONTCARE);
149 int GetSelectedItemCount();
151 wxColour GetTextColour();
154 long HitTest(const wxPoint& point, int& OUTPUT);
155 %name(InsertColumnWithInfo)long InsertColumn(long col, wxListItem& info);
156 long InsertColumn(long col, const wxString& heading,
157 int format = wxLIST_FORMAT_LEFT,
160 long InsertItem(wxListItem& info);
161 %name(InsertStringItem) long InsertItem(long index, const wxString& label);
162 %name(InsertImageItem) long InsertItem(long index, int imageIndex);
163 %name(InsertImageStringItem)long InsertItem(long index, const wxString& label,
166 bool ScrollList(int dx, int dy);
167 void SetBackgroundColour(const wxColour& col);
168 bool SetColumn(int col, wxListItem& item);
169 bool SetColumnWidth(int col, int width);
170 void SetImageList(wxImageList* imageList, int which);
171 bool SetItem(wxListItem& info);
172 %name(SetItemString)long SetItem(long index, int col, const wxString& label,
174 bool SetItemData(long item, long data);
175 bool SetItemImage(long item, int image, int selImage);
176 bool SetItemPosition(long item, const wxPoint& pos);
177 bool SetItemState(long item, long state, long stateMask);
178 void SetItemText(long item, const wxString& text);
179 void SetSingleStyle(long style, bool add = TRUE);
181 void SetTextColour(const wxColour& col);
183 void SetWindowStyleFlag(long style);
184 // TODO: bool SortItems(wxListCtrlCompare fn, long data);
189 //----------------------------------------------------------------------
197 bool IsOk() const { return m_itemId != 0; }
200 long GetId() { return (long)(*self); }
206 // **** This isn't very useful yet. This needs to be specialized to enable
207 // derived Python classes...
208 class wxTreeItemData {
213 const wxTreeItemId& GetId();
214 void SetId(const wxTreeItemId& id);
220 class wxTreeEvent : public wxCommandEvent {
222 wxTreeItemId GetItem();
223 wxTreeItemId GetOldItem();
230 // These are for the GetFirstChild/GetNextChild methods below
231 %typemap(python, in) long& INOUT = long* INOUT;
232 %typemap(python, argout) long& INOUT = long* INOUT;
235 class wxTreeCtrl : public wxControl {
237 wxTreeCtrl(wxWindow *parent, wxWindowID id = -1,
238 const wxPoint& pos = wxPyDefaultPosition,
239 const wxSize& size = wxPyDefaultSize,
240 long style = wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT,
241 const wxValidator& validator = wxPyDefaultValidator,
242 char* name = "wxTreeCtrl");
244 %pragma(python) addtomethod = "__init__:wxp._StdWindowCallbacks(self)"
247 unsigned int GetIndent();
248 void SetIndent(unsigned int indent);
249 wxImageList *GetImageList();
250 wxImageList *GetStateImageList();
251 void SetImageList(wxImageList *imageList);
252 void SetStateImageList(wxImageList *imageList);
254 wxString GetItemText(const wxTreeItemId& item);
255 int GetItemImage(const wxTreeItemId& item);
256 int GetItemSelectedImage(const wxTreeItemId& item);
257 wxTreeItemData *GetItemData(const wxTreeItemId& item);
259 void SetItemText(const wxTreeItemId& item, const wxString& text);
260 void SetItemImage(const wxTreeItemId& item, int image);
261 void SetItemSelectedImage(const wxTreeItemId& item, int image);
262 void SetItemData(const wxTreeItemId& item, wxTreeItemData *data);
264 bool IsVisible(const wxTreeItemId& item);
265 bool ItemHasChildren(const wxTreeItemId& item);
266 bool IsExpanded(const wxTreeItemId& item);
267 bool IsSelected(const wxTreeItemId& item);
269 wxTreeItemId GetRootItem();
270 wxTreeItemId GetSelection();
271 wxTreeItemId GetParent(const wxTreeItemId& item);
273 wxTreeItemId GetFirstChild(const wxTreeItemId& item, long& INOUT);
274 wxTreeItemId GetNextChild(const wxTreeItemId& item, long& INOUT);
275 wxTreeItemId GetNextSibling(const wxTreeItemId& item);
276 wxTreeItemId GetPrevSibling(const wxTreeItemId& item);
277 wxTreeItemId GetFirstVisibleItem();
278 wxTreeItemId GetNextVisible(const wxTreeItemId& item);
279 wxTreeItemId GetPrevVisible(const wxTreeItemId& item);
282 wxTreeItemId AddRoot(const wxString& text,
283 int image = -1, int selectedImage = -1,
284 wxTreeItemData *data = NULL);
285 wxTreeItemId PrependItem(const wxTreeItemId& parent,
286 const wxString& text,
287 int image = -1, int selectedImage = -1,
288 wxTreeItemData *data = NULL);
289 wxTreeItemId InsertItem(const wxTreeItemId& parent,
290 const wxTreeItemId& idPrevious,
291 const wxString& text,
292 int image = -1, int selectedImage = -1,
293 wxTreeItemData *data = NULL);
294 wxTreeItemId AppendItem(const wxTreeItemId& parent,
295 const wxString& text,
296 int image = -1, int selectedImage = -1,
297 wxTreeItemData *data = NULL);
299 void Delete(const wxTreeItemId& item);
300 void DeleteAllItems();
302 void Expand(const wxTreeItemId& item);
303 void Collapse(const wxTreeItemId& item);
304 void CollapseAndReset(const wxTreeItemId& item);
305 void Toggle(const wxTreeItemId& item);
308 void SelectItem(const wxTreeItemId& item);
309 void EnsureVisible(const wxTreeItemId& item);
310 void ScrollTo(const wxTreeItemId& item);
312 wxTextCtrl* EditLabel(const wxTreeItemId& item);
313 // **** figure out how to do this
314 // wxClassInfo* textCtrlClass = CLASSINFO(wxTextCtrl));
315 wxTextCtrl* GetEditControl();
316 void EndEditLabel(const wxTreeItemId& item, bool discardChanges = FALSE);
318 void SortChildren(const wxTreeItemId& item);
320 // wxTreeItemCmpFunc *cmpFunction = NULL);
326 //----------------------------------------------------------------------
330 class wxTabEvent : public wxCommandEvent {
336 class wxTabCtrl : public wxControl {
338 wxTabCtrl(wxWindow* parent, wxWindowID id,
339 const wxPoint& pos = wxPyDefaultPosition,
340 const wxSize& size = wxPyDefaultSize,
342 char* name = "tabCtrl");
344 %pragma(python) addtomethod = "__init__:wxp._StdWindowCallbacks(self)"
346 bool DeleteAllItems();
347 bool DeleteItem(int item);
348 wxImageList* GetImageList();
350 // TODO: void* GetItemData();
351 int GetItemImage(int item);
354 %new wxRect* GetItemRect(int item) {
355 wxRect* rect = new wxRect;
356 self->GetItemRect(item, *rect);
361 wxString GetItemText(int item);
364 int HitTest(const wxPoint& pt, long& OUTPUT);
365 void InsertItem(int item, const wxString& text,
366 int imageId = -1, void* clientData = NULL);
367 // TODO: bool SetItemData(int item, void* data);
368 bool SetItemImage(int item, int image);
369 void SetImageList(wxImageList* imageList);
370 void SetItemSize(const wxSize& size);
371 bool SetItemText(int item, const wxString& text);
372 void SetPadding(const wxSize& padding);
373 int SetSelection(int item);
380 //----------------------------------------------------------------------
383 /////////////////////////////////////////////////////////////////////////////
386 // Revision 1.7 1998/11/11 03:12:25 RD
387 // Additions for wxTreeCtrl
389 // Revision 1.6 1998/10/20 06:43:55 RD
390 // New wxTreeCtrl wrappers (untested)
391 // some changes in helpers
394 // Revision 1.5 1998/10/07 07:34:33 RD
395 // Version 0.4.1 for wxGTK
397 // Revision 1.4 1998/10/02 06:40:36 RD
399 // Version 0.4 of wxPython for MSW.
401 // Revision 1.3 1998/08/18 19:48:15 RD
402 // more wxGTK compatibility things.
404 // It builds now but there are serious runtime problems...
406 // Revision 1.2 1998/08/15 07:36:30 RD
407 // - Moved the header in the .i files out of the code that gets put into
408 // the .cpp files. It caused CVS conflicts because of the RCS ID being
409 // different each time.
411 // - A few minor fixes.
413 // Revision 1.1 1998/08/09 08:25:49 RD