]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/wincmn.cpp
added missing include; minor reformatting
[wxWidgets.git] / src / common / wincmn.cpp
index 8c1c94ec41475908d3fa4ddb0e766a86b816d099..891c0175832f0bf116e4d12ee48d035e36e6f863 100644 (file)
@@ -834,14 +834,14 @@ void wxWindowBase::DoSetVirtualSize( int x, int y )
 
 wxSize wxWindowBase::DoGetVirtualSize() const
 {
-    if ( m_virtualSize.IsFullySpecified() )
-        return m_virtualSize;
-
+    // we should use the entire client area so if it is greater than our
+    // virtual size, expand it to fit (otherwise if the window is big enough we
+    // wouldn't be using parts of it)
     wxSize size = GetClientSize();
-    if ( m_virtualSize.x != wxDefaultCoord )
+    if ( m_virtualSize.x > size.x )
         size.x = m_virtualSize.x;
 
-    if ( m_virtualSize.y != wxDefaultCoord )
+    if ( m_virtualSize.y >= size.y )
         size.y = m_virtualSize.y;
 
     return size;
@@ -2249,12 +2249,82 @@ void wxWindowBase::OnInitDialog( wxInitDialogEvent &WXUNUSED(event) )
     UpdateWindowUI(wxUPDATE_UI_RECURSE);
 }
 
-// process Ctrl-Alt-mclick
+// methods for drawing the sizers in a visible way
+#ifdef __WXDEBUG__
+
+static void DrawSizers(wxWindowBase *win);
+
+static void DrawBorder(wxWindowBase *win, const wxRect& rect, bool fill = false)
+{
+    wxClientDC dc((wxWindow *)win);
+    dc.SetPen(*wxRED_PEN);
+    dc.SetBrush(fill ? wxBrush(*wxRED, wxCROSSDIAG_HATCH): *wxTRANSPARENT_BRUSH);
+    dc.DrawRectangle(rect.Deflate(1, 1));
+}
+
+static void DrawSizer(wxWindowBase *win, wxSizer *sizer)
+{
+    const wxSizerItemList& items = sizer->GetChildren();
+    for ( wxSizerItemList::const_iterator i = items.begin(),
+                                        end = items.end();
+          i != end;
+          ++i )
+    {
+        wxSizerItem *item = *i;
+        if ( item->IsSizer() )
+        {
+            DrawBorder(win, item->GetRect().Deflate(2));
+            DrawSizer(win, item->GetSizer());
+        }
+        else if ( item->IsSpacer() )
+        {
+            DrawBorder(win, item->GetRect().Deflate(2), true);
+        }
+        else if ( item->IsWindow() )
+        {
+            DrawSizers(item->GetWindow());
+        }
+    }
+}
+
+static void DrawSizers(wxWindowBase *win)
+{
+    wxSizer *sizer = win->GetSizer();
+    if ( sizer )
+    {
+        DrawBorder(win, win->GetClientSize());
+        DrawSizer(win, sizer);
+    }
+    else // no sizer, still recurse into the children
+    {
+        const wxWindowList& children = win->GetChildren();
+        for ( wxWindowList::const_iterator i = children.begin(),
+                                         end = children.end();
+              i != end;
+              ++i )
+        {
+            DrawSizers(*i);
+        }
+    }
+}
+
+#endif // __WXDEBUG__
+
+// process special middle clicks
 void wxWindowBase::OnMiddleClick( wxMouseEvent& event )
 {
-#if wxUSE_MSGDLG
     if ( event.ControlDown() && event.AltDown() )
     {
+#ifdef __WXDEBUG__
+        // Ctrl-Alt-Shift-mclick makes the sizers visible in debug builds
+        if ( event.ShiftDown() )
+        {
+            DrawSizers(this);
+            return;
+        }
+#endif // __WXDEBUG__
+
+#if wxUSE_MSGDLG
         // don't translate these strings
         wxString port;
 
@@ -2293,7 +2363,7 @@ void wxWindowBase::OnMiddleClick( wxMouseEvent& event )
 
         wxMessageBox(wxString::Format(
                                       _T(
-                                        "       wxWidgets Library (%s port)\nVersion %d.%d.%d%s%s, compiled at %s %s%s\n   Copyright (c) 1995-2005 wxWidgets team"
+                                        "       wxWidgets Library (%s port)\nVersion %d.%d.%d%s%s, compiled at %s %s%s\n   Copyright (c) 1995-2006 wxWidgets team"
                                         ),
                                       port.c_str(),
                                       wxMAJOR_VERSION,
@@ -2365,7 +2435,7 @@ wxAccessible* wxWindowBase::CreateAccessible()
 #if wxUSE_STL
 
 #include "wx/listimpl.cpp"
-WX_DEFINE_LIST(wxWindowList);
+WX_DEFINE_LIST(wxWindowList)
 
 #else