From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Sun, 2 Jan 2011 22:05:14 +0000 (+0000)
Subject: Remove calls to wxApp::SetTopWindow() from the samples and documentation.
X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/18f42b94df62068a19258b96ac7f569d4d3ba400

Remove calls to wxApp::SetTopWindow() from the samples and documentation.

It is definitely not necessary to call SetTopWindow() when there is only a
single top level window and it is arguable whether it's useful to do it even
when there are many of them so don't encourage its use in the documentation
and also remove all its occurrences from the samples.

Closes #12816.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66528 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---

diff --git a/demos/life/life.cpp b/demos/life/life.cpp
index 0402bd9944..8366b49890 100644
--- a/demos/life/life.cpp
+++ b/demos/life/life.cpp
@@ -163,9 +163,8 @@ bool LifeApp::OnInit()
     // create the main application window
     LifeFrame *frame = new LifeFrame();
 
-    // show it and tell the application that it's our main window
+    // show it
     frame->Show(true);
-    SetTopWindow(frame);
 
     // just for Motif
 #ifdef __WXMOTIF__
diff --git a/docs/doxygen/overviews/app.h b/docs/doxygen/overviews/app.h
index 8217e20dde..261aa5efbf 100644
--- a/docs/doxygen/overviews/app.h
+++ b/docs/doxygen/overviews/app.h
@@ -27,8 +27,7 @@ the wxApp::OnInit member defined for a class derived from wxApp.
 @e OnInit will usually create a top window as a bare minimum. Unlike in earlier
 versions of wxWidgets, OnInit does not return a frame. Instead it returns a
 boolean value which indicates whether processing should continue (@true) or not
-(@false). You call wxApp::SetTopWindow to let wxWidgets know about the top
-window.
+(@false).
 
 Note that the program's command line arguments, represented by @e argc and
 @e argv, are available from within wxApp member functions.
@@ -59,7 +58,6 @@ bool DerivedApp::OnInit()
     wxFrame *the_frame = new wxFrame(NULL, ID_MYFRAME, argv[0]);
     ...
     the_frame->Show(true);
-    SetTopWindow(the_frame);
 
     return true;
 }
diff --git a/docs/doxygen/overviews/helloworld.h b/docs/doxygen/overviews/helloworld.h
index 913f76e826..fe1743958c 100644
--- a/docs/doxygen/overviews/helloworld.h
+++ b/docs/doxygen/overviews/helloworld.h
@@ -124,7 +124,6 @@ bool MyApp::OnInit()
 {
     MyFrame *frame = new MyFrame( "Hello World", wxPoint(50,50), wxSize(450,340) );
     frame->Show( true );
-    SetTopWindow( frame );
     return true;
 }
 @endcode
diff --git a/docs/doxygen/overviews/python.h b/docs/doxygen/overviews/python.h
index 0517b04dcb..04dde37b1d 100644
--- a/docs/doxygen/overviews/python.h
+++ b/docs/doxygen/overviews/python.h
@@ -206,8 +206,6 @@ python DialogUnits.py
 62:         frame = MyFrame(NULL, -1, "This is a test")
 63:         frame.Show(true)
 64:
-65:         # Tell wxWidgets that this is our main window
-66:         self.SetTopWindow(frame)
 67:
 68:         # Return a success flag
 69:         return true
@@ -257,8 +255,7 @@ Destroy() method as shown on line 36.
 
 Just like wxWidgets in C++, wxPython apps need to create a class derived from
 @c wxApp (line 56) that implements a method named @c OnInit, (line 59.) This
-method should create the application's main window (line 62) and use
-wxApp.SetTopWindow() (line 66) to inform wxWidgets about it.
+method should create the application's main window (line 62) and show it.
 
 And finally, at line 72 an instance of the application class is created. At
 this point wxPython finishes initializing itself, and calls the @c OnInit
diff --git a/samples/animate/anitest.cpp b/samples/animate/anitest.cpp
index 13d00db097..413558002f 100644
--- a/samples/animate/anitest.cpp
+++ b/samples/animate/anitest.cpp
@@ -102,8 +102,6 @@ bool MyApp::OnInit()
                                  wxDEFAULT_FRAME_STYLE);
     frame->Show(true);
 
