Support wxGenericAnimationCtrl by the animation control XRC handler
This commit is contained in:
committed by
Vadim Zeitlin
parent
cc5fb63bf7
commit
2cdcd84928
@@ -52,6 +52,7 @@
|
|||||||
#include "objrefdlg.h"
|
#include "objrefdlg.h"
|
||||||
// For functions to manipulate the corresponding controls.
|
// For functions to manipulate the corresponding controls.
|
||||||
#include "wx/animate.h"
|
#include "wx/animate.h"
|
||||||
|
#include "wx/generic/animate.h"
|
||||||
#include "wx/infobar.h"
|
#include "wx/infobar.h"
|
||||||
#include "wx/treectrl.h"
|
#include "wx/treectrl.h"
|
||||||
#include "wx/listctrl.h"
|
#include "wx/listctrl.h"
|
||||||
@@ -206,14 +207,17 @@ void MyFrame::OnAnimationCtrlPlay(wxCommandEvent& event)
|
|||||||
|
|
||||||
wxWindow *win = btn->GetParent();
|
wxWindow *win = btn->GetParent();
|
||||||
wxAnimationCtrl *ctrl = XRCCTRL(*win, "controls_animation_ctrl", wxAnimationCtrl);
|
wxAnimationCtrl *ctrl = XRCCTRL(*win, "controls_animation_ctrl", wxAnimationCtrl);
|
||||||
|
wxGenericAnimationCtrl *generic =
|
||||||
|
XRCCTRL(*win, "controls_generic_animation_ctrl", wxGenericAnimationCtrl);
|
||||||
if (ctrl->IsPlaying())
|
if (ctrl->IsPlaying())
|
||||||
{
|
{
|
||||||
ctrl->Stop();
|
ctrl->Stop();
|
||||||
|
generic->Stop();
|
||||||
btn->SetLabel("Play");
|
btn->SetLabel("Play");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (ctrl->Play())
|
if ( ctrl->Play() && generic->Play() )
|
||||||
btn->SetLabel("Stop");
|
btn->SetLabel("Stop");
|
||||||
else
|
else
|
||||||
wxLogError("Cannot play the animation...");
|
wxLogError("Cannot play the animation...");
|
||||||
|
@@ -68,7 +68,7 @@
|
|||||||
<object class="wxPanel" name="animctrl">
|
<object class="wxPanel" name="animctrl">
|
||||||
<object class="wxFlexGridSizer">
|
<object class="wxFlexGridSizer">
|
||||||
<cols>2</cols>
|
<cols>2</cols>
|
||||||
<rows>1</rows>
|
<rows>2</rows>
|
||||||
<vgap>0</vgap>
|
<vgap>0</vgap>
|
||||||
<hgap>0</hgap>
|
<hgap>0</hgap>
|
||||||
<growablecols>0,1</growablecols>
|
<growablecols>0,1</growablecols>
|
||||||
@@ -91,6 +91,17 @@
|
|||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
|
|
||||||
|
<object class="spacer"/>
|
||||||
|
|
||||||
|
<object class="sizeritem">
|
||||||
|
<flag>wxALIGN_CENTRE|wxALL</flag>
|
||||||
|
<border>5</border>
|
||||||
|
<object class="wxGenericAnimationCtrl" name="controls_generic_animation_ctrl">
|
||||||
|
<animation>throbber.gif</animation>
|
||||||
|
<inactive-bitmap>stop.xpm</inactive-bitmap>
|
||||||
|
</object>
|
||||||
|
</object>
|
||||||
|
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include "wx/xrc/xh_animatctrl.h"
|
#include "wx/xrc/xh_animatctrl.h"
|
||||||
#include "wx/animate.h"
|
#include "wx/animate.h"
|
||||||
|
#include "wx/generic/animate.h"
|
||||||
#include "wx/scopedptr.h"
|
#include "wx/scopedptr.h"
|
||||||
|
|
||||||
wxIMPLEMENT_DYNAMIC_CLASS(wxAnimationCtrlXmlHandler, wxXmlResourceHandler);
|
wxIMPLEMENT_DYNAMIC_CLASS(wxAnimationCtrlXmlHandler, wxXmlResourceHandler);
|
||||||
@@ -31,16 +32,65 @@ wxAnimationCtrlXmlHandler::wxAnimationCtrlXmlHandler() : wxXmlResourceHandler()
|
|||||||
|
|
||||||
wxObject *wxAnimationCtrlXmlHandler::DoCreateResource()
|
wxObject *wxAnimationCtrlXmlHandler::DoCreateResource()
|
||||||
{
|
{
|
||||||
XRC_MAKE_INSTANCE(ctrl, wxAnimationCtrl)
|
wxAnimationCtrlBase *ctrl = NULL;
|
||||||
|
if ( m_instance )
|
||||||
|
ctrl = wxStaticCast(m_instance, wxAnimationCtrlBase);
|
||||||
|
|
||||||
wxScopedPtr<wxAnimation> animation(GetAnimation(wxT("animation")));
|
if ( !ctrl )
|
||||||
|
{
|
||||||
|
if ( m_class == "wxAnimationCtrl" )
|
||||||
|
{
|
||||||
|
ctrl = new wxAnimationCtrl(m_parentAsWindow,
|
||||||
|
GetID(),
|
||||||
|
wxNullAnimation,
|
||||||
|
GetPosition(), GetSize(),
|
||||||
|
GetStyle("style", wxAC_DEFAULT_STYLE),
|
||||||
|
GetName());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ctrl = new wxGenericAnimationCtrl(m_parentAsWindow,
|
||||||
|
GetID(),
|
||||||
|
wxNullAnimation,
|
||||||
|
GetPosition(), GetSize(),
|
||||||
|
GetStyle("style", wxAC_DEFAULT_STYLE),
|
||||||
|
GetName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( GetBool("hidden", 0) == 1 )
|
||||||
|
ctrl->Hide();
|
||||||
|
|
||||||
ctrl->Create(m_parentAsWindow,
|
const wxString aniParam = "animation";
|
||||||
GetID(),
|
wxString path = GetFilePath(GetParamNode(aniParam));
|
||||||
animation ? *animation : wxNullAnimation,
|
// load the animation from file
|
||||||
GetPosition(), GetSize(),
|
if ( !path.empty() )
|
||||||
GetStyle(wxT("style"), wxAC_DEFAULT_STYLE),
|
{
|
||||||
GetName());
|
wxAnimation ani = ctrl->CreateAnimation();
|
||||||
|
#if wxUSE_FILESYSTEM
|
||||||
|
wxScopedPtr<wxFSFile> fsfile(
|
||||||
|
GetCurFileSystem().OpenFile(path, wxFS_READ | wxFS_SEEKABLE)
|
||||||
|
);
|
||||||
|
if (fsfile)
|
||||||
|
{
|
||||||
|
ani.Load(*fsfile->GetStream());
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
ani.LoadFile(name);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if ( ani.IsOk() )
|
||||||
|
{
|
||||||
|
ctrl->SetAnimation(ani);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ReportParamError
|
||||||
|
(
|
||||||
|
aniParam,
|
||||||
|
wxString::Format("cannot create animation from \"%s\"", path)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// if no inactive-bitmap has been provided, GetBitmap() will return wxNullBitmap
|
// if no inactive-bitmap has been provided, GetBitmap() will return wxNullBitmap
|
||||||
// which just tells wxAnimationCtrl to use the default for inactive status
|
// which just tells wxAnimationCtrl to use the default for inactive status
|
||||||
@@ -53,7 +103,8 @@ wxObject *wxAnimationCtrlXmlHandler::DoCreateResource()
|
|||||||
|
|
||||||
bool wxAnimationCtrlXmlHandler::CanHandle(wxXmlNode *node)
|
bool wxAnimationCtrlXmlHandler::CanHandle(wxXmlNode *node)
|
||||||
{
|
{
|
||||||
return IsOfClass(node, wxT("wxAnimationCtrl"));
|
return IsOfClass(node, wxT("wxAnimationCtrl")) ||
|
||||||
|
IsOfClass(node, wxT("wxGenericAnimationCtrl"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // wxUSE_XRC && wxUSE_ANIMATIONCTRL
|
#endif // wxUSE_XRC && wxUSE_ANIMATIONCTRL
|
||||||
|
Reference in New Issue
Block a user