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>
21 //----------------------------------------------------------------------
24 %include my_typemaps.i
26 // Import some definitions of other classes, etc.
34 %pragma(python) code = "import wx"
36 //----------------------------------------------------------------------
39 extern wxValidator wxPyDefaultValidator;
42 //----------------------------------------------------------------------
46 long m_mask; // Indicates what fields are valid
47 long m_itemId; // The zero-based item position
48 int m_col; // Zero-based column, if in report mode
49 long m_state; // The state of the item
50 long m_stateMask; // Which flags of m_state are valid (uses same flags)
51 wxString m_text; // The label/header text
52 int m_image; // The zero-based index into an image list
53 long m_data; // App-defined data
54 // wxColour *m_colour; // only wxGLC, not supported by Windows ;->
57 int m_format; // left, right, centre
58 int m_width; // width of column
64 class wxListEvent: public wxCommandEvent {
78 class wxListCtrl : public wxControl {
80 wxListCtrl(wxWindow* parent, wxWindowID id,
81 const wxPoint& pos = wxPyDefaultPosition,
82 const wxSize& size = wxPyDefaultSize,
83 long style = wxLC_ICON,
84 const wxValidator& validator = wxPyDefaultValidator,
85 char* name = "listCtrl");
87 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
89 bool Arrange(int flag = wxLIST_ALIGN_DEFAULT);
90 bool DeleteItem(long item);
91 bool DeleteAllItems();
92 bool DeleteColumn(int col);
93 bool DeleteAllColumns(void);
96 wxTextCtrl* EditLabel(long item);
97 bool EndEditLabel(bool cancel);
98 wxTextCtrl* GetEditControl();
100 bool EnsureVisible(long item);
101 long FindItem(long start, const wxString& str, bool partial = FALSE);
102 %name(FindItemData)long FindItem(long start, long data);
103 %name(FindItemAtPos)long FindItem(long start, const wxPoint& pt,
105 bool GetColumn(int col, wxListItem& item);
106 int GetColumnWidth(int col);
107 int GetCountPerPage();
108 wxImageList* GetImageList(int which);
109 long GetItemData(long item);
112 %new wxListItem* GetItem() {
113 wxListItem* info = new wxListItem;
114 self->GetItem(*info);
117 %new wxPoint* GetItemPosition(long item) {
118 wxPoint* pos = new wxPoint;
119 self->GetItemPosition(item, *pos);
122 %new wxRect* GetItemRect(long item, int code = wxLIST_RECT_BOUNDS) {
123 wxRect* rect= new wxRect;
124 self->GetItemRect(item, *rect, code);
129 int GetItemState(long item, long stateMask);
131 int GetItemSpacing(bool isSmall);
132 wxString GetItemText(long item);
133 long GetNextItem(long item,
134 int geometry = wxLIST_NEXT_ALL,
135 int state = wxLIST_STATE_DONTCARE);
136 int GetSelectedItemCount();
138 wxColour GetTextColour();
139 void SetTextColour(const wxColour& col);
142 long HitTest(const wxPoint& point, int& OUTPUT);
143 %name(InsertColumnWithInfo)long InsertColumn(long col, wxListItem& info);
144 long InsertColumn(long col, const wxString& heading,
145 int format = wxLIST_FORMAT_LEFT,
148 long InsertItem(wxListItem& info);
149 %name(InsertStringItem) long InsertItem(long index, const wxString& label);
150 %name(InsertImageItem) long InsertItem(long index, int imageIndex);
151 %name(InsertImageStringItem)long InsertItem(long index, const wxString& label,
154 bool ScrollList(int dx, int dy);
155 void SetBackgroundColour(const wxColour& col);
156 bool SetColumn(int col, wxListItem& item);
157 bool SetColumnWidth(int col, int width);
158 void SetImageList(wxImageList* imageList, int which);
159 bool SetItem(wxListItem& info);
160 %name(SetItemString)long SetItem(long index, int col, const wxString& label,
162 bool SetItemData(long item, long data);
163 bool SetItemImage(long item, int image, int selImage);
164 bool SetItemPosition(long item, const wxPoint& pos);
165 bool SetItemState(long item, long state, long stateMask);
166 void SetItemText(long item, const wxString& text);
167 void SetSingleStyle(long style, bool add = TRUE);
168 void SetWindowStyleFlag(long style);
169 // TODO: bool SortItems(wxListCtrlCompare fn, long data);
174 //----------------------------------------------------------------------
181 bool IsOk() const { return m_itemId != 0; }
184 // long GetId() { return (long)(*self); }
190 // **** This isn't very useful yet. This needs to be specialized to enable
191 // derived Python classes...
192 class wxTreeItemData {
197 const wxTreeItemId& GetId();
198 void SetId(const wxTreeItemId& id);
204 class wxTreeEvent : public wxCommandEvent {
206 wxTreeItemId GetItem();
207 wxTreeItemId GetOldItem();
214 // These are for the GetFirstChild/GetNextChild methods below
215 %typemap(python, in) long& INOUT = long* INOUT;
216 %typemap(python, argout) long& INOUT = long* INOUT;
219 class wxTreeCtrl : public wxControl {
221 wxTreeCtrl(wxWindow *parent, wxWindowID id = -1,
222 const wxPoint& pos = wxPyDefaultPosition,
223 const wxSize& size = wxPyDefaultSize,
224 long style = wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT,
225 const wxValidator& validator = wxPyDefaultValidator,
226 char* name = "wxTreeCtrl");
228 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
231 unsigned int GetIndent();
232 void SetIndent(unsigned int indent);
233 wxImageList *GetImageList();
234 wxImageList *GetStateImageList();
235 void SetImageList(wxImageList *imageList);
236 void SetStateImageList(wxImageList *imageList);
238 wxString GetItemText(const wxTreeItemId& item);
239 int GetItemImage(const wxTreeItemId& item);
240 int GetItemSelectedImage(const wxTreeItemId& item);
241 wxTreeItemData *GetItemData(const wxTreeItemId& item);
243 void SetItemText(const wxTreeItemId& item, const wxString& text);
244 void SetItemImage(const wxTreeItemId& item, int image);
245 void SetItemSelectedImage(const wxTreeItemId& item, int image);
246 void SetItemData(const wxTreeItemId& item, wxTreeItemData *data);
248 bool IsVisible(const wxTreeItemId& item);
249 bool ItemHasChildren(const wxTreeItemId& item);
250 bool IsExpanded(const wxTreeItemId& item);
251 bool IsSelected(const wxTreeItemId& item);
253 wxTreeItemId GetRootItem();
254 wxTreeItemId GetSelection();
255 wxTreeItemId GetParent(const wxTreeItemId& item);
257 wxTreeItemId GetFirstChild(const wxTreeItemId& item, long& INOUT);
258 wxTreeItemId GetNextChild(const wxTreeItemId& item, long& INOUT);
259 wxTreeItemId GetNextSibling(const wxTreeItemId& item);
260 wxTreeItemId GetPrevSibling(const wxTreeItemId& item);
261 wxTreeItemId GetFirstVisibleItem();
262 wxTreeItemId GetNextVisible(const wxTreeItemId& item);
263 wxTreeItemId GetPrevVisible(const wxTreeItemId& item);
266 wxTreeItemId AddRoot(const wxString& text,
267 int image = -1, int selectedImage = -1,
268 wxTreeItemData *data = NULL);
269 wxTreeItemId PrependItem(const wxTreeItemId& parent,
270 const wxString& text,
271 int image = -1, int selectedImage = -1,
272 wxTreeItemData *data = NULL);
273 wxTreeItemId InsertItem(const wxTreeItemId& parent,
274 const wxTreeItemId& idPrevious,
275 const wxString& text,
276 int image = -1, int selectedImage = -1,
277 wxTreeItemData *data = NULL);
278 wxTreeItemId AppendItem(const wxTreeItemId& parent,
279 const wxString& text,
280 int image = -1, int selectedImage = -1,
281 wxTreeItemData *data = NULL);
283 void Delete(const wxTreeItemId& item);
284 void DeleteAllItems();
286 void Expand(const wxTreeItemId& item);
287 void Collapse(const wxTreeItemId& item);
288 void CollapseAndReset(const wxTreeItemId& item);
289 void Toggle(const wxTreeItemId& item);
292 void SelectItem(const wxTreeItemId& item);
293 void EnsureVisible(const wxTreeItemId& item);
294 void ScrollTo(const wxTreeItemId& item);
296 wxTextCtrl* EditLabel(const wxTreeItemId& item);
297 // **** figure out how to do this
298 // wxClassInfo* textCtrlClass = CLASSINFO(wxTextCtrl));
299 wxTextCtrl* GetEditControl();
300 void EndEditLabel(const wxTreeItemId& item, bool discardChanges = FALSE);
302 // void SortChildren(const wxTreeItemId& item);
304 // wxTreeItemCmpFunc *cmpFunction = NULL);
306 void SetItemBold(const wxTreeItemId& item, bool bold = TRUE);
307 bool IsBold(const wxTreeItemId& item) const;
308 wxTreeItemId HitTest(const wxPoint& point);
312 //----------------------------------------------------------------------
316 class wxTabEvent : public wxCommandEvent {
322 class wxTabCtrl : public wxControl {
324 wxTabCtrl(wxWindow* parent, wxWindowID id,
325 const wxPoint& pos = wxPyDefaultPosition,
326 const wxSize& size = wxPyDefaultSize,
328 char* name = "tabCtrl");
330 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
332 bool DeleteAllItems();
333 bool DeleteItem(int item);
334 wxImageList* GetImageList();
336 // TODO: void* GetItemData();
337 int GetItemImage(int item);
340 %new wxRect* GetItemRect(int item) {
341 wxRect* rect = new wxRect;
342 self->GetItemRect(item, *rect);
347 wxString GetItemText(int item);
350 int HitTest(const wxPoint& pt, long& OUTPUT);
351 void InsertItem(int item, const wxString& text,
352 int imageId = -1, void* clientData = NULL);
353 // TODO: bool SetItemData(int item, void* data);
354 bool SetItemImage(int item, int image);
355 void SetImageList(wxImageList* imageList);
356 void SetItemSize(const wxSize& size);
357 bool SetItemText(int item, const wxString& text);
358 void SetPadding(const wxSize& padding);
359 int SetSelection(int item);
366 //----------------------------------------------------------------------
369 /////////////////////////////////////////////////////////////////////////////
372 // Revision 1.13 1998/12/17 14:07:34 RR
373 // Removed minor differences between wxMSW and wxGTK
375 // Revision 1.12 1998/12/16 22:10:52 RD
377 // Tweaks needed to be able to build wxPython with wxGTK.
379 // Revision 1.11 1998/12/15 20:41:16 RD
380 // Changed the import semantics from "from wxPython import *" to "from
381 // wxPython.wx import *" This is for people who are worried about
382 // namespace pollution, they can use "from wxPython import wx" and then
383 // prefix all the wxPython identifiers with "wx."
385 // Added wxTaskbarIcon for wxMSW.
387 // Made the events work for wxGrid.
391 // Added wxMiniFrame for wxGTK, (untested.)
393 // Changed many of the args and return values that were pointers to gdi
394 // objects to references to reflect changes in the wxWindows API.
396 // Other assorted fixes and additions.
398 // Revision 1.10 1998/11/25 08:45:23 RD
400 // Added wxPalette, wxRegion, wxRegionIterator, wxTaskbarIcon
401 // Added events for wxGrid
402 // Other various fixes and additions
404 // Revision 1.9 1998/11/16 00:00:54 RD
405 // Generic treectrl for wxPython/GTK compiles...
407 // Revision 1.8 1998/11/11 04:40:20 RD
408 // wxTreeCtrl now works (sort of) for wxPython-GTK. This is the new
409 // TreeCtrl in src/gtk/treectrl.cpp not the old generic one.
411 // Revision 1.7 1998/11/11 03:12:25 RD
413 // Additions for wxTreeCtrl
415 // Revision 1.6 1998/10/20 06:43:55 RD
416 // New wxTreeCtrl wrappers (untested)
417 // some changes in helpers
420 // Revision 1.5 1998/10/07 07:34:33 RD
421 // Version 0.4.1 for wxGTK
423 // Revision 1.4 1998/10/02 06:40:36 RD
425 // Version 0.4 of wxPython for MSW.
427 // Revision 1.3 1998/08/18 19:48:15 RD
428 // more wxGTK compatibility things.
430 // It builds now but there are serious runtime problems...
432 // Revision 1.2 1998/08/15 07:36:30 RD
433 // - Moved the header in the .i files out of the code that gets put into
434 // the .cpp files. It caused CVS conflicts because of the RCS ID being
435 // different each time.
437 // - A few minor fixes.
439 // Revision 1.1 1998/08/09 08:25:49 RD