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