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