]> git.saurik.com Git - wxWidgets.git/commitdiff
[ 1581391 ] wxAnimationCtrl XRC handler
authorRobert Roebling <robert@roebling.de>
Sat, 21 Oct 2006 13:59:25 +0000 (13:59 +0000)
committerRobert Roebling <robert@roebling.de>
Sat, 21 Oct 2006 13:59:25 +0000 (13:59 +0000)
   (most of)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42196 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

build/bakefiles/files.bkl
include/wx/xrc/xh_all.h
include/wx/xrc/xh_animatctrl.h [new file with mode: 0644]
include/wx/xrc/xmlres.h
src/xrc/xh_animatctrl.cpp [new file with mode: 0644]
src/xrc/xmlres.cpp
src/xrc/xmlrsall.cpp

index d02d1fde707309d184a3bf4b30570b1d35397a6a..465904f3a0c9761c467eaa8ad55d1518018e03a4 100644 (file)
@@ -2920,6 +2920,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
 <!-- ====================================================================== -->
 
 <set var="XRC_SRC" hints="files">
+    src/xrc/xh_animatctrl.cpp
     src/xrc/xh_bmp.cpp
     src/xrc/xh_bmpcbox.cpp
     src/xrc/xh_bmpbt.cpp
@@ -2975,6 +2976,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
 </set>
 <set var="XRC_HDR" hints="files">
     wx/xrc/xh_all.h
+    wx/xrc/xh_animatctrl.h
     wx/xrc/xh_bmpbt.h
     wx/xrc/xh_bmp.h
     wx/xrc/xh_bmpcbox.h
index 4e4922ef202491691b0c0f00a90eb426d0bdb108..d3364fc18e103ef1d5dc4f74ec684b3a973d8546 100644 (file)
@@ -64,5 +64,6 @@
 #include "wx/xrc/xh_dirpicker.h"
 #include "wx/xrc/xh_hyperlink.h"
 #include "wx/xrc/xh_bmpcbox.h"
+#include "wx/xrc/xh_animatctrl.h"
 
 #endif // _WX_XH_ALL_H_
diff --git a/include/wx/xrc/xh_animatctrl.h b/include/wx/xrc/xh_animatctrl.h
new file mode 100644 (file)
index 0000000..4831187
--- /dev/null
@@ -0,0 +1,30 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        wx/xrc/xh_animatctrl.h
+// Purpose:     XML resource handler for wxAnimationCtrl
+// Author:      Francesco Montorsi
+// Created:     2006-10-15
+// RCS-ID:      $Id$
+// Copyright:   (c) 2006 Francesco Montorsi
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_XH_ANIMATIONCTRL_H_
+#define _WX_XH_ANIMATIONCTRL_H_
+
+#include "wx/xrc/xmlres.h"
+
+#if wxUSE_XRC && wxUSE_ANIMATIONCTRL
+
+class WXDLLIMPEXP_XRC wxAnimationCtrlXmlHandler : public wxXmlResourceHandler
+{
+    DECLARE_DYNAMIC_CLASS(wxAnimationCtrlXmlHandler)
+
+public:
+    wxAnimationCtrlXmlHandler();
+    virtual wxObject *DoCreateResource();
+    virtual bool CanHandle(wxXmlNode *node);
+};
+
+#endif // wxUSE_XRC && wxUSE_ANIMATIONCTRL
+
+#endif // _WX_XH_ANIMATIONCTRL_H_
index 0c9a105cf452e84e30af2528e0761ac0245b2ce6..c581aafc8b4b1778c790b4009fd50b412bce2daa 100644 (file)
@@ -25,6 +25,7 @@
 #include "wx/icon.h"
 #include "wx/artprov.h"
 #include "wx/colour.h"
+#include "wx/animate.h"
 
 #include "wx/xml/xml.h"
 
@@ -127,6 +128,8 @@ public:
     // Destructor.
     virtual ~wxXmlResource();
 
+    wxXmlNode *GetFirstRoot();
+    
     // Loads resources from XML files that match given filemask.
     // This method understands VFS (see filesys.h).
     bool Load(const wxString& filemask);
@@ -450,6 +453,11 @@ protected:
                    const wxArtClient& defaultArtClient = wxART_OTHER,
                    wxSize size = wxDefaultSize);
 
+#if wxUSE_ANIMATIONCTRL
+    // Gets an animation.
+    wxAnimation GetAnimation(const wxString& param = wxT("animation"));
+#endif
+
     // Gets a font.
     wxFont GetFont(const wxString& param = wxT("font"));
 
