]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/wincmn.cpp
fixed handling of dst offset in wxAlphaBlend()
[wxWidgets.git] / src / common / wincmn.cpp
index 9ac1028a5084df53170259338d1e17ed442be47c..05f22c324f3a1486a56d67f6b505c156d0dda8b3 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
-// Name:        common/window.cpp
+// Name:        src/common/window.cpp
 // Purpose:     common (to all ports) wxWindow functions
 // Author:      Julian Smart, Vadim Zeitlin
 // Modified by:
 // headers
 // ----------------------------------------------------------------------------
 
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-    #pragma implementation "windowbase.h"
-#endif
-
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
@@ -44,6 +40,7 @@
     #include "wx/dialog.h"
     #include "wx/msgdlg.h"
     #include "wx/statusbr.h"
+    #include "wx/toolbar.h"
     #include "wx/dcclient.h"
 #endif //WX_PRECOMP
 
     #include "wx/sysopt.h"
 #endif
 
+// For reporting compile- and runtime version of GTK+ in the ctrl+alt+mclick dialog.
+// The gtk includes don't pull any other headers in, at least not on my system - MR
+#ifdef __WXGTK__
+    #ifdef __WXGTK20__
+        #include <gtk/gtkversion.h>
+    #else
+        #include <gtk/gtkfeatures.h>
+    #endif
+    extern const unsigned int gtk_major_version;
+    extern const unsigned int gtk_minor_version;
+    extern const unsigned int gtk_micro_version;
+#endif
+
 // ----------------------------------------------------------------------------
 // static data
 // ----------------------------------------------------------------------------
@@ -215,7 +225,7 @@ wxWindowBase::wxWindowBase()
 
     // VZ: this one shouldn't exist...
     m_isBeingDeleted = false;
-    
+
     // Reserved for future use
     m_windowReserved = NULL;
 }
@@ -494,13 +504,13 @@ void wxWindowBase::Centre(int direction)
     yNew += posParent.y;
 
     // FIXME:  This needs to get the client display rect of the display
-    // the window is (via wxDisplay::GetFromWindow). 
-    
+    // the window is (via wxDisplay::GetFromWindow).
+
     // Base size of the visible dimensions of the display
     // to take into account the taskbar. And the Mac menu bar at top.
     wxRect clientrect = wxGetClientDisplayRect();
 
-    // NB: in wxMSW, negative position may not neccessary mean "out of screen",
+    // NB: in wxMSW, negative position may not necessarily mean "out of screen",
     //     but it may mean that the window is placed on other than the main
     //     display. Therefore we only make sure centered window is on the main display
     //     if the parent is at least partially present here.
@@ -531,9 +541,9 @@ void wxWindowBase::Centre(int direction)
 // fits the window around the children
 void wxWindowBase::Fit()
 {
-    if ( GetChildren().GetCount() > 0 )
+    if ( !GetChildren().empty() )
     {
-        SetSize(GetBestSize());
+        SetClientSize(GetBestSize());
     }
     //else: do nothing if we have no children
 }
@@ -582,7 +592,7 @@ wxSize wxWindowBase::DoGetBestSize() const
 
     if ( m_windowSizer )
     {
-        best = m_windowSizer->GetMinSize();
+        best = GetWindowSizeForVirtualSize(m_windowSizer->GetMinSize());
     }
 #if wxUSE_CONSTRAINTS
     else if ( m_constraints )
@@ -682,11 +692,15 @@ wxSize wxWindowBase::DoGetBestSize() const
         // then, when the containing window is shrunk back (because our initial
         // best size had been used for computing the parent min size), we can't
         // be shrunk back any more because our best size is now bigger
-        if ( !GetMinSize().IsFullySpecified() )
-            wxConstCast(this, wxWindowBase)->SetMinSize(GetSize());
+        wxSize size = GetMinSize();
+        if ( !size.IsFullySpecified() )
+        {
+            size.SetDefaults(GetSize());
+            wxConstCast(this, wxWindowBase)->SetMinSize(size);
+        }
 
         // return as-is, unadjusted by the client size difference.
