[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]
[XaraXtreme-commits] Commit Complete
Commit by : alex
Repository : xara
Revision : 1087
Date : Tue May 16 17:39:45 BST 2006
Changed paths:
M /Trunk/XaraLX/wxOil/camresource.cpp
M /Trunk/XaraLX/wxOil/camresource.h
M /Trunk/XaraLX/wxOil/xrc/startup-lx.png
M /Trunk/XaraLX/wxXtra/Makefile.am
A /Trunk/XaraLX/wxXtra/advsplash.cpp
A /Trunk/XaraLX/wxXtra/advsplash.h
M /Trunk/XaraLX/wxXtra/wxXtra.h
Fix splash screen
Diff:
Index: Trunk/XaraLX/wxXtra/wxXtra.h
===================================================================
--- Trunk/XaraLX/wxXtra/wxXtra.h (revision 1086)
+++ Trunk/XaraLX/wxXtra/wxXtra.h (revision 1087)
@@ -14,3 +14,4 @@
#include "combog.h"
#include "odcombo.h"
#include "platform.h"
+#include "advsplash.h"
Index: Trunk/XaraLX/wxXtra/advsplash.cpp
===================================================================
--- Trunk/XaraLX/wxXtra/advsplash.cpp (revision 0)
+++ Trunk/XaraLX/wxXtra/advsplash.cpp (revision 1087)
@@ -0,0 +1,191 @@
+// $Id: doublebuffer.cpp 757 2006-04-01 16:04:45Z alex $
+/* @@tag:xara-cn-tp@@ THIRD PARTY COPYRIGHT */
+// The following line makes normalize.pl skip type fixing
+/* SKIPFIXTYPES: START */
+
+// This file is derived from CVSHEAD wxWidgets and is thus
+// under the wxWidgets / wxWindows license.
+//
+// Derived from wxWidgets splash.cpp, by Julian Smart
+
+#include "advsplash.h"
+#include <wx/splash.h>
+
+#if defined(__WXGTK20__)
+#include <gtk/gtk.h>
+#endif
+
+/*
+ * wxAdvSplashScreen
+ */
+
+#define wxSPLASH_TIMER_ID 9999
+
+IMPLEMENT_DYNAMIC_CLASS(wxAdvSplashScreen, wxFrame);
+
+BEGIN_EVENT_TABLE(wxAdvSplashScreen, wxFrame)
+ EVT_TIMER(wxSPLASH_TIMER_ID, wxAdvSplashScreen::OnNotify)
+ EVT_CLOSE(wxAdvSplashScreen::OnCloseWindow)
+END_EVENT_TABLE()
+
+/* Note that unless we pass a non-default size to the frame, SetClientSize
+ * won't work properly under Windows, and the splash screen frame is sized
+ * slightly too small.
+ */
+
+wxAdvSplashScreen::wxAdvSplashScreen(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__)
+#if GTK_CHECK_VERSION(2,2,0)
+ gtk_window_set_type_hint(GTK_WINDOW(m_widget),
+ GDK_WINDOW_TYPE_HINT_SPLASHSCREEN);
+#endif
+#endif
+
+ m_window = NULL;
+ m_splashStyle = splashStyle;
+ m_milliseconds = milliseconds;
+
+ m_window = new wxAdvSplashScreenWindow(bitmap, this, wxID_ANY, pos, size, wxNO_BORDER);
+
+ SetClientSize(bitmap.GetWidth()+2, bitmap.GetHeight()+2);
+
+ if (m_splashStyle & wxSPLASH_CENTRE_ON_PARENT)
+ CentreOnParent();
+ else if (m_splashStyle & wxSPLASH_CENTRE_ON_SCREEN)
+ CentreOnScreen();
+
+ if (m_splashStyle & wxSPLASH_TIMEOUT)
+ {
+ m_timer.SetOwner(this, wxSPLASH_TIMER_ID);
+ m_timer.Start(milliseconds, true);
+ }
+
+ Show(true);
+ m_window->SetFocus();
+#if defined( __WXMSW__ ) || defined(__WXMAC__)
+ Update(); // Without this, you see a blank screen for an instant
+#else
+ wxYieldIfNeeded(); // Should eliminate this
+#endif
+}
+
+wxAdvSplashScreen::~wxAdvSplashScreen()
+{
+ m_timer.Stop();
+}
+
+void wxAdvSplashScreen::OnNotify(wxTimerEvent& WXUNUSED(event))
+{
+ Close(true);
+}
+
+void wxAdvSplashScreen::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
+{
+ m_timer.Stop();
+ this->Destroy();
+}
+
+/*
+ * wxAdvSplashScreenWindow
+ */
+
+BEGIN_EVENT_TABLE(wxAdvSplashScreenWindow, wxWindow)
+#ifdef __WXGTK__
+ EVT_PAINT(wxAdvSplashScreenWindow::OnPaint)
+#endif
+ EVT_ERASE_BACKGROUND(wxAdvSplashScreenWindow::OnEraseBackground)
+ EVT_CHAR(wxAdvSplashScreenWindow::OnChar)
+ EVT_MOUSE_EVENTS(wxAdvSplashScreenWindow::OnMouseEvent)
+END_EVENT_TABLE()
+
+wxAdvSplashScreenWindow::wxAdvSplashScreenWindow(const wxBitmap& bitmap, wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style):
+ wxWindow(parent, id, pos, size, style)
+{
+ m_bitmap = bitmap;
+
+#if !defined(__WXGTK__) && wxUSE_PALETTE
+ bool hiColour = (wxDisplayDepth() >= 16) ;
+
+ if (bitmap.GetPalette() && !hiColour)
+ {
+ SetPalette(* bitmap.GetPalette());
+ }
+#endif
+
+}
+
+// VZ: why don't we do it under wxGTK?
+#if !defined(__WXGTK__) && wxUSE_PALETTE
+ #define USE_PALETTE_IN_SPLASH
+#endif
+
+static void wxDrawSplashBitmap(wxDC& dc, const wxBitmap& bitmap, int WXUNUSED(x), int WXUNUSED(y))
+{
+#if 0
+ wxMemoryDC dcMem;
+
+#ifdef USE_PALETTE_IN_SPLASH
+ bool hiColour = (wxDisplayDepth() >= 16) ;
+
+ if (bitmap.GetPalette() && !hiColour)
+ {
+ dcMem.SetPalette(* bitmap.GetPalette());
+ }
+#endif // USE_PALETTE_IN_SPLASH
+
+ dcMem.SelectObject(bitmap);
+ dc.Blit(0, 0, bitmap.GetWidth(), bitmap.GetHeight(), & dcMem, 0, 0);
+ dcMem.SelectObject(wxNullBitmap);
+
+#ifdef USE_PALETTE_IN_SPLASH
+ if (bitmap.GetPalette() && !hiColour)
+ {
+ dcMem.SetPalette(wxNullPalette);
+ }
+#endif // USE_PALETTE_IN_SPLASH
+#endif
+
+ dc.DrawBitmap(bitmap, 0, 0);
+
+}
+
+void wxAdvSplashScreenWindow::OnPaint(wxPaintEvent& WXUNUSED(event))
+{
+ wxPaintDC dc(this);
+ if (m_bitmap.Ok())
+ wxDrawSplashBitmap(dc, m_bitmap, 0, 0);
+}
+
+void wxAdvSplashScreenWindow::OnEraseBackground(wxEraseEvent& event)
+{
+ if (event.GetDC())
+ {
+ if (m_bitmap.Ok())
+ {
+ wxDrawSplashBitmap(* event.GetDC(), m_bitmap, 0, 0);
+ }
+ }
+ else
+ {
+ wxClientDC dc(this);
+ if (m_bitmap.Ok())
+ {
+ wxDrawSplashBitmap(dc, m_bitmap, 0, 0);
+ }
+ }
+}
+
+void wxAdvSplashScreenWindow::OnMouseEvent(wxMouseEvent& event)
+{
+ if (event.LeftDown() || event.RightDown())
+ GetParent()->Close(true);
+}
+
+void wxAdvSplashScreenWindow::OnChar(wxKeyEvent& WXUNUSED(event))
+{
+ GetParent()->Close(true);
+}
+
Index: Trunk/XaraLX/wxXtra/Makefile.am
===================================================================
--- Trunk/XaraLX/wxXtra/Makefile.am (revision 1086)
+++ Trunk/XaraLX/wxXtra/Makefile.am (revision 1087)
@@ -6,7 +6,9 @@
noinst_LIBRARIES = libwxXtra.a
# the application source, library search path, and link libraries
-libwxXtra_a_SOURCES = manager.cpp wxmousestate.cpp doublebuffer.cpp cwfrompoint.cpp combo.cpp combog.cpp odcombo.cpp platform.cpp
+libwxXtra_a_SOURCES = \
+ manager.cpp wxmousestate.cpp doublebuffer.cpp cwfrompoint.cpp combo.cpp combog.cpp odcombo.cpp \
+ platform.cpp advsplash.cpp
# make sure this does NOT have our include files in the path
# Don't use GTK includes for now - you will need this with sub-2.6.3 but that's not supported
Index: Trunk/XaraLX/wxXtra/advsplash.h
===================================================================
--- Trunk/XaraLX/wxXtra/advsplash.h (revision 0)
+++ Trunk/XaraLX/wxXtra/advsplash.h (revision 1087)
@@ -0,0 +1,76 @@
+// $Id: doublebuffer.h 751 2006-03-31 15:43:49Z alex $
+/* @@tag:xara-cn-tp@@ THIRD PARTY COPYRIGHT */
+// The following line makes normalize.pl skip type fixing
+/* SKIPFIXTYPES: START */
+
+// This file is derived from CVSHEAD wxWidgets and is thus
+// under the wxWidgets / wxWindows license.
+
+#ifndef __WXXTRA_ADVSPLASH_H
+#define __WXXTRA_ADVSPLASH_H
+
+#include <wx/wx.h>
+
+class wxAdvSplashScreenWindow;
+
+/*
+ * wxAdvSplashScreen
+ */
+
+class wxAdvSplashScreen: public wxFrame
+{
+public:
+ // for RTTI macros only
+ wxAdvSplashScreen() {}
+ wxAdvSplashScreen(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);
+ ~wxAdvSplashScreen();
+
+ void OnCloseWindow(wxCloseEvent& event);
+ void OnNotify(wxTimerEvent& event);
+
+ long GetSplashStyle() const { return m_splashStyle; }
+ wxAdvSplashScreenWindow* GetSplashWindow() const { return m_window; }
+ int GetTimeout() const { return m_milliseconds; }
+
+protected:
+ wxAdvSplashScreenWindow* m_window;
+ long m_splashStyle;
+ int m_milliseconds;
+ wxTimer m_timer;
+
+ DECLARE_DYNAMIC_CLASS(wxAdvSplashScreen)
+ DECLARE_EVENT_TABLE()
+ DECLARE_NO_COPY_CLASS(wxAdvSplashScreen)
+};
+
+/*
+ * wxAdvSplashScreenWindow
+ */
+
+class wxAdvSplashScreenWindow: public wxWindow
+{
+public:
+ wxAdvSplashScreenWindow(const wxBitmap& bitmap, wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxNO_BORDER);
+
+ void OnPaint(wxPaintEvent& event);
+ void OnEraseBackground(wxEraseEvent& event);
+ void OnMouseEvent(wxMouseEvent& event);
+ void OnChar(wxKeyEvent& event);
+
+ void SetBitmap(const wxBitmap& bitmap) { m_bitmap = bitmap; }
+ wxBitmap& GetBitmap() { return m_bitmap; }
+
+protected:
+ wxBitmap m_bitmap;
+
+ DECLARE_EVENT_TABLE()
+ DECLARE_NO_COPY_CLASS(wxAdvSplashScreenWindow)
+};
+
+
+
+#endif // __WXXTRA_ADVSPLASH_H
Index: Trunk/XaraLX/wxOil/camresource.cpp
===================================================================
--- Trunk/XaraLX/wxOil/camresource.cpp (revision 1086)
+++ Trunk/XaraLX/wxOil/camresource.cpp (revision 1087)
@@ -120,7 +120,7 @@
ResIDToString * CamResource::pObjectNameHash = NULL;
wxFileSystem * CamResource::pwxFileSystem = NULL;
wxBitmap * CamResource::pSplashBitmap= NULL;
-wxSplashScreen * CamResource::pSplashScreen = NULL;
+wxAdvSplashScreen * CamResource::pSplashScreen = NULL;
wxString * CamResource::pResourcePath = NULL;
CamResourceRemember * CamResource::pFirstRemember=NULL;
BOOL CamResource::HaveCheckedResourcePath = FALSE;
@@ -1714,27 +1714,27 @@
{
TRACET(_T("CamResource::Splash() called"));
-
- wxImage Image;
-
if (pSplashBitmap) delete pSplashBitmap;
pSplashBitmap=NULL;
+
+ pSplashBitmap = new wxBitmap();
+ if (!pSplashBitmap) return FALSE;
+
// We'd like to get the bitmap name from the resources, but, urm, we haven't yet
// loaded them
- if (!LoadwxImage(Image, _T("startup-lx.png") ))
+ if (!LoadwxBitmap(*pSplashBitmap, _T("startup-lx.png") ))
{
TRACE(_T("Cannot load splash bitmap - possible resource compilation error?"));
return TRUE;
}
-
- pSplashBitmap = new wxBitmap(Image);
- if (!pSplashBitmap) return FALSE;
- pSplashScreen = new wxSplashScreen(*pSplashBitmap,
+ if (!pSplashBitmap->Ok()) return FALSE;
+
+ pSplashScreen = new wxAdvSplashScreen(*pSplashBitmap,
wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_NO_TIMEOUT,
0, NULL, -1, wxDefaultPosition, wxDefaultSize,
- wxSIMPLE_BORDER
+ wxNO_BORDER
#if !defined (_DEBUG)
|wxSTAY_ON_TOP // Only stay on top in non-debug builds - too annoying for preinit debugging
#endif
Index: Trunk/XaraLX/wxOil/camresource.h
===================================================================
--- Trunk/XaraLX/wxOil/camresource.h (revision 1086)
+++ Trunk/XaraLX/wxOil/camresource.h (revision 1087)
@@ -113,7 +113,7 @@
class CCLexFile;
class wxFSFile;
class wxBimtap;
-class wxSplashScreen;
+class wxAdvSplashScreen;
class wxHelpProvider;
typedef UINT32 ResourceID;
@@ -250,7 +250,7 @@
static CamResourceRemember * pFirstRemember;
static wxBitmap * pSplashBitmap;
- static wxSplashScreen * pSplashScreen;
+ static wxAdvSplashScreen * pSplashScreen;
static ResourceStringToBitmap * pBitmapHash;
Index: Trunk/XaraLX/wxOil/xrc/startup-lx.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Xara