-    SetTopWindow(frame);
-
     return true;
 }
 
diff --git a/samples/aui/auidemo.cpp b/samples/aui/auidemo.cpp
index faea051a5c..33dbaac0ca 100644
--- a/samples/aui/auidemo.cpp
+++ b/samples/aui/auidemo.cpp
@@ -570,7 +570,6 @@ bool MyApp::OnInit()
                                  wxT("wxAUI Sample Application"),
                                  wxDefaultPosition,
                                  wxSize(800, 600));
-    SetTopWindow(frame);
     frame->Show();
 
     return true;
diff --git a/samples/config/conftest.cpp b/samples/config/conftest.cpp
index c30baf4271..a9c56761ab 100644
--- a/samples/config/conftest.cpp
+++ b/samples/config/conftest.cpp
@@ -119,7 +119,6 @@ bool MyApp::OnInit()
     // create the main program window
     MyFrame *frame = new MyFrame;
     frame->Show(true);
-    SetTopWindow(frame);
 
     // use our config object...
     if ( pConfig->Read(wxT("/Controls/Check"), 1l) != 0 ) {
diff --git a/samples/dataview/dataview.cpp b/samples/dataview/dataview.cpp
index baf7166263..ed3d828173 100644
--- a/samples/dataview/dataview.cpp
+++ b/samples/dataview/dataview.cpp
@@ -242,7 +242,6 @@ bool MyApp::OnInit()
 
     MyFrame *frame =
         new MyFrame(NULL, "wxDataViewCtrl sample", 40, 40, 1000, 540);
-    SetTopWindow(frame);
 
     frame->Show(true);
     return true;
diff --git a/samples/dialup/nettest.cpp b/samples/dialup/nettest.cpp
index 8e68d35171..e317e100ac 100644
--- a/samples/dialup/nettest.cpp
+++ b/samples/dialup/nettest.cpp
@@ -161,9 +161,8 @@ bool MyApp::OnInit()
     MyFrame *frame = new MyFrame(wxT("Dial-up wxWidgets demo"),
                                  wxPoint(50, 50), wxSize(450, 340));
 
-    // Show it and tell the application that it's our main window
+    // Show it
     frame->Show(true);
-    SetTopWindow(frame);
 
     // Init dial up manager
     m_dial = wxDialUpManager::Create();
diff --git a/samples/docview/docview.cpp b/samples/docview/docview.cpp
index e954421608..57eeef7c52 100644
--- a/samples/docview/docview.cpp
+++ b/samples/docview/docview.cpp
@@ -231,7 +231,6 @@ bool MyApp::OnInit()
     frame->Centre();
     frame->Show();
 
-    SetTopWindow(frame);
     return true;
 }
 
diff --git a/samples/drawing/drawing.cpp b/samples/drawing/drawing.cpp
index d48e299dab..ce823f9821 100644
--- a/samples/drawing/drawing.cpp
+++ b/samples/drawing/drawing.cpp
@@ -347,9 +347,8 @@ bool MyApp::OnInit()
     MyFrame *frame = new MyFrame(wxT("Drawing sample"),
                                  wxDefaultPosition, wxSize(550, 840));
 
-    // Show it and tell the application that it's our main window
+    // Show it
     frame->Show(true);
