X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/791fbf3481006a916c6d941fb037a17e9b9dc507..5f2502393e042e6e2c871ff94b7ccaf7a78b264d:/wxPython/src/_window.i diff --git a/wxPython/src/_window.i b/wxPython/src/_window.i index 8861980054..b59bf49633 100644 --- a/wxPython/src/_window.i +++ b/wxPython/src/_window.i @@ -175,12 +175,12 @@ Extra Styles wx.WS_EX_PROCESS_IDLE This window should always process idle events, even if the mode set by - wx.IdleEvent.SetMode is + `wx.IdleEvent.SetMode` is wx.IDLE_PROCESS_SPECIFIED. wx.WS_EX_PROCESS_UI_UPDATES This window should always process UI update events, even if the mode - set by wxUpdateUIEvent::SetMode is + set by `wx.UpdateUIEvent.SetMode` is wxUPDATE_UI_PROCESS_SPECIFIED. ============================= ===================================== @@ -259,6 +259,7 @@ instead."); + %pythonPrepend Destroy "args[0].this.own(False)" DocDeclStr( virtual bool , Destroy(), "Destroys the window safely. Frames and dialogs are not destroyed @@ -286,14 +287,13 @@ destructor.", ""); // window attributes // ----------------- - DocDeclStr( - virtual void , SetTitle( const wxString& title), - "Sets the window's title. Applicable only to frames and dialogs.", ""); - - DocDeclStr( - virtual wxString , GetTitle() const, - "Gets the window's title. Applicable only to frames and dialogs.", ""); + //DocDeclStr( + // virtual void , SetTitle( const wxString& title), + // "Sets the window's title. Applicable only to frames and dialogs.", ""); + //DocDeclStr( + // virtual wxString , GetTitle() const, + // "Gets the window's title. Applicable only to frames and dialogs.", ""); DocDeclStr( virtual void , SetLabel(const wxString& label), @@ -373,6 +373,25 @@ autogenerated) id", ""); autogenerated) id", ""); + DocDeclStr( + virtual wxLayoutDirection , GetLayoutDirection() const, + "Get the layout direction (LTR or RTL) for this window. Returns +``wx.Layout_Default`` if layout direction is not supported.", ""); + + DocDeclStr( + virtual void , SetLayoutDirection(wxLayoutDirection dir), + "Set the layout direction (LTR or RTL) for this window.", ""); + + + DocDeclStr( + virtual wxCoord , AdjustForLayoutDirection(wxCoord x, + wxCoord width, + wxCoord widthTotal) const, + "Mirror coordinates for RTL layout if this window uses it and if the +mirroring is not done automatically like Win32.", ""); + + + // moving/resizing @@ -437,13 +456,13 @@ window's *best size* values. Also set's the minsize for use with sizers.", ""); DocDeclStr( virtual void , Raise(), - "Raises the window to the top of the window hierarchy if it is a -managed window (dialog or frame).", ""); + "Raises the window to the top of the window hierarchy. In current +version of wxWidgets this works both for manage and child windows.", ""); DocDeclStr( virtual void , Lower(), - "Lowers the window to the bottom of the window hierarchy if it is a -managed window (dialog or frame).", ""); + "Lowers the window to the bottom of the window hierarchy. In current +version of wxWidgets this works both for manage and child windows.", ""); @@ -460,14 +479,32 @@ around panel items, for example.", ""); DocStr(GetPosition, // sets the docstring for both - "Get the window's position.", ""); - wxPoint GetPosition(); + "Get the window's position. Notice that the position is in client +coordinates for child windows and screen coordinates for the top level +ones, use `GetScreenPosition` if you need screen coordinates for all +kinds of windows.", ""); + wxPoint GetPosition() const; DocDeclAName( - void, GetPosition(int *OUTPUT, int *OUTPUT), + void, GetPosition(int *OUTPUT, int *OUTPUT) const, "GetPositionTuple() -> (x,y)", GetPositionTuple); + + DocStr(GetScreenPosition, // sets the docstring for both + "Get the position of the window in screen coordinantes.", ""); + wxPoint GetScreenPosition() const; + DocDeclAName( + void, GetScreenPosition(int *OUTPUT, int *OUTPUT) const, + "GetScreenPositionTuple() -> (x,y)", + GetScreenPositionTuple); + + DocDeclStr( + wxRect , GetScreenRect() const, + "Returns the size and position of the window in screen coordinantes as +a `wx.Rect` object.", " +:see: `GetRect`, `GetScreenPosition`"); + DocStr(GetSize, "Get the window size.", ""); wxSize GetSize() const; @@ -480,7 +517,7 @@ around panel items, for example.", ""); DocDeclStr( wxRect , GetRect() const, - "Returns the size and position of the window as a wx.Rect object.", ""); + "Returns the size and position of the window as a `wx.Rect` object.", ""); DocStr(GetClientSize, @@ -527,6 +564,10 @@ after calling Fit.", ""); "Reset the cached best size value so it will be recalculated the next time it is needed.", ""); + DocDeclStr( + void , CacheBestSize(const wxSize& size) const, + "Cache the best size so it doesn't need to be calculated again, (at least until +some properties of the window change.)", ""); DocDeclStr( @@ -556,17 +597,10 @@ cetering, and may be wx.HORIZONTAL, wx.VERTICAL or wx.BOTH. It may also include wx.CENTER_ON_SCREEN flag if you want to center the window on the entire screen and not on its parent window. If it is a top-level window and has no parent then it will always be centered -relative to the screen.", ""); - +relative to the screen.", ""); %pythoncode { Centre = Center } - DocDeclStr( - void , CenterOnScreen(int dir = wxBOTH), - "Center on screen (only works for top level windows)", ""); - %pythoncode { CentreOnScreen = CenterOnScreen } - - DocDeclStr( void , CenterOnParent(int dir = wxBOTH), "Center with respect to the the parent window", ""); @@ -699,6 +733,10 @@ sizer, interior children, or other means)", ""); +// void SetScrollHelper( wxScrollHelper *sh ); +// wxScrollHelper *GetScrollHelper(); + + // window state // ------------ @@ -736,6 +774,12 @@ window had already been in the specified state.", ""); bool , IsEnabled() const, "Returns true if the window is enabled for input, false otherwise.", ""); + DocDeclStr( + virtual bool , IsShownOnScreen() const, + "Returns ``True`` if the window is physically visible on the screen, +i.e. it is shown and all its parents up to the toplevel window are +shown as well.", ""); + @@ -847,20 +891,6 @@ it.", ""); - - DocDeclStr( - virtual wxWindow *, GetDefaultItem() const, - "Get the default child of this parent, i.e. the one which is activated -by pressing such as the OK button on a wx.Dialog.", ""); - - DocDeclStr( - virtual wxWindow *, SetDefaultItem(wxWindow * child), - "Set this child as default, return the old default.", ""); - - DocDeclStr( - virtual void , SetTmpDefaultItem(wxWindow * win), - "Set this child as temporary default", ""); - DocDeclAStr( virtual bool , Navigate(int flags = wxNavigationKeyEvent::IsForward), @@ -965,9 +995,18 @@ functions so should not be required by the application programmer.", ""); "Removes a child window. This is called automatically by window deletion functions so should not be required by the application programmer.", ""); - + DocStr(SetDoubleBuffered, + "Currently wxGTK2 only.", ""); +#ifdef __WXGTK__ + void SetDoubleBuffered(bool on); +#else + %extend { + void SetDoubleBuffered(bool on) {} + } +#endif + // looking for windows // ------------------- @@ -996,42 +1035,48 @@ its own event handler.", ""); DocDeclStr( void , SetEventHandler( wxEvtHandler *handler ), "Sets the event handler for this window. An event handler is an object -that is capable of processing the events sent to a window. By default, -the window is its own event handler, but an application may wish to -substitute another, for example to allow central implementation of -event-handling for a variety of different window classes. +that is capable of processing the events sent to a window. (In other +words, is able to dispatch the events to handler function.) By +default, the window is its own event handler, but an application may +wish to substitute another, for example to allow central +implementation of event-handling for a variety of different window +classes. It is usually better to use `wx.Window.PushEventHandler` since this sets up a chain of event handlers, where an event not handled by one event -handler is handed to the next one in the chain.", ""); +handler is handed off to the next one in the chain.", ""); DocDeclStr( void , PushEventHandler( wxEvtHandler *handler ), "Pushes this event handler onto the event handler stack for the window. An event handler is an object that is capable of processing the events -sent to a window. By default, the window is its own event handler, but -an application may wish to substitute another, for example to allow -central implementation of event-handling for a variety of different -window classes. +sent to a window. (In other words, is able to dispatch the events to +handler function.) By default, the window is its own event handler, +but an application may wish to substitute another, for example to +allow central implementation of event-handling for a variety of +different window classes. wx.Window.PushEventHandler allows an application to set up a chain of event handlers, where an event not handled by one event handler is -handed to the next one in the chain. Use `wx.Window.PopEventHandler` to -remove the event handler.", ""); +handed to the next one in the chain. Use `wx.Window.PopEventHandler` +to remove the event handler. Ownership of the handler is *not* given +to the window, so you should be sure to pop the handler before the +window is destroyed and either let PopEventHandler destroy it, or call +its Destroy method yourself.", ""); DocDeclStr( wxEvtHandler *, PopEventHandler( bool deleteHandler = false ), "Removes and returns the top-most event handler on the event handler stack. If deleteHandler is True then the wx.EvtHandler object will be -destroyed after it is popped.", ""); +destroyed after it is popped, and ``None`` will be returned instead.", ""); DocDeclStr( bool , RemoveEventHandler(wxEvtHandler *handler), "Find the given handler in the event handler chain and remove (but not -delete) it from the event handler chain, return True if it was found +delete) it from the event handler chain, returns True if it was found and False otherwise (this also results in an assert failure so this function should only be called when the handler is supposed to be there.)", ""); @@ -1183,7 +1228,13 @@ Note that wxWindows maintains the stack of windows having captured the mouse and when the mouse is released the capture returns to the window which had had captured it previously and it is only really released if there were no previous window. In particular, this means that you must -release the mouse as many times as you capture it.", ""); +release the mouse as many times as you capture it, unless the window +receives the `wx.MouseCaptureLostEvent` event. + +Any application which captures the mouse in the beginning of some +operation *must* handle `wx.MouseCaptureLostEvent` and cancel this +operation when it receives the event. The event handler must not +recapture mouse.", ""); DocDeclStr( void , ReleaseMouse(), @@ -1251,8 +1302,16 @@ it is a good idea to use it before inserting large amount of text into a wxTextCtrl under wxGTK) but is not implemented on all platforms nor for all controls so it is mostly just a hint to wxWindows and not a mandatory directive.", ""); + + + DocDeclStr( + virtual bool , IsFrozen() const, + "Returns ``True`` if the window has been frozen and not thawed yet. + +:see: `Freeze` and `Thaw`", ""); + DocDeclStr( virtual void , Thaw(), "Reenables window updating after a previous call to Freeze. Calls to @@ -1265,6 +1324,13 @@ times that Freeze was before the window will be updated.", ""); "Call this function to prepare the device context for drawing a scrolled image. It sets the device origin according to the current scroll position.", ""); + + DocDeclStr( + virtual bool , IsDoubleBuffered() const, + "Returns ``True`` if the window contents is double-buffered by the +system, i.e. if any drawing done on the window is really done on a +temporary backing surface and transferred to the screen all at once +later.", ""); DocDeclStr( @@ -1451,9 +1517,11 @@ be reset back to default.", ""); + %disownarg( wxCaret *caret ); DocDeclStr( void , SetCaret(wxCaret *caret), "Sets the caret associated with the window.", ""); + %cleardisown( wxCaret *caret ); DocDeclStr( wxCaret *, GetCaret() const, @@ -1555,7 +1623,7 @@ send an update UI event for each menubar menu item. You can call this function from your application to ensure that your UI is up-to-date at a particular point in time (as far as your EVT_UPDATE_UI handlers are concerned). This may be necessary if you have called -wx.UpdateUIEvent.SetMode or wx.UpdateUIEvent.SetUpdateInterval to +`wx.UpdateUIEvent.SetMode` or `wx.UpdateUIEvent.SetUpdateInterval` to limit the overhead that wxWindows incurs by sending update UI events in idle time.", " @@ -1595,7 +1663,10 @@ mouse cursor will be used.", ""); bool PopupMenu(wxMenu *menu, const wxPoint& pos=wxDefaultPosition); - + DocDeclStr( + virtual bool , HasMultiplePages() const, + "", ""); + %extend { DocStr(GetHandle, @@ -1740,7 +1811,7 @@ already on top/bottom and nothing was done.", ""); void , SetHelpText(const wxString& text), "Sets the help text to be used as context-sensitive help for this window. Note that the text is actually stored by the current -wxHelpProvider implementation, and not in the window object itself.", ""); +`wx.HelpProvider` implementation, and not in the window object itself.", ""); DocDeclStr( @@ -1750,10 +1821,20 @@ one.", ""); DocDeclStr( + virtual wxString , GetHelpTextAtPoint(const wxPoint& pt, + wxHelpEvent::Origin origin) const, + "Get the help string associated with the given position in this window. + +Notice that pt may be invalid if event origin is keyboard or unknown +and this method should return the global window help text then +", ""); + + + DocDeclStr( wxString , GetHelpText() const, "Gets the help text to be used as context-sensitive help for this window. Note that the text is actually stored by the current -wxHelpProvider implementation, and not in the window object itself.", ""); +`wx.HelpProvider` implementation, and not in the window object itself.", ""); @@ -1764,7 +1845,10 @@ wxHelpProvider implementation, and not in the window object itself.", ""); DocStr(SetToolTip, "Attach a tooltip to the window.", ""); %Rename(SetToolTipString, void, SetToolTip( const wxString &tip )); + + %disownarg( wxToolTip *tip ); void SetToolTip( wxToolTip *tip ); + %cleardisown( wxToolTip *tip ); DocDeclStr( wxToolTip* , GetToolTip() const, @@ -1779,16 +1863,12 @@ wxHelpProvider implementation, and not in the window object itself.", ""); // drag and drop // ------------- - // set/retrieve the drop target associated with this window (may be - // NULL; it's owned by the window and will be deleted by it) - %apply SWIGTYPE *DISOWN { wxPyDropTarget *dropTarget }; - + %disownarg( wxPyDropTarget *dropTarget ); DocDeclStr( virtual void , SetDropTarget( wxPyDropTarget *dropTarget ), "Associates a drop target with this window. If the window already has a drop target, it is deleted.", ""); - - %clear wxPyDropTarget *dropTarget; + %cleardisown( wxPyDropTarget *dropTarget ); DocDeclStr( @@ -1796,11 +1876,15 @@ a drop target, it is deleted.", ""); "Returns the associated drop target, which may be None.", ""); -#ifdef __WXMSW__ // TODO: should I drop-kick this? - DocDeclStr( - void , DragAcceptFiles(bool accept), + DocStr(DragAcceptFiles, "Enables or disables eligibility for drop file events, EVT_DROP_FILES. -Only available on Windows.", ""); +Only functional on Windows.", ""); +#ifdef __WXMSW__ + void DragAcceptFiles(bool accept); +#else + %extend { + void DragAcceptFiles(bool accept) {} + } #endif #endif @@ -1808,7 +1892,7 @@ Only available on Windows.", ""); // constraints and sizers // ---------------------- - // set the constraints for this window or retrieve them (may be NULL) + %disownarg(wxLayoutConstraints*); DocDeclStr( void , SetConstraints( wxLayoutConstraints *constraints ), "Sets the window to have the given layout constraints. If an existing @@ -1826,14 +1910,19 @@ effect.", ""); wxLayoutConstraints *, GetConstraints() const, "Returns a pointer to the window's layout constraints, or None if there are none.", ""); + %cleardisown(wxLayoutConstraints*); DocDeclStr( void , SetAutoLayout( bool autoLayout ), "Determines whether the Layout function will be called automatically -when the window is resized. It is called implicitly by SetSizer but -if you use SetConstraints you should call it manually or otherwise the -window layout won't be correctly updated when its size changes.", ""); +when the window is resized. lease note that this only happens for the +windows usually used to contain children, namely `wx.Panel` and +`wx.TopLevelWindow` (and the classes deriving from them). + +This method is called implicitly by `SetSizer` but if you use +`SetConstraints` you should call it manually or otherwise the window +layout won't be correctly updated when its size changes.", ""); DocDeclStr( bool , GetAutoLayout() const, @@ -1848,6 +1937,7 @@ this function gets called automatically by the default EVT_SIZE handler when the window is resized.", ""); + %disownarg( wxSizer *sizer ); DocDeclStr( void , SetSizer(wxSizer *sizer, bool deleteOld = true ), "Sets the window to have the given layout sizer. The window will then @@ -1861,7 +1951,8 @@ non-None, and False otherwise.", ""); void , SetSizerAndFit( wxSizer *sizer, bool deleteOld = true ), "The same as SetSizer, except it also sets the size hints for the window based on the sizer's minimum size.", ""); - + %cleardisown( wxSizer *sizer ); + DocDeclStr( wxSizer *, GetSizer() const, @@ -1940,6 +2031,26 @@ from the parent window. The base class version returns false, but this method is overridden in wxControl where it returns true.", ""); + + + DocDeclStr( + virtual bool , CanSetTransparent(), + "Returns ``True`` if the platform supports setting the transparency for +this window. Note that this method will err on the side of caution, +so it is possible that this will return ``False`` when it is in fact +possible to set the transparency. + +NOTE: On X-windows systems the X server must have the composite +extension loaded, and there must be a composite manager program (such +as xcompmgr) running.", ""); + + DocDeclStr( + virtual bool , SetTransparent(byte alpha), + "Attempt to set the transparency of this window to the ``alpha`` value, +returns True on success. The ``alpha`` value is an integer in the +range of 0 to 255, where 0 is fully transparent and 255 is fully +opaque.", ""); + %pythoncode { @@ -1956,9 +2067,73 @@ wxControl where it returns true.", ""); if hasattr(self, '_setCallbackInfo'): self._setCallbackInfo(self, self.__class__) } -}; + %pythoncode { + def SendSizeEvent(self): + self.GetEventHandler().ProcessEvent(wx.SizeEvent((-1,-1))) + } + + %property(AcceleratorTable, GetAcceleratorTable, SetAcceleratorTable, doc="See `GetAcceleratorTable` and `SetAcceleratorTable`"); + %property(AdjustedBestSize, GetAdjustedBestSize, doc="See `GetAdjustedBestSize`"); + %property(AutoLayout, GetAutoLayout, SetAutoLayout, doc="See `GetAutoLayout` and `SetAutoLayout`"); + %property(BackgroundColour, GetBackgroundColour, SetBackgroundColour, doc="See `GetBackgroundColour` and `SetBackgroundColour`"); + %property(BackgroundStyle, GetBackgroundStyle, SetBackgroundStyle, doc="See `GetBackgroundStyle` and `SetBackgroundStyle`"); + %property(BestFittingSize, GetBestFittingSize, SetBestFittingSize, doc="See `GetBestFittingSize` and `SetBestFittingSize`"); + %property(BestSize, GetBestSize, doc="See `GetBestSize`"); + %property(BestVirtualSize, GetBestVirtualSize, doc="See `GetBestVirtualSize`"); + %property(Border, GetBorder, doc="See `GetBorder`"); + %property(Caret, GetCaret, SetCaret, doc="See `GetCaret` and `SetCaret`"); + %property(CharHeight, GetCharHeight, doc="See `GetCharHeight`"); + %property(CharWidth, GetCharWidth, doc="See `GetCharWidth`"); + %property(Children, GetChildren, doc="See `GetChildren`"); + %property(ClientAreaOrigin, GetClientAreaOrigin, doc="See `GetClientAreaOrigin`"); + %property(ClientRect, GetClientRect, SetClientRect, doc="See `GetClientRect` and `SetClientRect`"); + %property(ClientSize, GetClientSize, SetClientSize, doc="See `GetClientSize` and `SetClientSize`"); + %property(Constraints, GetConstraints, SetConstraints, doc="See `GetConstraints` and `SetConstraints`"); + %property(ContainingSizer, GetContainingSizer, SetContainingSizer, doc="See `GetContainingSizer` and `SetContainingSizer`"); + %property(Cursor, GetCursor, SetCursor, doc="See `GetCursor` and `SetCursor`"); + %property(DefaultAttributes, GetDefaultAttributes, doc="See `GetDefaultAttributes`"); + %property(DropTarget, GetDropTarget, SetDropTarget, doc="See `GetDropTarget` and `SetDropTarget`"); + %property(EventHandler, GetEventHandler, SetEventHandler, doc="See `GetEventHandler` and `SetEventHandler`"); + %property(ExtraStyle, GetExtraStyle, SetExtraStyle, doc="See `GetExtraStyle` and `SetExtraStyle`"); + %property(Font, GetFont, SetFont, doc="See `GetFont` and `SetFont`"); + %property(ForegroundColour, GetForegroundColour, SetForegroundColour, doc="See `GetForegroundColour` and `SetForegroundColour`"); + %property(GrandParent, GetGrandParent, doc="See `GetGrandParent`"); + %property(Handle, GetHandle, doc="See `GetHandle`"); + %property(HelpText, GetHelpText, SetHelpText, doc="See `GetHelpText` and `SetHelpText`"); + %property(Id, GetId, SetId, doc="See `GetId` and `SetId`"); + %property(Label, GetLabel, SetLabel, doc="See `GetLabel` and `SetLabel`"); + %property(LayoutDirection, GetLayoutDirection, SetLayoutDirection, doc="See `GetLayoutDirection` and `SetLayoutDirection`"); + %property(MaxHeight, GetMaxHeight, doc="See `GetMaxHeight`"); + %property(MaxSize, GetMaxSize, SetMaxSize, doc="See `GetMaxSize` and `SetMaxSize`"); + %property(MaxWidth, GetMaxWidth, doc="See `GetMaxWidth`"); + %property(MinHeight, GetMinHeight, doc="See `GetMinHeight`"); + %property(MinSize, GetMinSize, SetMinSize, doc="See `GetMinSize` and `SetMinSize`"); + %property(MinWidth, GetMinWidth, doc="See `GetMinWidth`"); + %property(Name, GetName, SetName, doc="See `GetName` and `SetName`"); + %property(Parent, GetParent, doc="See `GetParent`"); + %property(Position, GetPosition, SetPosition, doc="See `GetPosition` and `SetPosition`"); + %property(Rect, GetRect, SetRect, doc="See `GetRect` and `SetRect`"); + %property(ScreenPosition, GetScreenPosition, doc="See `GetScreenPosition`"); + %property(ScreenRect, GetScreenRect, doc="See `GetScreenRect`"); + %property(Size, GetSize, SetSize, doc="See `GetSize` and `SetSize`"); + %property(Sizer, GetSizer, SetSizer, doc="See `GetSizer` and `SetSizer`"); + %property(ThemeEnabled, GetThemeEnabled, SetThemeEnabled, doc="See `GetThemeEnabled` and `SetThemeEnabled`"); + %property(ToolTip, GetToolTip, SetToolTip, doc="See `GetToolTip` and `SetToolTip`"); + %property(UpdateClientRect, GetUpdateClientRect, doc="See `GetUpdateClientRect`"); + %property(UpdateRegion, GetUpdateRegion, doc="See `GetUpdateRegion`"); + %property(Validator, GetValidator, SetValidator, doc="See `GetValidator` and `SetValidator`"); + %property(VirtualSize, GetVirtualSize, SetVirtualSize, doc="See `GetVirtualSize` and `SetVirtualSize`"); + %property(WindowStyle, GetWindowStyle, SetWindowStyle, doc="See `GetWindowStyle` and `SetWindowStyle`"); + %property(WindowStyleFlag, GetWindowStyleFlag, SetWindowStyleFlag, doc="See `GetWindowStyleFlag` and `SetWindowStyleFlag`"); + %property(WindowVariant, GetWindowVariant, SetWindowVariant, doc="See `GetWindowVariant` and `SetWindowVariant`"); + + %property(Shown, IsShown, Show, doc="See `IsShown` and `Show`"); + %property(Enabled, IsEnabled, Enable, doc="See `IsEnabled` and `Enable`"); + %property(TopLevel, IsTopLevel, doc="See `IsTopLevel`"); + +}; @@ -2053,7 +2228,8 @@ wxWindow* wxFindWindowByLabel( const wxString& label, WXHWND hWnd = (WXHWND)_hWnd; long id = wxGetWindowId(hWnd); wxWindow* win = new wxWindow; - parent->AddChild(win); + if (parent) + parent->AddChild(win); win->SetEventHandler(win); win->SetHWND(hWnd); win->SetId(id);