]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/animate.h
Fixes for semicolons, commas and wxSTRING_MAXLEN from Wlodek Szafran.
[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
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
c2f12218
PC
15typedef struct _GdkPixbufAnimation GdkPixbufAnimation;
16typedef struct _GdkPixbufAnimationIter GdkPixbufAnimationIter;
72045d57
VZ
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
a4adcc43 27class WXDLLIMPEXP_ADV wxAnimation : public wxAnimationBase
72045d57
VZ
28{
29public:
c2f12218
PC
30 wxAnimation(GdkPixbufAnimation *p = NULL) { m_pixbuf = p; }
31 wxAnimation(const wxAnimation&);
32 ~wxAnimation() { UnRef(); }
33
34 wxAnimation& operator= (const wxAnimation&);
72045d57
VZ
35
36 bool operator == (const wxAnimation& anim) const
37 { return m_pixbuf == anim.m_pixbuf; }
38 bool operator != (const wxAnimation& anim) const
39 { return m_pixbuf != anim.m_pixbuf; }
40
41 virtual bool IsOk() const
42 { return m_pixbuf != NULL; }
43
44
45 // unfortunately GdkPixbufAnimation does not expose these info:
46
47 virtual size_t GetFrameCount() const
48 { return 0; }
c2f12218 49 virtual wxImage GetFrame(size_t i) const;
72045d57
VZ
50
51 // we can retrieve the delay for a frame only after building
52 // a GdkPixbufAnimationIter...
53 virtual int GetDelay(size_t i) const
54 { return 0; }
55
c2f12218 56 virtual wxSize GetSize() const;
72045d57
VZ
57
58 virtual bool LoadFile(const wxString &name, wxAnimationType type = wxANIMATION_TYPE_ANY);
59 virtual bool Load(wxInputStream &stream, wxAnimationType type = wxANIMATION_TYPE_ANY);
60
c2f12218 61 // Implementation
72045d57
VZ
62public: // used by GTK callbacks
63
64 GdkPixbufAnimation *GetPixbuf() const
65 { return m_pixbuf; }
c2f12218 66 void SetPixbuf(GdkPixbufAnimation* p);
72045d57
VZ
67
68protected:
69 GdkPixbufAnimation *m_pixbuf;
70
c2f12218
PC
71private:
72 void UnRef();
73
74 typedef wxAnimationBase base_type;
72045d57
VZ
75 DECLARE_DYNAMIC_CLASS(wxAnimation)
76};
77
78
72045d57
VZ
79// ----------------------------------------------------------------------------
80// wxAnimationCtrl
81// ----------------------------------------------------------------------------
82
83// Resize to animation size if this is set
84#define wxAN_FIT_ANIMATION 0x0010
85
86class WXDLLIMPEXP_ADV wxAnimationCtrl: public wxAnimationCtrlBase
87{
88public:
05a98b6d 89 wxAnimationCtrl() { Init(); }
72045d57
VZ
90 wxAnimationCtrl(wxWindow *parent,
91 wxWindowID id,
92 const wxAnimation& anim = wxNullAnimation,
93 const wxPoint& pos = wxDefaultPosition,
94 const wxSize& size = wxDefaultSize,
95 long style = wxAC_DEFAULT_STYLE,
96 const wxString& name = wxAnimationCtrlNameStr)
97 {
05a98b6d
RR
98 Init();
99
72045d57
VZ
100 Create(parent, id, anim, pos, size, style, name);
101 }
102
05a98b6d
RR
103 void Init();
104
72045d57
VZ
105 bool Create(wxWindow *parent, wxWindowID id,
106 const wxAnimation& anim = wxNullAnimation,
107 const wxPoint& pos = wxDefaultPosition,
108 const wxSize& size = wxDefaultSize,
109 long style = wxAC_DEFAULT_STYLE,
110 const wxString& name = wxAnimationCtrlNameStr);
111
112 ~wxAnimationCtrl();
113
114public: // event handler
115
116 void OnTimer(wxTimerEvent &);
117
118public: // public API
119
120 virtual bool LoadFile(const wxString& filename, wxAnimationType type = wxANIMATION_TYPE_ANY);
121
122 virtual void SetAnimation(const wxAnimation &anim);
123 virtual wxAnimation GetAnimation() const
124 { return wxAnimation(m_anim); }
125
126 virtual bool Play();
127 virtual void Stop();
128
129 virtual bool IsPlaying() const;
130
131 bool SetBackgroundColour( const wxColour &colour );
8e458bb5 132 void SetInactiveBitmap(const wxBitmap &bmp);
72045d57
VZ
133
134protected:
135
136 virtual wxSize DoGetBestSize() const;
137 void FitToAnimation();
138 void ClearToBackgroundColour();
8e458bb5 139 void DisplayStaticImage();
72045d57 140
c2f12218
PC
141 void ResetAnim();
142 void ResetIter();
72045d57
VZ
143
144protected: // internal vars
145
146 GdkPixbufAnimation *m_anim;
147 GdkPixbufAnimationIter *m_iter;
148
149 wxTimer m_timer;
150 bool m_bPlaying;
151
152private:
c2f12218 153 typedef wxAnimationCtrlBase base_type;
72045d57
VZ
154 DECLARE_DYNAMIC_CLASS(wxAnimationCtrl)
155 DECLARE_EVENT_TABLE()
156};
157
158#endif // _WX_GTKANIMATEH__