-    SetTopWindow(frame);
 
     if ( !LoadImages() )
     {
diff --git a/samples/exec/exec.cpp b/samples/exec/exec.cpp
index 4f72a17958..6fe2ff9dd5 100644
--- a/samples/exec/exec.cpp
+++ b/samples/exec/exec.cpp
@@ -413,9 +413,8 @@ bool MyApp::OnInit()
     MyFrame *frame = new MyFrame(wxT("Exec wxWidgets sample"),
                                  wxDefaultPosition, wxSize(500, 140));
 
-    // Show it and tell the application that it's our main window
+    // Show it
     frame->Show(true);
-    SetTopWindow(frame);
 
     // success: wxApp::OnRun() will be called which will enter the main message
     // loop and the application will run. If we returned false here, the
diff --git a/samples/font/font.cpp b/samples/font/font.cpp
index 8dc2e42d2c..0bd4df1c5b 100644
--- a/samples/font/font.cpp
+++ b/samples/font/font.cpp
@@ -282,9 +282,8 @@ bool MyApp::OnInit()
     MyFrame *frame = new MyFrame(wxT("Font wxWidgets demo"),
                                  wxPoint(50, 50), wxSize(600, 400));
 
-    // Show it and tell the application that it's our main window
+    // Show it
     frame->Show(true);
-    SetTopWindow(frame);
 
     // success: wxApp::OnRun() will be called which will enter the main message
     // loop and the application will run. If we returned 'false' here, the
diff --git a/samples/help/demo.cpp b/samples/help/demo.cpp
index 8cc959c746..9ba0461c4b 100644
--- a/samples/help/demo.cpp
+++ b/samples/help/demo.cpp
@@ -324,7 +324,6 @@ bool MyApp::OnInit()
 #endif // !USE_SIMPLE_HELP_PROVIDER
 
     frame->Show(true);
-    SetTopWindow(frame);
 
     // initialise the help system: this means that we'll use doc.hlp file under
     // Windows and that the HTML docs are in the subdirectory doc for platforms
diff --git a/samples/html/help/help.cpp b/samples/html/help/help.cpp
index c1c2954466..490fdbef11 100644
--- a/samples/html/help/help.cpp
+++ b/samples/html/help/help.cpp
@@ -127,11 +127,8 @@ bool MyApp::OnInit()
     MyFrame *frame = new MyFrame(_("HTML Help Sample"),
         wxDefaultPosition, wxDefaultSize);
 
-    // Show it and tell the application that it's our main window
-    // @@@ what does it do exactly, in fact? is it necessary here?
+    // Show it
     frame->Show(true);
-    SetTopWindow(frame);
-
 
     // success: wxApp::OnRun() will be called which will enter the main message
     // loop and the application will run. If we returned false here, the
diff --git a/samples/html/printing/printing.cpp b/samples/html/printing/printing.cpp
index c6390fc413..3fea8d49eb 100644
--- a/samples/html/printing/printing.cpp
+++ b/samples/html/printing/printing.cpp
@@ -152,11 +152,8 @@ bool MyApp::OnInit()
     MyFrame *frame = new MyFrame(_("Printing test"),
         wxDefaultPosition, wxSize(640, 480));
 
-    // Show it and tell the application that it's our main window
-    // @@@ what does it do exactly, in fact? is it necessary here?
+    // Show it
     frame->Show(true);
-    SetTopWindow(frame);
-
 
     // success: wxApp::OnRun() will be called which will enter the main message
     // loop and the application will run. If we returned false here, the
diff --git a/samples/html/virtual/virtual.cpp b/samples/html/virtual/virtual.cpp
index 58310342a6..c22ce0ccfb 100644
--- a/samples/html/virtual/virtual.cpp
+++ b/samples/html/virtual/virtual.cpp
@@ -169,10 +169,9 @@ bool MyApp::OnInit()
     MyFrame *frame = new MyFrame(_("wxHtmlWindow testing application"),
         wxDefaultPosition, wxSize(640, 480));
 
-    // Show it and tell the application that it's our main window
-    // @@@ what does it do exactly, in fact? is it necessary here?
+    // Show it
     frame->Show(true);
-    SetTopWindow(frame);
+
     wxFileSystem::AddHandler(new MyVFS);
 
     // success: wxApp::OnRun() will be called which will enter the main message
diff --git a/samples/html/widget/widget.cpp b/samples/html/widget/widget.cpp
index c1449ce772..1a05c51ee8 100644
--- a/samples/html/widget/widget.cpp
+++ b/samples/html/widget/widget.cpp
@@ -162,10 +162,8 @@ bool MyApp::OnInit()
     MyFrame *frame = new MyFrame( _("wxHtmlWindow testing application"),
         wxDefaultPosition, wxSize(640, 480) );
 
-    // Show it and tell the application that it's our main window
-    // @@@ what does it do exactly, in fact? is it necessary here?
+    // Show it
     frame->Show(true);
-    SetTopWindow(frame);
 
     // success: wxApp::OnRun() will be called which will enter the main message
     // loop and the application will run. If we returned false here, the
diff --git a/samples/html/zip/zip.cpp b/samples/html/zip/zip.cpp
index 6363dfab85..accf15623f 100644
--- a/samples/html/zip/zip.cpp
+++ b/samples/html/zip/zip.cpp
@@ -123,10 +123,8 @@ bool MyApp::OnInit()
     MyFrame *frame = new MyFrame(_("wxHtmlWindow testing application"),
         wxDefaultPosition, wxSize(640, 480) );
 
-    // Show it and tell the application that it's our main window
-    // @@@ what does it do exactly, in fact? is it necessary here?
+    // Show it
     frame->Show(true);
-    SetTopWindow(frame);
 
     // success: wxApp::OnRun() will be called which will enter the main message
     // loop and the application will run. If we returned false here, the
diff --git a/samples/internat/internat.cpp b/samples/internat/internat.cpp
index 4ce95d0d13..b39fb8972c 100644
--- a/samples/internat/internat.cpp
+++ b/samples/internat/internat.cpp
@@ -271,7 +271,6 @@ bool MyApp::OnInit()
 
     // Show the frame
     frame->Show(true);
-    SetTopWindow(frame);
 
     return true;
 }
