]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/toplvcmn.cpp
added wxRTTI macros to stream classes (patch 1687073)
[wxWidgets.git] / src / common / toplvcmn.cpp
index 9e0d6357e52640fd698c44ff51d7a6376aee71bd..c1645bd9bec209455765167e66d79a5568965fa6 100644 (file)
@@ -39,6 +39,7 @@
 BEGIN_EVENT_TABLE(wxTopLevelWindowBase, wxWindow)
     EVT_CLOSE(wxTopLevelWindowBase::OnCloseWindow)
     EVT_SIZE(wxTopLevelWindowBase::OnSize)
+    EVT_WINDOW_DESTROY(wxTopLevelWindowBase::OnChildDestroy)
 END_EVENT_TABLE()
 
 // ============================================================================
@@ -140,6 +141,16 @@ bool wxTopLevelWindowBase::IsLastBeforeExit() const
 // wxTopLevelWindow geometry
 // ----------------------------------------------------------------------------
 
+void wxTopLevelWindowBase::SetMinSize(const wxSize& minSize)
+{
+    SetSizeHints( minSize.x, minSize.y, GetMaxWidth(), GetMaxHeight() );    
+}
+
+void wxTopLevelWindowBase::SetMaxSize(const wxSize& maxSize)
+{
+    SetSizeHints( GetMinWidth(), GetMinHeight(), maxSize.x, maxSize.y );
+}
+
 // set the min/max size of the window
 void wxTopLevelWindowBase::DoSetSizeHints(int minW, int minH,
                                   int maxW, int maxH,
@@ -163,22 +174,6 @@ void wxTopLevelWindowBase::GetRectForTopLevelChildren(int *x, int *y, int *w, in
     GetSize(w,h);
 }
 
-wxSize wxTopLevelWindowBase::GetMaxSize() const
-{
-    wxSize size = wxWindow::GetMaxSize();
-
-    int w, h;
-    wxClientDisplayRect(NULL, NULL, &w, &h );
-
-    if ( size.GetWidth() == wxDefaultCoord )
-        size.SetWidth(w);
-
-    if ( size.GetHeight() == wxDefaultCoord )
-        size.SetHeight(h);
-
-    return size;
-}
-
 /* static */
 wxSize wxTopLevelWindowBase::GetDefaultSize()
 {
@@ -237,7 +232,7 @@ void wxTopLevelWindowBase::DoCentre(int dir)
 
     if ( rectParent.IsEmpty() )
     {
-        // we were explicitely asked to centre this window on the entire screen
+        // we were explicitly asked to centre this window on the entire screen
         // or if we have no parent anyhow and so can't centre on it
         rectParent = rectDisplay;
     }
@@ -256,11 +251,11 @@ void wxTopLevelWindowBase::DoCentre(int dir)
     {
         if ( !rectDisplay.Contains(rect.GetBottomRight()) )
         {
-            // check if we can move the window so that the bottom right corner
-            // is visible without hiding the top left one
+            // move the window just enough for the bottom right corner to
+            // become visible
             int dx = rectDisplay.GetRight() - rect.GetRight();
             int dy = rectDisplay.GetBottom() - rect.GetBottom();
-            rect.Offset(dx, dy);
+            rect.Offset(dx < 0 ? dx : 0, dy < 0 ? dy : 0);
         }
         //else: the window top left and bottom right corner are both visible,
         //      although the window might still be not entirely on screen (with
@@ -320,6 +315,26 @@ bool wxTopLevelWindowBase::IsAlwaysMaximized() const
 #endif
 }
 
+// ----------------------------------------------------------------------------
+// icons
+// ----------------------------------------------------------------------------
+
+wxIcon wxTopLevelWindowBase::GetIcon() const
+{
+    return m_icons.IsEmpty() ? wxIcon() : m_icons.GetIcon( -1 );
+}
+
+void wxTopLevelWindowBase::SetIcon(const wxIcon& icon)
+{
+    // passing wxNullIcon to SetIcon() is possible (it means that we shouldn't
+    // have any icon), but adding an invalid icon to wxIconBundle is not
+    wxIconBundle icons;
+    if ( icon.Ok() )
+        icons.AddIcon(icon);
+
+    SetIcons(icons);
+}
+
 // ----------------------------------------------------------------------------
 // event handlers
 // ----------------------------------------------------------------------------
@@ -364,21 +379,7 @@ void wxTopLevelWindowBase::DoLayout()
             int clientW, clientH;
             DoGetClientSize(&clientW, &clientH);
 
-            // for whatever reasons, wxGTK wants to have a small offset - it
-            // probably looks better with it?
-#ifdef __WXGTK__
-            const int ofs = 1;
-            clientW -= 2 * ofs;
-            clientH -= 2 * ofs;
-            if (clientW < 0)
-                clientW = 0;
-            if (clientH < 0)
-                clientH = 0;
-#else
-            const int ofs = 0;
-#endif
-
-            child->SetSize(ofs, ofs, clientW, clientH);
+            child->SetSize(0, 0, clientW, clientH);
         }
     }
 }
@@ -389,6 +390,17 @@ void wxTopLevelWindowBase::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
     Destroy();
 }
 
+void wxTopLevelWindowBase::OnChildDestroy(wxWindowDestroyEvent& event)
+{
+    event.Skip();
+
+    wxWindow * const win = event.GetWindow();
+    if ( win == m_winDefault )
+        m_winDefault = NULL;
+    if ( win == m_winTmpDefault )
+        m_winTmpDefault = NULL;
+}
+
 bool wxTopLevelWindowBase::SendIconizeEvent(bool iconized)
 {
     wxIconizeEvent event(GetId(), iconized);