Update of /cvsroot/sharedaemon/ui-wx/src
In directory sc8-pr-cvs1:/tmp/cvs-serv31517
Modified Files:
MainDlg.cpp wxInterface.cpp wxInterface.h
Log Message:
Fixes wierd splashscreen behaviour if menubar/prefs are accessed before it disappears.
Index: MainDlg.cpp
===================================================================
RCS file: /cvsroot/sharedaemon/ui-wx/src/MainDlg.cpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- MainDlg.cpp 7 Dec 2003 21:59:58 -0000 1.22
+++ MainDlg.cpp 8 Dec 2003 01:08:10 -0000 1.23
@@ -671,11 +671,18 @@
/**
* Since EVT_TOOL and EVT_MENU are synonyms, we can't use event table to
* call the right functions for toolbar or menubar events. Instead, we use
- * this helper function to call them both. Both methods then check if the
- * event belongs to them, and abort if not, resulting the event being
- * passed to other one.
+ * this helper function to call them both and then update both as neccesery.
*/
void CMainDlg::MenuOrToolEvent(wxCommandEvent &event) {
+ /**
+ * If we still have active splash at this point, destroy it to avoid
+ * wierd behaviour.
+ */
+ if (wxGetApp().splash_active) {
+ delete wxGetApp().splash;
+ wxGetApp().splash_active = false;
+ }
+
if (event.GetEventType() == wxEVT_COMMAND_TOOL_CLICKED) {
ToolEvent(event);
MenuEvent(event);
Index: wxInterface.cpp
===================================================================
RCS file: /cvsroot/sharedaemon/ui-wx/src/wxInterface.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- wxInterface.cpp 30 Nov 2003 18:56:45 -0000 1.8
+++ wxInterface.cpp 8 Dec 2003 01:08:10 -0000 1.9
@@ -61,16 +61,18 @@
m_config->Read(wxT("/General/Show splashscreen"), &show_splash);
/* Display the splashscreen if allowed */
+ splash_active = false;
if (show_splash) {
- splash = new wxSplashScreen(
- img->GetImage(wxT("splashscreen")),
- wxSPLASH_CENTRE_ON_SCREEN|wxSPLASH_TIMEOUT,
+ splash = new CSplash(
+ img->GetImage(wxT("splashscreen")),
+ wxSPLASH_CENTRE_ON_SCREEN|wxSPLASH_TIMEOUT,
2000, NULL, -1
);
+ splash_active = true;
} // No need to delete splash - it will be deleted by wx
Localize();
-
+
/* Display the main dialog */
mainframe = new CMainDlg(
NULL, -1, APPVER_LONG, wxDefaultPosition,
@@ -269,4 +271,31 @@
} else {
return wxLANGUAGE_DEFAULT;
}
+}
+
+/***
+ * Splashscreen class
+ ***/
+/* Event table */
+BEGIN_EVENT_TABLE(CSplash, wxSplashScreen)
+ EVT_CLOSE(CSplash::OnCloseWindow)
+END_EVENT_TABLE()
+
+/* Constructor */
+CSplash::CSplash(
+ const wxBitmap &bitmap, long splashStyle, int milliseconds,
+ wxWindow *parent, wxWindowID id, const wxPoint &pos,
+ const wxSize &size, long style
+) : wxSplashScreen(
+ bitmap, splashStyle, milliseconds, parent, id, pos, size, style
+) {
+}
+
+/**
+ * Close splash window event handler. Set wxInterface splash_active variable
+ * to false.
+ */
+void CSplash::OnCloseWindow(wxCloseEvent &event) {
+ wxGetApp().splash_active = false;
+ event.Skip();
}
Index: wxInterface.h
===================================================================
RCS file: /cvsroot/sharedaemon/ui-wx/src/wxInterface.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- wxInterface.h 20 Nov 2003 01:27:26 -0000 1.1
+++ wxInterface.h 8 Dec 2003 01:08:10 -0000 1.2
@@ -34,22 +34,40 @@
#include "wxInterface.h"
#include "defines.h"
-/*
- * Base class for wxInterface. Everything else starts from here.
- */
+DECLARE_APP(wxInterface)
+
+/* Splashscreen class - only needed for OnCloseWindow event handling */
+class CSplash: public wxSplashScreen {
+public:
+ CSplash(
+ const wxBitmap &bitmap, long splashStyle, int milliseconds,
+ wxWindow *parent, wxWindowID id,
+ const wxPoint &pos = wxDefaultPosition,
+ const wxSize &size = wxDefaultSize,
+ long style = wxSIMPLE_BORDER|wxFRAME_NO_TASKBAR|wxSTAY_ON_TOP
+ );
+private:
+ DECLARE_EVENT_TABLE()
+ void OnCloseWindow(wxCloseEvent &event);
+};
+
+/* Base class for wxInterface. Everything else starts from here. */
class wxInterface: public wxApp {
public:
- virtual bool OnInit();
- virtual int OnExit();
+ virtual bool OnInit(); // Application initialization
+ virtual int OnExit(); // Application shutdown
+ CSplash *splash; // Pointer to splash screen
+ bool splash_active; // For detecting if splash is active
protected:
wxLocale m_locale;
private:
- wxSplashScreen *splash;
void Localize();
void CheckAndAddSupportedLangs();
void CheckAndAddSupportedIconSets();
int GetLangType(const wxString lang);
+ void OnCloseSplash(wxCloseEvent &event);
};
+
#endif
|