diff --git a/samples/joytest/joytest.cpp b/samples/joytest/joytest.cpp
index 0d25748342..729073fe04 100644
--- a/samples/joytest/joytest.cpp
+++ b/samples/joytest/joytest.cpp
@@ -89,8 +89,6 @@ bool MyApp::OnInit()
     frame->CenterOnScreen();
     frame->Show(true);
 
-    SetTopWindow(frame);
-
     return true;
 }
 
diff --git a/samples/listctrl/listtest.cpp b/samples/listctrl/listtest.cpp
index 4a08c29078..dc715e643b 100644
--- a/samples/listctrl/listtest.cpp
+++ b/samples/listctrl/listtest.cpp
@@ -100,8 +100,6 @@ bool MyApp::OnInit()
     // Show the frame
     frame->Show(true);
 
-    SetTopWindow(frame);
-
     return true;
 }
 
diff --git a/samples/menu/menu.cpp b/samples/menu/menu.cpp
index c4ce7f3673..a8ba08b034 100644
--- a/samples/menu/menu.cpp
+++ b/samples/menu/menu.cpp
@@ -365,8 +365,6 @@ bool MyApp::OnInit()
     frame->SetStatusText(wxT("Welcome to wxWidgets menu sample"));
 #endif // wxUSE_STATUSBAR
 
-    SetTopWindow(frame);
-
     return true;
 }
 
diff --git a/samples/nativdlg/nativdlg.cpp b/samples/nativdlg/nativdlg.cpp
index fa7c72140b..a3bb423cfd 100644
--- a/samples/nativdlg/nativdlg.cpp
+++ b/samples/nativdlg/nativdlg.cpp
@@ -67,9 +67,6 @@ bool MyApp::OnInit(void)
   frame->panel = new wxWindow(frame, wxID_ANY, wxPoint(0, 0), wxSize(400, 400), 0, wxT("MyMainFrame"));
   frame->Show(true);
 
-  // Return the main frame window
-  SetTopWindow(frame);
-
   return true;
 }
 
diff --git a/samples/notebook/notebook.cpp b/samples/notebook/notebook.cpp
index a0adb5ed61..5387775761 100644
--- a/samples/notebook/notebook.cpp
+++ b/samples/notebook/notebook.cpp
@@ -47,7 +47,6 @@ bool MyApp::OnInit()
 
     // Create the main window
     MyFrame *frame = new MyFrame();
-    SetTopWindow(frame);
 
     // Problem with generic wxNotebook implementation whereby it doesn't size
     // properly unless you set the size again
