]> git.saurik.com Git - wxWidgets.git/commitdiff
Make wxWindow::SetSizeHints() do nothing.
authorRobert Roebling <robert@roebling.de>
Sun, 29 Oct 2006 19:17:00 +0000 (19:17 +0000)
committerRobert Roebling <robert@roebling.de>
Sun, 29 Oct 2006 19:17:00 +0000 (19:17 +0000)
  Make wxTLW::SetSizeHints() set the various m_minWidth etc. fields.
  Override SetSizeHints() in wxGTK to call the relevant gtk funcion
    only there and not in every resize.
  Make GetMinWidth() etc. non-virtual.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42646 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/latex/wx/tlw.tex
docs/latex/wx/window.tex
include/wx/gtk/toplevel.h
include/wx/toplevel.h
include/wx/window.h
src/common/toplvcmn.cpp
src/common/wincmn.cpp
src/gtk/frame.cpp
src/gtk/toplevel.cpp

index f0134fd902935d6db7e138fb266cc40efa056c0c..75320a9040afbdf41e74a927e8c385a6fbf092d0 100644 (file)
@@ -280,6 +280,29 @@ Unavailable on full keyboard machines.
 \helpref{wxTopLevelWindow::SetRightMenu}{wxtoplevelwindowsetrightmenu}.
 
 
+\membersection{wxTopLevelWindow::SetSizeHints}\label{wxtoplevelwindowsetsizehints}
+
+\func{virtual void}{SetSizeHints}{\param{int}{ minW}, \param{int}{ minH}, \param{int}{ maxW=-1}, \param{int}{ maxH=-1},
+ \param{int}{ incW=-1}, \param{int}{ incH=-1}}
+
+\func{void}{SetSizeHints}{\param{const wxSize\&}{ minSize},
+\param{const wxSize\&}{ maxSize=wxDefaultSize}, \param{const wxSize\&}{ incSize=wxDefaultSize}}
+
+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 default values will be used.
+
+\docparam{incW}{Specifies the increment for sizing the width (Motif/Xt only).}
+
+\docparam{incH}{Specifies the increment for sizing the height (Motif/Xt only).}
+
+\docparam{incSize}{Increment size (Motif/Xt only).}
+
+\wxheading{Remarks}
+
+If this function is called, the user will not be able to size the window outside
+the given bounds. The resizing increments are only significant under Motif or Xt.
+
+
 \membersection{wxTopLevelWindow::SetRightMenu}\label{wxtoplevelwindowsetrightmenu}
 
 \func{void}{SetRightMenu}{\param{int}{ id = wxID\_ANY}, \param{const wxString\&}{ label = wxEmptyString}, \param{wxMenu *}{ subMenu = NULL}}
index 2ea573f0a98ffd93031966d366c29522e2ff272b..fc2585ede574bc985fdbbf27cc5ee10ae55e93b5 100644 (file)
@@ -767,8 +767,7 @@ Merges the window's best size into the min size and returns the result.
 \wxheading{See also}
 
 \helpref{wxWindow::GetBestSize}{wxwindowgetbestsize},\rtfsp
-\helpref{wxWindow::SetBestFittingSize}{wxwindowsetbestfittingsize},\rtfsp
-\helpref{wxWindow::SetSizeHints}{wxwindowsetsizehints}
+\helpref{wxWindow::SetBestFittingSize}{wxwindowsetbestfittingsize}
 
 
 \membersection{wxWindow::GetBestSize}\label{wxwindowgetbestsize}
@@ -2675,8 +2674,7 @@ needs of the window for layout.
 
 \helpref{wxWindow::SetSize}{wxwindowsetsize},\rtfsp
 \helpref{wxWindow::GetBestSize}{wxwindowgetbestsize},\rtfsp
