]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/animate.h
prefix implementation methods of wxBitmapButton with 'GTK' to prevent shadowing of...
[wxWidgets.git] / include / wx / gtk / animate.h
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
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart and Guillermo Rodriguez Garcia
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_GTKANIMATEH__
13 #define _WX_GTKANIMATEH__
14
15 typedef struct _GdkPixbufAnimation GdkPixbufAnimation;
16 typedef struct _GdkPixbufAnimationIter GdkPixbufAnimationIter;
17
18 // ----------------------------------------------------------------------------
19 // wxAnimation
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 // ----------------------------------------------------------------------------
26
27 class WXDLLIMPEXP_ADV wxAnimation : public wxAnimationBase
28 {
29 public:
30 wxAnimation(GdkPixbufAnimation *p = NULL);
31 wxAnimation(const wxAnimation&);
32 ~wxAnimation() { UnRef(); }
33
34 wxAnimation& operator= (const wxAnimation&);
35
36 virtual bool IsOk() const
37 { return m_pixbuf != NULL; }
38
39
40 // unfortunately GdkPixbufAnimation does not expose these info:
41
42 virtual unsigned int GetFrameCount() const { return 0; }
43 virtual wxImage GetFrame(unsigned int frame) const;
44
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; }
48
49 virtual wxSize GetSize() const;
50
51 virtual bool LoadFile(const wxString &name, wxAnimationType type = wxANIMATION_TYPE_ANY);
52 virtual bool Load(wxInputStream &stream, wxAnimationType type = wxANIMATION_TYPE_ANY);
53
54 // Implementation
55 public: // used by GTK callbacks
56
57 GdkPixbufAnimation *GetPixbuf() const
58 { return m_pixbuf; }
59 void SetPixbuf(GdkPixbufAnimation* p);
60
61 protected:
62 GdkPixbufAnimation *m_pixbuf;
63
64 private:
65 void UnRef();
66
67 typedef wxAnimationBase base_type;
68 DECLARE_DYNAMIC_CLASS(wxAnimation)
69 };
70
71
72 // ----------------------------------------------------------------------------
73 // wxAnimationCtrl
74 // ----------------------------------------------------------------------------
75
76 // Resize to animation size if this is set
77 #define wxAN_FIT_ANIMATION 0x0010
78
79 class WXDLLIMPEXP_ADV wxAnimationCtrl: public wxAnimationCtrlBase
80 {
81 public:
82 wxAnimationCtrl() { Init(); }
83 wxAnimationCtrl(wxWindow *parent,
84 wxWindowID id,
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)
90 {
91 Init();
92
93 Create(parent, id, anim, pos, size, style, name);
94 }
95
96 void Init();
97
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);
104
105 ~wxAnimationCtrl();
106
107 public: // event handler
108
109 void OnTimer(wxTimerEvent &);
110
111 public: // public API
112
113 virtual bool LoadFile(const wxString& filename, wxAnimationType type = wxANIMATION_TYPE_ANY);
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
126 protected:
127
128 virtual void DisplayStaticImage();
129 virtual wxSize DoGetBestSize() const;
130 void FitToAnimation();
131 void ClearToBackgroundColour();
132
133 void ResetAnim();
134 void ResetIter();
135
136 protected: // internal vars
137
138 GdkPixbufAnimation *m_anim;
139 GdkPixbufAnimationIter *m_iter;
140
141 wxTimer m_timer;
142 bool m_bPlaying;
143
144 private:
145 typedef wxAnimationCtrlBase base_type;
146 DECLARE_DYNAMIC_CLASS(wxAnimationCtrl)
147 DECLARE_EVENT_TABLE()
148 };
149
150 #endif // _WX_GTKANIMATEH__