]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/animate.h
make wxTmemchr() return (and take) char* instead of void* in ANSI build too
[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:
1afdfc9d 30 wxAnimation(GdkPixbufAnimation *p = NULL);
c2f12218
PC
31 wxAnimation(const wxAnimation&);
32 ~wxAnimation() { UnRef(); }
33
34 wxAnimation& operator= (const wxAnimation&);
72045d57 35
72045d57
VZ
36 virtual bool IsOk() const
37 { return m_pixbuf != NULL; }
38
39
40 // unfortunately GdkPixbufAnimation does not expose these info:
41
870cf35c
VZ
42 virtual unsigned int GetFrameCount() const { return 0; }
43 virtual wxImage GetFrame(unsigned int frame) const;
72045d57
VZ
44
45 // we can retrieve the delay for a frame only after building
46 // a GdkPixbufAnimationIter...
870cf35c 47 virtual int GetDelay(unsigned int frame) const { return 0; }
72045d57 48
c2f12218 49 virtual wxSize GetSize() const;
72045d57
VZ
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
c2f12218 54 // Implementation
72045d57
VZ
55public: // used by GTK callbacks
56
57 GdkPixbufAnimation *GetPixbuf() const
58 { return m_pixbuf; }
c2f12218 59 void SetPixbuf(GdkPixbufAnimation* p);
72045d57
VZ
60
61protected:
62 GdkPixbufAnimation *m_pixbuf;
63
c2f12218
PC
64private:
65 void UnRef();
66
67 typedef wxAnimationBase base_type;
72045d57
VZ
68 DECLARE_DYNAMIC_CLASS(wxAnimation)
69};
70
71
72045d57
VZ
72// ----------------------------------------------------------------------------
73// wxAnimationCtrl
74// ----------------------------------------------------------------------------
75
76// Resize to animation size if this is set
77#define wxAN_FIT_ANIMATION 0x0010
78
79class WXDLLIMPEXP_ADV wxAnimationCtrl: public wxAnimationCtrlBase
80{
81public:
05a98b6d 82 wxAnimationCtrl() { Init(); }
72045d57
VZ
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 {
05a98b6d
RR
91 Init();
92
72045d57
VZ
93 Create(parent, id, anim, pos, size, style, name);
94 }
95
05a98b6d
RR
96 void Init();
97
72045d57
VZ
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
107public: // event handler
108
109 void OnTimer(wxTimerEvent &);
110
111public: // 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
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;
72045d57
VZ
146 DECLARE_DYNAMIC_CLASS(wxAnimationCtrl)
147 DECLARE_EVENT_TABLE()
148};
149
150#endif // _WX_GTKANIMATEH__