Fixed helpview sample and app in binary compatible way by only exiting
on idle (would exit prematurely since help frame doesn't prevent app exit when still open) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@44610 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -43,20 +43,34 @@ class MyApp : public wxApp
|
|||||||
virtual bool OnInit();
|
virtual bool OnInit();
|
||||||
virtual int OnExit();
|
virtual int OnExit();
|
||||||
|
|
||||||
|
/// Respond to idle event
|
||||||
|
void OnIdle(wxIdleEvent& event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool m_exitIfNoMainWindow;
|
||||||
wxHtmlHelpController * help;
|
wxHtmlHelpController * help;
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
IMPLEMENT_APP(MyApp)
|
IMPLEMENT_APP(MyApp)
|
||||||
|
|
||||||
|
BEGIN_EVENT_TABLE(MyApp, wxApp)
|
||||||
|
EVT_IDLE(MyApp::OnIdle)
|
||||||
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
bool MyApp::OnInit()
|
bool MyApp::OnInit()
|
||||||
{
|
{
|
||||||
|
m_exitIfNoMainWindow = false;
|
||||||
#ifdef __WXMOTIF__
|
#ifdef __WXMOTIF__
|
||||||
delete wxLog::SetActiveTarget(new wxLogStderr); // So dialog boxes aren't used
|
delete wxLog::SetActiveTarget(new wxLogStderr); // So dialog boxes aren't used
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Don't exit on frame deletion, since the help window is programmed
|
||||||
|
// to cause the app to exit even if it is still open. We need to have the app
|
||||||
|
// close by other means.
|
||||||
|
SetExitOnFrameDelete(false);
|
||||||
|
|
||||||
wxInitAllImageHandlers();
|
wxInitAllImageHandlers();
|
||||||
wxFileSystem::AddHandler(new wxZipFSHandler);
|
wxFileSystem::AddHandler(new wxZipFSHandler);
|
||||||
|
|
||||||
@@ -80,10 +94,17 @@ bool MyApp::OnInit()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
help -> DisplayContents();
|
help -> DisplayContents();
|
||||||
|
SetTopWindow(help->GetFrame());
|
||||||
|
m_exitIfNoMainWindow = true;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MyApp::OnIdle(wxIdleEvent& event)
|
||||||
|
{
|
||||||
|
if (m_exitIfNoMainWindow && !GetTopWindow())
|
||||||
|
ExitMainLoop();
|
||||||
|
}
|
||||||
|
|
||||||
int MyApp::OnExit()
|
int MyApp::OnExit()
|
||||||
{
|
{
|
||||||
|
@@ -42,11 +42,16 @@ protected:
|
|||||||
|
|
||||||
IMPLEMENT_APP(hvApp)
|
IMPLEMENT_APP(hvApp)
|
||||||
|
|
||||||
|
BEGIN_EVENT_TABLE(hvApp, wxApp)
|
||||||
|
EVT_IDLE(hvApp::OnIdle)
|
||||||
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
hvApp::hvApp()
|
hvApp::hvApp()
|
||||||
{
|
{
|
||||||
#if wxUSE_IPC
|
#if wxUSE_IPC
|
||||||
m_server = NULL;
|
m_server = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
m_exitIfNoMainWindow = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hvApp::OnInit()
|
bool hvApp::OnInit()
|
||||||
@@ -55,6 +60,11 @@ bool hvApp::OnInit()
|
|||||||
delete wxLog::SetActiveTarget(new wxLogStderr); // So dialog boxes aren't used
|
delete wxLog::SetActiveTarget(new wxLogStderr); // So dialog boxes aren't used
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Don't exit on frame deletion, since the help window is programmed
|
||||||
|
// to cause the app to exit even if it is still open. We need to have the app
|
||||||
|
// close by other means.
|
||||||
|
SetExitOnFrameDelete(false);
|
||||||
|
|
||||||
wxArtProvider::Push(new AlternateArtProvider);
|
wxArtProvider::Push(new AlternateArtProvider);
|
||||||
|
|
||||||
#ifdef __WXMAC__
|
#ifdef __WXMAC__
|
||||||
@@ -218,10 +228,17 @@ bool hvApp::OnInit()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_helpController->DisplayContents();
|
m_helpController->DisplayContents();
|
||||||
|
SetTopWindow(m_helpController->GetFrame());
|
||||||
|
m_exitIfNoMainWindow = true;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void hvApp::OnIdle(wxIdleEvent& event)
|
||||||
|
{
|
||||||
|
if (m_exitIfNoMainWindow && !GetTopWindow())
|
||||||
|
ExitMainLoop();
|
||||||
|
}
|
||||||
|
|
||||||
int hvApp::OnExit()
|
int hvApp::OnExit()
|
||||||
{
|
{
|
||||||
|
@@ -50,14 +50,19 @@ public:
|
|||||||
wxList& GetConnections() { return m_connections; }
|
wxList& GetConnections() { return m_connections; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/// Respond to idle event
|
||||||
|
void OnIdle(wxIdleEvent& event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxHtmlHelpController* m_helpController;
|
wxHtmlHelpController* m_helpController;
|
||||||
|
bool m_exitIfNoMainWindow;
|
||||||
|
|
||||||
#if wxUSE_IPC
|
#if wxUSE_IPC
|
||||||
wxList m_connections;
|
wxList m_connections;
|
||||||
hvServer* m_server;
|
hvServer* m_server;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
#if wxUSE_IPC
|
#if wxUSE_IPC
|
||||||
|
Reference in New Issue
Block a user