-\helpref{wxWindow::GetBestFittingSize}{wxwindowgetbestfittingsize},\rtfsp
-\helpref{wxWindow::SetSizeHints}{wxwindowsetsizehints}
+\helpref{wxWindow::GetBestFittingSize}{wxwindowgetbestfittingsize}
 
 
 \membersection{wxWindow::SetCaret}\label{wxwindowsetcaret}
@@ -3292,42 +3290,9 @@ implements the following methods:\par
 
 \membersection{wxWindow::SetSizeHints}\label{wxwindowsetsizehints}
 
-\func{virtual void}{SetSizeHints}{\param{int}{ minW}, \param{int}{ minH}, \param{int}{ maxW=-1}, \param{int}{ maxH=-1},
- \param{int}{ incW=-1}, \param{int}{ incH=-1}}
-
-\func{void}{SetSizeHints}{\param{const wxSize\&}{ minSize},
-\param{const wxSize\&}{ maxSize=wxDefaultSize}, \param{const wxSize\&}{ incSize=wxDefaultSize}}
-
-
-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 default values will be used.
-
-\wxheading{Parameters}
-
-\docparam{minW}{Specifies the minimum width allowable.}
-
-\docparam{minH}{Specifies the minimum height allowable.}
-
-\docparam{maxW}{Specifies the maximum width allowable.}
-
-\docparam{maxH}{Specifies the maximum height allowable.}
-
-\docparam{incW}{Specifies the increment for sizing the width (Motif/Xt only).}
-
-\docparam{incH}{Specifies the increment for sizing the height (Motif/Xt only).}
-
-\docparam{minSize}{Minimum size.}
-
-\docparam{maxSize}{Maximum size.}
-
-\docparam{incSize}{Increment size (Motif/Xt only).}
-
-\wxheading{Remarks}
-
-If this function is called, the user will not be able to size the window outside the
-given bounds.
-
-The resizing increments are only significant under Motif or Xt.
+This method does nothing for a normal wxWindow and is only kept
+for backwards compatibility. The actual implementation is in
+\helpref{wxTopLevelWindow::SetSizeHints}{wxtoplevelwindowsetsizehints}.
 
 
 \membersection{wxWindow::SetSizer}\label{wxwindowsetsizer}
index cd48f4f7e1213b40654e2723bbdd1b5db0a6b2de..9886b2a8b1f7c4717a299e790915059d5e5456b6 100644 (file)
@@ -121,6 +121,10 @@ protected:
                            int width, int height,
                            int sizeFlags = wxSIZE_AUTO);
 
+    virtual void DoSetSizeHints( int minW, int minH,
+                                 int maxW = wxDefaultCoord, int maxH = wxDefaultCoord,
+                                 int incW = wxDefaultCoord, int incH = wxDefaultCoord );
+                                 
     virtual void DoSetClientSize(int width, int height);
     virtual void DoGetClientSize( int *width, int *height ) const;
 
index 737019df45b2cf0d363f6d453301f2012db134d5..bde3440ec79072ca65e0e486a90b887109e69211 100644 (file)
@@ -250,6 +250,10 @@ public:
     virtual void DoUpdateWindowUI(wxUpdateUIEvent& event) ;
 
 protected:
+    virtual void DoSetSizeHints( int minW, int minH,
+                                 int maxW = wxDefaultCoord, int maxH = wxDefaultCoord,
+                                 int incW = wxDefaultCoord, int incH = wxDefaultCoord );
+
     // the frame client to screen translation should take account of the
     // toolbar which may shift the origin of the client area
     virtual void DoClientToScreen(int *x, int *y) const;
index 38c73a5c10805dcafe4027b698b9fc07b30124a3..58d24c8201e7b05889b1080861ec2fd5bd8b0b62 100644 (file)
@@ -389,26 +389,26 @@ public:
         // set virtual size to satisfy children
     virtual void FitInside();
 
