]> git.saurik.com Git - wxWidgets.git/blame - utils/wxPython/src/controls2.i
Added more makefiles
[wxWidgets.git] / utils / wxPython / src / controls2.i
CommitLineData
7bf85405
RD
1/////////////////////////////////////////////////////////////////////////////
2// Name: controls2.i
3// Purpose: More control (widget) classes for wxPython
4//
5// Author: Robin Dunn
6//
7// Created: 6/10/98
8// RCS-ID: $Id$
9// Copyright: (c) 1998 by Total Control Software
10// Licence: wxWindows license
11/////////////////////////////////////////////////////////////////////////////
12
03e9bead 13%module controls2
7bf85405 14
03e9bead 15%{
7bf85405
RD
16#include "helpers.h"
17#include <wx/listctrl.h>
18#include <wx/treectrl.h>
7bf85405
RD
19%}
20
21//----------------------------------------------------------------------
22
23%include typemaps.i
24%include my_typemaps.i
25
26// Import some definitions of other classes, etc.
27%import _defs.i
28%import misc.i
29%import windows.i
30%import gdi.i
31%import events.i
32%import controls.i
33
b8b8dda7 34%pragma(python) code = "import wx"
9c039d08 35
7bf85405
RD
36//----------------------------------------------------------------------
37
38%{
39extern wxValidator wxPyDefaultValidator;
40%}
41
42//----------------------------------------------------------------------
43
44class wxListItem {
45public:
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 ;->
55
56 // For columns only
57 int m_format; // left, right, centre
58 int m_width; // width of column
59
60 wxListItem();
61 ~wxListItem();
62};
63
64class wxListEvent: public wxCommandEvent {
65public:
66 int m_code;
67 long m_itemIndex;
68 long m_oldItemIndex;
69 int m_col;
70 bool m_cancelled;
71 wxPoint m_pointDrag;
72 wxListItem m_item;
73};
74
75
76
77
78class wxListCtrl : public wxControl {
79public:
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");
86
b8b8dda7 87 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
9c039d08 88
7bf85405
RD
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);
94 void ClearAll(void);
4f22cf8d 95#ifdef __WXMSW__
7bf85405
RD
96 wxTextCtrl* EditLabel(long item);
97 bool EndEditLabel(bool cancel);
4f22cf8d 98 wxTextCtrl* GetEditControl();
fb5e0af0 99#endif
7bf85405
RD
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,
104 int direction);
105 bool GetColumn(int col, wxListItem& item);
106 int GetColumnWidth(int col);
107 int GetCountPerPage();
7bf85405
RD
108 wxImageList* GetImageList(int which);
109 long GetItemData(long item);
110
111 %addmethods {
112 %new wxListItem* GetItem() {
113 wxListItem* info = new wxListItem;
114 self->GetItem(*info);
115 return info;
116 }
117 %new wxPoint* GetItemPosition(long item) {
118 wxPoint* pos = new wxPoint;
119 self->GetItemPosition(item, *pos);
120 return pos;
121 }
122 %new wxRect* GetItemRect(long item, int code = wxLIST_RECT_BOUNDS) {
123 wxRect* rect= new wxRect;
124 self->GetItemRect(item, *rect, code);
125 return rect;
126 }
127 }
128
129 int GetItemState(long item, long stateMask);
130 int GetItemCount();
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();
fb5e0af0 137#ifdef __WXMSW__
7bf85405 138 wxColour GetTextColour();
4f22cf8d 139 void SetTextColour(const wxColour& col);
fb5e0af0 140#endif
7bf85405
RD
141 long GetTopItem();
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,
146 int width = -1);
147
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,
152 int imageIndex);
153
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,
161 int imageId = -1);
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);
7bf85405
RD
168 void SetWindowStyleFlag(long style);
169 // TODO: bool SortItems(wxListCtrlCompare fn, long data);
170};
171
172
173
174//----------------------------------------------------------------------
175
176
d5c9047a
RD
177class wxTreeItemId {
178public:
179 wxTreeItemId();
180 ~wxTreeItemId();
181 bool IsOk() const { return m_itemId != 0; }
182
60e05667
RD
183// %addmethods {
184// long GetId() { return (long)(*self); }
185// }
d5c9047a
RD
186};
187
188
189
190// **** This isn't very useful yet. This needs to be specialized to enable
191// derived Python classes...
192class wxTreeItemData {
193public:
194 wxTreeItemData();
195 ~wxTreeItemData();
196
630d84f2
RD
197 const wxTreeItemId& GetId();
198 void SetId(const wxTreeItemId& id);
d5c9047a
RD
199};
200
201
202
203
204class wxTreeEvent : public wxCommandEvent {
205public:
206 wxTreeItemId GetItem();
207 wxTreeItemId GetOldItem();
208 wxPoint GetPoint();
209 int GetCode();
210 void Veto();
211};
212
213
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;
217
218
219class wxTreeCtrl : public wxControl {
220public:
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");
227
b8b8dda7 228 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
d5c9047a
RD
229
230 size_t GetCount();
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);
237
238 wxString GetItemText(const wxTreeItemId& item);
239 int GetItemImage(const wxTreeItemId& item);
240 int GetItemSelectedImage(const wxTreeItemId& item);
241 wxTreeItemData *GetItemData(const wxTreeItemId& item);
242
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);
08127323 247 void SetItemHasChildren(const wxTreeItemId& item, bool hasChildren = TRUE);
d5c9047a
RD
248
249 bool IsVisible(const wxTreeItemId& item);
250 bool ItemHasChildren(const wxTreeItemId& item);
251 bool IsExpanded(const wxTreeItemId& item);
252 bool IsSelected(const wxTreeItemId& item);
253
254 wxTreeItemId GetRootItem();
255 wxTreeItemId GetSelection();
256 wxTreeItemId GetParent(const wxTreeItemId& item);
257
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);
265
266
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);
283
284 void Delete(const wxTreeItemId& item);
08127323 285 void DeleteChildren(const wxTreeItemId& item);
d5c9047a
RD
286 void DeleteAllItems();
287
288 void Expand(const wxTreeItemId& item);
289 void Collapse(const wxTreeItemId& item);
290 void CollapseAndReset(const wxTreeItemId& item);
291 void Toggle(const wxTreeItemId& item);
292
293 void Unselect();
294 void SelectItem(const wxTreeItemId& item);
295 void EnsureVisible(const wxTreeItemId& item);
296 void ScrollTo(const wxTreeItemId& item);
297
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);
303
60e05667 304// void SortChildren(const wxTreeItemId& item);
d5c9047a
RD
305 // **** And this too
306 // wxTreeItemCmpFunc *cmpFunction = NULL);
307
b8b8dda7
RD
308 void SetItemBold(const wxTreeItemId& item, bool bold = TRUE);
309 bool IsBold(const wxTreeItemId& item) const;
310 wxTreeItemId HitTest(const wxPoint& point);
d5c9047a
RD
311};
312
d5c9047a 313
7bf85405
RD
314//----------------------------------------------------------------------
315
9c039d08 316#ifdef SKIPTHIS
fb5e0af0 317#ifdef __WXMSW__
7bf85405
RD
318class wxTabEvent : public wxCommandEvent {
319public:
320};
321
322
323
324class wxTabCtrl : public wxControl {
325public:
326 wxTabCtrl(wxWindow* parent, wxWindowID id,
327 const wxPoint& pos = wxPyDefaultPosition,
328 const wxSize& size = wxPyDefaultSize,
329 long style = 0,
330 char* name = "tabCtrl");
331
b8b8dda7 332 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
9c039d08 333
7bf85405
RD
334 bool DeleteAllItems();
335 bool DeleteItem(int item);
336 wxImageList* GetImageList();
337 int GetItemCount();
338 // TODO: void* GetItemData();
339 int GetItemImage(int item);
340
341 %addmethods {
342 %new wxRect* GetItemRect(int item) {
343 wxRect* rect = new wxRect;
344 self->GetItemRect(item, *rect);
345 return rect;
346 }
347 }
348
349 wxString GetItemText(int item);
350 bool GetRowCount();
351 int GetSelection();
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);
362
363};
364
9c039d08 365#endif
fb5e0af0
RD
366#endif
367
7bf85405
RD
368//----------------------------------------------------------------------
369
370
371/////////////////////////////////////////////////////////////////////////////
372//
373// $Log$
08127323
RD
374// Revision 1.14 1999/01/30 07:30:10 RD
375// Added wxSashWindow, wxSashEvent, wxLayoutAlgorithm, etc.
376//
377// Various cleanup, tweaks, minor additions, etc. to maintain
378// compatibility with the current wxWindows.
379//
4f22cf8d 380// Revision 1.13 1998/12/17 14:07:34 RR
08127323 381//
4f22cf8d
RR
382// Removed minor differences between wxMSW and wxGTK
383//
105e45b9 384// Revision 1.12 1998/12/16 22:10:52 RD
4f22cf8d 385//
105e45b9
RD
386// Tweaks needed to be able to build wxPython with wxGTK.
387//
b8b8dda7
RD
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."
393//
394// Added wxTaskbarIcon for wxMSW.
395//
396// Made the events work for wxGrid.
397//
398// Added wxConfig.
399//
400// Added wxMiniFrame for wxGTK, (untested.)
401//
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.
404//
405// Other assorted fixes and additions.
406//
b639c3c5 407// Revision 1.10 1998/11/25 08:45:23 RD
b8b8dda7 408//
b639c3c5
RD
409// Added wxPalette, wxRegion, wxRegionIterator, wxTaskbarIcon
410// Added events for wxGrid
411// Other various fixes and additions
412//
62bd0874
RD
413// Revision 1.9 1998/11/16 00:00:54 RD
414// Generic treectrl for wxPython/GTK compiles...
415//
60e05667
RD
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.
419//
630d84f2 420// Revision 1.7 1998/11/11 03:12:25 RD
60e05667 421//
630d84f2
RD
422// Additions for wxTreeCtrl
423//
d5c9047a
RD
424// Revision 1.6 1998/10/20 06:43:55 RD
425// New wxTreeCtrl wrappers (untested)
426// some changes in helpers
427// etc.
428//
b26e2dc4
RD
429// Revision 1.5 1998/10/07 07:34:33 RD
430// Version 0.4.1 for wxGTK
431//
9c039d08 432// Revision 1.4 1998/10/02 06:40:36 RD
b26e2dc4 433//
9c039d08
RD
434// Version 0.4 of wxPython for MSW.
435//
fb5e0af0
RD
436// Revision 1.3 1998/08/18 19:48:15 RD
437// more wxGTK compatibility things.
438//
439// It builds now but there are serious runtime problems...
440//
03e9bead
RD
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.
445//
446// - A few minor fixes.
447//
7bf85405
RD
448// Revision 1.1 1998/08/09 08:25:49 RD
449// Initial version
450//
451//