]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/src/_window.i
SetDefault returns the former default widget
[wxWidgets.git] / wxPython / src / _window.i
index b83769abc24872a06269298bd2533539bb33e361..2935cb31c117ac4326ae687c1f00a594ef3dd3a6 100644 (file)
@@ -34,15 +34,27 @@ struct wxVisualAttributes
         ~wxVisualAttributes() { delete self; }
     } 
     
         ~wxVisualAttributes() { delete self; }
     } 
     
-    // the font used for control label/text inside it
-    wxFont font;
-
-    // the foreground colour
-    wxColour colFg;
+//     // the font used for control label/text inside it
+//     wxFont font;
+//     // the foreground colour
+//     wxColour colFg;
+//     // the background colour, may be wxNullColour if the controls background
+//     // colour is not solid
+//     wxColour colBg;
+
+    // Use our own getters and properties instead of the ones that SWIG will
+    // generate, so copies of the attributes will be made when they are
+    // accessed, instead of using a pointer to the one in the object which may
+    // be temporary.
+    %extend {
+        wxFont   _get_font()      { return self->font; }
+        wxColour _get_colFg()     { return self->colFg; }
+        wxColour _get_colBg()     { return self->colBg; }
+    }
 
 
-    // the background colour, may be wxNullColour if the controls background
-    // colour is not solid
-    wxColour colBg;
+    %property(font,  _get_font)
+    %property(colFg, _get_colFg)
+    %property(colBg, _get_colBg)
 };
 
 
 };
 
 
