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