1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/animate.h
3 // Purpose: Animation classes
4 // Author: Julian Smart and Guillermo Rodriguez Garcia
5 // Modified by: Francesco Montorsi
8 // Copyright: (c) Julian Smart and Guillermo Rodriguez Garcia
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_GTKANIMATEH__
13 #define _WX_GTKANIMATEH__
15 typedef struct _GdkPixbufAnimation GdkPixbufAnimation
;
16 typedef struct _GdkPixbufAnimationIter GdkPixbufAnimationIter
;
18 // ----------------------------------------------------------------------------
20 // Unlike the generic wxAnimation object (see generic\animate.cpp), we won't
21 // use directly wxAnimationHandlers as gdk-pixbuf already provides the
22 // concept of handler and will automatically use the available handlers.
23 // Like generic wxAnimation object, this implementation of wxAnimation is
24 // refcounted so that assignment is very fast
25 // ----------------------------------------------------------------------------
27 class WXDLLEXPORT wxAnimation
: public wxAnimationBase
30 wxAnimation(GdkPixbufAnimation
*p
= NULL
) { m_pixbuf
= p
; }
31 wxAnimation(const wxAnimation
&);
32 ~wxAnimation() { UnRef(); }
34 wxAnimation
& operator= (const wxAnimation
&);
36 bool operator == (const wxAnimation
& anim
) const
37 { return m_pixbuf
== anim
.m_pixbuf
; }
38 bool operator != (const wxAnimation
& anim
) const
39 { return m_pixbuf
!= anim
.m_pixbuf
; }
41 virtual bool IsOk() const
42 { return m_pixbuf
!= NULL
; }
45 // unfortunately GdkPixbufAnimation does not expose these info:
47 virtual size_t GetFrameCount() const
49 virtual wxImage
GetFrame(size_t i
) const;
51 // we can retrieve the delay for a frame only after building
52 // a GdkPixbufAnimationIter...
53 virtual int GetDelay(size_t i
) const
56 virtual wxSize
GetSize() const;
58 virtual bool LoadFile(const wxString
&name
, wxAnimationType type
= wxANIMATION_TYPE_ANY
);
59 virtual bool Load(wxInputStream
&stream
, wxAnimationType type
= wxANIMATION_TYPE_ANY
);
62 public: // used by GTK callbacks
64 GdkPixbufAnimation
*GetPixbuf() const
66 void SetPixbuf(GdkPixbufAnimation
* p
);
69 GdkPixbufAnimation
*m_pixbuf
;
71 // used temporary by Load()
72 //bool m_bLoadComplete;
77 typedef wxAnimationBase base_type
;
78 DECLARE_DYNAMIC_CLASS(wxAnimation
)
82 // ----------------------------------------------------------------------------
84 // ----------------------------------------------------------------------------
86 // Resize to animation size if this is set
87 #define wxAN_FIT_ANIMATION 0x0010
89 class WXDLLIMPEXP_ADV wxAnimationCtrl
: public wxAnimationCtrlBase
93 wxAnimationCtrl(wxWindow
*parent
,
95 const wxAnimation
& anim
= wxNullAnimation
,
96 const wxPoint
& pos
= wxDefaultPosition
,
97 const wxSize
& size
= wxDefaultSize
,
98 long style
= wxAC_DEFAULT_STYLE
,
99 const wxString
& name
= wxAnimationCtrlNameStr
)
101 Create(parent
, id
, anim
, pos
, size
, style
, name
);
104 bool Create(wxWindow
*parent
, wxWindowID id
,
105 const wxAnimation
& anim
= wxNullAnimation
,
106 const wxPoint
& pos
= wxDefaultPosition
,
107 const wxSize
& size
= wxDefaultSize
,
108 long style
= wxAC_DEFAULT_STYLE
,
109 const wxString
& name
= wxAnimationCtrlNameStr
);
113 public: // event handler
115 void OnTimer(wxTimerEvent
&);
117 public: // public API
119 virtual bool LoadFile(const wxString
& filename
, wxAnimationType type
= wxANIMATION_TYPE_ANY
);
121 virtual void SetAnimation(const wxAnimation
&anim
);
122 virtual wxAnimation
GetAnimation() const
123 { return wxAnimation(m_anim
); }
128 virtual bool IsPlaying() const;
130 bool SetBackgroundColour( const wxColour
&colour
);
134 virtual wxSize
DoGetBestSize() const;
135 void FitToAnimation();
136 void ClearToBackgroundColour();
141 protected: // internal vars
143 GdkPixbufAnimation
*m_anim
;
144 GdkPixbufAnimationIter
*m_iter
;
150 typedef wxAnimationCtrlBase base_type
;
151 DECLARE_DYNAMIC_CLASS(wxAnimationCtrl
)
152 DECLARE_EVENT_TABLE()
155 #endif // _WX_GTKANIMATEH__