]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/wincmn.cpp
fix other insert() overloads to work when inserting at the end of the list, continuat...
[wxWidgets.git] / src / common / wincmn.cpp
index 878bca5ae8c6abd5e3059f3c15b5d9bba23af67d..d9242cb93148c33c71de02f32ed5c0f22f3c101f 100644 (file)
@@ -38,6 +38,7 @@
     #include "wx/settings.h"
     #include "wx/dialog.h"
     #include "wx/msgdlg.h"
+    #include "wx/msgout.h"
     #include "wx/statusbr.h"
     #include "wx/toolbar.h"
     #include "wx/dcclient.h"
@@ -711,15 +712,36 @@ wxSize wxWindowBase::GetEffectiveMinSize() const
 {
     // merge the best size with the min size, giving priority to the min size
     wxSize min = GetMinSize();
+
     if (min.x == wxDefaultCoord || min.y == wxDefaultCoord)
     {
         wxSize best = GetBestSize();
         if (min.x == wxDefaultCoord) min.x =  best.x;
         if (min.y == wxDefaultCoord) min.y =  best.y;
     }
+
     return min;
 }
 
+wxSize wxWindowBase::GetBestSize() const
+{
+    if ((!m_windowSizer) && (m_bestSizeCache.IsFullySpecified()))
+        return m_bestSizeCache;
+
+    return DoGetBestSize();
+}
+
+void wxWindowBase::SetMinSize(const wxSize& minSize)
+{
+    m_minWidth = minSize.x;
+    m_minHeight = minSize.y;
+}
+
+void wxWindowBase::SetMaxSize(const wxSize& maxSize)
+{
+    m_maxWidth = maxSize.x;
+    m_maxHeight = maxSize.y;
+}
 
 void wxWindowBase::SetInitialSize(const wxSize& size)
 {
@@ -2518,11 +2540,12 @@ wxWindowBase::DoGetPopupMenuSelectionFromUser(wxMenu& menu, int x, int y)
 
 static void DrawSizers(wxWindowBase *win);
 
-static void DrawBorder(wxWindowBase *win, const wxRect& rect, bool fill = false)
+static void DrawBorder(wxWindowBase *win, const wxRect& rect, bool fill, const wxPen* pen)
 {
     wxClientDC dc((wxWindow *)win);
-    dc.SetPen(*wxRED_PEN);
-    dc.SetBrush(fill ? wxBrush(*wxRED, wxBRUSHSTYLE_CROSSDIAG_HATCH) : *wxTRANSPARENT_BRUSH);
+    dc.SetPen(*pen);
+    dc.SetBrush(fill ? wxBrush(pen->GetColour(), wxBRUSHSTYLE_CROSSDIAG_HATCH) :
+                       *wxTRANSPARENT_BRUSH);
     dc.DrawRectangle(rect.Deflate(1, 1));
 }
 
@@ -2537,26 +2560,29 @@ static void DrawSizer(wxWindowBase *win, wxSizer *sizer)
         wxSizerItem *item = *i;
         if ( item->IsSizer() )
         {
-            DrawBorder(win, item->GetRect().Deflate(2));
+            DrawBorder(win, item->GetRect().Deflate(2), false, wxRED_PEN);
             DrawSizer(win, item->GetSizer());
         }
         else if ( item->IsSpacer() )
         {
-            DrawBorder(win, item->GetRect().Deflate(2), true);
+            DrawBorder(win, item->GetRect().Deflate(2), true, wxBLUE_PEN);
         }
         else if ( item->IsWindow() )
         {
             DrawSizers(item->GetWindow());
         }
+        else
+            wxFAIL_MSG("inconsistent wxSizerItem status!");
     }
 }
 
 static void DrawSizers(wxWindowBase *win)
 {
+    DrawBorder(win, win->GetClientSize(), false, wxGREEN_PEN);
+
     wxSizer *sizer = win->GetSizer();
     if ( sizer )
     {
-        DrawBorder(win, win->GetClientSize());
         DrawSizer(win, sizer);
     }
     else // no sizer, still recurse into the children
@@ -2569,6 +2595,26 @@ static void DrawSizers(wxWindowBase *win)
         {
             DrawSizers(*i);
         }
+
+        // show all kind of sizes of this window; see the "window sizing" topic
+        // overview for more info about the various differences:
+        wxSize fullSz = win->GetSize();
+        wxSize clientSz = win->GetClientSize();
+        wxSize bestSz = win->GetBestSize();
+        wxSize minSz = win->GetMinSize();
+        wxSize maxSz = win->GetMaxSize();
+        wxSize virtualSz = win->GetVirtualSize();
+
+        wxMessageOutputDebug dbgout;
+        dbgout.Printf(
+            "%-10s => fullsz=%4d;%-4d  clientsz=%4d;%-4d  bestsz=%4d;%-4d  minsz=%4d;%-4d  maxsz=%4d;%-4d virtualsz=%4d;%-4d\n",
+            win->GetName(),
+            fullSz.x, fullSz.y,
+            clientSz.x, clientSz.y,
+            bestSz.x, bestSz.y,
+            minSz.x, minSz.y,
+            maxSz.x, maxSz.y,
+            virtualSz.x, virtualSz.y);
     }
 }