-        // set min/max size of the window
+
+        // Methods for setting size hints. This is only used
+        // for toplevel windows.
+        
     virtual void SetSizeHints( int minW, int minH,
                                int maxW = wxDefaultCoord, int maxH = wxDefaultCoord,
                                int incW = wxDefaultCoord, int incH = wxDefaultCoord )
-    {
-        DoSetSizeHints(minW, minH, maxW, maxH, incW, incH);
-    }
+    { DoSetSizeHints(minW, minH, maxW, maxH, incW, incH); }
 
     void SetSizeHints( const wxSize& minSize,
                        const wxSize& maxSize=wxDefaultSize,
                        const wxSize& incSize=wxDefaultSize)
-    {
-        DoSetSizeHints(minSize.x, minSize.y,
-                       maxSize.x, maxSize.y,
-                       incSize.x, incSize.y);
-    }
+    { DoSetSizeHints(minSize.x, minSize.y, maxSize.x, maxSize.y, incSize.x, incSize.y); }
+
+    virtual void DoSetSizeHints( int minW, int minH,
+                                 int maxW = wxDefaultCoord, int maxH = wxDefaultCoord,
+                                 int incW = wxDefaultCoord, int incH = wxDefaultCoord ) { }
 
-    virtual void DoSetSizeHints(int minW, int minH,
-                                int maxW = wxDefaultCoord, int maxH = wxDefaultCoord,
-                               int incW = wxDefaultCoord, int incH = wxDefaultCoord );
+        // Methods for setting virtual size hints
+        // FIXME: What are virtual size hints?
 
     virtual void SetVirtualSizeHints( int minW, int minH,
                                       int maxW = wxDefaultCoord, int maxH = wxDefaultCoord );
@@ -418,17 +418,20 @@ public:
         SetVirtualSizeHints(minSize.x, minSize.y, maxSize.x, maxSize.y);
     }
 
-    virtual int GetMinWidth() const { return m_minWidth; }
-    virtual int GetMinHeight() const { return m_minHeight; }
-    int GetMaxWidth() const { return m_maxWidth; }
-    int GetMaxHeight() const { return m_maxHeight; }
 
         // Override this method to control the values given to Sizers etc.
     virtual wxSize GetMaxSize() const { return wxSize( m_maxWidth, m_maxHeight ); }
     virtual wxSize GetMinSize() const { return wxSize( m_minWidth, m_minHeight ); }
 
-    void SetMinSize(const wxSize& minSize) { SetSizeHints(minSize); }
-    void SetMaxSize(const wxSize& maxSize) { SetSizeHints(GetMinSize(), maxSize); }
+        // If a class doesn't override GetMinSize() or GetMaxSize()
+        // these values will be returned
+    int GetMinWidth() const { return m_minWidth; }
+    int GetMinHeight() const { return m_minHeight; }
+    int GetMaxWidth() const { return m_maxWidth; }
+    int GetMaxHeight() const { return m_maxHeight; }
+    void SetMinSize(const wxSize& minSize) { m_minWidth = minSize.x; m_minHeight = minSize.y; }
+    void SetMaxSize(const wxSize& maxSize) { m_maxWidth = maxSize.x; m_maxHeight = maxSize.y; }
+
 
         // Methods for accessing the virtual size of a window.  For most
         // windows this is just the client area of the window, but for
index aa07d2f096b5195985daed11ea0a20243d885e8f..88350bebcfc4c63c90b2ff2dd9836f11e469d477 100644 (file)
@@ -140,6 +140,23 @@ bool wxTopLevelWindowBase::IsLastBeforeExit() const
 // wxTopLevelWindow geometry
 // ----------------------------------------------------------------------------
 
