1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/animate.h
3 // Purpose: Animation classes
4 // Author: Julian Smart and Guillermo Rodriguez Garcia
5 // Modified by: Francesco Montorsi
7 // Copyright: (c) Julian Smart and Guillermo Rodriguez Garcia
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_GTKANIMATEH__
12 #define _WX_GTKANIMATEH__
14 typedef struct _GdkPixbufAnimation GdkPixbufAnimation
;
15 typedef struct _GdkPixbufAnimationIter GdkPixbufAnimationIter
;
17 // ----------------------------------------------------------------------------
19 // Unlike the generic wxAnimation object (see generic\animate.cpp), we won't
20 // use directly wxAnimationHandlers as gdk-pixbuf already provides the
21 // concept of handler and will automatically use the available handlers.
22 // Like generic wxAnimation object, this implementation of wxAnimation is
23 // refcounted so that assignment is very fast
24 // ----------------------------------------------------------------------------
26 class WXDLLIMPEXP_ADV wxAnimation
: public wxAnimationBase
29 wxAnimation(const wxString
&name
, wxAnimationType type
= wxANIMATION_TYPE_ANY
)
30 : m_pixbuf(NULL
) { LoadFile(name
, type
); }
31 wxAnimation(GdkPixbufAnimation
*p
= NULL
);
32 wxAnimation(const wxAnimation
&);
33 ~wxAnimation() { UnRef(); }
35 wxAnimation
& operator= (const wxAnimation
&);
37 virtual bool IsOk() const
38 { return m_pixbuf
!= NULL
; }
41 // unfortunately GdkPixbufAnimation does not expose these info:
43 virtual unsigned int GetFrameCount() const { return 0; }
44 virtual wxImage
GetFrame(unsigned int frame
) const;
46 // we can retrieve the delay for a frame only after building
47 // a GdkPixbufAnimationIter...
48 virtual int GetDelay(unsigned int WXUNUSED(frame
)) const { return 0; }
50 virtual wxSize
GetSize() const;
52 virtual bool LoadFile(const wxString
&name
, wxAnimationType type
= wxANIMATION_TYPE_ANY
);
53 virtual bool Load(wxInputStream
&stream
, wxAnimationType type
= wxANIMATION_TYPE_ANY
);
56 public: // used by GTK callbacks
58 GdkPixbufAnimation
*GetPixbuf() const
60 void SetPixbuf(GdkPixbufAnimation
* p
);
63 GdkPixbufAnimation
*m_pixbuf
;
68 typedef wxAnimationBase base_type
;
69 DECLARE_DYNAMIC_CLASS(wxAnimation
)
73 // ----------------------------------------------------------------------------
75 // ----------------------------------------------------------------------------
77 // Resize to animation size if this is set
78 #define wxAN_FIT_ANIMATION 0x0010
80 class WXDLLIMPEXP_ADV wxAnimationCtrl
: public wxAnimationCtrlBase
83 wxAnimationCtrl() { Init(); }
84 wxAnimationCtrl(wxWindow
*parent
,
86 const wxAnimation
& anim
= wxNullAnimation
,
87 const wxPoint
& pos
= wxDefaultPosition
,
88 const wxSize
& size
= wxDefaultSize
,
89 long style
= wxAC_DEFAULT_STYLE
,
90 const wxString
& name
= wxAnimationCtrlNameStr
)
94 Create(parent
, id
, anim
, pos
, size
, style
, name
);
97 bool Create(wxWindow
*parent
, wxWindowID id
,
98 const wxAnimation
& anim
= wxNullAnimation
,
99 const wxPoint
& pos
= wxDefaultPosition
,
100 const wxSize
& size
= wxDefaultSize
,
101 long style
= wxAC_DEFAULT_STYLE
,
102 const wxString
& name
= wxAnimationCtrlNameStr
);
106 public: // event handler
108 void OnTimer(wxTimerEvent
&);
110 public: // public API
112 virtual bool LoadFile(const wxString
& filename
, wxAnimationType type
= wxANIMATION_TYPE_ANY
);
113 virtual bool Load(wxInputStream
& stream
, 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
;
149 DECLARE_DYNAMIC_CLASS(wxAnimationCtrl
)
150 DECLARE_EVENT_TABLE()
153 #endif // _WX_GTKANIMATEH__