From 92c01615ecb4afeb325e5148554b443fed830534 Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Sat, 15 Mar 2008 02:08:02 +0000
Subject: [PATCH] remove/replace redundant SetAutoLayout() and Fit() calls,
 leave just SetSizer[AndFit]() ones (patch 1905759)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52525 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 samples/artprov/artbrows.cpp        |  3 +--
 samples/controls/controls.cpp       |  1 -
 samples/display/display.cpp         |  1 -
 samples/dnd/dnd.cpp                 |  3 +--
 samples/editlbox/editlbox.cpp       |  3 +--
 samples/except/except.cpp           |  3 +--
 samples/grid/griddemo.cpp           |  5 +----
 samples/help/demo.cpp               |  5 +----
 samples/layout/layout.cpp           | 14 +++-----------
 samples/mediaplayer/mediaplayer.cpp |  1 -
 samples/notebook/notebook.cpp       |  1 -
 samples/popup/popup.cpp             |  6 +-----
 samples/scrollsub/scrollsub.cpp     |  2 --
 samples/statbar/statbar.cpp         |  5 +----
 samples/text/text.cpp               |  1 -
 samples/widgets/widgets.cpp         |  1 -
 samples/wizard/wizard.cpp           |  9 +++------
 17 files changed, 14 insertions(+), 50 deletions(-)

diff --git a/samples/artprov/artbrows.cpp b/samples/artprov/artbrows.cpp
index f4b8eb666f..599c36c9c3 100644
--- a/samples/artprov/artbrows.cpp
+++ b/samples/artprov/artbrows.cpp
@@ -162,8 +162,7 @@ wxArtBrowserDialog::wxArtBrowserDialog(wxWindow *parent)
     ok->SetDefault();
     sizer->Add(ok, 0, wxALIGN_RIGHT | wxALL, 10);
 
-    SetSizer(sizer);
-    sizer->Fit(this);
+    SetSizerAndFit(sizer);
 
     choice->SetSelection(6/*wxART_MESSAGE_BOX*/);
     SetArtClient(wxART_MESSAGE_BOX);
diff --git a/samples/controls/controls.cpp b/samples/controls/controls.cpp
index 236468c6cb..0b9b11546d 100644
--- a/samples/controls/controls.cpp
+++ b/samples/controls/controls.cpp
@@ -1015,7 +1015,6 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
 
     // sizer
     panel = new wxPanel(m_book);
-    panel->SetAutoLayout( true );
 
     wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
 
diff --git a/samples/display/display.cpp b/samples/display/display.cpp
index 683cb0375e..456f75f97e 100644
--- a/samples/display/display.cpp
+++ b/samples/display/display.cpp
@@ -313,7 +313,6 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size,
     wxBoxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
     sizer->Add(m_book, 1, wxEXPAND);
     panel->SetSizer(sizer);
-    sizer->Fit(this);
     sizer->SetSizeHints(this);
 }
 
diff --git a/samples/dnd/dnd.cpp b/samples/dnd/dnd.cpp
index f7af7468fe..307c07d4dd 100644
--- a/samples/dnd/dnd.cpp
+++ b/samples/dnd/dnd.cpp
@@ -1624,8 +1624,7 @@ DnDShapeDialog::DnDShapeDialog(wxFrame *parent, DnDShape *shape)
     buttonSizer->Add( bt, 0, wxALL, 2 );
     topSizer->Add( buttonSizer, 0, wxALL|wxALIGN_RIGHT, 2 );
 
-    SetSizer( topSizer );
-    topSizer->Fit( this );
+    SetSizerAndFit( topSizer );
 }
 
 DnDShape *DnDShapeDialog::GetShape() const
diff --git a/samples/editlbox/editlbox.cpp b/samples/editlbox/editlbox.cpp
index 66a91d19fe..a317e4edeb 100644
--- a/samples/editlbox/editlbox.cpp
+++ b/samples/editlbox/editlbox.cpp
@@ -48,8 +48,7 @@ bool MyApp::OnInit()
     sizer->Add(5,5);
 
     sizer->Add(new wxButton(&dlg, wxID_OK, _("OK")), 0, wxALIGN_RIGHT | wxALL, 10);
-    dlg.SetSizer(sizer);
-    sizer->Fit(&dlg);
+    dlg.SetSizerAndFit(sizer);
     dlg.Centre();
 
     dlg.ShowModal();
diff --git a/samples/except/except.cpp b/samples/except/except.cpp
index f401d6ce18..5e487845d5 100644
--- a/samples/except/except.cpp
+++ b/samples/except/except.cpp
@@ -475,8 +475,7 @@ MyDialog::MyDialog(wxFrame *parent)
     sizerTop->Add(new wxButton(this, wxID_CANCEL, _T("&Cancel")),
                   0, wxCENTRE | wxALL, 5);
 
