cleanup a bit the wxSplashScreen code; don't Yield() on wxGTK as it's not needed at all (at least with GTK+ 2.12.9

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58439 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Francesco Montorsi 2009-01-26 22:40:13 +00:00
parent 7fee9773c6
commit aac39d1d43
2 changed files with 30 additions and 21 deletions

View 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)
);

View File

@ -29,14 +29,14 @@
#include "wx/dcclient.h"
#endif
/*
* wxSplashScreen
*/
#define wxSPLASH_TIMER_ID 9999
// ----------------------------------------------------------------------------
// wxSplashScreen
// ----------------------------------------------------------------------------
#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))