-        return GetMinSize();
+        return size;
     }
 
     // Add any difference between size and client size
@@ -2235,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;
 
@@ -2250,32 +2334,36 @@ void wxWindowBase::OnMiddleClick( wxMouseEvent& event )
 
         switch ( wxGetOsVersion() )
         {
-            case wxMOTIF_X:     port += _T("Motif"); break;
+            case wxMOTIF_X:            port += _T("Motif"); break;
             case wxMAC:
-            case wxMAC_DARWIN:  port += _T("Mac"); break;
-            case wxBEOS:        port += _T("BeOS"); break;
+            case wxMAC_DARWIN:         port += _T("Mac"); break;
+            case wxBEOS:               port += _T("BeOS"); break;
             case wxGTK:
             case wxGTK_WIN32:
             case wxGTK_OS2:
-            case wxGTK_BEOS:    port += _T("GTK"); break;
+            case wxGTK_BEOS:           port += _T("GTK"); break;
             case wxWINDOWS:
             case wxPENWINDOWS:
             case wxWINDOWS_NT:
             case wxWIN32S:
             case wxWIN95:
-            case wxWIN386:      port += _T("MS Windows"); break;
+            case wxWIN386:             port += _T("MS Windows"); break;
             case wxMGL_UNIX:
             case wxMGL_X:
             case wxMGL_WIN32:
-            case wxMGL_OS2:     port += _T("MGL"); break;
+            case wxMGL_OS2:            port += _T("MGL"); break;
             case wxWINDOWS_OS2:
-            case wxOS2_PM:      port += _T("OS/2"); break;
+            case wxOS2_PM:             port += _T("OS/2"); break;
+            case wxPALMOS:             port += _T("Palm OS"); break;
+            case wxWINDOWS_CE:         port += _T("Windows CE (generic)"); break;
+            case wxWINDOWS_POCKETPC:   port += _T("Windows CE PocketPC"); break;
+            case wxWINDOWS_SMARTPHONE: port += _T("Windows CE Smartphone"); break;
             default:            port += _T("unknown"); break;
         }
 
         wxMessageBox(wxString::Format(
                                       _T(
-                                        "       wxWidgets Library (%s port)\nVersion %u.%u.%u%s%s, compiled at %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-2005 wxWidgets team"
                                         ),
                                       port.c_str(),
                                       wxMAJOR_VERSION,
@@ -2292,7 +2380,12 @@ void wxWindowBase::OnMiddleClick( wxMouseEvent& event )
                                       wxEmptyString,
 #endif
                                       __TDATE__,
-                                      __TTIME__
+                                      __TTIME__,
+#ifdef __WXGTK__
+                                      wxString::Format(_T("\nagainst GTK+ %d.%d.%d. Runtime GTK+ version: %d.%d.%d"), GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION, gtk_major_version, gtk_minor_version, gtk_micro_version).c_str()
+#else
+                                      ""
+#endif
                                      ),
                      _T("wxWidgets information"),
                      wxICON_INFORMATION | wxOK,
@@ -2341,8 +2434,8 @@ wxAccessible* wxWindowBase::CreateAccessible()
 
 #if wxUSE_STL
 
-#include <wx/listimpl.cpp>
-WX_DEFINE_LIST(wxWindowList);
+#include "wx/listimpl.cpp"
+WX_DEFINE_LIST(wxWindowList)
 
 #else
 
@@ -2497,7 +2590,7 @@ bool wxWindowBase::TryValidator(wxEvent& wxVALIDATOR_PARAM(event))
 
 bool wxWindowBase::TryParent(wxEvent& event)
 {
-    // carry on up the parent-child hierarchy if the propgation count hasn't
+    // carry on up the parent-child hierarchy if the propagation count hasn't
     // reached zero yet
     if ( event.ShouldPropagate() )
     {