-    SetSizer(sizerTop);
-    sizerTop->Fit(this);
+    SetSizerAndFit(sizerTop);
 }
 
 void MyDialog::OnThrowInt(wxCommandEvent& WXUNUSED(event))
diff --git a/samples/grid/griddemo.cpp b/samples/grid/griddemo.cpp
index a3c6b4287c..363fa80472 100644
--- a/samples/grid/griddemo.cpp
+++ b/samples/grid/griddemo.cpp
@@ -371,10 +371,7 @@ GridFrame::GridFrame()
                    wxEXPAND );
 #endif // wxUSE_LOG
 
-    SetAutoLayout(true);
-    SetSizer( topSizer );
-
-    topSizer->Fit( this );
+    SetSizerAndFit( topSizer );
 
     Centre();
     SetDefaults();
diff --git a/samples/help/demo.cpp b/samples/help/demo.cpp
index 7749c96fc8..74574c239f 100644
--- a/samples/help/demo.cpp
+++ b/samples/help/demo.cpp
@@ -711,10 +711,7 @@ MyModalDialog::MyModalDialog(wxWindow *parent)
     sizerTop->Add(text, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
     sizerTop->Add(sizerRow, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
 
-    SetSizer(sizerTop);
-
-    sizerTop->SetSizeHints(this);
-    sizerTop->Fit(this);
+    SetSizerAndFit(sizerTop);
 
     btnOK->SetFocus();
     btnOK->SetDefault();
diff --git a/samples/layout/layout.cpp b/samples/layout/layout.cpp
index 110b6ef213..da5a8580b5 100644
--- a/samples/layout/layout.cpp
+++ b/samples/layout/layout.cpp
@@ -426,12 +426,10 @@ MySizerDialog::MySizerDialog(wxWindow *parent, const wxString &title)
     wxButton *button2 = new wxButton( panel, wxID_ANY, _T("Hallo") );
     panelsizer->Add( button2, 0, wxALIGN_RIGHT | wxLEFT|wxRIGHT|wxBOTTOM, 30 );
 
-    panel->SetAutoLayout( true );
     panel->SetSizer( panelsizer );
 
     // Tell dialog to use sizer
-    SetSizer( topsizer );
-    topsizer->SetSizeHints( this );
+    SetSizerAndFit( topsizer );
 }
 
 // ----------------------------------------------------------------------------
@@ -662,11 +660,7 @@ MyNestedSizerFrame::MyNestedSizerFrame(const wxString &title, int x, int y )
     m_target = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80, wxDefaultCoord ) );
     main_sizer->Add( m_target, 1, wxALL|wxGROW, 5 );
 
-    SetSizer( main_sizer);
-
-    Layout();
-    GetSizer()->Fit( this );
-    GetSizer()->SetSizeHints( this );
+    SetSizerAndFit( main_sizer);
 }
 
 
@@ -708,8 +702,6 @@ MyWrapSizerFrame::MyWrapSizerFrame(const wxString &title, int x, int y )
     root->Add( ps_bottom, 1, wxEXPAND | wxALL, 5 );
         
     // Set sizer for window
-    SetSizer( root );
-    root->Fit( this );
-    root->SetSizeHints( this );
+    SetSizerAndFit( root );
 }
 
diff --git a/samples/mediaplayer/mediaplayer.cpp b/samples/mediaplayer/mediaplayer.cpp
index aeba330fc5..e1f0961a4c 100644
--- a/samples/mediaplayer/mediaplayer.cpp
+++ b/samples/mediaplayer/mediaplayer.cpp
@@ -1534,7 +1534,6 @@ wxMediaPlayerNotebookPage::wxMediaPlayerNotebookPage(wxMediaPlayerFrame* parentF
     //
     wxFlexGridSizer* sizer = new wxFlexGridSizer(2, 1, 0, 0);
     this->SetSizer(sizer);
-    this->SetAutoLayout(true);
     sizer->AddGrowableRow(0);
     sizer->AddGrowableCol(0);
 
diff --git a/samples/notebook/notebook.cpp b/samples/notebook/notebook.cpp
index 62dcd75b0a..14f3fd951c 100644
--- a/samples/notebook/notebook.cpp
+++ b/samples/notebook/notebook.cpp
@@ -332,7 +332,6 @@ MyFrame::MyFrame()
 
     m_panel->SetSizer(m_sizerFrame);
 
-    m_sizerFrame->Fit(this);
     m_sizerFrame->SetSizeHints(this);
 
     Centre(wxBOTH);
diff --git a/samples/popup/popup.cpp b/samples/popup/popup.cpp
index 6ea7c912db..8a3bcf268c 100644
--- a/samples/popup/popup.cpp
+++ b/samples/popup/popup.cpp
@@ -142,7 +142,6 @@ SimpleTransientPopup::SimpleTransientPopup( wxWindow *parent )
     topSizer->Add( m_spinCtrl, 0, wxALL, 5 );
     topSizer->Add( m_mouseText, 0, wxCENTRE|wxALL, 5 );
 
-    m_panel->SetAutoLayout( true );
     m_panel->SetSizer( topSizer );
     topSizer->Fit(m_panel);
     topSizer->Fit(this);
@@ -365,7 +364,6 @@ MyFrame::MyFrame(const wxString& title)
     topSizer->Add( button2, 0, wxALL, 5 );
     topSizer->Add( m_logWin, 1, wxEXPAND|wxALL, 5 );
 
-    panel->SetAutoLayout( true );
     panel->SetSizer( topSizer );
 
 }