diff --git a/src/xrc/xh_animatctrl.cpp b/src/xrc/xh_animatctrl.cpp
new file mode 100644 (file)
index 0000000..78e53e0
--- /dev/null
@@ -0,0 +1,57 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        src/xrc/xh_animatctrl.cpp
+// Purpose:     XML resource handler for wxAnimationCtrl
+// Author:      Francesco Montorsi
+// Created:     2006-10-15
+// RCS-ID:      $Id$
+// Copyright:   (c) 2006 Francesco Montorsi
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+    #pragma hdrstop
+#endif
+
+#if wxUSE_XRC && wxUSE_ANIMATIONCTRL
+
+#include "wx/xrc/xh_animatctrl.h"
+#include "wx/animate.h"
+
+IMPLEMENT_DYNAMIC_CLASS(wxAnimationCtrlXmlHandler, wxXmlResourceHandler)
+
+wxAnimationCtrlXmlHandler::wxAnimationCtrlXmlHandler() : wxXmlResourceHandler()
+{
+    XRC_ADD_STYLE(wxAC_NO_AUTORESIZE);
+    XRC_ADD_STYLE(wxAC_DEFAULT_STYLE);
+    AddWindowStyles();
+}
+
+wxObject *wxAnimationCtrlXmlHandler::DoCreateResource()
+{
+    XRC_MAKE_INSTANCE(ctrl, wxAnimationCtrl)
+
+    ctrl->Create(m_parentAsWindow,
+                  GetID(),
+                  GetAnimation(wxT("animation")),
+                  GetPosition(), GetSize(),
+                  GetStyle(_T("style"), wxAC_DEFAULT_STYLE),
+                  GetName());
+
+    // if no inactive-bitmap has been provided, GetBitmap() will return wxNullBitmap
+    // which just tells wxAnimationCtrl to use the default for inactive status
+    ctrl->SetInactiveBitmap(GetBitmap(wxT("inactive-bitmap")));
+
+    SetupWindow(ctrl);
+
+    return ctrl;
+}
+
+bool wxAnimationCtrlXmlHandler::CanHandle(wxXmlNode *node)
+{
+    return IsOfClass(node, wxT("wxAnimationCtrl"));
+}
+
+#endif // wxUSE_XRC && wxUSE_ANIMATIONCTRL
index 17ee4098124be76f78ae3e889f0e7c47978ef411..c2aa6a5586fb6c66dd94f44465d58380bbb6c964 100644 (file)
@@ -1139,6 +1139,39 @@ wxBitmap wxXmlResourceHandler::GetBitmap(const wxString& param,
     return wxBitmap(img);
 }
 
+#if wxUSE_ANIMATIONCTRL
+wxAnimation wxXmlResourceHandler::GetAnimation(const wxString& param)
+{
+    wxAnimation ani;
+
+    /* load the animation from file: */
+    wxString name = GetParamValue(param);
+    if (name.empty()) return wxNullAnimation;
+#if wxUSE_FILESYSTEM
+    wxFSFile *fsfile = GetCurFileSystem().OpenFile(name);
+    if (fsfile == NULL)
+    {
+        wxLogError(_("XRC resource: Cannot create animation from '%s'."),
+                   name.c_str());
+        return wxNullAnimation;
+    }
+    ani.Load(*(fsfile->GetStream()));
+    delete fsfile;
+#else
+    ani.LoadFile(name);
+#endif
+
+    if (!ani.IsOk())
+    {
+        wxLogError(_("XRC resource: Cannot create animation from '%s'."),
+                   name.c_str());
+        return wxNullAnimation;
+    }
+
+    return ani;
+}
+#endif      // wxUSE_ANIMATIONCTRL
+
 
 
 wxIcon wxXmlResourceHandler::GetIcon(const wxString& param,
index c87da9a59287252dc26cc5f2e51aa01d0e220cf9..01cd0874d1e58c97efb140e5aea04daef3c330a4 100644 (file)
@@ -167,6 +167,9 @@ void wxXmlResource::InitAllHandlers()
 #if wxUSE_HYPERLINKCTRL
     AddHandler( new wxHyperlinkCtrlXmlHandler);
 #endif
+#if wxUSE_ANIMATIONCTRL
+    AddHandler( new wxAnimationCtrlXmlHandler);
+#endif
 }
 
 #endif // wxUSE_XRC