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 WXDLLIMPEXP_ADV wxAnimation
: public wxAnimationBase
30 wxAnimation(const wxString
&name
, wxAnimationType type
= wxANIMATION_TYPE_ANY
)
31 : m_pixbuf(NULL
) { LoadFile(name
, type
); }
32 wxAnimation(GdkPixbufAnimation
*p
= NULL
);
33 wxAnimation(const wxAnimation
&);
34 ~wxAnimation() { UnRef(); }
36 wxAnimation
& operator= (const wxAnimation
&);
38 virtual bool IsOk() const
39 { return m_pixbuf
!= NULL
; }
42 // unfortunately GdkPixbufAnimation does not expose these info:
44 virtual unsigned int GetFrameCount() const { return 0; }
45 virtual wxImage
GetFrame(unsigned int frame
) const;
47 // we can retrieve the delay for a frame only after building
48 // a GdkPixbufAnimationIter...
49 virtual int GetDelay(unsigned int WXUNUSED(frame
)) const { return 0; }
51 virtual wxSize
GetSize() const;
53 virtual bool LoadFile(const wxString
&name
, wxAnimationType type
= wxANIMATION_TYPE_ANY
);
54 virtual bool Load(wxInputStream
&stream
, wxAnimationType type
= wxANIMATION_TYPE_ANY
);
57 public: // used by GTK callbacks
59 GdkPixbufAnimation
*GetPixbuf() const
61 void SetPixbuf(GdkPixbufAnimation
* p
);
64 GdkPixbufAnimation
*m_pixbuf
;
69 typedef wxAnimationBase base_type
;
70 DECLARE_DYNAMIC_CLASS(wxAnimation
)
74 // ----------------------------------------------------------------------------
76 // ----------------------------------------------------------------------------
78 // Resize to animation size if this is set
79 #define wxAN_FIT_ANIMATION 0x0010
81 class WXDLLIMPEXP_ADV wxAnimationCtrl
: public wxAnimationCtrlBase
84 wxAnimationCtrl() { Init(); }
85 wxAnimationCtrl(wxWindow
*parent
,
87 const wxAnimation
& anim
= wxNullAnimation
,
88 const wxPoint
& pos
= wxDefaultPosition
,
89 const wxSize
& size
= wxDefaultSize
,
90 long style
= wxAC_DEFAULT_STYLE
,
91 const wxString
& name
= wxAnimationCtrlNameStr
)
95 Create(parent
, id
, anim
, pos
, size
, style
, name
);
100 bool Create(wxWindow
*parent
, wxWindowID id
,
101 const wxAnimation
& anim
= wxNullAnimation
,
102 const wxPoint
& pos
= wxDefaultPosition
,
103 const wxSize
& size
= wxDefaultSize
,
104 long style
= wxAC_DEFAULT_STYLE
,
105 const wxString
& name
= wxAnimationCtrlNameStr
);
109 public: // event handler
111 void OnTimer(wxTimerEvent
&);
113 public: // public API
115 virtual bool LoadFile(const wxString
& filename
, wxAnimationType type
= wxANIMATION_TYPE_ANY
);
116 virtual bool Load(wxInputStream
& stream
, wxAnimationType type
= wxANIMATION_TYPE_ANY
);
118 virtual void SetAnimation(const wxAnimation
&anim
);
119 virtual wxAnimation
GetAnimation() const
120 { return wxAnimation(m_anim
); }
125 virtual bool IsPlaying() const;
127 bool SetBackgroundColour( const wxColour
&colour
);
131 virtual void DisplayStaticImage();
132 virtual wxSize
DoGetBestSize() const;
133 void FitToAnimation();
134 void ClearToBackgroundColour();
139 protected: // internal vars
141 GdkPixbufAnimation
*m_anim
;
142 GdkPixbufAnimationIter
*m_iter
;
148 typedef wxAnimationCtrlBase base_type
;
149 DECLARE_DYNAMIC_CLASS(wxAnimationCtrl
)
150 DECLARE_EVENT_TABLE()
153 #endif // _WX_GTKANIMATEH__