+ wxCHECK_MSG( node, false, wxT("Failed to find child node") );
+
+ wxSizerItem *item = node->GetData();
+ node->SetData(newitem);
+
+ if (item->IsWindow() && item->GetWindow())
+ item->GetWindow()->SetContainingSizer(NULL);
+
+ delete item;
+
+ return true;
+}
+
+void wxSizer::Clear( bool delete_windows )
+{
+ // First clear the ContainingSizer pointers
+ wxSizerItemList::compatibility_iterator node = m_children.GetFirst();
+ while (node)
+ {
+ wxSizerItem *item = node->GetData();
+
+ if (item->IsWindow())
+ item->GetWindow()->SetContainingSizer( NULL );
+ node = node->GetNext();
+ }
+
+ // Destroy the windows if needed
+ if (delete_windows)
+ DeleteWindows();
+
+ // Now empty the list
+ WX_CLEAR_LIST(wxSizerItemList, m_children);
+}
+
+void wxSizer::DeleteWindows()
+{
+ wxSizerItemList::compatibility_iterator node = m_children.GetFirst();
+ while (node)
+ {
+ wxSizerItem *item = node->GetData();
+
+ item->DeleteWindows();
+ node = node->GetNext();
+ }
+}
+
+wxSize wxSizer::ComputeFittingClientSize(wxWindow *window)
+{
+ wxCHECK_MSG( window, wxDefaultSize, "window can't be NULL" );
+
+ // take the min size by default and limit it by max size
+ wxSize size = GetMinClientSize(window);
+ wxSize sizeMax;
+
+ wxTopLevelWindow *tlw = wxDynamicCast(window, wxTopLevelWindow);
+ if ( tlw )
+ {
+ // hack for small screen devices where TLWs are always full screen
+ if ( tlw->IsAlwaysMaximized() )
+ {
+ return tlw->GetClientSize();
+ }
+
+ // limit the window to the size of the display it is on
+ int disp = wxDisplay::GetFromWindow(window);
+ if ( disp == wxNOT_FOUND )
+ {
+ // or, if we don't know which one it is, of the main one
+ disp = 0;
+ }
+
+ sizeMax = wxDisplay(disp).GetClientArea().GetSize();
+
+ // If determining the display size failed, skip the max size checks as
+ // we really don't want to create windows of (0, 0) size.
+ if ( !sizeMax.x || !sizeMax.y )
+ return size;
+
+ // space for decorations and toolbars etc.
+ sizeMax = tlw->WindowToClientSize(sizeMax);
+ }
+ else
+ {
+ sizeMax = GetMaxClientSize(window);
+ }
+
+ if ( sizeMax.x != wxDefaultCoord && size.x > sizeMax.x )
+ size.x = sizeMax.x;
+ if ( sizeMax.y != wxDefaultCoord && size.y > sizeMax.y )
+ size.y = sizeMax.y;
+
+ return size;
+}
+
+wxSize wxSizer::ComputeFittingWindowSize(wxWindow *window)
+{
+ wxCHECK_MSG( window, wxDefaultSize, "window can't be NULL" );
+
+ return window->ClientToWindowSize(ComputeFittingClientSize(window));
+}
+
+wxSize wxSizer::Fit( wxWindow *window )
+{
+ wxCHECK_MSG( window, wxDefaultSize, "window can't be NULL" );
+
+ // set client size
+ window->SetClientSize(ComputeFittingClientSize(window));
+
+ // return entire size
+ return window->GetSize();