]>
Commit | Line | Data |
---|---|---|
d14a1e28 RD |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: _window.i | |
3 | // Purpose: SWIG interface for wxWindow | |
4 | // | |
5 | // Author: Robin Dunn | |
6 | // | |
7 | // Created: 24-June-1997 | |
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 | ||
dd9f7fea RD |
21 | MAKE_CONST_WXSTRING(PanelNameStr); |
22 | ||
d14a1e28 RD |
23 | //--------------------------------------------------------------------------- |
24 | %newgroup | |
25 | ||
0facd0e5 | 26 | |
174051f6 RD |
27 | DocStr(wxVisualAttributes, |
28 | "struct containing all the visual attributes of a control"); | |
29 | ||
30 | struct wxVisualAttributes | |
31 | { | |
32 | %extend { | |
baf1aa5d | 33 | wxVisualAttributes() { return new wxVisualAttributes; } |
174051f6 RD |
34 | ~wxVisualAttributes() {} |
35 | } | |
36 | ||
37 | // the font used for control label/text inside it | |
38 | wxFont font; | |
39 | ||
40 | // the foreground colour | |
41 | wxColour colFg; | |
42 | ||
43 | // the background colour, may be wxNullColour if the controls background | |
44 | // colour is not solid | |
45 | wxColour colBg; | |
46 | }; | |
47 | ||
48 | ||
49 | ||
50 | ||
8d332bdd RD |
51 | enum wxWindowVariant |
52 | { | |
8d332bdd RD |
53 | wxWINDOW_VARIANT_NORMAL, // Normal size |
54 | wxWINDOW_VARIANT_SMALL, // Smaller size (about 25 % smaller than normal ) | |
55 | wxWINDOW_VARIANT_MINI, // Mini size (about 33 % smaller than normal ) | |
56 | wxWINDOW_VARIANT_LARGE, // Large size (about 25 % larger than normal ) | |
174051f6 | 57 | wxWINDOW_VARIANT_MAX |
8d332bdd RD |
58 | }; |
59 | ||
60 | ||
0facd0e5 RD |
61 | DocStr(wxWindow, |
62 | " | |
63 | wx.Window is the base class for all windows and represents any visible | |
64 | object on the screen. All controls, top level windows and so on are | |
65 | wx.Windows. Sizers and device contexts are not however, as they don't | |
66 | appear on screen themselves. | |
67 | "); | |
68 | ||
69 | RefDoc(wxWindow, " | |
70 | Styles | |
71 | ||
72 | wx.SIMPLE_BORDER: Displays a thin border around the window. | |
73 | ||
74 | wx.DOUBLE_BORDER: Displays a double border. Windows and Mac only. | |
75 | ||
76 | wx.SUNKEN_BORDER: Displays a sunken border. | |
77 | ||
78 | wx.RAISED_BORDER: Displays a raised border. | |
79 | ||
80 | wx.STATIC_BORDER: Displays a border suitable for a static | |
81 | control. Windows only. | |
82 | ||
83 | wx.NO_BORDER: Displays no border, overriding the default | |
84 | border style for the window. | |
85 | ||
86 | wx.TRANSPARENT_WINDOW: The window is transparent, that is, it | |
87 | will not receive paint events. Windows only. | |
88 | ||
89 | wx.TAB_TRAVERSAL: Use this to enable tab traversal for | |
90 | non-dialog windows. | |
91 | ||
92 | wx.WANTS_CHARS: Use this to indicate that the window | |
93 | wants to get all char/key events for | |
94 | all keys - even for keys like TAB or | |
95 | ENTER which are usually used for | |
96 | dialog navigation and which wouldn't | |
97 | be generated without this style. If | |
98 | you need to use this style in order to | |
99 | get the arrows or etc., but would | |
100 | still like to have normal keyboard | |
101 | navigation take place, you should | |
102 | create and send a wxNavigationKeyEvent | |
103 | in response to the key events for Tab | |
104 | and Shift-Tab. | |
105 | ||
106 | wx.NO_FULL_REPAINT_ON_RESIZE: Disables repainting the window | |
107 | completely when its size is changed | |
108 | - you will have to repaint the new | |
109 | window area manually if you use this | |
110 | style. As of version 2.5.1 this | |
111 | style is on by default. Use | |
112 | wx.FULL_REPAINT_ON_RESIZE to | |
113 | deactivate it. | |
114 | ||
115 | wx.VSCROLL: Use this style to enable a vertical scrollbar. | |
116 | ||
117 | wx.HSCROLL: Use this style to enable a horizontal scrollbar. | |
118 | ||
119 | wx.ALWAYS_SHOW_SB: If a window has scrollbars, disable them | |
120 | instead of hiding them when they are | |
121 | not needed (i.e. when the size of the | |
122 | window is big enough to not require | |
123 | the scrollbars to navigate it). This | |
124 | style is currently only implemented | |
125 | for wxMSW and wxUniversal and does | |
126 | nothing on the other platforms. | |
127 | ||
128 | wx.CLIP_CHILDREN: Use this style to eliminate flicker caused by | |
129 | the background being repainted, then | |
130 | children being painted over | |
131 | them. Windows only. | |
132 | ||
133 | wx.FULL_REPAINT_ON_RESIZE: Use this style to force a complete | |
134 | redraw of the window whenever it is | |
135 | resized instead of redrawing just the | |
136 | part of the window affected by | |
137 | resizing. Note that this was the | |
138 | behaviour by default before 2.5.1 | |
139 | release and that if you experience | |
140 | redraw problems with the code which | |
141 | previously used to work you may want | |
142 | to try this. | |
143 | ||
144 | Extra Styles | |
145 | ||
146 | wx.WS_EX_VALIDATE_RECURSIVELY: By default, | |
147 | Validate/TransferDataTo/FromWindow() | |
148 | only work on direct children of | |
149 | the window (compatible | |
150 | behaviour). Set this flag to make | |
151 | them recursively descend into all | |
152 | subwindows. | |
153 | ||
154 | wx.WS_EX_BLOCK_EVENTS: wx.CommandEvents and the objects of the | |
155 | derived classes are forwarded to | |
156 | the parent window and so on | |
157 | recursively by default. Using this | |
158 | flag for the given window allows | |
159 | to block this propagation at this | |
160 | window, i.e. prevent the events | |
161 | from being propagated further | |
162 | upwards. Dialogs have this flag on | |
163 | by default. | |
164 | ||
165 | wx.WS_EX_TRANSIENT Don't use this window as an implicit parent for | |
166 | the other windows: this must be | |
167 | used with transient windows as | |
168 | otherwise there is the risk of | |
169 | creating a dialog/frame with this | |
170 | window as a parent which would | |
171 | lead to a crash if the parent is | |
172 | destroyed before the child. | |
173 | ||
174 | wx.WS_EX_PROCESS_IDLE: This window should always process idle | |
175 | events, even if the mode set by | |
176 | wx.IdleEvent.SetMode is | |
177 | wx.IDLE_PROCESS_SPECIFIED. | |
178 | ||
179 | wx.WS_EX_PROCESS_UI_UPDATES This window should always process UI | |
180 | update events, even if the mode | |
181 | set by wxUpdateUIEvent::SetMode is | |
182 | wxUPDATE_UI_PROCESS_SPECIFIED. | |
183 | ||
184 | "); | |
185 | ||
186 | ||
187 | ||
d14a1e28 RD |
188 | class wxWindow : public wxEvtHandler |
189 | { | |
190 | public: | |
2b9048c5 RD |
191 | %pythonAppend wxWindow "self._setOORInfo(self)" |
192 | %pythonAppend wxWindow() "" | |
d14a1e28 | 193 | |
e029dde7 RD |
194 | RefDoc(wxWindow, ""); // turn it off for the ctors |
195 | ||
0facd0e5 | 196 | DocCtorStr( |
baf1aa5d | 197 | wxWindow(wxWindow* parent, const wxWindowID id=-1, |
0facd0e5 RD |
198 | const wxPoint& pos = wxDefaultPosition, |
199 | const wxSize& size = wxDefaultSize, | |
200 | long style = 0, | |
201 | const wxString& name = wxPyPanelNameStr), | |
202 | "Construct and show a generic Window."); | |
203 | ||
204 | DocCtorStrName( | |
205 | wxWindow(), | |
206 | "Precreate a Window for 2-phase creation.", | |
207 | PreWindow); | |
208 | ||
d14a1e28 | 209 | |
0facd0e5 | 210 | DocDeclStr( |
baf1aa5d | 211 | bool , Create(wxWindow* parent, const wxWindowID id=-1, |
d14a1e28 RD |
212 | const wxPoint& pos = wxDefaultPosition, |
213 | const wxSize& size = wxDefaultSize, | |
214 | long style = 0, | |
0facd0e5 RD |
215 | const wxString& name = wxPyPanelNameStr), |
216 | "Create the GUI part of the Window for 2-phase creation mode."); | |
217 | ||
d14a1e28 RD |
218 | |
219 | // deleting the window | |
220 | // ------------------- | |
221 | ||
d14a1e28 | 222 | |
0facd0e5 RD |
223 | DocDeclStr( |
224 | bool , Close( bool force = False ), | |
225 | "This function simply generates a EVT_CLOSE event whose handler usually | |
226 | tries to close the window. It doesn't close the window itself, | |
227 | however. If force is False (the default) then the window's close | |
228 | handler will be allowed to veto the destruction of the window. | |
229 | ||
230 | Usually Close is only used with the top level windows (wx.Frame and | |
231 | wx.Dialog classes) as the others are not supposed to have any special | |
232 | EVT_CLOSE logic. | |
233 | ||
234 | The close handler should check whether the window is being deleted | |
235 | forcibly, using wx.CloseEvent.GetForce, in which case it should | |
236 | destroy the window using wx.Window.Destroy. | |
237 | ||
238 | Note that calling Close does not guarantee that the window will be | |
239 | destroyed; but it provides a way to simulate a manual close of a | |
240 | window, which may or may not be implemented by destroying the | |
241 | window. The default EVT_CLOSE handler for wx.Dialog does not | |
242 | necessarily delete the dialog, since it will simply simulate an | |
243 | wxID_CANCEL event which is handled by the appropriate button event | |
244 | handler and may do anything at all. | |
245 | ||
246 | To guarantee that the window will be destroyed, call wx.Window.Destroy | |
247 | instead."); | |
248 | ||
249 | ||
250 | ||
251 | DocDeclStr( | |
252 | virtual bool , Destroy(), | |
253 | "Destroys the window safely. Frames and dialogs are not destroyed | |
254 | immediately when this function is called -- they are added to a list | |
255 | of windows to be deleted on idle time, when all the window's events | |
256 | have been processed. This prevents problems with events being sent to | |
257 | non-existent windows. | |
d14a1e28 | 258 | |
0facd0e5 RD |
259 | Returns True if the window has either been successfully deleted, or it |
260 | has been added to the list of windows pending real deletion."); | |
261 | ||
d14a1e28 | 262 | |
0facd0e5 RD |
263 | DocDeclStr( |
264 | bool , DestroyChildren(), | |
265 | "Destroys all children of a window. Called automatically by the destructor."); | |
266 | ||
d14a1e28 | 267 | |
0facd0e5 RD |
268 | DocDeclStr( |
269 | bool , IsBeingDeleted() const, | |
270 | "Is the window in the process of being deleted?"); | |
271 | ||
d14a1e28 | 272 | |
0facd0e5 | 273 | |
d14a1e28 RD |
274 | // window attributes |
275 | // ----------------- | |
276 | ||
0facd0e5 RD |
277 | DocDeclStr( |
278 | virtual void , SetTitle( const wxString& title), | |
279 | "Sets the window's title. Applicable only to frames and dialogs."); | |
280 | ||
281 | DocDeclStr( | |
282 | virtual wxString , GetTitle() const, | |
283 | "Gets the window's title. Applicable only to frames and dialogs."); | |
284 | ||
d14a1e28 | 285 | |
0facd0e5 RD |
286 | DocDeclStr( |
287 | virtual void , SetLabel(const wxString& label), | |
288 | "Set the text which the window shows in its label if applicable."); | |
289 | ||
290 | DocDeclStr( | |
291 | virtual wxString , GetLabel() const, | |
8d332bdd RD |
292 | "Generic way of getting a label from any window, for |
293 | identification purposes. The interpretation of this function | |
294 | differs from class to class. For frames and dialogs, the value | |
295 | returned is the title. For buttons or static text controls, it is | |
296 | the button text. This function can be useful for meta-programs | |
174051f6 | 297 | such as testing tools or special-needs access programs)which |
8d332bdd | 298 | need to identify windows by name."); |
0facd0e5 | 299 | |
d14a1e28 | 300 | |
0facd0e5 RD |
301 | DocDeclStr( |
302 | virtual void , SetName( const wxString &name ), | |
8d332bdd RD |
303 | "Sets the window's name. The window name is used for ressource |
304 | setting in X, it is not the same as the window title/label"); | |
0facd0e5 RD |
305 | |
306 | DocDeclStr( | |
307 | virtual wxString , GetName() const, | |
174051f6 | 308 | "Returns the windows name. This name is not guaranteed to be |
8d332bdd RD |
309 | unique; it is up to the programmer to supply an appropriate name |
310 | in the window constructor or via wx.Window.SetName."); | |
8d332bdd RD |
311 | |
312 | ||
313 | DocDeclStr( | |
314 | void , SetWindowVariant( wxWindowVariant variant ), | |
315 | "Sets the variant of the window/font size to use for this window, | |
174051f6 RD |
316 | if the platform supports variants, for example, wxMac. Variant values are: |
317 | ||
318 | wx.WINDOW_VARIANT_NORMAL Normal size | |
319 | wx.WINDOW_VARIANT_SMALL Smaller size (about 25 % smaller than normal) | |
320 | wx.WINDOW_VARIANT_MINI Mini size (about 33 % smaller than normal) | |
321 | wx.WINDOW_VARIANT_LARGE Large size (about 25 % larger than normal) | |
322 | "); | |
8d332bdd RD |
323 | |
324 | DocDeclStr( | |
325 | wxWindowVariant , GetWindowVariant() const, | |
326 | ""); | |
0facd0e5 | 327 | |
d14a1e28 | 328 | |
0facd0e5 RD |
329 | DocDeclStr( |
330 | void , SetId( wxWindowID winid ), | |
331 | "Sets the identifier of the window. Each window has an integer | |
332 | identifier. If the application has not provided one, an identifier | |
333 | will be generated. Normally, the identifier should be provided on | |
334 | creation and should not be modified subsequently."); | |
335 | ||
336 | DocDeclStr( | |
337 | wxWindowID , GetId() const, | |
338 | "Returns the identifier of the window. Each window has an integer | |
339 | identifier. If the application has not provided one (or the default Id | |
340 | -1 is used) then an unique identifier with a negative value will be | |
341 | generated."); | |
342 | ||
d14a1e28 | 343 | |
0facd0e5 RD |
344 | DocDeclStr( |
345 | static int , NewControlId(), | |
346 | "Generate a control id for the controls which were not given one."); | |
347 | ||
d14a1e28 | 348 | |
0facd0e5 RD |
349 | DocDeclStr( |
350 | static int , NextControlId(int winid), | |
351 | "Get the id of the control following the one with the given\n" | |
352 | "(autogenerated) id"); | |
353 | ||
d14a1e28 | 354 | |
0facd0e5 RD |
355 | DocDeclStr( |
356 | static int , PrevControlId(int winid), | |
357 | "Get the id of the control preceding the one with the given\n" | |
358 | "(autogenerated) id"); | |
359 | ||
d14a1e28 RD |
360 | |
361 | ||
362 | ||
363 | // moving/resizing | |
364 | // --------------- | |
365 | ||
d14a1e28 | 366 | |
0facd0e5 RD |
367 | DocDeclStr( |
368 | void , SetSize( const wxSize& size ), | |
369 | "Sets the size of the window in pixels."); | |
d14a1e28 | 370 | |
d14a1e28 | 371 | |
0facd0e5 RD |
372 | DocDeclStrName( |
373 | void , SetSize( int x, int y, int width, int height, | |
374 | int sizeFlags = wxSIZE_AUTO ), | |
375 | "Sets the position and size of the window in pixels. The sizeFlags | |
376 | parameter indicates the interpretation of the other params if they are | |
377 | -1. wx.SIZE_AUTO*: a -1 indicates that a class-specific default | |
378 | shoudl be used. wx.SIZE_USE_EXISTING: existing dimensions should be | |
379 | used if -1 values are supplied. wxSIZE_ALLOW_MINUS_ONE: allow | |
380 | dimensions of -1 and less to be interpreted as real dimensions, not | |
381 | default values.", | |
382 | SetDimensions); | |
383 | ||
384 | ||
385 | DocDeclStrName( | |
386 | void , SetSize(const wxRect& rect, int sizeFlags = wxSIZE_AUTO), | |
387 | "Sets the position and size of the window in pixels using a wx.Rect.", | |
388 | SetRect); | |
389 | ||
390 | ||
391 | DocDeclStrName( | |
392 | void , SetSize( int width, int height ), | |
393 | "Sets the size of the window in pixels.", | |
394 | SetSizeWH); | |
395 | ||
d14a1e28 | 396 | |
0facd0e5 RD |
397 | DocDeclStr( |
398 | void , Move(const wxPoint& pt, int flags = wxSIZE_USE_EXISTING), | |
399 | "Moves the window to the given position."); | |
400 | ||
d14a1e28 RD |
401 | %pythoncode { SetPosition = Move } |
402 | ||
d14a1e28 | 403 | |
0facd0e5 RD |
404 | DocDeclStrName( |
405 | void , Move(int x, int y, int flags = wxSIZE_USE_EXISTING), | |
406 | "Moves the window to the given position.", | |
407 | MoveXY); | |
408 | ||
409 | ||
d14a1e28 | 410 | |
0facd0e5 RD |
411 | DocDeclStr( |
412 | virtual void , Raise(), | |
413 | "Raises the window to the top of the window hierarchy if it is a | |
414 | managed window (dialog or frame)."); | |
415 | ||
416 | DocDeclStr( | |
417 | virtual void , Lower(), | |
418 | "Lowers the window to the bottom of the window hierarchy if it is a | |
419 | managed window (dialog or frame)."); | |
420 | ||
421 | ||
422 | ||
d14a1e28 | 423 | // client size is the size of the area available for subwindows |
0facd0e5 RD |
424 | DocStr(SetClientSize, |
425 | "This sets the size of the window client area in pixels. Using this | |
426 | function to size a window tends to be more device-independent than | |
427 | wx.Window.SetSize, since the application need not worry about what | |
428 | dimensions the border or title bar have when trying to fit the window | |
429 | around panel items, for example."); | |
d14a1e28 RD |
430 | void SetClientSize( const wxSize& size ); |
431 | %name(SetClientSizeWH) void SetClientSize( int width, int height ); | |
432 | %name(SetClientRect) void SetClientSize(const wxRect& rect); | |
433 | ||
434 | ||
dd9f7fea RD |
435 | DocStr(GetPosition, // sets the docstring for both |
436 | "Get the window's position."); | |
437 | wxPoint GetPosition(); | |
d14a1e28 | 438 | |
dd9f7fea RD |
439 | DocDeclAName( |
440 | void, GetPosition(int *OUTPUT, int *OUTPUT), | |
441 | "GetPositionTuple() -> (x,y)", | |
442 | GetPositionTuple); | |
d14a1e28 | 443 | |
322913ce | 444 | |
dd9f7fea RD |
445 | DocStr(GetSize, "Get the window size."); |
446 | wxSize GetSize() const; | |
447 | DocDeclAName( | |
448 | void, GetSize( int *OUTPUT, int *OUTPUT ) const, | |
449 | "GetSizeTuple() -> (width, height)", | |
450 | GetSizeTuple); | |
451 | ||
452 | ||
d14a1e28 | 453 | |
0facd0e5 RD |
454 | DocDeclStr( |
455 | wxRect , GetRect() const, | |
456 | "Returns the size and position of the window as a wx.Rect object."); | |
457 | ||
458 | ||
459 | DocStr(GetClientSize, | |
460 | "This gets the size of the window's 'client area' in pixels. The client | |
461 | area is the area which may be drawn on by the programmer, excluding | |
462 | title bar, border, scrollbars, etc."); | |
d14a1e28 | 463 | wxSize GetClientSize() const; |
dd9f7fea RD |
464 | DocDeclAName( |
465 | void, GetClientSize( int *OUTPUT, int *OUTPUT ) const, | |
466 | "GetClientSizeTuple() -> (width, height)", | |
467 | GetClientSizeTuple); | |
d14a1e28 | 468 | |
0facd0e5 | 469 | |
d14a1e28 | 470 | |
0facd0e5 RD |
471 | DocDeclStr( |
472 | virtual wxPoint , GetClientAreaOrigin() const, | |
473 | "Get the origin of the client area of the window relative to the | |
474 | window's top left corner (the client area may be shifted because of | |
475 | the borders, scrollbars, other decorations...)"); | |
476 | ||
d14a1e28 | 477 | |
0facd0e5 RD |
478 | DocDeclStr( |
479 | wxRect , GetClientRect() const, | |
480 | "Get the client area position and size as a wx.Rect object."); | |
481 | ||
d14a1e28 | 482 | |
0facd0e5 | 483 | |
dd9f7fea | 484 | DocStr(GetBestSize, |
0facd0e5 RD |
485 | "This functions returns the best acceptable minimal size for the |
486 | window, if applicable. For example, for a static text control, it will be | |
487 | the minimal size such that the control label is not truncated. For | |
488 | windows containing subwindows (suzh aswx.Panel), the size returned | |
489 | by this function will be the same as the size the window would have | |
490 | had after calling Fit."); | |
d14a1e28 | 491 | wxSize GetBestSize() const; |
dd9f7fea RD |
492 | DocDeclAName( |
493 | void, GetBestSize(int *OUTPUT, int *OUTPUT) const, | |
494 | "GetBestSizeTuple() -> (width, height)", | |
495 | GetBestSizeTuple); | |
496 | ||
d14a1e28 | 497 | |
0facd0e5 RD |
498 | DocDeclStr( |
499 | wxSize , GetAdjustedBestSize() const, | |
500 | "This method is similar to GetBestSize, except in one | |
501 | thing. GetBestSize should return the minimum untruncated size of the | |
502 | window, while this method will return the largest of BestSize and any | |
503 | user specified minimum size. ie. it is the minimum size the window | |
504 | should currently be drawn at, not the minimal size it can possibly | |
505 | tolerate."); | |
506 | ||
d14a1e28 RD |
507 | |
508 | ||
0facd0e5 RD |
509 | |
510 | DocDeclStr( | |
511 | void , Center( int direction = wxBOTH ), | |
512 | "Centers the window. The parameter specifies the direction for | |
513 | cetering, and may be wx.HORIZONTAL, wx.VERTICAL or wx.BOTH. It may | |
514 | also include wx.CENTER_ON_SCREEN flag if you want to center the window | |
515 | on the entire screen and not on its parent window. If it is a | |
516 | top-level window and has no parent then it will always be centered | |
517 | relative to the screen."); | |
518 | ||
d14a1e28 RD |
519 | %pythoncode { Centre = Center } |
520 | ||
0facd0e5 RD |
521 | |
522 | DocDeclStr( | |
523 | void , CenterOnScreen(int dir = wxBOTH), | |
524 | "Center on screen (only works for top level windows)"); | |
d14a1e28 RD |
525 | %pythoncode { CentreOnScreen = CenterOnScreen } |
526 | ||
d14a1e28 | 527 | |
0facd0e5 RD |
528 | DocDeclStr( |
529 | void , CenterOnParent(int dir = wxBOTH), | |
530 | "Center with respect to the the parent window"); | |
531 | %pythoncode { CentreOnParent = CenterOnParent } | |
d14a1e28 | 532 | |
0facd0e5 | 533 | |
d14a1e28 | 534 | |
0facd0e5 RD |
535 | DocDeclStr( |
536 | virtual void , Fit(), | |
537 | "Sizes the window so that it fits around its subwindows. This function | |
538 | won't do anything if there are no subwindows and will only really work | |
539 | correctly if sizers are used for the subwindows layout. Also, if the | |
540 | window has exactly one subwindow it is better (faster and the result | |
541 | is more precise as Fit adds some margin to account for fuzziness of | |
542 | its calculations) to call window.SetClientSize(child.GetSize()) | |
543 | instead of calling Fit."); | |
544 | ||
d14a1e28 | 545 | |
0facd0e5 RD |
546 | DocDeclStr( |
547 | virtual void , FitInside(), | |
548 | "Similar to Fit, but sizes the interior (virtual) size of a | |
549 | window. Mainly useful with scrolled windows to reset scrollbars after | |
550 | sizing changes that do not trigger a size event, and/or scrolled | |
551 | windows without an interior sizer. This function similarly won't do | |
552 | anything if there are no subwindows."); | |
553 | ||
d14a1e28 | 554 | |
33e10b88 RD |
555 | |
556 | %nokwargs SetSizeHints; | |
557 | DocStr(SetSizeHints, | |
0facd0e5 RD |
558 | "Allows specification of minimum and maximum window sizes, and window |
559 | size increments. If a pair of values is not set (or set to -1), the | |
560 | default values will be used. If this function is called, the user | |
561 | will not be able to size the window outside the given bounds. The | |
562 | resizing increments are only significant under Motif or Xt."); | |
33e10b88 RD |
563 | virtual void SetSizeHints( int minW, int minH, |
564 | int maxW = -1, int maxH = -1, | |
565 | int incW = -1, int incH = -1 ); | |
566 | void SetSizeHints( const wxSize& minSize, | |
567 | const wxSize& maxSize=wxDefaultSize, | |
568 | const wxSize& incSize=wxDefaultSize); | |
d14a1e28 | 569 | |
33e10b88 RD |
570 | |
571 | %nokwargs SetVirtualSizeHints; | |
572 | DocStr(SetVirtualSizeHints, | |
0facd0e5 RD |
573 | "Allows specification of minimum and maximum virtual window sizes. If a |
574 | pair of values is not set (or set to -1), the default values will be | |
575 | used. If this function is called, the user will not be able to size | |
576 | the virtual area of the window outside the given bounds."); | |
33e10b88 RD |
577 | virtual void SetVirtualSizeHints( int minW, int minH, |
578 | int maxW = -1, int maxH = -1 ); | |
579 | void SetVirtualSizeHints( const wxSize& minSize, | |
580 | const wxSize& maxSize=wxDefaultSize); | |
0facd0e5 RD |
581 | |
582 | DocDeclStr( | |
583 | virtual int , GetMinWidth() const, | |
584 | ""); | |
585 | ||
586 | DocDeclStr( | |
587 | virtual int , GetMinHeight() const, | |
588 | ""); | |
589 | ||
590 | DocDeclStr( | |
591 | int , GetMaxWidth() const, | |
592 | ""); | |
593 | ||
594 | DocDeclStr( | |
595 | int , GetMaxHeight() const, | |
596 | ""); | |
597 | ||
d14a1e28 | 598 | |
0facd0e5 RD |
599 | DocDeclStr( |
600 | virtual wxSize , GetMaxSize() const, | |
601 | ""); | |
602 | ||
d14a1e28 | 603 | |
33e10b88 RD |
604 | DocDeclStr( |
605 | virtual wxSize , GetMinSize() const, | |
606 | ""); | |
607 | ||
dd9f7fea RD |
608 | |
609 | DocStr(SetVirtualSize, | |
0facd0e5 RD |
610 | "Set the the virtual size of a window in pixels. For most windows this |
611 | is just the client area of the window, but for some like scrolled | |
612 | windows it is more or less independent of the screen window size."); | |
dd9f7fea | 613 | void SetVirtualSize(const wxSize& size ); |
d14a1e28 RD |
614 | %name(SetVirtualSizeWH) void SetVirtualSize( int w, int h ); |
615 | ||
dd9f7fea RD |
616 | |
617 | DocStr(GetVirtualSize, | |
0facd0e5 RD |
618 | "Get the the virtual size of the window in pixels. For most windows |
619 | this is just the client area of the window, but for some like scrolled | |
620 | windows it is more or less independent of the screen window size."); | |
d14a1e28 | 621 | wxSize GetVirtualSize() const; |
dd9f7fea RD |
622 | DocDeclAName( |
623 | void, GetVirtualSize( int *OUTPUT, int *OUTPUT ) const, | |
624 | "GetVirtualSizeTuple() -> (width, height)", | |
625 | GetVirtualSizeTuple); | |
d14a1e28 RD |
626 | |
627 | ||
628 | // TODO: using directors? | |
629 | // // Override these methods for windows that have a virtual size | |
630 | // // independent of their client size. eg. the virtual area of a | |
631 | // // wxScrolledWindow. Default is to alias VirtualSize to ClientSize. | |
632 | // virtual void DoSetVirtualSize( int x, int y ); | |
633 | // virtual wxSize DoGetVirtualSize() const; // { return m_virtualSize; } | |
634 | ||
635 | ||
0facd0e5 RD |
636 | DocDeclStr( |
637 | virtual wxSize , GetBestVirtualSize() const, | |
638 | "Return the largest of ClientSize and BestSize (as determined by a | |
639 | sizer, interior children, or other means)"); | |
640 | ||
d14a1e28 RD |
641 | |
642 | ||
643 | // window state | |
644 | // ------------ | |
645 | ||
0facd0e5 RD |
646 | DocDeclStr( |
647 | virtual bool , Show( bool show = True ), | |
648 | "Shows or hides the window. You may need to call Raise for a top level | |
649 | window if you want to bring it to top, although this is not needed if | |
e2bbfc8f RD |
650 | Show is called immediately after the frame creation. Returns True if |
651 | the window has been shown or hidden or False if nothing was done | |
0facd0e5 RD |
652 | because it already was in the requested state."); |
653 | ||
654 | DocDeclStr( | |
655 | bool , Hide(), | |
656 | "Equivalent to calling Show(False)."); | |
657 | ||
d14a1e28 | 658 | |
0facd0e5 RD |
659 | DocDeclStr( |
660 | virtual bool , Enable( bool enable = True ), | |
661 | "Enable or disable the window for user input. Note that when a parent | |
662 | window is disabled, all of its children are disabled as well and they | |
663 | are reenabled again when the parent is. Returns true if the window | |
664 | has been enabled or disabled, false if nothing was done, i.e. if the | |
665 | window had already been in the specified state."); | |
666 | ||
667 | DocDeclStr( | |
668 | bool , Disable(), | |
669 | "Disables the window, same as Enable(false)."); | |
670 | ||
d14a1e28 | 671 | |
0facd0e5 RD |
672 | DocDeclStr( |
673 | bool , IsShown() const, | |
674 | "Returns true if the window is shown, false if it has been hidden."); | |
675 | ||
676 | DocDeclStr( | |
677 | bool , IsEnabled() const, | |
678 | "Returns true if the window is enabled for input, false otherwise."); | |
d14a1e28 | 679 | |
0facd0e5 | 680 | |
d14a1e28 | 681 | |
d14a1e28 | 682 | |
0facd0e5 RD |
683 | DocDeclStr( |
684 | virtual void , SetWindowStyleFlag( long style ), | |
685 | "Sets the style of the window. Please note that some styles cannot be | |
686 | changed after the window creation and that Refresh() might be called | |
687 | after changing the others for the change to take place immediately."); | |
688 | ||
689 | DocDeclStr( | |
690 | virtual long , GetWindowStyleFlag() const, | |
e2bbfc8f RD |
691 | "Gets the window style that was passed to the constructor or Create |
692 | method."); | |
d14a1e28 | 693 | |
0facd0e5 RD |
694 | %pythoncode { SetWindowStyle = SetWindowStyleFlag; GetWindowStyle = GetWindowStyleFlag } |
695 | ||
696 | ||
697 | DocDeclStr( | |
698 | bool , HasFlag(int flag) const, | |
699 | "Test if the given style is set for this window."); | |
700 | ||
d14a1e28 | 701 | |
0facd0e5 RD |
702 | DocDeclStr( |
703 | virtual bool , IsRetained() const, | |
704 | "Returns true if the window is retained, false otherwise. Retained | |
705 | windows are only available on X platforms."); | |
706 | ||
d14a1e28 | 707 | |
d14a1e28 | 708 | |
0facd0e5 RD |
709 | DocDeclStr( |
710 | virtual void , SetExtraStyle(long exStyle), | |
711 | "Sets the extra style bits for the window. Extra styles are the less | |
712 | often used style bits which can't be set with the constructor or with | |
713 | SetWindowStyleFlag()"); | |
714 | ||
715 | DocDeclStr( | |
716 | long , GetExtraStyle() const, | |
717 | "Returns the extra style bits for the window."); | |
718 | ||
d14a1e28 | 719 | |
0facd0e5 RD |
720 | |
721 | DocDeclStr( | |
722 | virtual void , MakeModal(bool modal = True), | |
723 | "Disables all other windows in the application so that the user can | |
724 | only interact with this window. Passing False will reverse this | |
725 | effect."); | |
726 | ||
d14a1e28 | 727 | |
0facd0e5 RD |
728 | |
729 | DocDeclStr( | |
730 | virtual void , SetThemeEnabled(bool enableTheme), | |
731 | "This function tells a window if it should use the system's \"theme\" | |
732 | code to draw the windows' background instead if its own background | |
733 | drawing code. This will only have an effect on platforms that support | |
734 | the notion of themes in user defined windows. One such platform is | |
735 | GTK+ where windows can have (very colourful) backgrounds defined by a | |
736 | user's selected theme. | |
737 | ||
738 | Dialogs, notebook pages and the status bar have this flag set to true | |
739 | by default so that the default look and feel is simulated best."); | |
740 | ||
741 | DocDeclStr( | |
742 | virtual bool , GetThemeEnabled() const, | |
743 | "Return the themeEnabled flag."); | |
744 | ||
d14a1e28 | 745 | |
0facd0e5 RD |
746 | // TODO with directors |
747 | // // controls by default inherit the colours of their parents, if a | |
748 | // // particular control class doesn't want to do it, it can override | |
749 | // // ShouldInheritColours() to return False | |
750 | // virtual bool ShouldInheritColours() const; | |
d14a1e28 | 751 | |
d14a1e28 | 752 | |
d14a1e28 | 753 | |
0facd0e5 | 754 | |
d14a1e28 | 755 | |
0facd0e5 RD |
756 | // focus and keyboard handling |
757 | // --------------------------- | |
d14a1e28 | 758 | |
0facd0e5 RD |
759 | |
760 | DocDeclStr( | |
761 | virtual void , SetFocus(), | |
762 | "Set's the focus to this window, allowing it to receive keyboard input."); | |
763 | ||
764 | DocDeclStr( | |
765 | virtual void , SetFocusFromKbd(), | |
766 | "Set focus to this window as the result of a keyboard action. Normally | |
767 | only called internally."); | |
768 | ||
769 | ||
770 | ||
771 | DocDeclStr( | |
772 | static wxWindow *, FindFocus(), | |
773 | "Returns the window or control that currently has the keyboard focus, | |
774 | or None."); | |
775 | ||
d14a1e28 | 776 | |
0facd0e5 RD |
777 | DocDeclStr( |
778 | virtual bool , AcceptsFocus() const, | |
779 | "Can this window have focus?"); | |
780 | ||
d14a1e28 | 781 | |
0facd0e5 RD |
782 | DocDeclStr( |
783 | virtual bool , AcceptsFocusFromKeyboard() const, | |
784 | "Can this window be given focus by keyboard navigation? if not, the | |
785 | only way to give it focus (provided it accepts it at all) is to click | |
e2bbfc8f | 786 | it."); |
0facd0e5 | 787 | |
d14a1e28 RD |
788 | |
789 | ||
0facd0e5 RD |
790 | |
791 | DocDeclStr( | |
792 | virtual wxWindow *, GetDefaultItem() const, | |
793 | "Get the default child of this parent, i.e. the one which is activated | |
e2bbfc8f | 794 | by pressing <Enter> such as the OK button on a wx.Dialog."); |
0facd0e5 RD |
795 | |
796 | DocDeclStr( | |
797 | virtual wxWindow *, SetDefaultItem(wxWindow * child), | |
798 | "Set this child as default, return the old default."); | |
799 | ||
800 | DocDeclStr( | |
801 | virtual void , SetTmpDefaultItem(wxWindow * win), | |
802 | "Set this child as temporary default"); | |
803 | ||
804 | ||
805 | ||
806 | ||
d14a1e28 RD |
807 | |
808 | // parent/children relations | |
809 | // ------------------------- | |
810 | ||
0facd0e5 | 811 | |
d14a1e28 RD |
812 | //wxWindowList& GetChildren(); // TODO: Do a typemap or a wrapper for wxWindowList |
813 | %extend { | |
0facd0e5 RD |
814 | DocStr(GetChildren, |
815 | "Returns a list of the window's children. NOTE: Currently this is a | |
816 | copy of the child window list maintained by the window, so the return | |
817 | value of this function is only valid as long as the window's children | |
818 | do not change."); | |
d14a1e28 RD |
819 | PyObject* GetChildren() { |
820 | wxWindowList& list = self->GetChildren(); | |
821 | return wxPy_ConvertList(&list); | |
822 | } | |
823 | } | |
824 | ||
0facd0e5 RD |
825 | DocDeclStr( |
826 | wxWindow *, GetParent() const, | |
827 | "Returns the parent window of this window, or None if there isn't one."); | |
828 | ||
829 | DocDeclStr( | |
830 | wxWindow *, GetGrandParent() const, | |
831 | "Returns the parent of the parent of this window, or None if there isn't one."); | |
832 | ||
d14a1e28 | 833 | |
0facd0e5 RD |
834 | |
835 | DocDeclStr( | |
836 | virtual bool , IsTopLevel() const, | |
837 | "Returns true if the given window is a top-level one. Currently all | |
838 | frames and dialogs are always considered to be top-level windows (even | |
839 | if they have a parent window)."); | |
840 | ||
d14a1e28 | 841 | |
dd9f7fea RD |
842 | // change the real parent of this window, return True if the parent |
843 | // was changed, False otherwise (error or newParent == oldParent) | |
0facd0e5 RD |
844 | DocDeclStr( |
845 | virtual bool , Reparent( wxWindow *newParent ), | |
846 | "Reparents the window, i.e the window will be removed from its current | |
847 | parent window (e.g. a non-standard toolbar in a wxFrame) and then | |
848 | re-inserted into another. Available on Windows and GTK. Returns True | |
849 | if the parent was changed, False otherwise (error or newParent == | |
850 | oldParent)"); | |
851 | ||
d14a1e28 | 852 | |
0facd0e5 RD |
853 | DocDeclStr( |
854 | virtual void , AddChild( wxWindow *child ), | |
855 | "Adds a child window. This is called automatically by window creation | |
856 | functions so should not be required by the application programmer."); | |
857 | ||
858 | DocDeclStr( | |
859 | virtual void , RemoveChild( wxWindow *child ), | |
860 | "Removes a child window. This is called automatically by window | |
861 | deletion functions so should not be required by the application | |
862 | programmer."); | |
863 | ||
d14a1e28 RD |
864 | |
865 | ||
866 | ||
867 | // looking for windows | |
868 | // ------------------- | |
869 | ||
0facd0e5 RD |
870 | DocDeclStrName( |
871 | wxWindow *, FindWindow( long winid ), | |
872 | "Find a chld of this window by window ID", | |
873 | FindWindowById); | |
874 | ||
875 | DocDeclStrName( | |
876 | wxWindow *, FindWindow( const wxString& name ), | |
877 | "Find a child of this window by name", | |
878 | FindWindowByName); | |
879 | ||
d14a1e28 RD |
880 | |
881 | ||
882 | // event handler stuff | |
883 | // ------------------- | |
884 | ||
0facd0e5 RD |
885 | DocDeclStr( |
886 | wxEvtHandler *, GetEventHandler() const, | |
887 | "Returns the event handler for this window. By default, the window is | |
888 | its own event handler."); | |
889 | ||
d14a1e28 | 890 | |
0facd0e5 RD |
891 | DocDeclStr( |
892 | void , SetEventHandler( wxEvtHandler *handler ), | |
893 | "Sets the event handler for this window. An event handler is an object | |
894 | that is capable of processing the events sent to a window. By default, | |
895 | the window is its own event handler, but an application may wish to | |
896 | substitute another, for example to allow central implementation of | |
897 | event-handling for a variety of different window classes. | |
898 | ||
899 | It is usually better to use wx.Window.PushEventHandler since this sets | |
900 | up a chain of event handlers, where an event not handled by one event | |
901 | handler is handed to the next one in the chain."); | |
902 | ||
d14a1e28 | 903 | |
0facd0e5 RD |
904 | DocDeclStr( |
905 | void , PushEventHandler( wxEvtHandler *handler ), | |
906 | "Pushes this event handler onto the event handler stack for the window. | |
907 | An event handler is an object that is capable of processing the events | |
908 | sent to a window. By default, the window is its own event handler, but | |
909 | an application may wish to substitute another, for example to allow | |
910 | central implementation of event-handling for a variety of different | |
911 | window classes. | |
d14a1e28 | 912 | |
0facd0e5 RD |
913 | wx.Window.PushEventHandler allows an application to set up a chain of |
914 | event handlers, where an event not handled by one event handler is | |
915 | handed to the next one in the chain. Use wx.Window.PopEventHandler to | |
916 | remove the event handler."); | |
917 | ||
918 | ||
919 | DocDeclStr( | |
920 | wxEvtHandler *, PopEventHandler( bool deleteHandler = False ), | |
921 | "Removes and returns the top-most event handler on the event handler | |
922 | stack. If deleteHandler is True then the wx.EvtHandler object will be | |
923 | destroyed after it is popped."); | |
924 | ||
925 | ||
926 | DocDeclStr( | |
927 | bool , RemoveEventHandler(wxEvtHandler *handler), | |
928 | "Find the given handler in the event handler chain and remove (but | |
929 | not delete) it from the event handler chain, return True if it was | |
930 | found and False otherwise (this also results in an assert failure so | |
931 | this function should only be called when the handler is supposed to | |
932 | be there.)"); | |
933 | ||
d14a1e28 RD |
934 | |
935 | ||
936 | ||
937 | // validators | |
938 | // ---------- | |
939 | ||
940 | // a window may have an associated validator which is used to control | |
941 | // user input | |
0facd0e5 RD |
942 | DocDeclStr( |
943 | virtual void , SetValidator( const wxValidator &validator ), | |
944 | "Deletes the current validator (if any) and sets the window validator, | |
945 | having called wx.Validator.Clone to create a new validator of this | |
946 | type."); | |
947 | ||
948 | DocDeclStr( | |
949 | virtual wxValidator *, GetValidator(), | |
950 | "Returns a pointer to the current validator for the window, or None if | |
951 | there is none."); | |
b8fd6d07 RD |
952 | |
953 | ||
954 | DocDeclStr( | |
955 | virtual bool , Validate(), | |
956 | "Validates the current values of the child controls using their | |
957 | validators. If the window has wx.WS_EX_VALIDATE_RECURSIVELY | |
958 | extra style flag set, the method will also call Validate() of all | |
959 | child windows. Returns false if any of the validations failed."); | |
960 | ||
961 | ||
962 | DocDeclStr( | |
963 | virtual bool , TransferDataToWindow(), | |
964 | "Transfers values to child controls from data areas specified by | |
965 | their validators. If the window has wx.WS_EX_VALIDATE_RECURSIVELY | |
966 | extra style flag set, the method will also call | |
967 | TransferDataToWindow() of all child windows."); | |
968 | ||
969 | DocDeclStr( | |
970 | virtual bool , TransferDataFromWindow(), | |
971 | "Transfers values from child controls to data areas specified by | |
972 | their validators. Returns false if a transfer failed. If the | |
973 | window has wx.WS_EX_VALIDATE_RECURSIVELY extra style flag set, the | |
974 | method will also call TransferDataFromWindow() of all child | |
975 | windows."); | |
976 | ||
977 | ||
978 | DocDeclStr( | |
979 | virtual void , InitDialog(), | |
980 | "Sends an EVT_INIT_DIALOG event, whose handler usually transfers | |
981 | data to the dialog via validators."); | |
982 | ||
0facd0e5 | 983 | |
d14a1e28 RD |
984 | |
985 | ||
986 | // accelerators | |
987 | // ------------ | |
988 | ||
0facd0e5 RD |
989 | DocDeclStr( |
990 | virtual void , SetAcceleratorTable( const wxAcceleratorTable& accel ), | |
991 | "Sets the accelerator table for this window."); | |
992 | ||
993 | DocDeclStr( | |
994 | wxAcceleratorTable *, GetAcceleratorTable(), | |
995 | "Gets the accelerator table for this window."); | |
996 | ||
d14a1e28 RD |
997 | |
998 | ||
999 | ||
1000 | ||
1001 | // hot keys (system wide accelerators) | |
1002 | // ----------------------------------- | |
1003 | %extend { | |
0facd0e5 RD |
1004 | DocStr(RegisterHotKey, |
1005 | "Registers a system wide hotkey. Every time the user presses the hotkey | |
1006 | registered here, this window will receive a hotkey event. It will | |
1007 | receive the event even if the application is in the background and | |
1008 | does not have the input focus because the user is working with some | |
1009 | other application. To bind an event handler function to this hotkey | |
1010 | use EVT_HOTKEY with an id equal to hotkeyId. Returns True if the | |
1011 | hotkey was registered successfully."); | |
d14a1e28 | 1012 | bool RegisterHotKey(int hotkeyId, int modifiers, int keycode) { |
baf1aa5d | 1013 | %#if wxUSE_HOTKEY |
d14a1e28 | 1014 | return self->RegisterHotKey(hotkeyId, modifiers, keycode); |
baf1aa5d | 1015 | %#else |
dd9f7fea | 1016 | return False; |
baf1aa5d | 1017 | %#endif |
d14a1e28 RD |
1018 | } |
1019 | ||
0facd0e5 RD |
1020 | |
1021 | DocStr(UnregisterHotKey, | |
1022 | "Unregisters a system wide hotkey."); | |
d14a1e28 RD |
1023 | bool UnregisterHotKey(int hotkeyId) { |
1024 | #if wxUSE_HOTKEY | |
1025 | return self->UnregisterHotKey(hotkeyId); | |
1026 | #else | |
dd9f7fea | 1027 | return False; |
d14a1e28 RD |
1028 | #endif |
1029 | } | |
1030 | } | |
1031 | ||
1032 | ||
1033 | ||
1034 | // "dialog units" translations | |
1035 | // --------------------------- | |
1036 | ||
0facd0e5 | 1037 | DocStr(ConvertDialogToPixels, |
e2bbfc8f RD |
1038 | "Converts a point or size from dialog units to pixels. Dialog units |
1039 | are used for maintaining a dialog's proportions even if the font | |
0facd0e5 RD |
1040 | changes. For the x dimension, the dialog units are multiplied by the |
1041 | average character width and then divided by 4. For the y dimension, | |
1042 | the dialog units are multiplied by the average character height and | |
1043 | then divided by 8."); | |
d14a1e28 RD |
1044 | %name(ConvertDialogPointToPixels) wxPoint ConvertDialogToPixels(const wxPoint& pt); |
1045 | %name(ConvertDialogSizeToPixels) wxSize ConvertDialogToPixels(const wxSize& sz); | |
d14a1e28 RD |
1046 | %name(DLG_PNT) wxPoint ConvertDialogToPixels(const wxPoint& pt); |
1047 | %name(DLG_SZE) wxSize ConvertDialogToPixels(const wxSize& sz); | |
1048 | ||
0facd0e5 RD |
1049 | |
1050 | DocStr(ConvertPixelPointToDialog, | |
1051 | "Converts a point or size from pixels to dialog units. Dialog units | |
1052 | are used for maintaining a dialog's proportions even if the font | |
1053 | changes. For the x dimension, the dialog units are multiplied by the | |
1054 | average character width and then divided by 4. For the y dimension, | |
1055 | the dialog units are multiplied by the average character height and | |
1056 | then divided by 8."); | |
d14a1e28 RD |
1057 | %name(ConvertPixelPointToDialog) wxPoint ConvertPixelsToDialog(const wxPoint& pt); |
1058 | %name(ConvertPixelSizeToDialog) wxSize ConvertPixelsToDialog(const wxSize& sz); | |
1059 | ||
1060 | ||
1061 | ||
1062 | // mouse functions | |
1063 | // --------------- | |
1064 | ||
0facd0e5 RD |
1065 | DocDeclStr( |
1066 | virtual void , WarpPointer(int x, int y), | |
1067 | "Moves the pointer to the given position on the window. | |
1068 | ||
1069 | NOTE: This function is not supported under Mac because Apple Human | |
1070 | Interface Guidelines forbid moving the mouse cursor programmatically."); | |
1071 | ||
d14a1e28 | 1072 | |
0facd0e5 RD |
1073 | DocDeclStr( |
1074 | void , CaptureMouse(), | |
1075 | "Directs all mouse input to this window. Call wx.Window.ReleaseMouse to | |
1076 | release the capture. | |
d14a1e28 | 1077 | |
0facd0e5 RD |
1078 | Note that wxWindows maintains the stack of windows having captured the |
1079 | mouse and when the mouse is released the capture returns to the window | |
1080 | which had had captured it previously and it is only really released if | |
1081 | there were no previous window. In particular, this means that you must | |
1082 | release the mouse as many times as you capture it."); | |
1083 | ||
1084 | DocDeclStr( | |
1085 | void , ReleaseMouse(), | |
1086 | "Releases mouse input captured with wx.Window.CaptureMouse."); | |
1087 | ||
1088 | ||
1089 | DocDeclStr( | |
1090 | static wxWindow *, GetCapture(), | |
1091 | "Returns the window which currently captures the mouse or None"); | |
1092 | ||
d14a1e28 | 1093 | |
0facd0e5 RD |
1094 | DocDeclStr( |
1095 | virtual bool , HasCapture() const, | |
1096 | "Returns true if this window has the current mouse capture."); | |
1097 | ||
d14a1e28 RD |
1098 | |
1099 | ||
0facd0e5 | 1100 | |
d14a1e28 RD |
1101 | |
1102 | // painting the window | |
1103 | // ------------------- | |
1104 | ||
0facd0e5 RD |
1105 | DocDeclStr( |
1106 | virtual void , Refresh( bool eraseBackground = True, | |
1107 | const wxRect *rect = NULL ), | |
1108 | "Mark the specified rectangle (or the whole window) as \"dirty\" so it | |
1109 | will be repainted. Causes an EVT_PAINT event to be generated and sent | |
1110 | to the window."); | |
1111 | ||
d14a1e28 | 1112 | |
0facd0e5 RD |
1113 | DocDeclStr( |
1114 | void , RefreshRect(const wxRect& rect), | |
1115 | "Redraws the contents of the given rectangle: the area inside it will | |
1116 | be repainted. This is the same as Refresh but has a nicer syntax."); | |
1117 | ||
d14a1e28 | 1118 | |
0facd0e5 RD |
1119 | DocDeclStr( |
1120 | virtual void , Update(), | |
1121 | "Calling this method immediately repaints the invalidated area of the | |
1122 | window instead of waiting for the EVT_PAINT event to happen, (normally | |
1123 | this would usually only happen when the flow of control returns to the | |
1124 | event loop.) Notice that this function doesn't refresh the window and | |
1125 | does nothing if the window has been already repainted. Use Refresh | |
1126 | first if you want to immediately redraw the window (or some portion of | |
1127 | it) unconditionally."); | |
1128 | ||
d14a1e28 | 1129 | |
0facd0e5 RD |
1130 | DocDeclStr( |
1131 | virtual void , ClearBackground(), | |
1132 | "Clears the window by filling it with the current background | |
1133 | colour. Does not cause an erase background event to be generated."); | |
1134 | ||
d14a1e28 | 1135 | |
d14a1e28 | 1136 | |
0facd0e5 RD |
1137 | DocDeclStr( |
1138 | virtual void , Freeze(), | |
2f4ad68c RD |
1139 | "Freezes the window or, in other words, prevents any updates from taking place |
1140 | on screen, the window is not redrawn at all. Thaw must be called to reenable | |
1141 | window redrawing. Calls to Freeze/Thaw may be nested, with the actual Thaw | |
1142 | being delayed until all the nesting has been undone. | |
d14a1e28 | 1143 | |
0facd0e5 RD |
1144 | This method is useful for visual appearance optimization (for example, |
1145 | it is a good idea to use it before inserting large amount of text into | |
1146 | a wxTextCtrl under wxGTK) but is not implemented on all platforms nor | |
1147 | for all controls so it is mostly just a hint to wxWindows and not a | |
1148 | mandatory directive."); | |
1149 | ||
d14a1e28 | 1150 | |
0facd0e5 RD |
1151 | DocDeclStr( |
1152 | virtual void , Thaw(), | |
2f4ad68c RD |
1153 | "Reenables window updating after a previous call to Freeze. Calls to |
1154 | Freeze/Thaw may be nested, so Thaw must be called the same number of times | |
1155 | that Freeze was before the window will be updated."); | |
0facd0e5 | 1156 | |
d14a1e28 | 1157 | |
0facd0e5 RD |
1158 | DocDeclStr( |
1159 | virtual void , PrepareDC( wxDC & dc ), | |
1160 | "Call this function to prepare the device context for drawing a | |
1161 | scrolled image. It sets the device origin according to the current | |
1162 | scroll position."); | |
1163 | ||
1164 | ||
1165 | DocDeclStr( | |
1166 | wxRegion& , GetUpdateRegion(), | |
1167 | "Returns the region specifying which parts of the window have been | |
1168 | damaged. Should only be called within an EVT_PAINT handler."); | |
1169 | ||
d14a1e28 | 1170 | |
0facd0e5 RD |
1171 | DocDeclStr( |
1172 | wxRect , GetUpdateClientRect() const, | |
1173 | "Get the update rectangle region bounding box in client coords."); | |
1174 | ||
1175 | ||
1176 | DocStr(IsExposed, | |
1177 | "Returns true if the given point or rectangle area has been exposed | |
1178 | since the last repaint. Call this in an paint event handler to | |
1179 | optimize redrawing by only redrawing those areas, which have been | |
1180 | exposed."); | |
d14a1e28 RD |
1181 | bool IsExposed( int x, int y, int w=1, int h=1 ) const; |
1182 | %name(IsExposedPoint) bool IsExposed( const wxPoint& pt ) const; | |
2f4ad68c | 1183 | %name(IsExposedRect) bool IsExposed( const wxRect& rect ) const; |
d14a1e28 RD |
1184 | |
1185 | ||
1186 | ||
1187 | // colours, fonts and cursors | |
1188 | // -------------------------- | |
1189 | ||
d14a1e28 | 1190 | |
174051f6 RD |
1191 | DocDeclStr( |
1192 | wxVisualAttributes , GetDefaultAttributes() const, | |
1193 | "Get the default attributes for an instance of this class. This | |
1194 | is useful if you want to use the same font or colour in your own | |
1195 | control as in a standard control -- which is a much better idea | |
1196 | than hard coding specific colours or fonts which might look | |
1197 | completely out of place on the users system, especially if it | |
1198 | uses themes."); | |
1199 | ||
d14a1e28 | 1200 | |
174051f6 RD |
1201 | DocDeclStr( |
1202 | static wxVisualAttributes , | |
1203 | GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL), | |
1204 | "Get the default attributes for this class. This is useful if | |
1205 | you want to use the same font or colour in your own control as | |
1206 | in a standard control -- which is a much better idea than hard | |
1207 | coding specific colours or fonts which might look completely out | |
1208 | of place on the users system, especially if it uses themes. | |
1209 | ||
1210 | The variant parameter is only relevant under Mac currently and is | |
1211 | ignore under other platforms. Under Mac, it will change the size of the | |
1212 | returned font. See SetWindowVariant for more about this."); | |
1213 | ||
0facd0e5 RD |
1214 | |
1215 | DocDeclStr( | |
1216 | virtual bool , SetBackgroundColour( const wxColour &colour ), | |
1217 | "Sets the background colour of the window. Returns True if the colour | |
1218 | was changed. The background colour is usually painted by the default | |
1219 | EVT_ERASE_BACKGROUND event handler function under Windows and | |
1220 | automatically under GTK. | |
1221 | ||
1222 | Note that setting the background colour does not cause an immediate | |
1223 | refresh, so you may wish to call ClearBackground or Refresh after | |
1224 | calling this function. | |
1225 | ||
1226 | Use this function with care under GTK+ as the new appearance of the | |
1227 | window might not look equally well when used with themes, i.e GTK+'s | |
1228 | ability to change its look as the user wishes with run-time loadable | |
1229 | modules."); | |
1230 | ||
1231 | DocDeclStr( | |
1232 | virtual bool , SetForegroundColour( const wxColour &colour ), | |
1233 | "Sets the foreground colour of the window. Returns True is the colour | |
1234 | was changed. The interpretation of foreground colour is dependent on | |
1235 | the window class; it may be the text colour or other colour, or it may | |
1236 | not be used at all."); | |
174051f6 | 1237 | |
0facd0e5 RD |
1238 | |
1239 | DocDeclStr( | |
1240 | wxColour , GetBackgroundColour() const, | |
1241 | "Returns the background colour of the window."); | |
1242 | ||
1243 | DocDeclStr( | |
1244 | wxColour , GetForegroundColour() const, | |
1245 | "Returns the foreground colour of the window. The interpretation of | |
1246 | foreground colour is dependent on the window class; it may be the text | |
1247 | colour or other colour, or it may not be used at all."); | |
1248 | ||
d14a1e28 | 1249 | |
d14a1e28 | 1250 | |
0facd0e5 RD |
1251 | |
1252 | DocDeclStr( | |
1253 | virtual bool , SetCursor( const wxCursor &cursor ), | |
1254 | "Sets the window's cursor. Notice that the window cursor also sets it | |
1255 | for the children of the window implicitly. | |
d14a1e28 | 1256 | |
0facd0e5 RD |
1257 | The cursor may be wx.NullCursor in which case the window cursor will |
1258 | be reset back to default."); | |
1259 | ||
1260 | DocDeclStr( | |
1261 | wxCursor& , GetCursor(), | |
1262 | "Return the cursor associated with this window."); | |
1263 | ||
d14a1e28 | 1264 | |
0facd0e5 RD |
1265 | |
1266 | DocDeclStr( | |
1267 | virtual bool , SetFont( const wxFont &font ), | |
1268 | "Sets the font for this window."); | |
1269 | ||
1270 | DocDeclStr( | |
1271 | wxFont& , GetFont(), | |
2f4ad68c | 1272 | "Returns the default font used for this window."); |
0facd0e5 RD |
1273 | |
1274 | ||
1275 | ||
1276 | DocDeclStr( | |
1277 | void , SetCaret(wxCaret *caret), | |
1278 | "Sets the caret associated with the window."); | |
1279 | ||
1280 | DocDeclStr( | |
1281 | wxCaret *, GetCaret() const, | |
1282 | "Returns the caret associated with the window."); | |
1283 | ||
1284 | ||
1285 | ||
1286 | DocDeclStr( | |
1287 | virtual int , GetCharHeight() const, | |
1288 | "Get the (average) character size for the current font."); | |
1289 | ||
1290 | DocDeclStr( | |
1291 | virtual int , GetCharWidth() const, | |
1292 | "Get the (average) character size for the current font."); | |
1293 | ||
d14a1e28 | 1294 | |
dd9f7fea RD |
1295 | |
1296 | DocDeclAStr( | |
1297 | void, GetTextExtent(const wxString& string, int *OUTPUT, int *OUTPUT), | |
64e8a1f0 | 1298 | "GetTextExtent(String string) -> (width, height)", |
dd9f7fea RD |
1299 | "Get the width and height of the text using the current font."); |
1300 | DocDeclAStrName( | |
1301 | void, GetTextExtent(const wxString& string, | |
1302 | int *OUTPUT, int *OUTPUT, int *OUTPUT, int* OUTPUT, | |
1303 | const wxFont* font = NULL), | |
64e8a1f0 | 1304 | "GetFullTextExtent(String string, Font font=None) ->\n (width, height, descent, externalLeading)", |
0facd0e5 RD |
1305 | "Get the width, height, decent and leading of the text using the |
1306 | current or specified font.", | |
dd9f7fea RD |
1307 | GetFullTextExtent); |
1308 | ||
d14a1e28 RD |
1309 | |
1310 | ||
1311 | // client <-> screen coords | |
1312 | // ------------------------ | |
1313 | ||
1314 | %apply int * INOUT { int* x, int* y }; | |
1315 | ||
1316 | // translate to/from screen/client coordinates | |
0facd0e5 RD |
1317 | DocDeclAStrName( |
1318 | void , ClientToScreen( int *x, int *y ) const, | |
1319 | "ClientToScreenXY(int x, int y) -> (x,y)", | |
1320 | "Converts to screen coordinates from coordinates relative to this window.", | |
1321 | ClientToScreenXY); | |
1322 | ||
1323 | DocDeclAStrName( | |
1324 | void , ScreenToClient( int *x, int *y ) const, | |
1325 | "ScreenToClientXY(int x, int y) -> (x,y)", | |
1326 | "Converts from screen to client window coordinates.", | |
1327 | ScreenToClientXY); | |
1328 | ||
d14a1e28 | 1329 | |
0facd0e5 RD |
1330 | DocDeclStr( |
1331 | wxPoint , ClientToScreen(const wxPoint& pt) const, | |
1332 | "Converts to screen coordinates from coordinates relative to this window."); | |
1333 | ||
1334 | DocDeclStr( | |
1335 | wxPoint , ScreenToClient(const wxPoint& pt) const, | |
1336 | "Converts from screen to client window coordinates."); | |
1337 | ||
d14a1e28 | 1338 | |
0facd0e5 RD |
1339 | |
1340 | DocDeclStrName( | |
1341 | wxHitTest , HitTest(wxCoord x, wxCoord y) const, | |
1342 | "Test where the given (in client coords) point lies", | |
1343 | HitTestXY); | |
1344 | ||
1345 | DocDeclStr( | |
1346 | wxHitTest , HitTest(const wxPoint& pt) const, | |
1347 | "Test where the given (in client coords) point lies"); | |
1348 | ||
d14a1e28 RD |
1349 | |
1350 | ||
1351 | ||
1352 | // misc | |
1353 | // ---- | |
1354 | ||
0facd0e5 RD |
1355 | %nokwargs GetBorder; |
1356 | DocDeclStr( | |
1357 | wxBorder , GetBorder(long flags) const, | |
1358 | "Get the window border style from the given flags: this is different | |
1359 | from simply doing flags & wxBORDER_MASK because it uses | |
1360 | GetDefaultBorder() to translate wxBORDER_DEFAULT to something | |
1361 | reasonable. | |
1362 | "); | |
1363 | ||
1364 | DocDeclStr( | |
1365 | wxBorder , GetBorder() const, | |
1366 | "Get border for the flags of this window"); | |
1367 | ||
d14a1e28 | 1368 | |
0facd0e5 | 1369 | |
d14a1e28 | 1370 | |
0facd0e5 RD |
1371 | DocDeclStr( |
1372 | virtual void , UpdateWindowUI(long flags = wxUPDATE_UI_NONE), | |
1373 | "This function sends EVT_UPDATE_UI events to the window. The particular | |
1374 | implementation depends on the window; for example a wx.ToolBar will | |
1375 | send an update UI event for each toolbar button, and a wx.Frame will | |
1376 | send an update UI event for each menubar menu item. You can call this | |
1377 | function from your application to ensure that your UI is up-to-date at | |
1378 | a particular point in time (as far as your EVT_UPDATE_UI handlers are | |
1379 | concerned). This may be necessary if you have called | |
1380 | wx.UpdateUIEvent.SetMode or wx.UpdateUIEvent.SetUpdateInterval to | |
1381 | limit the overhead that wxWindows incurs by sending update UI events | |
1382 | in idle time. | |
1383 | ||
1384 | The flags should be a bitlist of one or more of the following values: | |
1385 | ||
1386 | wx.UPDATE_UI_NONE No particular value | |
1387 | wx.UPDATE_UI_RECURSE Call the function for descendants | |
1388 | wx.UPDATE_UI_FROMIDLE Invoked from OnIdle | |
1389 | ||
1390 | If you are calling this function from an OnIdle function, make sure | |
1391 | you pass the wx.UPDATE_UI_FROMIDLE flag, since this tells the window to | |
1392 | only update the UI elements that need to be updated in idle time. Some | |
1393 | windows update their elements only when necessary, for example when a | |
1394 | menu is about to be shown. The following is an example of how to call | |
1395 | UpdateWindowUI from an idle function. | |
1396 | ||
1397 | def OnIdle(self, evt): | |
1398 | if wx.UpdateUIEvent.CanUpdate(self): | |
1399 | self.UpdateWindowUI(wx.UPDATE_UI_FROMIDLE); | |
1400 | "); | |
1401 | ||
d14a1e28 RD |
1402 | |
1403 | // TODO: using directors? | |
1404 | // // do the window-specific processing after processing the update event | |
1405 | // virtual void DoUpdateWindowUI(wxUpdateUIEvent& event) ; | |
1406 | ||
0facd0e5 RD |
1407 | |
1408 | DocStr(PopupMenu, | |
1409 | "Pops up the given menu at the specified coordinates, relative to this | |
1410 | window, and returns control when the user has dismissed the menu. If a | |
1411 | menu item is selected, the corresponding menu event is generated and | |
1412 | will be processed as usual."); | |
d14a1e28 RD |
1413 | %name(PopupMenuXY) bool PopupMenu(wxMenu *menu, int x, int y); |
1414 | bool PopupMenu(wxMenu *menu, const wxPoint& pos); | |
1415 | ||
0facd0e5 RD |
1416 | |
1417 | ||
1418 | ||
d14a1e28 | 1419 | %extend { |
0facd0e5 RD |
1420 | DocStr(GetHandle, |
1421 | "Returns the platform-specific handle (as a long integer) of the | |
1422 | physical window. Currently on wxMac it returns the handle of the | |
1423 | toplevel parent of the window."); | |
d14a1e28 RD |
1424 | long GetHandle() { |
1425 | return wxPyGetWinHandle(self); | |
1426 | } | |
1427 | } | |
1428 | ||
1429 | ||
0facd0e5 | 1430 | |
d14a1e28 RD |
1431 | #ifdef __WXMSW__ |
1432 | // A way to do the native draw first... Too bad it isn't in wxGTK too. | |
1433 | void OnPaint(wxPaintEvent& event); | |
1434 | #endif | |
1435 | ||
1436 | ||
1437 | ||
1438 | // scrollbars | |
1439 | // ---------- | |
1440 | ||
0facd0e5 RD |
1441 | |
1442 | DocDeclStr( | |
1443 | bool , HasScrollbar(int orient) const, | |
1444 | "Does the window have the scrollbar for this orientation?"); | |
1445 | ||
d14a1e28 RD |
1446 | |
1447 | // configure the window scrollbars | |
0facd0e5 RD |
1448 | DocDeclStr( |
1449 | virtual void , SetScrollbar( int orientation, | |
1450 | int pos, | |
1451 | int thumbvisible, | |
1452 | int range, | |
1453 | bool refresh = True ), | |
1454 | "Sets the scrollbar properties of a built-in scrollbar. | |
1455 | ||
1456 | orientation: Determines the scrollbar whose page size is to be | |
1457 | set. May be wx.HORIZONTAL or wx.VERTICAL. | |
1458 | ||
1459 | position: The position of the scrollbar in scroll units. | |
1460 | ||
1461 | thumbSize: The size of the thumb, or visible portion of the | |
1462 | scrollbar, in scroll units. | |
1463 | ||
1464 | range: The maximum position of the scrollbar. | |
1465 | ||
1466 | refresh: True to redraw the scrollbar, false otherwise."); | |
1467 | ||
1468 | DocDeclStr( | |
1469 | virtual void , SetScrollPos( int orientation, int pos, bool refresh = True ), | |
1470 | "Sets the position of one of the built-in scrollbars."); | |
1471 | ||
1472 | DocDeclStr( | |
1473 | virtual int , GetScrollPos( int orientation ) const, | |
1474 | "Returns the built-in scrollbar position."); | |
1475 | ||
1476 | DocDeclStr( | |
1477 | virtual int , GetScrollThumb( int orientation ) const, | |
1478 | "Returns the built-in scrollbar thumb size."); | |
1479 | ||
1480 | DocDeclStr( | |
1481 | virtual int , GetScrollRange( int orientation ) const, | |
1482 | "Returns the built-in scrollbar range."); | |
1483 | ||
1484 | ||
1485 | ||
1486 | ||
1487 | DocDeclStr( | |
1488 | virtual void , ScrollWindow( int dx, int dy, | |
1489 | const wxRect* rect = NULL ), | |
1490 | "Physically scrolls the pixels in the window and move child windows | |
1491 | accordingly. Use this function to optimise your scrolling | |
1492 | implementations, to minimise the area that must be redrawn. Note that | |
1493 | it is rarely required to call this function from a user program. | |
1494 | ||
1495 | dx: Amount to scroll horizontally. | |
1496 | ||
1497 | dy: Amount to scroll vertically. | |
1498 | ||
1499 | rect: Rectangle to invalidate. If this is None, the whole window | |
1500 | is invalidated. If you pass a rectangle corresponding to the | |
1501 | area of the window exposed by the scroll, your painting | |
1502 | handler can optimize painting by checking for the | |
1503 | invalidated region."); | |
1504 | ||
1505 | ||
1506 | DocDeclStr( | |
1507 | virtual bool , ScrollLines(int lines), | |
1508 | "If the platform and window class supports it, scrolls the window by | |
1509 | the given number of lines down, if lines is positive, or up if lines | |
1510 | is negative. Returns True if the window was scrolled, False if it was | |
1511 | already on top/bottom and nothing was done."); | |
1512 | ||
1513 | DocDeclStr( | |
1514 | virtual bool , ScrollPages(int pages), | |
1515 | "If the platform and window class supports it, scrolls the window by | |
1516 | the given number of pages down, if pages is positive, or up if pages | |
1517 | is negative. Returns True if the window was scrolled, False if it was | |
1518 | already on top/bottom and nothing was done."); | |
1519 | ||
1520 | ||
1521 | DocDeclStr( | |
1522 | bool , LineUp(), | |
1523 | "This is just a wrapper for ScrollLines(-1)."); | |
1524 | ||
1525 | DocDeclStr( | |
1526 | bool , LineDown(), | |
1527 | "This is just a wrapper for ScrollLines(1)."); | |
1528 | ||
1529 | DocDeclStr( | |
1530 | bool , PageUp(), | |
1531 | "This is just a wrapper for ScrollPages(-1)."); | |
1532 | ||
1533 | DocDeclStr( | |
1534 | bool , PageDown(), | |
1535 | "This is just a wrapper for ScrollPages(1)."); | |
1536 | ||
d14a1e28 RD |
1537 | |
1538 | ||
1539 | ||
1540 | // context-sensitive help | |
1541 | // ---------------------- | |
1542 | ||
0facd0e5 RD |
1543 | DocDeclStr( |
1544 | void , SetHelpText(const wxString& text), | |
1545 | "Sets the help text to be used as context-sensitive help for this | |
1546 | window. Note that the text is actually stored by the current | |
1547 | wxHelpProvider implementation, and not in the window object itself."); | |
1548 | ||
d14a1e28 | 1549 | |
0facd0e5 RD |
1550 | DocDeclStr( |
1551 | void , SetHelpTextForId(const wxString& text), | |
1552 | "Associate this help text with all windows with the same id as this | |
1553 | one."); | |
1554 | ||
d14a1e28 | 1555 | |
0facd0e5 RD |
1556 | DocDeclStr( |
1557 | wxString , GetHelpText() const, | |
1558 | "Gets the help text to be used as context-sensitive help for this | |
1559 | window. Note that the text is actually stored by the current | |
1560 | wxHelpProvider implementation, and not in the window object itself."); | |
1561 | ||
d14a1e28 RD |
1562 | |
1563 | ||
f87da722 | 1564 | #ifndef __WXX11__ |
d14a1e28 RD |
1565 | // tooltips |
1566 | // -------- | |
1567 | ||
0facd0e5 RD |
1568 | DocStr(SetToolTip, |
1569 | "Attach a tooltip to the window."); | |
d14a1e28 | 1570 | %name(SetToolTipString) void SetToolTip( const wxString &tip ); |
d14a1e28 RD |
1571 | void SetToolTip( wxToolTip *tip ); |
1572 | ||
0facd0e5 RD |
1573 | DocDeclStr( |
1574 | wxToolTip* , GetToolTip() const, | |
1575 | "get the associated tooltip or None if none"); | |
1576 | ||
d14a1e28 | 1577 | // LINK ERROR --> wxString GetToolTipText() const; |
f87da722 | 1578 | #endif |
d14a1e28 RD |
1579 | |
1580 | ||
f87da722 RD |
1581 | |
1582 | #ifndef __WXX11__ | |
d14a1e28 RD |
1583 | // drag and drop |
1584 | // ------------- | |
1585 | ||
1586 | // set/retrieve the drop target associated with this window (may be | |
1587 | // NULL; it's owned by the window and will be deleted by it) | |
8668c242 | 1588 | %apply SWIGTYPE *DISOWN { wxPyDropTarget *dropTarget }; |
0facd0e5 RD |
1589 | |
1590 | DocDeclStr( | |
1591 | virtual void , SetDropTarget( wxPyDropTarget *dropTarget ), | |
1592 | "Associates a drop target with this window. If the window already has | |
1593 | a drop target, it is deleted."); | |
1594 | ||
8668c242 | 1595 | %clear wxPyDropTarget *dropTarget; |
0facd0e5 RD |
1596 | |
1597 | ||
1598 | DocDeclStr( | |
1599 | virtual wxPyDropTarget *, GetDropTarget() const, | |
1600 | "Returns the associated drop target, which may be None."); | |
8668c242 | 1601 | |
d14a1e28 RD |
1602 | |
1603 | #ifdef __WXMSW__ // TODO: should I drop-kick this? | |
0facd0e5 RD |
1604 | DocDeclStr( |
1605 | void , DragAcceptFiles(bool accept), | |
1606 | "Enables or disables eligibility for drop file events, EVT_DROP_FILES. | |
1607 | Only available on Windows."); | |
d14a1e28 | 1608 | #endif |
f87da722 RD |
1609 | #endif |
1610 | ||
d14a1e28 RD |
1611 | |
1612 | // constraints and sizers | |
1613 | // ---------------------- | |
1614 | ||
1615 | // set the constraints for this window or retrieve them (may be NULL) | |
0facd0e5 RD |
1616 | DocDeclStr( |
1617 | void , SetConstraints( wxLayoutConstraints *constraints ), | |
1618 | "Sets the window to have the given layout constraints. If an existing | |
1619 | layout constraints object is already owned by the window, it will be | |
1620 | deleted. Pass None to disassociate and delete the window's current | |
1621 | constraints. | |
1622 | ||
1623 | You must call SetAutoLayout to tell a window to use the constraints | |
1624 | automatically in its default EVT_SIZE handler; otherwise, you must | |
1625 | handle EVT_SIZE yourself and call Layout() explicitly. When setting | |
1626 | both a wx.LayoutConstraints and a wx.Sizer, only the sizer will have | |
1627 | effect."); | |
1628 | ||
1629 | DocDeclStr( | |
1630 | wxLayoutConstraints *, GetConstraints() const, | |
1631 | "Returns a pointer to the window's layout constraints, or None if there | |
1632 | are none."); | |
1633 | ||
d14a1e28 | 1634 | |
0facd0e5 RD |
1635 | DocDeclStr( |
1636 | void , SetAutoLayout( bool autoLayout ), | |
1637 | "Determines whether the Layout function will be called automatically | |
1638 | when the window is resized. It is called implicitly by SetSizer but | |
1639 | if you use SetConstraints you should call it manually or otherwise the | |
1640 | window layout won't be correctly updated when its size changes."); | |
1641 | ||
1642 | DocDeclStr( | |
1643 | bool , GetAutoLayout() const, | |
1644 | "Returns the current autoLayout setting"); | |
1645 | ||
d14a1e28 | 1646 | |
0facd0e5 RD |
1647 | DocDeclStr( |
1648 | virtual bool , Layout(), | |
1649 | "Invokes the constraint-based layout algorithm or the sizer-based | |
1650 | algorithm for this window. See SetAutoLayout: when auto layout is on, | |
1651 | this function gets called automatically by the default EVT_SIZE | |
1652 | handler when the window is resized."); | |
1653 | ||
d14a1e28 | 1654 | |
0facd0e5 RD |
1655 | DocDeclStr( |
1656 | void , SetSizer(wxSizer *sizer, bool deleteOld = True ), | |
1657 | "Sets the window to have the given layout sizer. The window will then | |
1658 | own the object, and will take care of its deletion. If an existing | |
1659 | layout sizer object is already owned by the window, it will be deleted | |
1660 | if the deleteOld parameter is true. Note that this function will also | |
1661 | call SetAutoLayout implicitly with a True parameter if the sizer is | |
1662 | non-NoneL and False otherwise."); | |
1663 | ||
1664 | DocDeclStr( | |
1665 | void , SetSizerAndFit( wxSizer *sizer, bool deleteOld = True ), | |
1666 | "The same as SetSizer, except it also sets the size hints for the | |
1667 | window based on the sizer's minimum size."); | |
1668 | ||
d14a1e28 | 1669 | |
0facd0e5 RD |
1670 | DocDeclStr( |
1671 | wxSizer *, GetSizer() const, | |
1672 | "Return the sizer associated with the window by a previous call to | |
1673 | SetSizer or None if there isn't one."); | |
1674 | ||
d14a1e28 RD |
1675 | |
1676 | // Track if this window is a member of a sizer | |
0facd0e5 RD |
1677 | DocDeclStr( |
1678 | void , SetContainingSizer(wxSizer* sizer), | |
1679 | "This normally does not need to be called by application code. It is | |
1680 | called internally when a window is added to a sizer, and is used so | |
1681 | the window can remove itself from the sizer when it is destroyed."); | |
1682 | ||
1683 | DocDeclStr( | |
1684 | wxSizer *, GetContainingSizer() const, | |
1685 | "Return the sizer that this window is a member of, if any, otherwise None."); | |
1686 | ||
d14a1e28 RD |
1687 | |
1688 | ||
1689 | ||
1690 | // accessibility | |
1691 | // ---------------------- | |
1692 | #if wxUSE_ACCESSIBILITY | |
1693 | // Override to create a specific accessible object. | |
1694 | virtual wxAccessible* CreateAccessible(); | |
1695 | ||
1696 | // Sets the accessible object. | |
1697 | void SetAccessible(wxAccessible* accessible) ; | |
1698 | ||
1699 | // Returns the accessible object. | |
1700 | wxAccessible* GetAccessible() { return m_accessible; }; | |
1701 | ||
1702 | // Returns the accessible object, creating if necessary. | |
1703 | wxAccessible* GetOrCreateAccessible() ; | |
1704 | #endif | |
1705 | ||
1706 | ||
1707 | ||
1708 | %pythoncode { | |
1709 | def PostCreate(self, pre): | |
0facd0e5 RD |
1710 | """ |
1711 | Phase 3 of the 2-phase create <wink!> | |
1712 | Call this method after precreating the window with the 2-phase create method. | |
1713 | """ | |
d14a1e28 RD |
1714 | self.this = pre.this |
1715 | self.thisown = pre.thisown | |
1716 | pre.thisown = 0 | |
1717 | if hasattr(self, '_setOORInfo'): | |
1718 | self._setOORInfo(self) | |
1719 | if hasattr(self, '_setCallbackInfo'): | |
1720 | self._setCallbackInfo(self, self.__class__) | |
1721 | } | |
1722 | }; | |
1723 | ||
1724 | ||
1725 | ||
1726 | ||
1727 | ||
1728 | ||
1729 | ||
1730 | ||
1731 | %pythoncode { | |
1732 | def DLG_PNT(win, point_or_x, y=None): | |
0facd0e5 RD |
1733 | """ |
1734 | Convenience function for converting a Point or (x,y) in | |
1735 | dialog units to pixel units. | |
1736 | """ | |
d14a1e28 RD |
1737 | if y is None: |
1738 | return win.ConvertDialogPointToPixels(point_or_x) | |
1739 | else: | |
fd3f2efe | 1740 | return win.ConvertDialogPointToPixels(wx.Point(point_or_x, y)) |
d14a1e28 RD |
1741 | |
1742 | def DLG_SZE(win, size_width, height=None): | |
0facd0e5 RD |
1743 | """ |
1744 | Convenience function for converting a Size or (w,h) in | |
1745 | dialog units to pixel units. | |
1746 | """ | |
d14a1e28 RD |
1747 | if height is None: |
1748 | return win.ConvertDialogSizeToPixels(size_width) | |
1749 | else: | |
fd3f2efe | 1750 | return win.ConvertDialogSizeToPixels(wx.Size(size_width, height)) |
d14a1e28 RD |
1751 | } |
1752 | ||
1753 | ||
1754 | ||
1755 | ||
1756 | // Unfortunatly the names of these new static methods clash with the | |
1757 | // names wxPython has been using forever for the overloaded | |
1758 | // wxWindow::FindWindow, so instead of swigging them as statics create | |
1759 | // standalone functions for them. | |
1760 | ||
1761 | ||
0facd0e5 RD |
1762 | DocStr(wxFindWindowById, |
1763 | "Find the first window in the application with the given id. If parent | |
1764 | is None, the search will start from all top-level frames and dialog | |
1765 | boxes; if non-None, the search will be limited to the given window | |
1766 | hierarchy. The search is recursive in both cases."); | |
1767 | ||
1768 | DocStr(wxFindWindowByName, | |
1769 | "Find a window by its name (as given in a window constructor or Create | |
1770 | function call). If parent is None, the search will start from all | |
1771 | top-level frames and dialog boxes; if non-None, the search will be | |
1772 | limited to the given window hierarchy. The search is recursive in both | |
1773 | cases. | |
1774 | ||
1775 | If no window with such name is found, wx.FindWindowByLabel is called."); | |
1776 | ||
1777 | DocStr(wxFindWindowByLabel, | |
1778 | "Find a window by its label. Depending on the type of window, the label | |
1779 | may be a window title or panel item label. If parent is None, the | |
1780 | search will start from all top-level frames and dialog boxes; if | |
1781 | non-None, the search will be limited to the given window | |
1782 | hierarchy. The search is recursive in both cases."); | |
1783 | ||
1784 | ||
d14a1e28 RD |
1785 | %inline %{ |
1786 | wxWindow* wxFindWindowById( long id, const wxWindow *parent = NULL ) { | |
1787 | return wxWindow::FindWindowById(id, parent); | |
1788 | } | |
1789 | ||
1790 | wxWindow* wxFindWindowByName( const wxString& name, | |
1791 | const wxWindow *parent = NULL ) { | |
1792 | return wxWindow::FindWindowByName(name, parent); | |
1793 | } | |
1794 | ||
1795 | wxWindow* wxFindWindowByLabel( const wxString& label, | |
1796 | const wxWindow *parent = NULL ) { | |
1797 | return wxWindow::FindWindowByLabel(label, parent); | |
1798 | } | |
1799 | %} | |
1800 | ||
1801 | ||
1802 | ||
96577d6d RD |
1803 | %{ |
1804 | #ifdef __WXMSW__ | |
1805 | #include <wx/msw/private.h> // to get wxGetWindowId | |
1806 | #endif | |
1807 | %} | |
1808 | ||
d14a1e28 | 1809 | %inline %{ |
2f4ad68c | 1810 | wxWindow* wxWindow_FromHWND(wxWindow* parent, unsigned long _hWnd) { |
d14a1e28 | 1811 | #ifdef __WXMSW__ |
2f4ad68c RD |
1812 | WXHWND hWnd = (WXHWND)_hWnd; |
1813 | long id = wxGetWindowId(hWnd); | |
d14a1e28 | 1814 | wxWindow* win = new wxWindow; |
2f4ad68c RD |
1815 | parent->AddChild(win); |
1816 | win->SetEventHandler(win); | |
1817 | win->SetHWND(hWnd); | |
1818 | win->SetId(id); | |
1819 | win->SubclassWin(hWnd); | |
1820 | win->AdoptAttributesFromHWND(); | |
1821 | win->SetupColours(); | |
d14a1e28 RD |
1822 | return win; |
1823 | #else | |
81cfe5e1 | 1824 | wxPyRaiseNotImplemented(); |
d14a1e28 RD |
1825 | return NULL; |
1826 | #endif | |
1827 | } | |
1828 | %} | |
1829 | ||
1830 | //--------------------------------------------------------------------------- | |
1831 | //--------------------------------------------------------------------------- | |
1832 |