diff --git a/samples/oleauto/oleauto.cpp b/samples/oleauto/oleauto.cpp
index a9dd3cb48b..bf3b5ca1cf 100644
--- a/samples/oleauto/oleauto.cpp
+++ b/samples/oleauto/oleauto.cpp
@@ -132,10 +132,8 @@ bool MyApp::OnInit()
     MyFrame *frame = new MyFrame(wxT("OleAuto wxWidgets App"),
                                  wxPoint(50, 50), wxSize(450, 340));
 
-    // Show it and tell the application that it's our main window
-    // @@@ what does it do exactly, in fact? is it necessary here?
+    // Show it
     frame->Show(true);
-    SetTopWindow(frame);
 
     // success: wxApp::OnRun() will be called which will enter the main message
     // loop and the application will run. If we returned false here, the
diff --git a/samples/opengl/isosurf/isosurf.cpp b/samples/opengl/isosurf/isosurf.cpp
index 6b04b47168..a2ea654f91 100644
--- a/samples/opengl/isosurf/isosurf.cpp
+++ b/samples/opengl/isosurf/isosurf.cpp
@@ -57,7 +57,7 @@ bool MyApp::OnInit()
         return false;
 
     // Create the main frame window
-    SetTopWindow(new MyFrame(NULL, wxT("wxWidgets OpenGL Isosurf Sample")));
+    MyFrame *frame = new MyFrame(NULL, wxT("wxWidgets OpenGL Isosurf Sample"));
 
     return true;
 }
diff --git a/samples/ownerdrw/ownerdrw.cpp b/samples/ownerdrw/ownerdrw.cpp
index b15aa9d68c..80a7c2eb74 100644
--- a/samples/ownerdrw/ownerdrw.cpp
+++ b/samples/ownerdrw/ownerdrw.cpp
@@ -97,8 +97,6 @@ bool OwnerDrawnApp::OnInit(void)
         = new OwnerDrawnFrame(NULL, wxT("wxWidgets Ownerdraw Sample"),
                               50, 50, 450, 340);
 
-    SetTopWindow(pFrame);
-
     return true;
 }
 
diff --git a/samples/printing/printing.cpp b/samples/printing/printing.cpp
index 205caee637..bb4daffb35 100644
--- a/samples/printing/printing.cpp
+++ b/samples/printing/printing.cpp
@@ -123,8 +123,6 @@ bool MyApp::OnInit(void)
     frame->Centre(wxBOTH);
     frame->Show();
 
-    SetTopWindow(frame);
-
     return true;
 }
 
diff --git a/samples/regtest/regtest.cpp b/samples/regtest/regtest.cpp
index ac77e7bb81..64a96ef3ef 100644
--- a/samples/regtest/regtest.cpp
+++ b/samples/regtest/regtest.cpp
@@ -326,8 +326,6 @@ bool RegApp::OnInit()
     RegFrame *frame = new RegFrame(NULL, wxT("wxRegTest"), 50, 50, 600, 350);
     frame->Show(true);
 
-    SetTopWindow(frame);
-
     return true;
 }
 
diff --git a/samples/ribbon/ribbondemo.cpp b/samples/ribbon/ribbondemo.cpp
index e85a3217cb..976544ee40 100644
--- a/samples/ribbon/ribbondemo.cpp
+++ b/samples/ribbon/ribbondemo.cpp
@@ -139,7 +139,6 @@ bool MyApp::OnInit()
         return false;
 
     wxFrame* frame = new MyFrame;
-    SetTopWindow(frame);
     frame->Show();
 
     return true;
diff --git a/samples/sashtest/sashtest.cpp b/samples/sashtest/sashtest.cpp
index b42bac05ac..5ed6c61b88 100644
--- a/samples/sashtest/sashtest.cpp
+++ b/samples/sashtest/sashtest.cpp
@@ -79,8 +79,6 @@ bool MyApp::OnInit(void)
 
   frame->Show(true);
 
-  SetTopWindow(frame);
-
   return true;
 }
 
