animate.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/animate.h
  3. // Purpose: wxAnimation and wxAnimationCtrl
  4. // Author: Julian Smart and Guillermo Rodriguez Garcia
  5. // Modified by: Francesco Montorsi
  6. // Created: 13/8/99
  7. // Copyright: (c) Julian Smart and Guillermo Rodriguez Garcia
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_ANIMATE_H_
  11. #define _WX_ANIMATE_H_
  12. #include "wx/defs.h"
  13. #if wxUSE_ANIMATIONCTRL
  14. #include "wx/animdecod.h"
  15. #include "wx/control.h"
  16. #include "wx/timer.h"
  17. #include "wx/bitmap.h"
  18. class WXDLLIMPEXP_FWD_ADV wxAnimation;
  19. extern WXDLLIMPEXP_DATA_ADV(wxAnimation) wxNullAnimation;
  20. extern WXDLLIMPEXP_DATA_ADV(const char) wxAnimationCtrlNameStr[];
  21. // ----------------------------------------------------------------------------
  22. // wxAnimationBase
  23. // ----------------------------------------------------------------------------
  24. class WXDLLIMPEXP_ADV wxAnimationBase : public wxObject
  25. {
  26. public:
  27. wxAnimationBase() {}
  28. virtual bool IsOk() const = 0;
  29. // can be -1
  30. virtual int GetDelay(unsigned int frame) const = 0;
  31. virtual unsigned int GetFrameCount() const = 0;
  32. virtual wxImage GetFrame(unsigned int frame) const = 0;
  33. virtual wxSize GetSize() const = 0;
  34. virtual bool LoadFile(const wxString& name,
  35. wxAnimationType type = wxANIMATION_TYPE_ANY) = 0;
  36. virtual bool Load(wxInputStream& stream,
  37. wxAnimationType type = wxANIMATION_TYPE_ANY) = 0;
  38. protected:
  39. DECLARE_ABSTRACT_CLASS(wxAnimationBase)
  40. };
  41. // ----------------------------------------------------------------------------
  42. // wxAnimationCtrlBase
  43. // ----------------------------------------------------------------------------
  44. // do not autoresize to the animation's size when SetAnimation() is called
  45. #define wxAC_NO_AUTORESIZE (0x0010)
  46. // default style does not include wxAC_NO_AUTORESIZE, that is, the control
  47. // auto-resizes by default to fit the new animation when SetAnimation() is called
  48. #define wxAC_DEFAULT_STYLE (wxBORDER_NONE)
  49. class WXDLLIMPEXP_ADV wxAnimationCtrlBase : public wxControl
  50. {
  51. public:
  52. wxAnimationCtrlBase() { }
  53. // public API
  54. virtual bool LoadFile(const wxString& filename,
  55. wxAnimationType type = wxANIMATION_TYPE_ANY) = 0;
  56. virtual bool Load(wxInputStream& stream,
  57. wxAnimationType type = wxANIMATION_TYPE_ANY) = 0;
  58. virtual void SetAnimation(const wxAnimation &anim) = 0;
  59. virtual wxAnimation GetAnimation() const = 0;
  60. virtual bool Play() = 0;
  61. virtual void Stop() = 0;
  62. virtual bool IsPlaying() const = 0;
  63. virtual void SetInactiveBitmap(const wxBitmap &bmp);
  64. // always return the original bitmap set in this control
  65. wxBitmap GetInactiveBitmap() const
  66. { return m_bmpStatic; }
  67. protected:
  68. // the inactive bitmap as it was set by the user
  69. wxBitmap m_bmpStatic;
  70. // the inactive bitmap currently shown in the control
  71. // (may differ in the size from m_bmpStatic)
  72. wxBitmap m_bmpStaticReal;
  73. // updates m_bmpStaticReal from m_bmpStatic if needed
  74. virtual void UpdateStaticImage();
  75. // called by SetInactiveBitmap
  76. virtual void DisplayStaticImage() = 0;
  77. private:
  78. DECLARE_ABSTRACT_CLASS(wxAnimationCtrlBase)
  79. };
  80. // ----------------------------------------------------------------------------
  81. // include the platform-specific version of the wxAnimationCtrl class
  82. // ----------------------------------------------------------------------------
  83. #if defined(__WXGTK20__) && !defined(__WXUNIVERSAL__)
  84. #include "wx/gtk/animate.h"
  85. #else
  86. #include "wx/generic/animate.h"
  87. #endif
  88. #endif // wxUSE_ANIMATIONCTRL
  89. #endif // _WX_ANIMATE_H_