]> git.saurik.com Git - wxWidgets.git/blame - utils/wxPython/src/controls2.i
Removing some ifdef's for wxGTK
[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>
9c039d08 19#if 0
7bf85405 20#include <wx/tabctrl.h>
9c039d08 21#endif
7bf85405
RD
22%}
23
24//----------------------------------------------------------------------
25
26%include typemaps.i
27%include my_typemaps.i
28
29// Import some definitions of other classes, etc.
30%import _defs.i
31%import misc.i
32%import windows.i
33%import gdi.i
34%import events.i
35%import controls.i
36
9c039d08
RD
37%pragma(python) code = "import wxp"
38
7bf85405
RD
39//----------------------------------------------------------------------
40
41%{
42extern wxValidator wxPyDefaultValidator;
43%}
44
45//----------------------------------------------------------------------
46
47class wxListItem {
48public:
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 ;->
58
59 // For columns only
60 int m_format; // left, right, centre
61 int m_width; // width of column
62
63 wxListItem();
64 ~wxListItem();
65};
66
67class wxListEvent: public wxCommandEvent {
68public:
69 int m_code;
70 long m_itemIndex;
71 long m_oldItemIndex;
72 int m_col;
73 bool m_cancelled;
74 wxPoint m_pointDrag;
75 wxListItem m_item;
76};
77
78
79
80
81class wxListCtrl : public wxControl {
82public:
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");
89
9c039d08
RD
90 %pragma(python) addtomethod = "__init__:wxp._StdWindowCallbacks(self)"
91
7bf85405
RD
92 bool Arrange(int flag = wxLIST_ALIGN_DEFAULT);
93 bool DeleteItem(long item);
94 bool DeleteAllItems();
95 bool DeleteColumn(int col);
fb5e0af0 96#ifdef __WXMSW__
7bf85405
RD
97 bool DeleteAllColumns(void);
98 void ClearAll(void);
99 wxTextCtrl* EditLabel(long item);
100 bool EndEditLabel(bool cancel);
fb5e0af0 101#endif
7bf85405
RD
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,
106 int direction);
107 bool GetColumn(int col, wxListItem& item);
108 int GetColumnWidth(int col);
109 int GetCountPerPage();
9c039d08 110#ifdef __WXMSW__
7bf85405 111 wxTextCtrl* GetEditControl();
fb5e0af0 112#endif
7bf85405
RD
113 wxImageList* GetImageList(int which);
114 long GetItemData(long item);
115
116 %addmethods {
117 %new wxListItem* GetItem() {
118 wxListItem* info = new wxListItem;
119 self->GetItem(*info);
120 return info;
121 }
122 %new wxPoint* GetItemPosition(long item) {
123 wxPoint* pos = new wxPoint;
124 self->GetItemPosition(item, *pos);
125 return pos;
126 }
127 %new wxRect* GetItemRect(long item, int code = wxLIST_RECT_BOUNDS) {
128 wxRect* rect= new wxRect;
129 self->GetItemRect(item, *rect, code);
130 return rect;
131 }
132 }
133
134 int GetItemState(long item, long stateMask);
135 int GetItemCount();
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();
fb5e0af0 142#ifdef __WXMSW__
7bf85405 143 wxColour GetTextColour();
fb5e0af0 144#endif
7bf85405
RD
145 long GetTopItem();
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,
150 int width = -1);
151
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,
156 int imageIndex);
157
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,
165 int imageId = -1);
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);
fb5e0af0 172#ifdef __WXMSW__
7bf85405 173 void SetTextColour(const wxColour& col);
fb5e0af0 174#endif
7bf85405
RD
175 void SetWindowStyleFlag(long style);
176 // TODO: bool SortItems(wxListCtrlCompare fn, long data);
177};
178
179
180
181//----------------------------------------------------------------------
182
183
60e05667 184//#ifdef __WXMSW__
d5c9047a
RD
185class wxTreeItemId {
186public:
187 wxTreeItemId();
188 ~wxTreeItemId();
189 bool IsOk() const { return m_itemId != 0; }
190
60e05667
RD
191// %addmethods {
192// long GetId() { return (long)(*self); }
193// }
d5c9047a
RD
194};
195
196
197
198// **** This isn't very useful yet. This needs to be specialized to enable
199// derived Python classes...
200class wxTreeItemData {
201public:
202 wxTreeItemData();
203 ~wxTreeItemData();
204
630d84f2
RD
205 const wxTreeItemId& GetId();
206 void SetId(const wxTreeItemId& id);
d5c9047a
RD
207};
208
209
210
211
212class wxTreeEvent : public wxCommandEvent {
213public:
214 wxTreeItemId GetItem();
215 wxTreeItemId GetOldItem();
216 wxPoint GetPoint();
217 int GetCode();
218 void Veto();
219};
220
221
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;
225
226
227class wxTreeCtrl : public wxControl {
228public:
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");
235
236 %pragma(python) addtomethod = "__init__:wxp._StdWindowCallbacks(self)"
237
238 size_t GetCount();
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);
245
246 wxString GetItemText(const wxTreeItemId& item);
247 int GetItemImage(const wxTreeItemId& item);
248 int GetItemSelectedImage(const wxTreeItemId& item);
249 wxTreeItemData *GetItemData(const wxTreeItemId& item);
250
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);
255
256 bool IsVisible(const wxTreeItemId& item);
257 bool ItemHasChildren(const wxTreeItemId& item);
258 bool IsExpanded(const wxTreeItemId& item);
259 bool IsSelected(const wxTreeItemId& item);
260
261 wxTreeItemId GetRootItem();
262 wxTreeItemId GetSelection();
263 wxTreeItemId GetParent(const wxTreeItemId& item);
264
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);
272
273
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);
290
291 void Delete(const wxTreeItemId& item);
292 void DeleteAllItems();
293
294 void Expand(const wxTreeItemId& item);
295 void Collapse(const wxTreeItemId& item);
296 void CollapseAndReset(const wxTreeItemId& item);
297 void Toggle(const wxTreeItemId& item);
298
299 void Unselect();
300 void SelectItem(const wxTreeItemId& item);
301 void EnsureVisible(const wxTreeItemId& item);
302 void ScrollTo(const wxTreeItemId& item);
303
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);
309
60e05667 310// void SortChildren(const wxTreeItemId& item);
d5c9047a
RD
311 // **** And this too
312 // wxTreeItemCmpFunc *cmpFunction = NULL);
313
314};
315
60e05667 316//#endif
d5c9047a 317
7bf85405
RD
318//----------------------------------------------------------------------
319
9c039d08 320#ifdef SKIPTHIS
fb5e0af0 321#ifdef __WXMSW__
7bf85405
RD
322class wxTabEvent : public wxCommandEvent {
323public:
324};
325
326
327
328class wxTabCtrl : public wxControl {
329public:
330 wxTabCtrl(wxWindow* parent, wxWindowID id,
331 const wxPoint& pos = wxPyDefaultPosition,
332 const wxSize& size = wxPyDefaultSize,
333 long style = 0,
334 char* name = "tabCtrl");
335
9c039d08
RD
336 %pragma(python) addtomethod = "__init__:wxp._StdWindowCallbacks(self)"
337
7bf85405
RD
338 bool DeleteAllItems();
339 bool DeleteItem(int item);
340 wxImageList* GetImageList();
341 int GetItemCount();
342 // TODO: void* GetItemData();
343 int GetItemImage(int item);
344
345 %addmethods {
346 %new wxRect* GetItemRect(int item) {
347 wxRect* rect = new wxRect;
348 self->GetItemRect(item, *rect);
349 return rect;
350 }
351 }
352
353 wxString GetItemText(int item);
354 bool GetRowCount();
355 int GetSelection();
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);
366
367};
368
9c039d08 369#endif
fb5e0af0
RD
370#endif
371
7bf85405
RD
372//----------------------------------------------------------------------
373
374
375/////////////////////////////////////////////////////////////////////////////
376//
377// $Log$
60e05667
RD
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.
381//
630d84f2 382// Revision 1.7 1998/11/11 03:12:25 RD
60e05667 383//
630d84f2
RD
384// Additions for wxTreeCtrl
385//
d5c9047a
RD
386// Revision 1.6 1998/10/20 06:43:55 RD
387// New wxTreeCtrl wrappers (untested)
388// some changes in helpers
389// etc.
390//
b26e2dc4
RD
391// Revision 1.5 1998/10/07 07:34:33 RD
392// Version 0.4.1 for wxGTK
393//
9c039d08 394// Revision 1.4 1998/10/02 06:40:36 RD
b26e2dc4 395//
9c039d08
RD
396// Version 0.4 of wxPython for MSW.
397//
fb5e0af0
RD
398// Revision 1.3 1998/08/18 19:48:15 RD
399// more wxGTK compatibility things.
400//
401// It builds now but there are serious runtime problems...
402//
03e9bead
RD
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.
407//
408// - A few minor fixes.
409//
7bf85405
RD
410// Revision 1.1 1998/08/09 08:25:49 RD
411// Initial version
412//
413//