]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix for the irksome, 'Details' sizing bug. Or at least a patch on a hornet's
authorRon Lee <ron@debian.org>
Mon, 1 Jul 2002 10:27:29 +0000 (10:27 +0000)
committerRon Lee <ron@debian.org>
Mon, 1 Jul 2002 10:27:29 +0000 (10:27 +0000)
nest.  Thanks to jill@emeraldgate.com for tracking this one (and the previous
StatusBar patch too).

There's more work here if someone wants it..  :-)

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

src/generic/logg.cpp
src/gtk/toplevel.cpp
src/gtk1/toplevel.cpp

index 494df3262ea9318e96ac80b974fcdcc0fb5f15a6..ec11439ee96b612051cc26b242b90afb07278a81 100644 (file)
@@ -764,6 +764,15 @@ wxLogDialog::wxLogDialog(wxWindow *parent,
     SetSizer(sizerTop);
 
     // see comments in OnDetails()
+    //
+    // Note: Doing this, this way, triggered a nasty bug in
+    //       wxTopLevelWindowGTK::GtkOnSize which took -1 literally once
+    //       either of maxWidth or maxHeight was set.  This symptom has been
+    //       fixed there, but it is a problem that remains as long as we allow
+    //       unchecked access to the internal size members.  We really need to
+    //       encapuslate window sizes more cleanly and make it clear when -1 will
+    //       be substituted and when it will not.
+
     wxSize size = sizerTop->Fit(this);
     m_maxHeight = size.y;
     SetSizeHints(size.x, size.y, m_maxWidth, m_maxHeight);
@@ -1015,6 +1024,7 @@ void wxLogDialog::OnDetails(wxCommandEvent& WXUNUSED(event))
     // we have to reset min size constraints or Fit() would never reduce the
     // dialog size when collapsing it and we have to reset max constraint
     // because it wouldn't expand it otherwise
+
     m_minHeight =
     m_maxHeight = -1;
 
@@ -1146,3 +1156,4 @@ void wxLogTextCtrl::DoLogString(const wxChar *szString, time_t WXUNUSED(t))
 
 #endif // wxUSE_TEXTCTRL
 
+// vi:sts=4:sw=4:et
index 0edae9fb0ee0ac288c6472c3d09c9e5e42a9db18..eb820f7f15c7725effb31c30c6cc5d930fee86e1 100644 (file)
@@ -710,14 +710,37 @@ void wxTopLevelWindowGTK::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y),
     if (m_mainWidget)
     {
         // set size hints
-        gint flag = 0; // GDK_HINT_POS;
+        gint            flag = 0; // GDK_HINT_POS;
+        GdkGeometry     geom;
+
         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;
+
+            // Because of the way we set GDK_HINT_MAX_SIZE above, if either of
+            // maxHeight or maxWidth is set, we must set them both, else the
+            // remaining -1 will be taken literally.
+
+            // I'm certain this also happens elsewhere, and is the probable
+            // cause of other such things as:
+            // Gtk-WARNING **: gtk_widget_size_allocate():
+            //       attempt to allocate widget with width 65535 and height 600
+            // but I don't have time to track them all now..
+            // 
+            // Really we need to encapulate all this height/width business and
+            // stop any old method from ripping at the members directly and
+            // scattering -1's without regard for who might resolve them later.
+
+        geom.max_width = ( maxHeight == -1 ) ? maxWidth
+                         : ( maxWidth == -1 ) ? wxGetDisplaySize().GetWidth()
+                           : maxWidth ;
+
+        geom.max_height = ( maxWidth == -1 ) ? maxHeight    // ( == -1 here )
+                          : ( maxHeight == -1 ) ? wxGetDisplaySize().GetHeight()
+                            : maxHeight ;
+
         gtk_window_set_geometry_hints( GTK_WINDOW(m_widget),
                                        (GtkWidget*) NULL,
                                        &geom,
@@ -733,6 +756,7 @@ void wxTopLevelWindowGTK::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y),
         int client_y = m_miniEdge + m_miniTitle;
         int client_w = m_width - 2*m_miniEdge;
         int client_h = m_height - 2*m_miniEdge - m_miniTitle;
+
         gtk_pizza_set_size( GTK_PIZZA(m_mainWidget),
                               m_wxwindow,
                               client_x, client_y, client_w, client_h );
@@ -896,3 +920,5 @@ void wxTopLevelWindowGTK::RemoveGrab()
         m_grabbed = FALSE;
     }
 }
+
+// vi:sts=4:sw=4:et
index 0edae9fb0ee0ac288c6472c3d09c9e5e42a9db18..eb820f7f15c7725effb31c30c6cc5d930fee86e1 100644 (file)
@@ -710,14 +710,37 @@ void wxTopLevelWindowGTK::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y),
     if (m_mainWidget)
     {
         // set size hints
-        gint flag = 0; // GDK_HINT_POS;
+        gint            flag = 0; // GDK_HINT_POS;
+        GdkGeometry     geom;
+
         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;
+
+            // Because of the way we set GDK_HINT_MAX_SIZE above, if either of
+            // maxHeight or maxWidth is set, we must set them both, else the
+            // remaining -1 will be taken literally.
+
+            // I'm certain this also happens elsewhere, and is the probable
+            // cause of other such things as:
+            // Gtk-WARNING **: gtk_widget_size_allocate():
+            //       attempt to allocate widget with width 65535 and height 600
+            // but I don't have time to track them all now..
+            // 
+            // Really we need to encapulate all this height/width business and
+            // stop any old method from ripping at the members directly and
+            // scattering -1's without regard for who might resolve them later.
+
+        geom.max_width = ( maxHeight == -1 ) ? maxWidth
+                         : ( maxWidth == -1 ) ? wxGetDisplaySize().GetWidth()
+                           : maxWidth ;
+
+        geom.max_height = ( maxWidth == -1 ) ? maxHeight    // ( == -1 here )
+                          : ( maxHeight == -1 ) ? wxGetDisplaySize().GetHeight()
+                            : maxHeight ;
+
         gtk_window_set_geometry_hints( GTK_WINDOW(m_widget),
                                        (GtkWidget*) NULL,
                                        &geom,
@@ -733,6 +756,7 @@ void wxTopLevelWindowGTK::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y),
         int client_y = m_miniEdge + m_miniTitle;
         int client_w = m_width - 2*m_miniEdge;
         int client_h = m_height - 2*m_miniEdge - m_miniTitle;
+
         gtk_pizza_set_size( GTK_PIZZA(m_mainWidget),
                               m_wxwindow,
                               client_x, client_y, client_w, client_h );
@@ -896,3 +920,5 @@ void wxTopLevelWindowGTK::RemoveGrab()
         m_grabbed = FALSE;
     }
 }
+
+// vi:sts=4:sw=4:et