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(GdkPixbufAnimation
*p
= NULL
);
31 wxAnimation(const wxAnimation
&);
32 ~wxAnimation() { UnRef(); }
34 wxAnimation
& operator= (const wxAnimation
&);
36 virtual bool IsOk() const
37 { return m_pixbuf
!= NULL
; }
40 // unfortunately GdkPixbufAnimation does not expose these info:
42 virtual unsigned int GetFrameCount() const { return 0; }
43 virtual wxImage
GetFrame(unsigned int frame
) const;
45 // we can retrieve the delay for a frame only after building
46 // a GdkPixbufAnimationIter...
47 virtual int GetDelay(unsigned int WXUNUSED(frame
)) const { return 0; }
49 virtual wxSize
GetSize() const;
51 virtual bool LoadFile(const wxString
&name
, wxAnimationType type
= wxANIMATION_TYPE_ANY
);
52 virtual bool Load(wxInputStream
&stream
, wxAnimationType type
= wxANIMATION_TYPE_ANY
);
55 public: // used by GTK callbacks
57 GdkPixbufAnimation
*GetPixbuf() const
59 void SetPixbuf(GdkPixbufAnimation
* p
);
62 GdkPixbufAnimation
*m_pixbuf
;
67 typedef wxAnimationBase base_type
;
68 DECLARE_DYNAMIC_CLASS(wxAnimation
)
72 // ----------------------------------------------------------------------------
74 // ----------------------------------------------------------------------------
76 // Resize to animation size if this is set
77 #define wxAN_FIT_ANIMATION 0x0010
79 class WXDLLIMPEXP_ADV wxAnimationCtrl
: public wxAnimationCtrlBase
82 wxAnimationCtrl() { Init(); }
83 wxAnimationCtrl(wxWindow
*parent
,
85 const wxAnimation
& anim
= wxNullAnimation
,
86 const wxPoint
& pos
= wxDefaultPosition
,
87 const wxSize
& size
= wxDefaultSize
,
88 long style
= wxAC_DEFAULT_STYLE
,
89 const wxString
& name
= wxAnimationCtrlNameStr
)
93 Create(parent
, id
, anim
, pos
, size
, style
, name
);
98 bool Create(wxWindow
*parent
, wxWindowID id
,
99 const wxAnimation
& anim
= wxNullAnimation
,
100 const wxPoint
& pos
= wxDefaultPosition
,
101 const wxSize
& size
= wxDefaultSize
,
102 long style
= wxAC_DEFAULT_STYLE
,
103 const wxString
& name
= wxAnimationCtrlNameStr
);
107 public: // event handler
109 void OnTimer(wxTimerEvent
&);
111 public: // public API
113 virtual bool LoadFile(const wxString
& filename
, wxAnimationType type
= wxANIMATION_TYPE_ANY
);
115 virtual void SetAnimation(const wxAnimation
&anim
);
116 virtual wxAnimation
GetAnimation() const
117 { return wxAnimation(m_anim
); }
122 virtual bool IsPlaying() const;
124 bool SetBackgroundColour( const wxColour
&colour
);
128 virtual void DisplayStaticImage();
129 virtual wxSize
DoGetBestSize() const;
130 void FitToAnimation();
131 void ClearToBackgroundColour();
136 protected: // internal vars
138 GdkPixbufAnimation
*m_anim
;
139 GdkPixbufAnimationIter
*m_iter
;
145 typedef wxAnimationCtrlBase base_type
;
146 DECLARE_DYNAMIC_CLASS(wxAnimationCtrl
)
147 DECLARE_EVENT_TABLE()
150 #endif // _WX_GTKANIMATEH__