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 {
83 wxListCtrl(wxWindow* parent, wxWindowID id,
84 const wxPoint& pos = wxPyDefaultPosition,
85 const wxSize& size = wxPyDefaultSize,
86 long style = wxLC_ICON,
87 const wxValidator& validator = wxPyDefaultValidator,
88 char* name = "listCtrl");
90 %pragma(python) addtomethod = "__init__:wxp._StdWindowCallbacks(self)"
92 bool Arrange(int flag = wxLIST_ALIGN_DEFAULT);
93 bool DeleteItem(long item);
94 bool DeleteAllItems();
95 bool DeleteColumn(int col);
97 bool DeleteAllColumns(void);
99 wxTextCtrl* EditLabel(long item);
100 bool EndEditLabel(bool cancel);
102 bool EnsureVisible(long item);
103 long FindItem(long start, const wxString& str, bool partial = FALSE);
104 %name(FindItemData)long FindItem(long start, long data);
105 %name(FindItemAtPos)long FindItem(long start, const wxPoint& pt,
107 bool GetColumn(int col, wxListItem& item);
108 int GetColumnWidth(int col);
109 int GetCountPerPage();
111 wxTextCtrl* GetEditControl();
113 wxImageList* GetImageList(int which);
114 long GetItemData(long item);
117 %new wxListItem* GetItem() {
118 wxListItem* info = new wxListItem;
119 self->GetItem(*info);
122 %new wxPoint* GetItemPosition(long item) {
123 wxPoint* pos = new wxPoint;
124 self->GetItemPosition(item, *pos);
127 %new wxRect* GetItemRect(long item, int code = wxLIST_RECT_BOUNDS) {
128 wxRect* rect= new wxRect;
129 self->GetItemRect(item, *rect, code);
134 int GetItemState(long item, long stateMask);
136 int GetItemSpacing(bool isSmall);
137 wxString GetItemText(long item);
138 long GetNextItem(long item,
139 int geometry = wxLIST_NEXT_ALL,
140 int state = wxLIST_STATE_DONTCARE);
141 int GetSelectedItemCount();
143 wxColour GetTextColour();
146 long HitTest(const wxPoint& point, int& OUTPUT);
147 %name(InsertColumnWithInfo)long InsertColumn(long col, wxListItem& info);
148 long InsertColumn(long col, const wxString& heading,
149 int format = wxLIST_FORMAT_LEFT,
152 long InsertItem(wxListItem& info);
153 %name(InsertStringItem) long InsertItem(long index, const wxString& label);
154 %name(InsertImageItem) long InsertItem(long index, int imageIndex);
155 %name(InsertImageStringItem)long InsertItem(long index, const wxString& label,
158 bool ScrollList(int dx, int dy);
159 void SetBackgroundColour(const wxColour& col);
160 bool SetColumn(int col, wxListItem& item);
161 bool SetColumnWidth(int col, int width);
162 void SetImageList(wxImageList* imageList, int which);
163 bool SetItem(wxListItem& info);
164 %name(SetItemString)long SetItem(long index, int col, const wxString& label,
166 bool SetItemData(long item, long data);
167 bool SetItemImage(long item, int image, int selImage);
168 bool SetItemPosition(long item, const wxPoint& pos);
169 bool SetItemState(long item, long state, long stateMask);
170 void SetItemText(long item, const wxString& text);
171 void SetSingleStyle(long style, bool add = TRUE);
173 void SetTextColour(const wxColour& col);
175 void SetWindowStyleFlag(long style);
176 // TODO: bool SortItems(wxListCtrlCompare fn, long data);
181 //----------------------------------------------------------------------
189 bool IsOk() const { return m_itemId != 0; }
192 // long GetId() { return (long)(*self); }
198 // **** This isn't very useful yet. This needs to be specialized to enable
199 // derived Python classes...
200 class wxTreeItemData {
205 const wxTreeItemId& GetId();
206 void SetId(const wxTreeItemId& id);
212 class wxTreeEvent : public wxCommandEvent {
214 wxTreeItemId GetItem();
215 wxTreeItemId GetOldItem();
222 // These are for the GetFirstChild/GetNextChild methods below
223 %typemap(python, in) long& INOUT = long* INOUT;
224 %typemap(python, argout) long& INOUT = long* INOUT;
227 class wxTreeCtrl : public wxControl {
229 wxTreeCtrl(wxWindow *parent, wxWindowID id = -1,
230 const wxPoint& pos = wxPyDefaultPosition,
231 const wxSize& size = wxPyDefaultSize,
232 long style = wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT,
233 const wxValidator& validator = wxPyDefaultValidator,
234 char* name = "wxTreeCtrl");
236 %pragma(python) addtomethod = "__init__:wxp._StdWindowCallbacks(self)"
239 unsigned int GetIndent();
240 void SetIndent(unsigned int indent);
241 wxImageList *GetImageList();
242 wxImageList *GetStateImageList();
243 void SetImageList(wxImageList *imageList);
244 void SetStateImageList(wxImageList *imageList);
246 wxString GetItemText(const wxTreeItemId& item);
247 int GetItemImage(const wxTreeItemId& item);
248 int GetItemSelectedImage(const wxTreeItemId& item);
249 wxTreeItemData *GetItemData(const wxTreeItemId& item);
251 void SetItemText(const wxTreeItemId& item, const wxString& text);
252 void SetItemImage(const wxTreeItemId& item, int image);
253 void SetItemSelectedImage(const wxTreeItemId& item, int image);
254 void SetItemData(const wxTreeItemId& item, wxTreeItemData *data);
256 bool IsVisible(const wxTreeItemId& item);
257 bool ItemHasChildren(const wxTreeItemId& item);
258 bool IsExpanded(const wxTreeItemId& item);
259 bool IsSelected(const wxTreeItemId& item);
261 wxTreeItemId GetRootItem();
262 wxTreeItemId GetSelection();
263 wxTreeItemId GetParent(const wxTreeItemId& item);
265 wxTreeItemId GetFirstChild(const wxTreeItemId& item, long& INOUT);
266 wxTreeItemId GetNextChild(const wxTreeItemId& item, long& INOUT);
267 wxTreeItemId GetNextSibling(const wxTreeItemId& item);
268 wxTreeItemId GetPrevSibling(const wxTreeItemId& item);
269 wxTreeItemId GetFirstVisibleItem();
270 wxTreeItemId GetNextVisible(const wxTreeItemId& item);
271 wxTreeItemId GetPrevVisible(const wxTreeItemId& item);
274 wxTreeItemId AddRoot(const wxString& text,
275 int image = -1, int selectedImage = -1,
276 wxTreeItemData *data = NULL);
277 wxTreeItemId PrependItem(const wxTreeItemId& parent,
278 const wxString& text,
279 int image = -1, int selectedImage = -1,
280 wxTreeItemData *data = NULL);
281 wxTreeItemId InsertItem(const wxTreeItemId& parent,
282 const wxTreeItemId& idPrevious,
283 const wxString& text,
284 int image = -1, int selectedImage = -1,
285 wxTreeItemData *data = NULL);
286 wxTreeItemId AppendItem(const wxTreeItemId& parent,
287 const wxString& text,
288 int image = -1, int selectedImage = -1,
289 wxTreeItemData *data = NULL);
291 void Delete(const wxTreeItemId& item);
292 void DeleteAllItems();
294 void Expand(const wxTreeItemId& item);
295 void Collapse(const wxTreeItemId& item);
296 void CollapseAndReset(const wxTreeItemId& item);
297 void Toggle(const wxTreeItemId& item);
300 void SelectItem(const wxTreeItemId& item);
301 void EnsureVisible(const wxTreeItemId& item);
302 void ScrollTo(const wxTreeItemId& item);
304 wxTextCtrl* EditLabel(const wxTreeItemId& item);
305 // **** figure out how to do this
306 // wxClassInfo* textCtrlClass = CLASSINFO(wxTextCtrl));
307 wxTextCtrl* GetEditControl();
308 void EndEditLabel(const wxTreeItemId& item, bool discardChanges = FALSE);
310 // void SortChildren(const wxTreeItemId& item);
312 // wxTreeItemCmpFunc *cmpFunction = NULL);
318 //----------------------------------------------------------------------
322 class wxTabEvent : public wxCommandEvent {
328 class wxTabCtrl : public wxControl {
330 wxTabCtrl(wxWindow* parent, wxWindowID id,
331 const wxPoint& pos = wxPyDefaultPosition,
332 const wxSize& size = wxPyDefaultSize,
334 char* name = "tabCtrl");
336 %pragma(python) addtomethod = "__init__:wxp._StdWindowCallbacks(self)"
338 bool DeleteAllItems();
339 bool DeleteItem(int item);
340 wxImageList* GetImageList();
342 // TODO: void* GetItemData();
343 int GetItemImage(int item);
346 %new wxRect* GetItemRect(int item) {
347 wxRect* rect = new wxRect;
348 self->GetItemRect(item, *rect);
353 wxString GetItemText(int item);
356 int HitTest(const wxPoint& pt, long& OUTPUT);
357 void InsertItem(int item, const wxString& text,
358 int imageId = -1, void* clientData = NULL);
359 // TODO: bool SetItemData(int item, void* data);
360 bool SetItemImage(int item, int image);
361 void SetImageList(wxImageList* imageList);
362 void SetItemSize(const wxSize& size);
363 bool SetItemText(int item, const wxString& text);
364 void SetPadding(const wxSize& padding);
365 int SetSelection(int item);
372 //----------------------------------------------------------------------
375 /////////////////////////////////////////////////////////////////////////////
378 // Revision 1.8 1998/11/11 04:40:20 RD
379 // wxTreeCtrl now works (sort of) for wxPython-GTK. This is the new
380 // TreeCtrl in src/gtk/treectrl.cpp not the old generic one.
382 // Revision 1.7 1998/11/11 03:12:25 RD
384 // Additions for wxTreeCtrl
386 // Revision 1.6 1998/10/20 06:43:55 RD
387 // New wxTreeCtrl wrappers (untested)
388 // some changes in helpers
391 // Revision 1.5 1998/10/07 07:34:33 RD
392 // Version 0.4.1 for wxGTK
394 // Revision 1.4 1998/10/02 06:40:36 RD
396 // Version 0.4 of wxPython for MSW.
398 // Revision 1.3 1998/08/18 19:48:15 RD
399 // more wxGTK compatibility things.
401 // It builds now but there are serious runtime problems...
403 // Revision 1.2 1998/08/15 07:36:30 RD
404 // - Moved the header in the .i files out of the code that gets put into
405 // the .cpp files. It caused CVS conflicts because of the RCS ID being
406 // different each time.
408 // - A few minor fixes.
410 // Revision 1.1 1998/08/09 08:25:49 RD