]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_gbsizer.i
Script updates
[wxWidgets.git] / wxPython / src / _gbsizer.i
CommitLineData
d14a1e28
RD
1/////////////////////////////////////////////////////////////////////////////
2// Name: _gbsizer.i
3// Purpose: SWIG interface stuff for wxGBGridBagSizer and etc.
4//
5// Author: Robin Dunn
6//
7// Created: 05-Nov-2003
8// RCS-ID: $Id$
9// Copyright: (c) 2003 by Total Control Software
10// Licence: wxWindows license
11/////////////////////////////////////////////////////////////////////////////
12
13// Not a %module
14
15
16//---------------------------------------------------------------------------
17
18%{
19%}
20
21//---------------------------------------------------------------------------
22
23%typemap(in) wxGBPosition& (wxGBPosition temp) {
24 $1 = &temp;
25 if ( ! wxGBPosition_helper($input, &$1)) SWIG_fail;
26}
27%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER) wxGBPosition& {
28 $1 = wxPySimple_typecheck($input, wxT("wxGBPosition"), 2);
29}
30
31%typemap(in) wxGBSpan& (wxGBSpan temp) {
32 $1 = &temp;
33 if ( ! wxGBSpan_helper($input, &$1)) SWIG_fail;
34}
35%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER) wxGBSpan& {
36 $1 = wxPySimple_typecheck($input, wxT("wxGBSpan"), 2);
37}
38
39
40%{
41bool wxGBPosition_helper(PyObject* source, wxGBPosition** obj)
42{
43 return wxPyTwoIntItem_helper(source, obj, wxT("wxGBPosition"));
44}
45
46bool wxGBSpan_helper(PyObject* source, wxGBSpan** obj)
47{
48 return wxPyTwoIntItem_helper(source, obj, wxT("wxGBSpan"));
49}
50
51%}
52
53
54//---------------------------------------------------------------------------
55%newgroup;
94d33c49 56
d14a1e28
RD
57
58class wxGBPosition
59{
60public:
61 wxGBPosition(int row=0, int col=0);
62
63 int GetRow() const;
64 int GetCol() const;
65 void SetRow(int row);
66 void SetCol(int col);
67
22faec7d
RD
68 %extend {
69 bool __eq__(const wxGBPosition* other) { return other ? (*self == *other) : False; }
70 bool __ne__(const wxGBPosition* other) { return other ? (*self != *other) : True; }
71 }
d14a1e28
RD
72
73 %extend {
dd9f7fea
RD
74 void Set(int row=0, int col=0) {
75 self->SetRow(row);
76 self->SetCol(col);
77 }
78
79 PyObject* Get() {
d14a1e28
RD
80 wxPyBeginBlockThreads();
81 PyObject* tup = PyTuple_New(2);
82 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->GetRow()));
83 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->GetCol()));
84 wxPyEndBlockThreads();
85 return tup;
86 }
87 }
88 %pythoncode {
dd9f7fea
RD
89 asTuple = Get
90 def __str__(self): return str(self.Get())
91 def __repr__(self): return 'wx.GBPosition'+str(self.Get())
92 def __len__(self): return len(self.Get())
93 def __getitem__(self, index): return self.Get()[index]
d14a1e28
RD
94 def __setitem__(self, index, val):
95 if index == 0: self.SetRow(val)
96 elif index == 1: self.SetCol(val)
97 else: raise IndexError
dd9f7fea 98 def __nonzero__(self): return self.Get() != (0,0)
02376d73
RD
99 __safe_for_unpickling__ = True
100 def __reduce__(self): return (wx.GBPosition, self.Get())
d14a1e28
RD
101 }
102
103 %pythoncode {
104 row = property(GetRow, SetRow)
105 col = property(GetCol, SetCol)
106 }
107};
108
109
110
d14a1e28
RD
111
112class wxGBSpan
113{
114public:
115 wxGBSpan(int rowspan=1, int colspan=1);
116
117 int GetRowspan() const;
118 int GetColspan() const;
119 void SetRowspan(int rowspan);
120 void SetColspan(int colspan);
121
22faec7d
RD
122 %extend {
123 bool __eq__(const wxGBSpan* other) { return other ? (*self == *other) : False; }
124 bool __ne__(const wxGBSpan* other) { return other ? (*self != *other) : True; }
125 }
d14a1e28
RD
126
127 %extend {
dd9f7fea
RD
128 void Set(int rowspan=1, int colspan=1) {
129 self->SetRowspan(rowspan);
130 self->SetColspan(colspan);
131 }
132
133 PyObject* Get() {
d14a1e28
RD
134 wxPyBeginBlockThreads();
135 PyObject* tup = PyTuple_New(2);
136 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->GetRowspan()));
137 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->GetColspan()));
138 wxPyEndBlockThreads();
139 return tup;
140 }
141 }
142 %pythoncode {
dd9f7fea
RD
143 asTuple = Get
144 def __str__(self): return str(self.Get())
145 def __repr__(self): return 'wx.GBSpan'+str(self.Get())
146 def __len__(self): return len(self.Get())
147 def __getitem__(self, index): return self.Get()[index]
d14a1e28
RD
148 def __setitem__(self, index, val):
149 if index == 0: self.SetRowspan(val)
150 elif index == 1: self.SetColspan(val)
151 else: raise IndexError
dd9f7fea 152 def __nonzero__(self): return self.Get() != (0,0)
02376d73
RD
153 __safe_for_unpickling__ = True
154 def __reduce__(self): return (wx.GBSpan, self.Get())
d14a1e28
RD
155 }
156
157 %pythoncode {
158 rowspan = property(GetRowspan, SetRowspan)
159 colspan = property(GetColspan, SetColspan)
160 }
161};
162
163
164%immutable;
165const wxGBSpan wxDefaultSpan;
166%mutable;
167
168
169//---------------------------------------------------------------------------
170
171
172class wxGBSizerItem : public wxSizerItem
173{
174public:
175 wxGBSizerItem();
176
177 %name(GBSizerItemWindow) wxGBSizerItem( wxWindow *window,
178 const wxGBPosition& pos,
179 const wxGBSpan& span,
180 int flag,
181 int border,
182 wxObject* userData );
183
184 %name(GBSizerItemSizer) wxGBSizerItem( wxSizer *sizer,
185 const wxGBPosition& pos,
186 const wxGBSpan& span,
187 int flag,
188 int border,
189 wxObject* userData );
190
191 %name(GBSizerItemSpacer) wxGBSizerItem( int width,
192 int height,
193 const wxGBPosition& pos,
194 const wxGBSpan& span,
195 int flag,
196 int border,
197 wxObject* userData);
198
199
200 // Get the grid position of the item
201 wxGBPosition GetPos() const;
dd9f7fea 202 %pythoncode { def GetPosTuple(self): return self.GetPos().Get() }
d14a1e28
RD
203
204 // Get the row and column spanning of the item
205 wxGBSpan GetSpan() const;
dd9f7fea 206 %pythoncode { def GetSpanTuple(self): return self.GetSpan().Get() }
d14a1e28
RD
207
208 // If the item is already a member of a sizer then first ensure that there
209 // is no other item that would intersect with this one at the new
dd9f7fea 210 // position, then set the new position. Returns True if the change is
d14a1e28
RD
211 // successful and after the next Layout the item will be moved.
212 bool SetPos( const wxGBPosition& pos );
213
214 // If the item is already a member of a sizer then first ensure that there
215 // is no other item that would intersect with this one with its new
dd9f7fea 216 // spanning size, then set the new spanning. Returns True if the change
d14a1e28
RD
217 // is successful and after the next Layout the item will be resized.
218 bool SetSpan( const wxGBSpan& span );
219
220 %nokwargs Intersects;
221
dd9f7fea 222 // Returns True if this item and the other item instersect
d14a1e28
RD
223 bool Intersects(const wxGBSizerItem& other);
224
dd9f7fea 225 // Returns True if the given pos/span would intersect with this item.
d14a1e28
RD
226 bool Intersects(const wxGBPosition& pos, const wxGBSpan& span);
227
228 // Get the row and column of the endpoint of this item
229 void GetEndPos(int& row, int& col);
230
231
232 wxGridBagSizer* GetGBSizer() const;
233 void SetGBSizer(wxGridBagSizer* sizer);
234
235};
236
237
238//---------------------------------------------------------------------------
239
240
241class wxGridBagSizer : public wxFlexGridSizer
242{
243public:
244 wxGridBagSizer(int vgap = 0, int hgap = 0 );
245
dd9f7fea
RD
246 // The Add method returns True if the item was successfully placed at the
247 // given cell position, False if something was already there.
d14a1e28
RD
248 %extend {
249 bool Add( PyObject* item,
250 const wxGBPosition& pos,
251 const wxGBSpan& span = wxDefaultSpan,
252 int flag = 0,
253 int border = 0,
254 PyObject* userData = NULL ) {
255
256 wxPyUserData* data = NULL;
257 wxPyBeginBlockThreads();
dd9f7fea 258 wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, True, False);
d14a1e28
RD
259 if ( userData && (info.window || info.sizer || info.gotSize) )
260 data = new wxPyUserData(userData);
261 wxPyEndBlockThreads();
262
263 // Now call the real Add method if a valid item type was found
264 if ( info.window )
265 return self->Add(info.window, pos, span, flag, border, data);
266 else if ( info.sizer )
267 return self->Add(info.sizer, pos, span, flag, border, data);
268 else if (info.gotSize)
269 return self->Add(info.size.GetWidth(), info.size.GetHeight(),
270 pos, span, flag, border, data);
dd9f7fea 271 return False;
d14a1e28
RD
272 }
273 }
274
275 %name(AddItem) bool Add( wxGBSizerItem *item );
276
277
278 // Get/Set the size used for cells in the grid with no item.
279 wxSize GetEmptyCellSize() const;
280 void SetEmptyCellSize(const wxSize& sz);
281
282 // Get the grid position of the specified item
283 %nokwargs GetItemPosition;
284 wxGBPosition GetItemPosition(wxWindow *window);
285 wxGBPosition GetItemPosition(wxSizer *sizer);
286 wxGBPosition GetItemPosition(size_t index);
287
dd9f7fea 288 // Set the grid position of the specified item. Returns True on success.
d14a1e28 289 // If the move is not allowed (because an item is already there) then
dd9f7fea 290 // False is returned.
d14a1e28
RD
291 %nokwargs SetItemPosition;
292 bool SetItemPosition(wxWindow *window, const wxGBPosition& pos);
293 bool SetItemPosition(wxSizer *sizer, const wxGBPosition& pos);
294 bool SetItemPosition(size_t index, const wxGBPosition& pos);
295
296 // Get the row/col spanning of the specified item
297 %nokwargs GetItemSpan;
298 wxGBSpan GetItemSpan(wxWindow *window);
299 wxGBSpan GetItemSpan(wxSizer *sizer);
300 wxGBSpan GetItemSpan(size_t index);
301
dd9f7fea 302 // Set the row/col spanning of the specified item. Returns True on
d14a1e28 303 // success. If the move is not allowed (because an item is already there)
dd9f7fea 304 // then False is returned.
d14a1e28
RD
305 %nokwargs SetItemSpan;
306 bool SetItemSpan(wxWindow *window, const wxGBSpan& span);
307 bool SetItemSpan(wxSizer *sizer, const wxGBSpan& span);
308 bool SetItemSpan(size_t index, const wxGBSpan& span);
309
310
311 // Find the sizer item for the given window or subsizer, returns NULL if
312 // not found. (non-recursive)
313 %nokwargs FindItem;
314 wxGBSizerItem* FindItem(wxWindow* window);
315 wxGBSizerItem* FindItem(wxSizer* sizer);
316
317
318 // Return the sizer item for the given grid cell, or NULL if there is no
319 // item at that position. (non-recursive)
320 wxGBSizerItem* FindItemAtPosition(const wxGBPosition& pos);
321
322
dd9f7fea
RD
323 // Return the sizer item located at the point given in pt, or NULL if
324 // there is no item at that point. The (x,y) coordinates in pt correspond
325 // to the client coordinates of the window using the sizer for
326 // layout. (non-recursive)
327 wxGBSizerItem* FindItemAtPoint(const wxPoint& pt);
328
329
d14a1e28
RD
330 // Return the sizer item that has a matching user data (it only compares
331 // pointer values) or NULL if not found. (non-recursive)
332 wxGBSizerItem* FindItemWithData(const wxObject* userData);
333
334
335 // These are what make the sizer do size calculations and layout
336 virtual void RecalcSizes();
337 virtual wxSize CalcMin();
338
339
340 // Look at all items and see if any intersect (or would overlap) the given
dd9f7fea 341 // item. Returns True if so, False if there would be no overlap. If an
d14a1e28
RD
342 // excludeItem is given then it will not be checked for intersection, for
343 // example it may be the item we are checking the position of.
344 %nokwargs CheckForIntersection;
345 bool CheckForIntersection(wxGBSizerItem* item, wxGBSizerItem* excludeItem = NULL);
346 bool CheckForIntersection(const wxGBPosition& pos, const wxGBSpan& span, wxGBSizerItem* excludeItem = NULL);
347
348};
349
350
351//---------------------------------------------------------------------------