X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fe161a2685012cf90bb5bfe95f2260aee71d8ad7..e6113e3a52d1c1c486b3a31cb22b59e2d9555b2d:/wxPython/src/_window.i?ds=sidebyside diff --git a/wxPython/src/_window.i b/wxPython/src/_window.i index cb217eea1a..10844879f6 100644 --- a/wxPython/src/_window.i +++ b/wxPython/src/_window.i @@ -32,7 +32,7 @@ struct wxVisualAttributes %extend { wxVisualAttributes() { return new wxVisualAttributes; } ~wxVisualAttributes() { delete self; } - } + } // the font used for control label/text inside it wxFont font; @@ -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. ============================= ===================================== @@ -190,13 +190,16 @@ Extra Styles MustHaveApp(wxWindow); MustHaveApp(wxWindow::FindFocus); MustHaveApp(wxWindow::GetCapture); -MustHaveApp(wxWindow::GetClassDefaultAttributes); + +// This one is not restricted to wxWindow +MustHaveApp(GetClassDefaultAttributes); class wxWindow : public wxEvtHandler { public: %pythonAppend wxWindow "self._setOORInfo(self)" %pythonAppend wxWindow() "" + %typemap(out) wxWindow*; // turn off this typemap DocCtorStr( wxWindow(wxWindow* parent, const wxWindowID id=-1, @@ -211,7 +214,10 @@ public: "Precreate a Window for 2-phase creation.", "", PreWindow); + // Turn it back on again + %typemap(out) wxWindow* { $result = wxPyMake_wxObject($1, $owner); } + DocDeclStr( bool , Create(wxWindow* parent, const wxWindowID id=-1, const wxPoint& pos = wxDefaultPosition, @@ -226,7 +232,7 @@ public: DocDeclStr( - bool , Close( bool force = False ), + bool , Close( bool force = false ), "This function simply generates a EVT_CLOSE event whose handler usually tries to close the window. It doesn't close the window itself, however. If force is False (the default) then the window's close @@ -253,6 +259,7 @@ instead."); + %pythonAppend Destroy "args[0].thisown = 0" DocDeclStr( virtual bool , Destroy(), "Destroys the window safely. Frames and dialogs are not destroyed @@ -280,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), @@ -367,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 @@ -383,11 +408,18 @@ autogenerated) id", ""); int sizeFlags = wxSIZE_AUTO ), "Sets the position and size of the window in pixels. The sizeFlags parameter indicates the interpretation of the other params if they are --1. wx.SIZE_AUTO*: a -1 indicates that a class-specific default -shoudl be used. wx.SIZE_USE_EXISTING: existing dimensions should be -used if -1 values are supplied. wxSIZE_ALLOW_MINUS_ONE: allow -dimensions of -1 and less to be interpreted as real dimensions, not -default values.", "", +equal to -1. + + ======================== ====================================== + wx.SIZE_AUTO A -1 indicates that a class-specific + default should be used. + wx.SIZE_USE_EXISTING Axisting dimensions should be used if + -1 values are supplied. + wxSIZE_ALLOW_MINUS_ONE Allow dimensions of -1 and less to be + interpreted as real dimensions, not + default values. + ======================== ====================================== +", "", SetDimensions); @@ -424,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.", ""); @@ -442,19 +474,37 @@ wx.Window.SetSize, since the application need not worry about what dimensions the border or title bar have when trying to fit the window around panel items, for example.", ""); void SetClientSize( const wxSize& size ); - %name(SetClientSizeWH) void SetClientSize( int width, int height ); - %name(SetClientRect) void SetClientSize(const wxRect& rect); + %Rename(SetClientSizeWH, void, SetClientSize( int width, int height )); + %Rename(SetClientRect, void, SetClientSize(const wxRect& rect)); 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; @@ -467,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, @@ -509,6 +559,25 @@ after calling Fit.", ""); GetBestSizeTuple); + DocDeclStr( + void , InvalidateBestSize(), + "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( + wxSize , GetBestFittingSize() const, + "This function will merge the window's best size into the window's +minimum size, giving priority to the min size components, and returns +the results. +", ""); + + DocDeclStr( wxSize , GetAdjustedBestSize() const, "This method is similar to GetBestSize, except in one @@ -528,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", ""); @@ -567,7 +629,6 @@ anything if there are no subwindows.", ""); - %nokwargs SetSizeHints; DocStr(SetSizeHints, "Allows specification of minimum and maximum window sizes, and window size increments. If a pair of values is not set (or set to -1), the @@ -580,24 +641,25 @@ The resizing increments are only significant under Motif or Xt.", " :see: `GetMinSize`, `GetMaxSize`, `SetMinSize`, `SetMaxSize` "); - void SetSizeHints( const wxSize& minSize, - const wxSize& maxSize=wxDefaultSize, - const wxSize& incSize=wxDefaultSize); virtual void SetSizeHints( int minW, int minH, int maxW = -1, int maxH = -1, int incW = -1, int incH = -1 ); + %Rename(SetSizeHintsSz, void, SetSizeHints( const wxSize& minSize, + const wxSize& maxSize=wxDefaultSize, + const wxSize& incSize=wxDefaultSize)); - %nokwargs SetVirtualSizeHints; DocStr(SetVirtualSizeHints, "Allows specification of minimum and maximum virtual window sizes. If a pair of values is not set (or set to -1), the default values will be used. If this function is called, the user will not be able to size the virtual area of the window outside the given bounds.", ""); - void SetVirtualSizeHints( const wxSize& minSize, - const wxSize& maxSize=wxDefaultSize); virtual void SetVirtualSizeHints( int minW, int minH, int maxW = -1, int maxH = -1 ); + %Rename(SetVirtualSizeHintsSz, void, SetVirtualSizeHints( + const wxSize& minSize, const wxSize& maxSize=wxDefaultSize)); + + DocDeclStr( virtual wxSize , GetMaxSize() const, @@ -642,7 +704,7 @@ max size.", ""); is just the client area of the window, but for some like scrolled windows it is more or less independent of the screen window size.", ""); void SetVirtualSize(const wxSize& size ); - %name(SetVirtualSizeWH) void SetVirtualSize( int w, int h ); + %Rename(SetVirtualSizeWH, void, SetVirtualSize( int w, int h )); DocStr(GetVirtualSize, @@ -675,7 +737,7 @@ sizer, interior children, or other means)", ""); // ------------ DocDeclStr( - virtual bool , Show( bool show = True ), + virtual bool , Show( bool show = true ), "Shows or hides the window. You may need to call Raise for a top level window if you want to bring it to top, although this is not needed if Show is called immediately after the frame creation. Returns True if @@ -688,7 +750,7 @@ because it already was in the requested state.", ""); DocDeclStr( - virtual bool , Enable( bool enable = True ), + virtual bool , Enable( bool enable = true ), "Enable or disable the window for user input. Note that when a parent window is disabled, all of its children are disabled as well and they are reenabled again when the parent is. Returns true if the window @@ -751,7 +813,7 @@ SetWindowStyleFlag()", ""); DocDeclStr( - virtual void , MakeModal(bool modal = True), + virtual void , MakeModal(bool modal = true), "Disables all other windows in the application so that the user can only interact with this window. Passing False will reverse this effect.", ""); @@ -819,20 +881,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), @@ -840,22 +888,44 @@ by pressing such as the OK button on a wx.Dialog.", ""); "Does keyboard navigation from this window to another, by sending a `wx.NavigationKeyEvent`.", " - :param flags: A combination of the ``IsForward`` and ``WinChange`` - values in the `wx.NavigationKeyEvent` class, which determine - if the navigation should be in forward or reverse order, and - if it should be able to cross parent window boundaries, such - as between notebook pages or MDI child frames. Typically the - status of the Shift key (for forward or reverse) or the - Control key (for WinChange) would be used to determine how to - set the flags. + :param flags: A combination of the ``IsForward`` or ``IsBackward`` + and the ``WinChange`` values in the `wx.NavigationKeyEvent` + class, which determine if the navigation should be in forward + or reverse order, and if it should be able to cross parent + window boundaries, such as between notebook pages or MDI child + frames. Typically the status of the Shift key (for forward or + backward) or the Control key (for WinChange) would be used to + determine how to set the flags. One situation in which you may wish to call this method is from a text control custom keypress handler to do the default navigation behaviour for the tab key, since the standard default behaviour for a multiline text control with the wx.TE_PROCESS_TAB style is to insert a tab and not navigate to the next control."); + + DocDeclStr( + void , MoveAfterInTabOrder(wxWindow *win), + "Moves this window in the tab navigation order after the specified +sibling window. This means that when the user presses the TAB key on +that other window, the focus switches to this window. + +The default tab order is the same as creation order. This function +and `MoveBeforeInTabOrder` allow to change it after creating all the +windows. +", ""); + + + DocDeclStr( + void , MoveBeforeInTabOrder(wxWindow *win), + "Same as `MoveAfterInTabOrder` except that it inserts this window just +before win instead of putting it right after it.", ""); + + + + + @@ -915,9 +985,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 // ------------------- @@ -972,7 +1051,7 @@ remove the event handler.", ""); DocDeclStr( - wxEvtHandler *, PopEventHandler( bool deleteHandler = False ), + 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.", ""); @@ -1067,7 +1146,7 @@ hotkey was registered successfully.", ""); %#if wxUSE_HOTKEY return self->RegisterHotKey(hotkeyId, modifiers, keycode); %#else - return False; + return false; %#endif } @@ -1078,7 +1157,7 @@ hotkey was registered successfully.", ""); #if wxUSE_HOTKEY return self->UnregisterHotKey(hotkeyId); #else - return False; + return false; #endif } } @@ -1095,10 +1174,10 @@ changes. For the x dimension, the dialog units are multiplied by the average character width and then divided by 4. For the y dimension, the dialog units are multiplied by the average character height and then divided by 8.", ""); - %name(ConvertDialogPointToPixels) wxPoint ConvertDialogToPixels(const wxPoint& pt); - %name(ConvertDialogSizeToPixels) wxSize ConvertDialogToPixels(const wxSize& sz); - %name(DLG_PNT) wxPoint ConvertDialogToPixels(const wxPoint& pt); - %name(DLG_SZE) wxSize ConvertDialogToPixels(const wxSize& sz); + %Rename(ConvertDialogPointToPixels, wxPoint, ConvertDialogToPixels(const wxPoint& pt)); + %Rename(ConvertDialogSizeToPixels, wxSize, ConvertDialogToPixels(const wxSize& sz)); + %Rename(DLG_PNT, wxPoint, ConvertDialogToPixels(const wxPoint& pt)); + %Rename(DLG_SZE, wxSize, ConvertDialogToPixels(const wxSize& sz)); DocStr(ConvertPixelPointToDialog, @@ -1108,8 +1187,8 @@ changes. For the x dimension, the dialog units are multiplied by the average character width and then divided by 4. For the y dimension, the dialog units are multiplied by the average character height and then divided by 8.", ""); - %name(ConvertPixelPointToDialog) wxPoint ConvertPixelsToDialog(const wxPoint& pt); - %name(ConvertPixelSizeToDialog) wxSize ConvertPixelsToDialog(const wxSize& sz); + %Rename(ConvertPixelPointToDialog, wxPoint, ConvertPixelsToDialog(const wxPoint& pt)); + %Rename(ConvertPixelSizeToDialog, wxSize, ConvertPixelsToDialog(const wxSize& sz)); @@ -1133,7 +1212,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(), @@ -1157,7 +1242,7 @@ release the mouse as many times as you capture it.", ""); // ------------------- DocDeclStr( - virtual void , Refresh( bool eraseBackground = True, + virtual void , Refresh( bool eraseBackground = true, const wxRect *rect = NULL ), "Mark the specified rectangle (or the whole window) as \"dirty\" so it will be repainted. Causes an EVT_PAINT event to be generated and sent @@ -1165,7 +1250,7 @@ to the window.", ""); DocDeclStr( - void , RefreshRect(const wxRect& rect), + void , RefreshRect(const wxRect& rect, bool eraseBackground = true), "Redraws the contents of the given rectangle: the area inside it will be repainted. This is the same as Refresh but has a nicer syntax.", ""); @@ -1234,8 +1319,8 @@ since the last repaint. Call this in an paint event handler to optimize redrawing by only redrawing those areas, which have been exposed.", ""); bool IsExposed( int x, int y, int w=1, int h=1 ) const; - %name(IsExposedPoint) bool IsExposed( const wxPoint& pt ) const; - %name(IsExposedRect) bool IsExposed( const wxRect& rect ) const; + %Rename(IsExposedPoint, bool, IsExposed( const wxPoint& pt ) const); + %Rename(IsExposedRect, bool, IsExposed( const wxRect& rect ) const); @@ -1285,7 +1370,7 @@ themes represent the appearance chosen by the user to be used for all applications on the system.", ""); DocDeclStr( - void , SetDefaultBackgroundColour(const wxColour& colour), + void , SetOwnBackgroundColour(const wxColour& colour), "", ""); @@ -1298,7 +1383,7 @@ the window class; it may be the text colour or other colour, or it may not be used at all.", ""); DocDeclStr( - void , SetDefaultForegroundColour(const wxColour& colour), + void , SetOwnForegroundColour(const wxColour& colour), "", ""); @@ -1312,9 +1397,64 @@ not be used at all.", ""); "Returns the foreground colour of the window. The interpretation of foreground colour is dependent on the window class; it may be the text colour or other colour, or it may not be used at all.", ""); + + DocDeclStr( + bool , InheritsBackgroundColour() const, + "", ""); + + DocDeclStr( + bool , UseBgCol() const, + "", ""); + + +// TODO: +// // if the window shouldn't inherit its colour from the parent, override +// // this function to return true +// // +// // this is currently only used by wxMSW and wxUniv but should be useful for +// // the other ports too +// virtual bool ProvidesBackground() const; + + + // Set/get the background style. + // Pass one of wxBG_STYLE_SYSTEM, wxBG_STYLE_COLOUR, wxBG_STYLE_CUSTOM + DocDeclStr( + virtual bool , SetBackgroundStyle(wxBackgroundStyle style), + "Returns the background style of the window. The background style +indicates how the background of the window is drawn. + + ====================== ======================================== + wx.BG_STYLE_SYSTEM The background colour or pattern should + be determined by the system + wx.BG_STYLE_COLOUR The background should be a solid colour + wx.BG_STYLE_CUSTOM The background will be implemented by the + application. + ====================== ======================================== + +On GTK+, use of wx.BG_STYLE_CUSTOM allows the flicker-free drawing of +a custom background, such as a tiled bitmap. Currently the style has +no effect on other platforms. + +:see: `GetBackgroundStyle`, `SetBackgroundColour`", ""); + DocDeclStr( + virtual wxBackgroundStyle , GetBackgroundStyle() const, + "Returns the background style of the window. + +:see: `SetBackgroundStyle`", ""); + + DocDeclStr( + bool , HasTransparentBackground(), + "Returns True if this window's background is transparent (as, for +example, for `wx.StaticText`) and should show the parent window's +background. +This method is mostly used internally by the library itself and you +normally shouldn't have to call it. You may, however, have to override +it in your custom control classes to ensure that background is painted +correctly.", ""); + DocDeclStr( virtual bool , SetCursor( const wxCursor &cursor ), @@ -1325,7 +1465,7 @@ The cursor may be wx.NullCursor in which case the window cursor will be reset back to default.", ""); DocDeclStr( - wxCursor& , GetCursor(), + wxCursor , GetCursor(), "Return the cursor associated with this window.", ""); @@ -1335,20 +1475,22 @@ be reset back to default.", ""); "Sets the font for this window.", ""); DocDeclStr( - void , SetDefaultFont(const wxFont& font), + void , SetOwnFont(const wxFont& font), "", ""); DocDeclStr( - wxFont& , GetFont(), + wxFont , GetFont(), "Returns the default font used for this window.", ""); + %disownarg( wxCaret *caret ); DocDeclStr( void , SetCaret(wxCaret *caret), "Sets the caret associated with the window.", ""); + %cleardisown( wxCaret *caret ); DocDeclStr( wxCaret *, GetCaret() const, @@ -1450,7 +1592,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.", " @@ -1486,11 +1628,14 @@ and returns control when the user has dismissed the menu. If a menu item is selected, the corresponding menu event is generated and will be processed as usual. If the default position is given then the current position of the mouse cursor will be used.", ""); - %name(PopupMenuXY) bool PopupMenu(wxMenu *menu, int x=-1, int y=-1); + %Rename(PopupMenuXY, bool, PopupMenu(wxMenu *menu, int x=-1, int y=-1)); bool PopupMenu(wxMenu *menu, const wxPoint& pos=wxDefaultPosition); - + DocDeclStr( + virtual bool , HasMultiplePages() const, + "", ""); + %extend { DocStr(GetHandle, @@ -1502,6 +1647,20 @@ toplevel parent of the window.", ""); } } + DocStr( + AssociateHandle, + "Associate the window with a new native handle", ""); + %extend { + void AssociateHandle(long handle) { + self->AssociateHandle((WXWidget)handle); + } + } + + + DocDeclStr( + virtual void , DissociateHandle(), + "Dissociate the current native handle from the window", ""); + #ifdef __WXMSW__ @@ -1526,7 +1685,7 @@ toplevel parent of the window.", ""); int position, int thumbSize, int range, - bool refresh = True ), + bool refresh = true ), "Sets the scrollbar properties of a built-in scrollbar.", " :param orientation: Determines the scrollbar whose page size is to @@ -1543,7 +1702,7 @@ toplevel parent of the window.", ""); "); DocDeclStr( - virtual void , SetScrollPos( int orientation, int pos, bool refresh = True ), + virtual void , SetScrollPos( int orientation, int pos, bool refresh = true ), "Sets the position of one of the built-in scrollbars.", ""); DocDeclStr( @@ -1567,8 +1726,8 @@ toplevel parent of the window.", ""); "Physically scrolls the pixels in the window and move child windows accordingly. Use this function to optimise your scrolling implementations, to minimise the area that must be redrawn. Note that -it is rarely required to call this function from a user program.", -" +it is rarely required to call this function from a user program."," + :param dx: Amount to scroll horizontally. :param dy: Amount to scroll vertically. @@ -1621,7 +1780,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( @@ -1631,10 +1790,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.", ""); @@ -1644,8 +1813,11 @@ wxHelpProvider implementation, and not in the window object itself.", ""); DocStr(SetToolTip, "Attach a tooltip to the window.", ""); - %name(SetToolTipString) void SetToolTip( const wxString &tip ); + %Rename(SetToolTipString, void, SetToolTip( const wxString &tip )); + + %disownarg( wxToolTip *tip ); void SetToolTip( wxToolTip *tip ); + %cleardisown( wxToolTip *tip ); DocDeclStr( wxToolTip* , GetToolTip() const, @@ -1660,16 +1832,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( @@ -1677,11 +1845,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 @@ -1689,7 +1861,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 @@ -1707,14 +1879,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, @@ -1729,20 +1906,22 @@ 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 ), + void , SetSizer(wxSizer *sizer, bool deleteOld = true ), "Sets the window to have the given layout sizer. The window will then own the object, and will take care of its deletion. If an existing layout sizer object is already owned by the window, it will be deleted if the deleteOld parameter is true. Note that this function will also call SetAutoLayout implicitly with a True parameter if the sizer is -non-NoneL and False otherwise.", ""); +non-None, and False otherwise.", ""); DocDeclStr( - void , SetSizerAndFit( wxSizer *sizer, bool deleteOld = True ), + 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, @@ -1793,14 +1972,14 @@ colours. By 'intelligently' the following is meant: by default, all windows use their own default attributes. However if some of the parent's attributes are explicitly changed (that is, using SetFont and not -SetDefaultFont) and if the corresponding attribute hadn't been +SetOwnFont) and if the corresponding attribute hadn't been explicitly set for this window itself, then this window takes the same value as used by the parent. In addition, if the window overrides ShouldInheritColours to return false, the colours will not be changed no matter what and only the font might. -This rather complicated logic is necessary in order to accomodate the -different usage scenarius. The most common one is when all default +This rather complicated logic is necessary in order to accommodate the +different usage scenarios. The most common one is when all default attributes are used and in this case, nothing should be inherited as in modern GUIs different controls use different fonts (and colours) than their siblings so they can't inherit the same value from the @@ -1821,6 +2000,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 { @@ -1837,9 +2036,72 @@ 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(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`"); + +}; @@ -1934,7 +2196,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); @@ -1949,6 +2212,20 @@ wxWindow* wxFindWindowByLabel( const wxString& label, } %} +//--------------------------------------------------------------------------- + +DocStr(GetTopLevelWindows, +"Returns a list of the the application's top-level windows, (frames, +dialogs, etc.) NOTE: Currently this is a copy of the list maintained +by wxWidgets, and so it is only valid as long as no top-level windows +are closed or new top-level windows are created. +", ""); +%inline %{ + PyObject* GetTopLevelWindows() { + return wxPy_ConvertList(&wxTopLevelWindows); + } +%} + //--------------------------------------------------------------------------- //---------------------------------------------------------------------------