@@ -452,9 +450,7 @@ MyDialog::MyDialog(const wxString& title)
     topSizer->AddSpacer(40);
     topSizer->Add( okButton, 0, wxALL, 5 );
 
-    panel->SetAutoLayout( true );
-    panel->SetSizer( topSizer );
-    topSizer->Fit(this);
+    panel->SetSizerAndFit( topSizer );
 }
 
 void MyDialog::OnStartSimplePopup(wxCommandEvent& event)
diff --git a/samples/scrollsub/scrollsub.cpp b/samples/scrollsub/scrollsub.cpp
index e26edd550f..0799ec5aa6 100644
--- a/samples/scrollsub/scrollsub.cpp
+++ b/samples/scrollsub/scrollsub.cpp
@@ -174,7 +174,6 @@ MyScrolledWindow::MyScrolledWindow( wxWindow *parent, wxWindowID id,
 
     mainsizer->Add( middlesizer, 1, wxEXPAND );
 
-    SetAutoLayout( true );
     SetSizer( mainsizer );
 }
 
@@ -421,7 +420,6 @@ MyFrame::MyFrame()
     topsizer->Add( m_log, 0, wxEXPAND );
 #endif // wxUSE_LOG
 
-    SetAutoLayout( true );
     SetSizer( topsizer );
 }
 
diff --git a/samples/statbar/statbar.cpp b/samples/statbar/statbar.cpp
index 8915cd4c40..91cf5c9c90 100644
--- a/samples/statbar/statbar.cpp
+++ b/samples/statbar/statbar.cpp
@@ -576,10 +576,7 @@ MyAboutDialog::MyAboutDialog(wxWindow *parent)
     sizerTop->Add(-1, 10, 1, wxGROW);
     sizerTop->Add(statbarBottom, 0, wxGROW);
 
-    SetSizer(sizerTop);
-
-    sizerTop->Fit(this);
-    sizerTop->SetSizeHints(this);
+    SetSizerAndFit(sizerTop);
 }
 
 // ----------------------------------------------------------------------------
diff --git a/samples/text/text.cpp b/samples/text/text.cpp
index e33d90679f..40a25e533f 100644
--- a/samples/text/text.cpp
+++ b/samples/text/text.cpp
@@ -1145,7 +1145,6 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
     topSizer->Add( m_log, 1, wxALL | wxEXPAND, 10 );
 #endif
 
-    SetAutoLayout( true );
     SetSizer(topSizer);
 }
 
diff --git a/samples/widgets/widgets.cpp b/samples/widgets/widgets.cpp
index 1e06e50c3b..1637eb113b 100644
--- a/samples/widgets/widgets.cpp
+++ b/samples/widgets/widgets.cpp
@@ -448,7 +448,6 @@ WidgetsFrame::WidgetsFrame(const wxString& title)
 
     m_panel->SetSizer(sizerTop);
 
-    sizerTop->Fit(this);
     sizerTop->SetSizeHints(this);
 
 #if USE_LOG && !defined(__WXCOCOA__)
diff --git a/samples/wizard/wizard.cpp b/samples/wizard/wizard.cpp
index efb436c0d8..d253471f7d 100644
--- a/samples/wizard/wizard.cpp
+++ b/samples/wizard/wizard.cpp
@@ -146,8 +146,7 @@ public:
             wxALL,
             5 // Border
         );
-        SetSizer(mainSizer);
-        mainSizer->Fit(this);
+        SetSizerAndFit(mainSizer);
     }
 
     virtual bool TransferDataFromWindow()
@@ -204,8 +203,7 @@ public:
             5 // Border
         );
 
-        SetSizer(mainSizer);
-        mainSizer->Fit(this);
+        SetSizerAndFit(mainSizer);
     }
 
     // wizard event handlers
@@ -314,8 +312,7 @@ public:
         wxTextCtrl* textCtrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, textSize, wxTE_MULTILINE);
         mainSizer->Add(textCtrl, 0, wxALL|wxEXPAND, 5);
 
-        SetSizer(mainSizer);
-        mainSizer->Fit(this);
+        SetSizerAndFit(mainSizer);
     }
 
     // implement wxWizardPage functions
-- 
2.47.2