+// set the min/max size of the window
+void wxTopLevelWindowBase::DoSetSizeHints(int minW, int minH,
+                                  int maxW, int maxH,
+                                  int WXUNUSED(incW), int WXUNUSED(incH))
+{
+    // setting min width greater than max width leads to infinite loops under
+    // X11 and generally doesn't make any sense, so don't allow it
+    wxCHECK_RET( (minW == wxDefaultCoord || maxW == wxDefaultCoord || minW <= maxW) &&
+                    (minH == wxDefaultCoord || maxH == wxDefaultCoord || minH <= maxH),
+                 _T("min width/height must be less than max width/height!") );
+
+    m_minWidth = minW;
+    m_maxWidth = maxW;
+    m_minHeight = minH;
+    m_maxHeight = maxH;
+}
+
 void wxTopLevelWindowBase::GetRectForTopLevelChildren(int *x, int *y, int *w, int *h)
 {
     GetPosition(x,y);
index 44b93da89dcefb4ad9816151eb0b8ed74597e024..421497abad33eee225202b326510e29268bac5f4 100644 (file)
@@ -615,23 +615,6 @@ wxPoint wxWindowBase::GetClientAreaOrigin() const
     return wxPoint(0,0);
 }
 
-// set the min/max size of the window
-void wxWindowBase::DoSetSizeHints(int minW, int minH,
-                                  int maxW, int maxH,
-                                  int WXUNUSED(incW), int WXUNUSED(incH))
-{
-    // setting min width greater than max width leads to infinite loops under
-    // X11 and generally doesn't make any sense, so don't allow it
-    wxCHECK_RET( (minW == wxDefaultCoord || maxW == wxDefaultCoord || minW <= maxW) &&
-                    (minH == wxDefaultCoord || maxH == wxDefaultCoord || minH <= maxH),
-                 _T("min width/height must be less than max width/height!") );
-
-    m_minWidth = minW;
-    m_maxWidth = maxW;
-    m_minHeight = minH;
-    m_maxHeight = maxH;
-}
-
 void wxWindowBase::SetWindowVariant( wxWindowVariant variant )
 {
     if ( m_windowVariant != variant )
index 5c01cae6db376cbeb6266d73a2ebde5ccccc7947..08a0d0e713ebaae7d40af2c2e19894cbd429da16 100644 (file)
@@ -352,19 +352,6 @@ void wxFrame::GtkOnSize()
 
     if (m_mainWidget)
     {
-        // set size hints
-        gint flag = 0; // GDK_HINT_POS;
-        if ((minWidth != -1) || (minHeight != -1)) flag |= GDK_HINT_MIN_SIZE;
-        if ((maxWidth != -1) || (maxHeight != -1)) flag |= GDK_HINT_MAX_SIZE;
-        GdkGeometry geom;
-        geom.min_width = minWidth;
-        geom.min_height = minHeight;
-        geom.max_width = maxWidth;
-        geom.max_height = maxHeight;
-        gtk_window_set_geometry_hints( GTK_WINDOW(m_widget),
-                                       (GtkWidget*) NULL,
-                                       &geom,
-                                       (GdkWindowHints) flag );
         // TODO
         // Rewrite this terrible code to using GtkVBox
 
index d243ce4b584299242c57d5270342eff60ce0627b..85f4b536dd1f9949cff890da5a1b9552d189bb57 100644 (file)
@@ -958,43 +958,19 @@ void wxTopLevelWindowGTK::DoSetClientSize( int width, int height )
               width + m_miniEdge*2, height  + m_miniEdge*2 + m_miniTitle, 0);
 }
 
