]> git.saurik.com Git - wxWidgets.git/commitdiff
cleanup a bit the wxSplashScreen code; don't Yield() on wxGTK as it's not needed...
authorFrancesco Montorsi <f18m_cpp217828@yahoo.it>
Mon, 26 Jan 2009 22:40:13 +0000 (22:40 +0000)
committerFrancesco Montorsi <f18m_cpp217828@yahoo.it>
Mon, 26 Jan 2009 22:40:13 +0000 (22:40 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58439 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/splash/splash.cpp
src/generic/splash.cpp

index 644caf2d765154d7e5929cc5593427f0686d24c0..3b9af61fd46bb74cbe03544d697637117bbcd884 100644 (file)
@@ -147,7 +147,11 @@ bool MyApp::OnInit()
             6000, frame, wxID_ANY, wxDefaultPosition, wxDefaultSize,
             wxSIMPLE_BORDER|wxSTAY_ON_TOP);
     }
+
+#if !defined(__WXGTK20__)
+    // we don't need it at least on wxGTK with GTK+ 2.12.9
     wxYield();
+#endif
 
     // and show it (the frames, unlike simple controls, are not shown when
     // created initially)
@@ -220,14 +224,17 @@ void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
     if (ok)
     {
         wxImage image = bitmap.ConvertToImage();
+
         // do not scale on already small screens
         if (!m_isPda)
             image.Rescale( bitmap.GetWidth()/2, bitmap.GetHeight()/2 );
+
         bitmap = wxBitmap(image);
         wxSplashScreen *splash = new wxSplashScreen(bitmap,
             wxSPLASH_CENTRE_ON_PARENT | wxSPLASH_NO_TIMEOUT,
             0, this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
             wxSIMPLE_BORDER|wxSTAY_ON_TOP);
+
         wxWindow *win = splash->GetSplashWindow();
 #if wxUSE_MEDIACTRL
         wxMediaCtrl *media = new wxMediaCtrl( win, wxID_EXIT, _T("press.mpg"), wxPoint(2,2));
@@ -235,7 +242,7 @@ void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
 #else
         wxStaticText *text = new wxStaticText( win,
                                                wxID_EXIT,
-                                               _T("click somewhere\non image"),
+                                               _T("click somewhere\non this image"),
                                                wxPoint(m_isPda ? 0 : 13,
                                                        m_isPda ? 0 : 11)
                                              );
index 3fded78761c6de9d4ed3d6569b1a301b940b64dd..a88a79d17f2ee623c8c869bdcd09e6eb05069fb8 100644 (file)
     #include "wx/dcclient.h"
 #endif
 
-/*
- * wxSplashScreen
- */
 
-#define wxSPLASH_TIMER_ID 9999
+// ----------------------------------------------------------------------------
+// wxSplashScreen
+// ----------------------------------------------------------------------------
 
-IMPLEMENT_DYNAMIC_CLASS(wxSplashScreen, wxFrame)
+#define wxSPLASH_TIMER_ID       9999
 
+IMPLEMENT_DYNAMIC_CLASS(wxSplashScreen, wxFrame)
 BEGIN_EVENT_TABLE(wxSplashScreen, wxFrame)
     EVT_TIMER(wxSPLASH_TIMER_ID, wxSplashScreen::OnNotify)
     EVT_CLOSE(wxSplashScreen::OnCloseWindow)
@@ -47,8 +47,10 @@ END_EVENT_TABLE()
  * slightly too small.
  */
 
-wxSplashScreen::wxSplashScreen(const wxBitmap& bitmap, long splashStyle, int milliseconds, wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style):
-    wxFrame(parent, id, wxEmptyString, wxPoint(0,0), wxSize(100, 100), style)
+wxSplashScreen::wxSplashScreen(const wxBitmap& bitmap, long splashStyle, int milliseconds,
+                               wxWindow* parent, wxWindowID id, const wxPoint& pos,
+                               const wxSize& size, long style)
+    : wxFrame(parent, id, wxEmptyString, wxPoint(0,0), wxSize(100, 100), style)
 {
     // At least for GTK+ 2.0, this hint is not available.
 #if defined(__WXGTK20__)
@@ -81,6 +83,8 @@ wxSplashScreen::wxSplashScreen(const wxBitmap& bitmap, long splashStyle, int mil
     m_window->SetFocus();
 #if defined( __WXMSW__ ) || defined(__WXMAC__)
     Update(); // Without this, you see a blank screen for an instant
+#elif defined(__WXGTK20__)
+    // we don't need to do anything at least on wxGTK with GTK+ 2.12.9
 #else
     wxYieldIfNeeded(); // Should eliminate this
 #endif
@@ -102,9 +106,9 @@ void wxSplashScreen::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
     this->Destroy();
 }
 
-/*
- * wxSplashScreenWindow
- */
+// ----------------------------------------------------------------------------
+// wxSplashScreenWindow
+// ----------------------------------------------------------------------------
 
 BEGIN_EVENT_TABLE(wxSplashScreenWindow, wxWindow)
 #ifdef __WXGTK__
@@ -115,8 +119,10 @@ BEGIN_EVENT_TABLE(wxSplashScreenWindow, wxWindow)
     EVT_MOUSE_EVENTS(wxSplashScreenWindow::OnMouseEvent)
 END_EVENT_TABLE()
 
-wxSplashScreenWindow::wxSplashScreenWindow(const wxBitmap& bitmap, wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style):
-    wxWindow(parent, id, pos, size, style)
+wxSplashScreenWindow::wxSplashScreenWindow(const wxBitmap& bitmap, wxWindow* parent,
+                                           wxWindowID id, const wxPoint& pos,
+                                           const wxSize& size, long style)
+    : wxWindow(parent, id, pos, size, style)
 {
     m_bitmap = bitmap;
 
@@ -128,7 +134,6 @@ wxSplashScreenWindow::wxSplashScreenWindow(const wxBitmap& bitmap, wxWindow* par
         SetPalette(* bitmap.GetPalette());
     }
 #endif
-
 }
 
 // VZ: why don't we do it under wxGTK?
@@ -170,20 +175,15 @@ void wxSplashScreenWindow::OnPaint(wxPaintEvent& WXUNUSED(event))
 
 void wxSplashScreenWindow::OnEraseBackground(wxEraseEvent& event)
 {
-    if (event.GetDC())
+    if (event.GetDC() && m_bitmap.Ok())
     {
-        if (m_bitmap.Ok())
-        {
-            wxDrawSplashBitmap(* event.GetDC(), m_bitmap, 0, 0);
-        }
+        wxDrawSplashBitmap(* event.GetDC(), m_bitmap, 0, 0);
     }
     else
     {
         wxClientDC dc(this);
         if (m_bitmap.Ok())
-        {
             wxDrawSplashBitmap(dc, m_bitmap, 0, 0);
-        }
     }
 }
 
@@ -191,6 +191,8 @@ void wxSplashScreenWindow::OnMouseEvent(wxMouseEvent& event)
 {
     if (event.LeftDown() || event.RightDown())
         GetParent()->Close(true);
+    else
+        event.Skip();
 }
 
 void wxSplashScreenWindow::OnChar(wxKeyEvent& WXUNUSED(event))