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);
247 void SetItemHasChildren(const wxTreeItemId& item, bool hasChildren = TRUE);
249 bool IsVisible(const wxTreeItemId& item);
250 bool ItemHasChildren(const wxTreeItemId& item);
251 bool IsExpanded(const wxTreeItemId& item);
252 bool IsSelected(const wxTreeItemId& item);
254 wxTreeItemId GetRootItem();
255 wxTreeItemId GetSelection();
256 wxTreeItemId GetParent(const wxTreeItemId& item);
258 wxTreeItemId GetFirstChild(const wxTreeItemId& item, long& INOUT);
259 wxTreeItemId GetNextChild(const wxTreeItemId& item, long& INOUT);
260 wxTreeItemId GetNextSibling(const wxTreeItemId& item);
261 wxTreeItemId GetPrevSibling(const wxTreeItemId& item);
262 wxTreeItemId GetFirstVisibleItem();
263 wxTreeItemId GetNextVisible(const wxTreeItemId& item);
264 wxTreeItemId GetPrevVisible(const wxTreeItemId& item);
267 wxTreeItemId AddRoot(const wxString& text,
268 int image = -1, int selectedImage = -1,
269 wxTreeItemData *data = NULL);
270 wxTreeItemId PrependItem(const wxTreeItemId& parent,
271 const wxString& text,
272 int image = -1, int selectedImage = -1,
273 wxTreeItemData *data = NULL);
274 wxTreeItemId InsertItem(const wxTreeItemId& parent,
275 const wxTreeItemId& idPrevious,
276 const wxString& text,
277 int image = -1, int selectedImage = -1,
278 wxTreeItemData *data = NULL);
279 wxTreeItemId AppendItem(const wxTreeItemId& parent,
280 const wxString& text,
281 int image = -1, int selectedImage = -1,
282 wxTreeItemData *data = NULL);
284 void Delete(const wxTreeItemId& item);
285 void DeleteChildren(const wxTreeItemId& item);
286 void DeleteAllItems();
288 void Expand(const wxTreeItemId& item);
289 void Collapse(const wxTreeItemId& item);
290 void CollapseAndReset(const wxTreeItemId& item);
291 void Toggle(const wxTreeItemId& item);
294 void SelectItem(const wxTreeItemId& item);
295 void EnsureVisible(const wxTreeItemId& item);
296 void ScrollTo(const wxTreeItemId& item);
298 wxTextCtrl* EditLabel(const wxTreeItemId& item);
299 // **** figure out how to do this
300 // wxClassInfo* textCtrlClass = CLASSINFO(wxTextCtrl));
301 wxTextCtrl* GetEditControl();
302 void EndEditLabel(const wxTreeItemId& item, bool discardChanges = FALSE);
304 // void SortChildren(const wxTreeItemId& item);
306 // wxTreeItemCmpFunc *cmpFunction = NULL);
308 void SetItemBold(const wxTreeItemId& item, bool bold = TRUE);
309 bool IsBold(const wxTreeItemId& item) const;
310 wxTreeItemId HitTest(const wxPoint& point);
314 //----------------------------------------------------------------------
318 class wxTabEvent : public wxCommandEvent {
324 class wxTabCtrl : public wxControl {
326 wxTabCtrl(wxWindow* parent, wxWindowID id,
327 const wxPoint& pos = wxPyDefaultPosition,
328 const wxSize& size = wxPyDefaultSize,
330 char* name = "tabCtrl");
332 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
334 bool DeleteAllItems();
335 bool DeleteItem(int item);
336 wxImageList* GetImageList();
338 // TODO: void* GetItemData();
339 int GetItemImage(int item);
342 %new wxRect* GetItemRect(int item) {
343 wxRect* rect = new wxRect;
344 self->GetItemRect(item, *rect);
349 wxString GetItemText(int item);
352 int HitTest(const wxPoint& pt, long& OUTPUT);
353 void InsertItem(int item, const wxString& text,
354 int imageId = -1, void* clientData = NULL);
355 // TODO: bool SetItemData(int item, void* data);
356 bool SetItemImage(int item, int image);
357 void SetImageList(wxImageList* imageList);
358 void SetItemSize(const wxSize& size);
359 bool SetItemText(int item, const wxString& text);
360 void SetPadding(const wxSize& padding);
361 int SetSelection(int item);
368 //----------------------------------------------------------------------
371 /////////////////////////////////////////////////////////////////////////////
374 // Revision 1.14 1999/01/30 07:30:10 RD
375 // Added wxSashWindow, wxSashEvent, wxLayoutAlgorithm, etc.
377 // Various cleanup, tweaks, minor additions, etc. to maintain
378 // compatibility with the current wxWindows.
380 // Revision 1.13 1998/12/17 14:07:34 RR
382 // Removed minor differences between wxMSW and wxGTK
384 // Revision 1.12 1998/12/16 22:10:52 RD
386 // Tweaks needed to be able to build wxPython with wxGTK.
388 // Revision 1.11 1998/12/15 20:41:16 RD
389 // Changed the import semantics from "from wxPython import *" to "from
390 // wxPython.wx import *" This is for people who are worried about
391 // namespace pollution, they can use "from wxPython import wx" and then
392 // prefix all the wxPython identifiers with "wx."
394 // Added wxTaskbarIcon for wxMSW.
396 // Made the events work for wxGrid.
400 // Added wxMiniFrame for wxGTK, (untested.)
402 // Changed many of the args and return values that were pointers to gdi
403 // objects to references to reflect changes in the wxWindows API.
405 // Other assorted fixes and additions.
407 // Revision 1.10 1998/11/25 08:45:23 RD
409 // Added wxPalette, wxRegion, wxRegionIterator, wxTaskbarIcon
410 // Added events for wxGrid
411 // Other various fixes and additions
413 // Revision 1.9 1998/11/16 00:00:54 RD
414 // Generic treectrl for wxPython/GTK compiles...
416 // Revision 1.8 1998/11/11 04:40:20 RD
417 // wxTreeCtrl now works (sort of) for wxPython-GTK. This is the new
418 // TreeCtrl in src/gtk/treectrl.cpp not the old generic one.
420 // Revision 1.7 1998/11/11 03:12:25 RD
422 // Additions for wxTreeCtrl
424 // Revision 1.6 1998/10/20 06:43:55 RD
425 // New wxTreeCtrl wrappers (untested)
426 // some changes in helpers
429 // Revision 1.5 1998/10/07 07:34:33 RD
430 // Version 0.4.1 for wxGTK
432 // Revision 1.4 1998/10/02 06:40:36 RD
434 // Version 0.4 of wxPython for MSW.
436 // Revision 1.3 1998/08/18 19:48:15 RD
437 // more wxGTK compatibility things.
439 // It builds now but there are serious runtime problems...
441 // Revision 1.2 1998/08/15 07:36:30 RD
442 // - Moved the header in the .i files out of the code that gets put into
443 // the .cpp files. It caused CVS conflicts because of the RCS ID being
444 // different each time.
446 // - A few minor fixes.
448 // Revision 1.1 1998/08/09 08:25:49 RD