-void wxTopLevelWindowGTK::GtkOnSize()
+void wxTopLevelWindowGTK::DoSetSizeHints( int minW, int minH,
+                                          int maxW, int maxH,
+                                          int incW, int incH )
 {
-    // avoid recursions
-    if (m_resizing) return;
-    m_resizing = true;
-
-    if ( m_wxwindow == NULL ) return;
-
-    /* wxMDIChildFrame derives from wxFrame but it _is_ a wxWindow as it uses
-       wxWindow::Create to create it's GTK equivalent. m_mainWidget is only
-       set in wxFrame::Create so it is used to check what kind of frame we
-       have here. if m_mainWidget is NULL it is a wxMDIChildFrame and so we
-       skip the part which handles m_frameMenuBar, m_frameToolBar and (most
-       importantly) m_mainWidget */
-
-    int minWidth = GetMinWidth(),
-        minHeight = GetMinHeight(),
-        maxWidth = GetMaxWidth(),
-        maxHeight = GetMaxHeight();
-
-#ifdef __WXGPE__
-    // GPE's window manager doesn't like size hints
-    // at all, esp. when the user has to use the
-    // virtual keyboard.
-    minWidth = -1;
-    minHeight = -1;
-    maxWidth = -1;
-    maxHeight = -1;
-#endif
-
-    if ((minWidth != -1) && (m_width < minWidth)) m_width = minWidth;
-    if ((minHeight != -1) && (m_height < minHeight)) m_height = minHeight;
-    if ((maxWidth != -1) && (m_width > maxWidth)) m_width = maxWidth;
-    if ((maxHeight != -1) && (m_height > maxHeight)) m_height = maxHeight;
-
-    if (m_mainWidget)
+    wxTopLevelWindowBase::DoSetSizeHints( minW, minH, maxW, maxH, incW, incH );
+    
+    if (m_widget)
     {
+        int minWidth = GetMinWidth(),
+            minHeight = GetMinHeight(),
+            maxWidth = GetMaxWidth(),
+            maxHeight = GetMaxHeight();
+            
         // set size hints
         gint            flag = 0; // GDK_HINT_POS;
         GdkGeometry     geom;
@@ -1031,13 +1007,49 @@ void wxTopLevelWindowGTK::GtkOnSize()
                                        (GtkWidget*) NULL,
                                        &geom,
                                        (GdkWindowHints) flag );
+    }
+}
 
-        /* I revert back to wxGTK's original behaviour. m_mainWidget holds the
-         * menubar, the toolbar and the client area, which is represented by
-         * m_wxwindow.
-         * this hurts in the eye, but I don't want to call SetSize()
-         * because I don't want to call any non-native functions here. */
 
+void wxTopLevelWindowGTK::GtkOnSize()
+{
+    // avoid recursions
+    if (m_resizing) return;
+    m_resizing = true;
+
+    if ( m_wxwindow == NULL ) return;
+
+    /* wxMDIChildFrame derives from wxFrame but it _is_ a wxWindow as it uses
+       wxWindow::Create to create it's GTK equivalent. m_mainWidget is only
+       set in wxFrame::Create so it is used to check what kind of frame we
+       have here. if m_mainWidget is NULL it is a wxMDIChildFrame and so we
+       skip the part which handles m_frameMenuBar, m_frameToolBar and (most
+       importantly) m_mainWidget */
+
+    int minWidth = GetMinWidth(),
+        minHeight = GetMinHeight(),
+        maxWidth = GetMaxWidth(),
+        maxHeight = GetMaxHeight();
+
+#ifdef __WXGPE__
+    // GPE's window manager doesn't like size hints
+    // at all, esp. when the user has to use the
+    // virtual keyboard.
+    minWidth = -1;
+    minHeight = -1;
+    maxWidth = -1;
+    maxHeight = -1;
+#endif
+
+    if ((minWidth != -1) && (m_width < minWidth)) m_width = minWidth;
+    if ((minHeight != -1) && (m_height < minHeight)) m_height = minHeight;
+    if ((maxWidth != -1) && (m_width > maxWidth)) m_width = maxWidth;
+    if ((maxHeight != -1) && (m_height > maxHeight)) m_height = maxHeight;
+
+    if (m_mainWidget)
+    {
+        // m_mainWidget holds the menubar, the toolbar and the client area,
+        // which is represented by m_wxwindow.
         int client_x = m_miniEdge;
         int client_y = m_miniEdge + m_miniTitle;
         int client_w = m_width - 2*m_miniEdge;