]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/animate.h
Don't define __STRICT_ANSI__, we should build both with and without it.
[wxWidgets.git] / include / wx / gtk / animate.h
CommitLineData
72045d57
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/gtk/animate.h
3// Purpose: Animation classes
4// Author: Julian Smart and Guillermo Rodriguez Garcia
5// Modified by: Francesco Montorsi
6// Created: 13/8/99
72045d57
VZ
7// Copyright: (c) Julian Smart and Guillermo Rodriguez Garcia
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_GTKANIMATEH__
12#define _WX_GTKANIMATEH__
13
c2f12218
PC
14typedef struct _GdkPixbufAnimation GdkPixbufAnimation;
15typedef struct _GdkPixbufAnimationIter GdkPixbufAnimationIter;
72045d57
VZ
16
17// ----------------------------------------------------------------------------
18// wxAnimation
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// ----------------------------------------------------------------------------
25
a4adcc43 26class WXDLLIMPEXP_ADV wxAnimation : public wxAnimationBase
72045d57
VZ
27{
28public:
70f9d2be
FM
29 wxAnimation(const wxString &name, wxAnimationType type = wxANIMATION_TYPE_ANY)
30 : m_pixbuf(NULL) { LoadFile(name, type); }
1afdfc9d 31 wxAnimation(GdkPixbufAnimation *p = NULL);
c2f12218
PC
32 wxAnimation(const wxAnimation&);
33 ~wxAnimation() { UnRef(); }
34
35 wxAnimation& operator= (const wxAnimation&);
72045d57 36
72045d57
VZ
37 virtual bool IsOk() const
38 { return m_pixbuf != NULL; }
39
40
41 // unfortunately GdkPixbufAnimation does not expose these info:
42
870cf35c 43 virtual unsigned int GetFrameCount() const { return 0; }
a8ed16c9 44 virtual wxImage GetFrame(unsigned int frame) const;
72045d57
VZ
45
46 // we can retrieve the delay for a frame only after building
47 // a GdkPixbufAnimationIter...
e4161a2a 48 virtual int GetDelay(unsigned int WXUNUSED(frame)) const { return 0; }
72045d57 49
c2f12218 50 virtual wxSize GetSize() const;
72045d57
VZ
51
52 virtual bool LoadFile(const wxString &name, wxAnimationType type = wxANIMATION_TYPE_ANY);
53 virtual bool Load(wxInputStream &stream, wxAnimationType type = wxANIMATION_TYPE_ANY);
54
c2f12218 55 // Implementation
72045d57
VZ
56public: // used by GTK callbacks
57
58 GdkPixbufAnimation *GetPixbuf() const
59 { return m_pixbuf; }
c2f12218 60 void SetPixbuf(GdkPixbufAnimation* p);
72045d57
VZ
61
62protected:
63 GdkPixbufAnimation *m_pixbuf;
64
c2f12218
PC
65private:
66 void UnRef();
67
68 typedef wxAnimationBase base_type;
72045d57
VZ
69 DECLARE_DYNAMIC_CLASS(wxAnimation)
70};
71
72
72045d57
VZ
73// ----------------------------------------------------------------------------
74// wxAnimationCtrl
75// ----------------------------------------------------------------------------
76
77// Resize to animation size if this is set
78#define wxAN_FIT_ANIMATION 0x0010
79
80class WXDLLIMPEXP_ADV wxAnimationCtrl: public wxAnimationCtrlBase
81{
82public:
05a98b6d 83 wxAnimationCtrl() { Init(); }
72045d57
VZ
84 wxAnimationCtrl(wxWindow *parent,
85 wxWindowID id,
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)
91 {
05a98b6d
RR
92 Init();
93
72045d57
VZ
94 Create(parent, id, anim, pos, size, style, name);
95 }
96
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);
103
104 ~wxAnimationCtrl();
105
106public: // event handler
107
108 void OnTimer(wxTimerEvent &);
109
110public: // public API
111
112 virtual bool LoadFile(const wxString& filename, wxAnimationType type = wxANIMATION_TYPE_ANY);
462167a9 113 virtual bool Load(wxInputStream& stream, wxAnimationType type = wxANIMATION_TYPE_ANY);
72045d57
VZ
114
115 virtual void SetAnimation(const wxAnimation &anim);
116 virtual wxAnimation GetAnimation() const
117 { return wxAnimation(m_anim); }
118
119 virtual bool Play();
120 virtual void Stop();
121
122 virtual bool IsPlaying() const;
123
124 bool SetBackgroundColour( const wxColour &colour );
125
126protected:
127
1bd2ceb5 128 virtual void DisplayStaticImage();
72045d57
VZ
129 virtual wxSize DoGetBestSize() const;
130 void FitToAnimation();
131 void ClearToBackgroundColour();
132
c2f12218
PC
133 void ResetAnim();
134 void ResetIter();
72045d57
VZ
135
136protected: // internal vars
137
138 GdkPixbufAnimation *m_anim;
139 GdkPixbufAnimationIter *m_iter;
140
141 wxTimer m_timer;
142 bool m_bPlaying;
143
144private:
c2f12218 145 typedef wxAnimationCtrlBase base_type;
95dc31e0
PC
146
147 void Init();
148
72045d57
VZ
149 DECLARE_DYNAMIC_CLASS(wxAnimationCtrl)
150 DECLARE_EVENT_TABLE()
151};
152
153#endif // _WX_GTKANIMATEH__