From: Volker Bartheld on 23 Nov 2006 06:48 Hi! I was playing a litte with wxAnimation and wxAnimationCtrl in wxWidgets 2.8.0. Does it have a reason why the enum value wxANIM_TYPE_ANY (see %WXDIR%include\wx\animdecod.h) is encapsulated in #if wxUSE_STREAMS #endif ? I think, wxAnimation could be well used without wxUSE_STREAMS being defined. At least wxAnimation TheAnimation; if(TheAnimation.LoadFile(fileName, (wxAnimationType)3 /*wxANIM_TYPE_ANY*/)) // was the animation loaded correctly from the file? { m_animationCtrl=new wxAnimationCtrl(this, wxID_ANY, TheAnimation); // create the control m_animationCtrl->Play(); // and play it } worked fine for me. Another little question: Since wxAnimationCtrl was formely called wxGIFAnimationCtrl and also exposes a different interface, I find myself in need to use some defines to branch between wxW-versions. In this case, # if (wxVERSION_NUMBER>=2800) wxAnimation TheAnimation; if(TheAnimation.LoadFile(fileName, (wxAnimationType)3 /*wxANIM_TYPE_ANY*/)) // was the animation loaded correctly from the file? { m_animationCtrl=new wxAnimationCtrl(m_imageArea, wxID_ANY, TheAnimation); // create the control m_animationCtrl->Play(); // and play it } // if(TheAnimation.LoadFile(fileName, (wxAnimationType)3 /*wxANIM_TYPE_ANY*/)) # else // #if (wxVERSION_NUMBER>=2800) m_animationCtrl=new wxGIFAnimationCtrl(m_imageArea, wxID_ANY, fileName); // create wxGIFAnimationCtrl from file if(m_animationCtrl::IsValid()) m_animationCtrl->Play(); // and play if valid # endif // #if (wxVERSION_NUMBER>=2800) seemed the way to go. However, at the definition of wxVERSION_NUMBER in %WXDIR%\include\wx\version.h, I read the following comment: /* some more defines, not really sure if they're [still] useful */ So - is there a better way to do this branch? Thanks a lot and greets from Munich, Volker __ Mail replies to/an V B A R T H E L D at G M X dot D E
From: Francesco Montorsi on 23 Nov 2006 18:05 Volker Bartheld ha scritto: > Hi! > > I was playing a litte with wxAnimation and wxAnimationCtrl in wxWidgets > 2.8.0. Does it have a reason why the enum value wxANIM_TYPE_ANY (see > %WXDIR%include\wx\animdecod.h) is encapsulated in > > #if wxUSE_STREAMS > #endif > > ? the only way to load data into a wxAnimationDecoder-derived class is by using the Load( wxInputStream& stream ) function; if wx streams are disabled, then wxAnimationDecoder classes wouldn't be very useful... > I think, wxAnimation could be well used without wxUSE_STREAMS being > defined. At least > > wxAnimation TheAnimation; > if(TheAnimation.LoadFile(fileName, (wxAnimationType)3 /*wxANIM_TYPE_ANY*/)) // was the animation loaded correctly from the file? > { > m_animationCtrl=new wxAnimationCtrl(this, wxID_ANY, TheAnimation); // create the control > m_animationCtrl->Play(); // and play it > } > > worked fine for me. with wxUSE_STREAMS==0 ? It seems strange to me as wxAnimation::LoadFile uses wxFileInputStream (at least in its generic implementation - in GTK version uses a native function). Are you using wxGTK? > Another little question: Since wxAnimationCtrl was formely called > wxGIFAnimationCtrl and also exposes a different interface, I find myself > in need to use some defines to branch between wxW-versions. In this > case, > > # if (wxVERSION_NUMBER>=2800) > wxAnimation TheAnimation; > if(TheAnimation.LoadFile(fileName, (wxAnimationType)3 /*wxANIM_TYPE_ANY*/)) // was the animation loaded correctly from the file? > { > m_animationCtrl=new wxAnimationCtrl(m_imageArea, wxID_ANY, TheAnimation); // create the control > m_animationCtrl->Play(); // and play it > } // if(TheAnimation.LoadFile(fileName, (wxAnimationType)3 /*wxANIM_TYPE_ANY*/)) > # else // #if (wxVERSION_NUMBER>=2800) > m_animationCtrl=new wxGIFAnimationCtrl(m_imageArea, wxID_ANY, fileName); // create wxGIFAnimationCtrl from file > if(m_animationCtrl::IsValid()) m_animationCtrl->Play(); // and play if valid I guess the :: are a -> in the line above, isn't it? > # endif // #if (wxVERSION_NUMBER>=2800) > > seemed the way to go. yes, seems good to me (if you want to support wx < 2.8) > However, at the definition of wxVERSION_NUMBER in > %WXDIR%\include\wx\version.h, I read the following comment: > > /* some more defines, not really sure if they're [still] useful */ > > So - is there a better way to do this branch? probably using the wxCHECK_VERSION macro would be a more reliable (and supported) way to do it. Francesco --------------------------------------------------------------------- To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org
From: Volker Bartheld on 24 Nov 2006 06:15 Hi Francesco! >> I was playing a litte with wxAnimation and wxAnimationCtrl in wxWidgets >> 2.8.0. Does it have a reason why the enum value wxANIM_TYPE_ANY (see >> %WXDIR%include\wx\animdecod.h) is encapsulated in >> #if wxUSE_STREAMS >> #endif >> I think, wxAnimation could be well used without wxUSE_STREAMS being >> defined. >with wxUSE_STREAMS==0 ? After a night's sleep, it seems like either I must have been totally confused when I wrote that post or IntelliSense/Visual Assist's autocomplete played me a nasty trick. Note the slight but subtle difference between wxANIM_TYPE_ANY and wxANIMATION_TYPE_ANY .. *D-O-H* And, yes, wxUSE_STREAMS was defined 1 (by default) in my project and animate.h happily includes animdecod.h, which has the wxAnimationType-enumeration. Sorry. My bad. Cheers, Volker __ Mail replies to/an V B A R T H E L D at G M X dot D E
From: Francesco Montorsi on 24 Nov 2006 15:35 Volker Bartheld ha scritto: > Hi Francesco! > >>> I was playing a litte with wxAnimation and wxAnimationCtrl in wxWidgets >>> 2.8.0. Does it have a reason why the enum value wxANIM_TYPE_ANY (see >>> %WXDIR%include\wx\animdecod.h) is encapsulated in >>> #if wxUSE_STREAMS >>> #endif >>> I think, wxAnimation could be well used without wxUSE_STREAMS being >>> defined. > >> with wxUSE_STREAMS==0 ? > > After a night's sleep, it seems like either I must have been totally > confused when I wrote that post or IntelliSense/Visual Assist's > autocomplete played me a nasty trick. no problem ;) > Note the slight but subtle difference between > wxANIM_TYPE_ANY > and > wxANIMATION_TYPE_ANY > . *D-O-H* whops; this lead me to note that docs are using old-style wxANIM_* enums; I've submitted a patch to fix them. Francesco --------------------------------------------------------------------- To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org
|
Pages: 1 Prev: wxRichTextCtrl printing problem Next: Problem with wxCalendarCtrl |