@@ -259,7 +271,7 @@ instead.");
     
 
 
     
 
 
-    %pythonAppend Destroy "args[0].thisown = 0"
+    %pythonPrepend Destroy "args[0].this.own(False)"
     DocDeclStr(
         virtual bool , Destroy(),
         "Destroys the window safely.  Frames and dialogs are not destroyed
     DocDeclStr(
         virtual bool , Destroy(),
         "Destroys the window safely.  Frames and dialogs are not destroyed
@@ -448,21 +460,21 @@ equal to -1.
         MoveXY);
     
     DocDeclStr(
         MoveXY);
     
     DocDeclStr(
-        void , SetBestFittingSize(const wxSize& size=wxDefaultSize),
+        void , SetInitialSize(const wxSize& size=wxDefaultSize),
         "A 'Smart' SetSize that will fill in default size components with the
 window's *best size* values.  Also set's the minsize for use with sizers.", "");
         "A 'Smart' SetSize that will fill in default size components with the
 window's *best size* values.  Also set's the minsize for use with sizers.", "");
-    
+    %pythoncode { SetBestFittingSize = wx._deprecated(SetInitialSize, 'Use `SetInitialSize`') }
 
     
     DocDeclStr(
         virtual void , Raise(),
         "Raises the window to the top of the window hierarchy.  In current
 
     
     DocDeclStr(
         virtual void , Raise(),
         "Raises the window to the top of the window hierarchy.  In current
-version of wxWidgets this works both for manage and child windows.", "");
+version of wxWidgets this works both for managed and child windows.", "");
     
     DocDeclStr(
         virtual void , Lower(),
         "Lowers the window to the bottom of the window hierarchy.  In current
     
     DocDeclStr(
         virtual void , Lower(),
         "Lowers the window to the bottom of the window hierarchy.  In current
-version of wxWidgets this works both for manage and child windows.", "");
+version of wxWidgets this works both for managed and child windows.", "");
     
 
     
     
 
     
@@ -571,25 +583,23 @@ some properties of the window change.)", "");
 
     
     DocDeclStr(
 
     
     DocDeclStr(
-        wxSize , GetBestFittingSize() const,
+        wxSize , GetEffectiveMinSize() 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.
 ", "");
         "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.
 ", "");
-    
+    %pythoncode { GetBestFittingSize = wx._deprecated(GetEffectiveMinSize, 'Use `GetEffectiveMinSize` instead.') }
 
 
-    DocDeclStr(
-        wxSize , GetAdjustedBestSize() const,
-        "This method is similar to GetBestSize, except in one
-thing. GetBestSize should return the minimum untruncated size of the
-window, while this method will return the largest of BestSize and any
-user specified minimum size. ie. it is the minimum size the window
-should currently be drawn at, not the minimal size it can possibly
-tolerate.", "");
+    %pythoncode {
+        def GetAdjustedBestSize(self):
+            s = self.GetBestSize()
+            return wx.Size(max(s.width,  self.GetMinWidth()),
+                           max(s.height, self.GetMinHeight()))
+        GetAdjustedBestSize = wx._deprecated(GetAdjustedBestSize, 'Use `GetEffectiveMinSize` instead.')
+    }
     
 
 
     
 
 
-
     DocDeclStr(
         void , Center( int direction = wxBOTH ),
         "Centers the window.  The parameter specifies the direction for
     DocDeclStr(
         void , Center( int direction = wxBOTH ),
         "Centers the window.  The parameter specifies the direction for
@@ -670,12 +680,12 @@ the virtual area of the window outside the given bounds.", "");
         "", "");
     
     DocDeclStr(
         "", "");
     
     DocDeclStr(
-        void , SetMinSize(const wxSize& minSize),
+        virtual void , SetMinSize(const wxSize& minSize),
         "A more convenient method than `SetSizeHints` for setting just the
 min size.", "");
     
     DocDeclStr(
         "A more convenient method than `SetSizeHints` for setting just the
 min size.", "");
     
     DocDeclStr(
-        void , SetMaxSize(const wxSize& maxSize),
+        virtual void , SetMaxSize(const wxSize& maxSize),
         "A more convenient method than `SetSizeHints` for setting just the
 max size.", "");
     
         "A more convenient method than `SetSizeHints` for setting just the
 max size.", "");
     
@@ -718,6 +728,11 @@ windows it is more or less independent of the screen window size.", "");
         GetVirtualSizeTuple);
 
 
         GetVirtualSizeTuple);
 
 
+    DocDeclStr(
+        virtual wxSize , GetWindowBorderSize() const,
+        "Return the size of the left/right and top/bottom borders.", "");
+    
+   
 // TODO: using directors?
 //     // Override these methods for windows that have a virtual size
 //     // independent of their client size.  eg. the virtual area of a
 // TODO: using directors?
 //     // Override these methods for windows that have a virtual size
 //     // independent of their client size.  eg. the virtual area of a
@@ -772,7 +787,16 @@ window had already been in the specified state.", "");
     
     DocDeclStr(
         bool , IsEnabled() const,
     
     DocDeclStr(
         bool , IsEnabled() const,
-        "Returns true if the window is enabled for input, false otherwise.", "");
+        "Returns true if the window is enabled for input, false otherwise.
+This method takes into account the enabled state of parent windows up
+to the top-level window.", "");
+
+    DocDeclStr(
+        bool , IsThisEnabled() const,
+        "Returns the internal enabled state independent of the parent(s) state,
+i.e. the state in which the window would be if all of its parents are
+enabled.  Use `IsEnabled` to get the effective window state.", "");
+    
 
     DocDeclStr(
         virtual bool , IsShownOnScreen() const,
 
     DocDeclStr(
         virtual bool , IsShownOnScreen() const,
@@ -809,6 +833,12 @@ method.", "");
 windows are only available on X platforms.", "");
     
 
 windows are only available on X platforms.", "");
     
 
+    DocDeclStr(
+        bool , ToggleWindowStyle(int flag),
+        "Turn the flag on if it had been turned off before and vice versa,
+returns True if the flag is turned on by this function call.", "");
+    
+    
 
     DocDeclStr(
         virtual void , SetExtraStyle(long exStyle),
 
     DocDeclStr(
         virtual void , SetExtraStyle(long exStyle),
@@ -883,6 +913,12 @@ or None.", "");
         "Can this window have focus?", "");
     
 
         "Can this window have focus?", "");
     
 
+    DocDeclStr(
+        bool , CanAcceptFocus() const,
+        "Can this window have focus right now?", "");
+    
+
     DocDeclStr(
         virtual bool , AcceptsFocusFromKeyboard() const,
         "Can this window be given focus by keyboard navigation? if not, the
     DocDeclStr(
         virtual bool , AcceptsFocusFromKeyboard() const,
         "Can this window be given focus by keyboard navigation? if not, the
@@ -890,13 +926,24 @@ only way to give it focus (provided it accepts it at all) is to click
 it.", "");
     
 
 it.", "");
     
 
+    
+    DocDeclStr(
+        bool , CanAcceptFocusFromKeyboard() const,
+        "Can this window be assigned focus from keyboard right now?", "");
+    
+
+
+    DocDeclAStr(
+        virtual bool , NavigateIn(int flags = wxNavigationKeyEvent::IsForward),
+        "NavigateIn(self, int flags=NavigationKeyEvent.IsForward) -> bool",
+        "Navigates inside this window.", "");
 
 
     DocDeclAStr(
         virtual bool , Navigate(int flags = wxNavigationKeyEvent::IsForward),
         "Navigate(self, int flags=NavigationKeyEvent.IsForward) -> bool",
 
 
     DocDeclAStr(
         virtual bool , Navigate(int flags = wxNavigationKeyEvent::IsForward),
         "Navigate(self, int flags=NavigationKeyEvent.IsForward) -> bool",
-        "Does keyboard navigation from this window to another, by sending a
-`wx.NavigationKeyEvent`.", "
+        "Does keyboard navigation starting from this window to another.  This is
+equivalient to self.GetParent().NavigateIn().", "
  
     :param flags: A combination of the ``IsForward`` or ``IsBackward``
         and the ``WinChange`` values in the `wx.NavigationKeyEvent`
  
     :param flags: A combination of the ``IsForward`` or ``IsBackward``
         and the ``WinChange`` values in the `wx.NavigationKeyEvent`
@@ -964,8 +1011,16 @@ do not change.", "");
         wxWindow *, GetGrandParent() const,
         "Returns the parent of the parent of this window, or None if there
 isn't one.", "");
         wxWindow *, GetGrandParent() const,
         "Returns the parent of the parent of this window, or None if there
 isn't one.", "");
-    
 
 
+    
+    %extend {
+        DocDeclStr(wxWindow *, GetTopLevelParent(),
+                   "Returns the first frame or dialog in this window's parental hierarchy.", "")
+        {
+            return wxGetTopLevelParent(self);
+        }
+    }
+    
 
     DocDeclStr(
         virtual bool , IsTopLevel() const,
 
     DocDeclStr(
         virtual bool , IsTopLevel() const,
@@ -1277,7 +1332,7 @@ be repainted.  This is the same as Refresh but has a nicer syntax.", "");
 window instead of waiting for the EVT_PAINT event to happen, (normally
 this would usually only happen when the flow of control returns to the
 event loop.)  Notice that this function doesn't refresh the window and
 window instead of waiting for the EVT_PAINT event to happen, (normally
 this would usually only happen when the flow of control returns to the
 event loop.)  Notice that this function doesn't refresh the window and
-does nothing if the window has been already repainted.  Use Refresh
+does nothing if the window has been already repainted.  Use `Refresh`
 first if you want to immediately redraw the window (or some portion of
 it) unconditionally.", "");
     
 first if you want to immediately redraw the window (or some portion of
 it) unconditionally.", "");
     
@@ -1324,6 +1379,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.", "");
         "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(
     
 
     DocDeclStr(
@@ -2056,9 +2118,15 @@ opaque.", "");
         self.thisown = pre.thisown
         pre.thisown = 0
         if hasattr(self, '_setOORInfo'):
         self.thisown = pre.thisown
         pre.thisown = 0
         if hasattr(self, '_setOORInfo'):
-            self._setOORInfo(self)
+            try:
+                self._setOORInfo(self)
+            except TypeError:
+                pass
         if hasattr(self, '_setCallbackInfo'):
         if hasattr(self, '_setCallbackInfo'):
-            self._setCallbackInfo(self, self.__class__)
+            try:
+                self._setCallbackInfo(self, pre.__class__)
+            except TypeError:
+                pass
     }
 
     %pythoncode {
     }
 
     %pythoncode {
@@ -2068,11 +2136,10 @@ opaque.", "");
 
     
     %property(AcceleratorTable, GetAcceleratorTable, SetAcceleratorTable, doc="See `GetAcceleratorTable` and `SetAcceleratorTable`");
 
     
     %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(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(EffectiveMinSize, GetEffectiveMinSize, doc="See `GetEffectiveMinSize`");
     %property(BestSize, GetBestSize, doc="See `GetBestSize`");
     %property(BestVirtualSize, GetBestVirtualSize, doc="See `GetBestVirtualSize`");
     %property(Border, GetBorder, doc="See `GetBorder`");
     %property(BestSize, GetBestSize, doc="See `GetBestSize`");
     %property(BestVirtualSize, GetBestVirtualSize, doc="See `GetBestVirtualSize`");
     %property(Border, GetBorder, doc="See `GetBorder`");
@@ -2093,6 +2160,7 @@ opaque.", "");
     %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(Font, GetFont, SetFont, doc="See `GetFont` and `SetFont`");
     %property(ForegroundColour, GetForegroundColour, SetForegroundColour, doc="See `GetForegroundColour` and `SetForegroundColour`");
     %property(GrandParent, GetGrandParent, doc="See `GetGrandParent`");
+    %property(TopLevelParent, GetTopLevelParent, doc="See `GetTopLevelParent`");
     %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(Handle, GetHandle, doc="See `GetHandle`");
     %property(HelpText, GetHelpText, SetHelpText, doc="See `GetHelpText` and `SetHelpText`");
     %property(Id, GetId, SetId, doc="See `GetId` and `SetId`");
@@ -2215,6 +2283,8 @@ wxWindow* wxFindWindowByLabel( const wxString& label,
 #endif
 %}
 
 #endif
 %}
 
+MustHaveApp(wxWindow_FromHWND);
+
 %inline %{
     wxWindow* wxWindow_FromHWND(wxWindow* parent, unsigned long _hWnd) {
 #ifdef __WXMSW__
 %inline %{
     wxWindow* wxWindow_FromHWND(wxWindow* parent, unsigned long _hWnd) {
 #ifdef __WXMSW__