diff --git a/samples/sockets/client.cpp b/samples/sockets/client.cpp
index b45ccb3f09..7b67c98dd8 100644
--- a/samples/sockets/client.cpp
+++ b/samples/sockets/client.cpp
@@ -190,9 +190,8 @@ bool MyApp::OnInit()
   // Create the main application window
   MyFrame *frame = new MyFrame();
 
-  // Show it and tell the application that it's our main window
+  // Show it
   frame->Show(true);
-  SetTopWindow(frame);
 
   // success
   return true;
diff --git a/samples/sockets/server.cpp b/samples/sockets/server.cpp
index 4187191cee..a57137cbed 100644
--- a/samples/sockets/server.cpp
+++ b/samples/sockets/server.cpp
@@ -162,9 +162,8 @@ bool MyApp::OnInit()
   // Create the main application window
   MyFrame *frame = new MyFrame();
 
-  // Show it and tell the application that it's our main window
+  // Show it
   frame->Show(true);
-  SetTopWindow(frame);
 
   // Success
   return true;
diff --git a/samples/stc/stctest.cpp b/samples/stc/stctest.cpp
index 9b83838205..069008b544 100644
--- a/samples/stc/stctest.cpp
+++ b/samples/stc/stctest.cpp
@@ -226,7 +226,6 @@ bool App::OnInit () {
     // open application frame
     m_frame->Layout ();
     m_frame->Show (true);
-    SetTopWindow (m_frame);
 
     return true;
 }
diff --git a/samples/svg/svgtest.cpp b/samples/svg/svgtest.cpp
index 6f42626b66..159a15cf9c 100644
--- a/samples/svg/svgtest.cpp
+++ b/samples/svg/svgtest.cpp
@@ -160,8 +160,6 @@ bool MyApp::OnInit()
 
     frame->Show(true);
 
-    SetTopWindow(frame);
-
     return true;
 }
 
diff --git a/samples/text/text.cpp b/samples/text/text.cpp
index 8880c78808..3a2f94a910 100644
--- a/samples/text/text.cpp
+++ b/samples/text/text.cpp
@@ -545,8 +545,6 @@ bool MyApp::OnInit()
 
     frame->Show(true);
 
-    SetTopWindow(frame);
-
     // report success
     return true;
 }
diff --git a/samples/toolbar/toolbar.cpp b/samples/toolbar/toolbar.cpp
index e1fdb33f7a..180ac7ccd4 100644
--- a/samples/toolbar/toolbar.cpp
+++ b/samples/toolbar/toolbar.cpp
@@ -315,8 +315,6 @@ bool MyApp::OnInit()
 
     wxInitAllImageHandlers();
 
-    SetTopWindow(frame);
-
     return true;
 }
 
diff --git a/samples/treectrl/treetest.cpp b/samples/treectrl/treetest.cpp
index f22c467189..96a72c2940 100644
--- a/samples/treectrl/treetest.cpp
+++ b/samples/treectrl/treetest.cpp
@@ -198,7 +198,6 @@ bool MyApp::OnInit()
 
     // Show the frame
     frame->Show(true);
-    SetTopWindow(frame);
 
     return true;
 }
diff --git a/samples/typetest/typetest.cpp b/samples/typetest/typetest.cpp
index c5d6574ea4..61a6de06df 100644
--- a/samples/typetest/typetest.cpp
+++ b/samples/typetest/typetest.cpp
@@ -116,8 +116,6 @@ bool MyApp::OnInit()
     // Show the frame
     frame->Show(true);
 
-    SetTopWindow(frame);
-
     return true;
 }
 
diff --git a/samples/validate/validate.cpp b/samples/validate/validate.cpp
index 8b81a9f710..344f719d14 100644
--- a/samples/validate/validate.cpp
+++ b/samples/validate/validate.cpp
@@ -136,7 +136,7 @@ bool MyApp::OnInit()
     MyFrame *frame = new MyFrame((wxFrame *) NULL, wxT("Validator Test"),
                                  50, 50, 300, 250);
     frame->Show(true);
-    SetTopWindow(frame);
+
     return true;
 }