]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/animate.h
and more inlines called before defined
[wxWidgets.git] / include / wx / generic / animate.h
CommitLineData
72045d57
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/generic/animate.h
3// Purpose: wxAnimation and wxAnimationCtrl
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_GENERIC_ANIMATEH__
13#define _WX_GENERIC_ANIMATEH__
14
72045d57
VZ
15// ----------------------------------------------------------------------------
16// wxAnimation
17// ----------------------------------------------------------------------------
18
e07c1146 19WX_DECLARE_LIST_WITH_DECL(wxAnimationDecoder, wxAnimationDecoderList, class WXDLLIMPEXP_ADV);
72045d57
VZ
20
21class WXDLLIMPEXP_ADV wxAnimation : public wxAnimationBase
22{
23public:
72045d57
VZ
24 bool operator == (const wxAnimation& anim) const
25 { return m_refData == anim.m_refData; }
26 bool operator != (const wxAnimation& anim) const
27 { return m_refData != anim.m_refData; }
28
29 bool IsOk() const
30 { return m_refData != NULL; }
31
32 size_t GetFrameCount() const;
33 int GetDelay(size_t i) const;
34 wxImage GetFrame(size_t i) const;
35 wxSize GetSize() const;
36
37 bool LoadFile(const wxString& filename, wxAnimationType type = wxANIMATION_TYPE_ANY);
38 bool Load(wxInputStream &stream, wxAnimationType type = wxANIMATION_TYPE_ANY);
39
40public: // extended interface used by the generic implementation of wxAnimationCtrl
41
42 wxPoint GetFramePosition(size_t frame) const;
43 wxAnimationDisposal GetDisposalMethod(size_t frame) const;
44 wxColour GetBackgroundColour() const;
45
46protected:
47 static wxAnimationDecoderList sm_handlers;
48
49public:
50 static inline wxAnimationDecoderList& GetHandlers() { return sm_handlers; }
51 static void AddHandler(wxAnimationDecoder *handler);
52 static void InsertHandler(wxAnimationDecoder *handler);
53 static const wxAnimationDecoder *FindHandler( wxAnimationType animType );
54
55 static void CleanUpHandlers();
56 static void InitStandardHandlers();
57
72045d57
VZ
58 DECLARE_DYNAMIC_CLASS(wxAnimation)
59};
60
61
62// ----------------------------------------------------------------------------
63// wxAnimationCtrl
64// ----------------------------------------------------------------------------
65
66class WXDLLIMPEXP_ADV wxAnimationCtrl: public wxAnimationCtrlBase
67{
68public:
c2f12218 69 wxAnimationCtrl();
72045d57
VZ
70 wxAnimationCtrl(wxWindow *parent,
71 wxWindowID id,
72 const wxAnimation& anim = wxNullAnimation,
73 const wxPoint& pos = wxDefaultPosition,
74 const wxSize& size = wxDefaultSize,
75 long style = wxAC_DEFAULT_STYLE,
76 const wxString& name = wxAnimationCtrlNameStr)
77 {
78 Create(parent, id, anim, pos, size, style, name);
79 }
80
81 bool Create(wxWindow *parent, wxWindowID id,
82 const wxAnimation& anim = wxNullAnimation,
83 const wxPoint& pos = wxDefaultPosition,
84 const wxSize& size = wxDefaultSize,
85 long style = wxAC_DEFAULT_STYLE,
86 const wxString& name = wxAnimationCtrlNameStr);
87
88 ~wxAnimationCtrl();
89
90public:
91 virtual bool LoadFile(const wxString& filename, wxAnimationType type = wxANIMATION_TYPE_ANY);
92
93 virtual void Stop();
94 virtual bool Play()
95 { return Play(true /* looped */); }
96 virtual bool IsPlaying() const
97 { return m_isPlaying; }
98
99 void SetAnimation(const wxAnimation &animation);
100 wxAnimation GetAnimation() const
101 { return m_animation; }
102
103public: // event handlers
104
105 void OnPaint(wxPaintEvent& event);
106 void OnTimer(wxTimerEvent& event);
107 void OnSize(wxSizeEvent& event);
108
109public: // extended API specific to this implementation of wxAnimateCtrl
110
111 // Specify whether the animation's background colour is to be shown (the default),
112 // or whether the window background should show through
113 void SetUseWindowBackgroundColour(bool useWinBackground = true)
114 { m_useWinBackgroundColour = useWinBackground; }
115 bool IsUsingWindowBackgroundColour() const
116 { return m_useWinBackgroundColour; }
117
118 // This overload of Play() lets you specify if the animation must loop or not
119 bool Play(bool looped);
120
121 // Draw the current frame of the animation into given DC.
122 // This is fast as current frame is always cached.
123 void DrawCurrentFrame(wxDC& dc);
124
125 // Returns a wxBitmap with the current frame drawn in it
126 wxBitmap& GetBackingStore()
127 { return m_backingStore; }
128
129protected: // internal utilities
130
131 // resize this control to fit m_animation
132 void FitToAnimation();
133
134 // Draw the background; use this when e.g. previous frame had wxANIM_TOBACKGROUND disposal.
135 void DisposeToBackground(wxDC& dc);
136
137 void IncrementalUpdateBackingStore();
138 void RebuildBackingStoreUpToFrame(size_t);
139 void DrawFrame(wxDC &dc, size_t);
140
141 virtual wxSize DoGetBestSize() const;
142
143protected:
144 size_t m_currentFrame; // Current frame
145 bool m_looped; // Looped, or not
146 wxTimer m_timer; // The timer
147 wxAnimation m_animation; // The animation
148
149 bool m_isPlaying; // Is the animation playing?
150 bool m_useWinBackgroundColour; // Use animation bg colour or window bg colour?
151
152 wxBitmap m_backingStore; // The frames are drawn here and then blitted
153 // on the screen
154
155private:
c2f12218 156 typedef wxAnimationCtrlBase base_type;
72045d57
VZ
157 DECLARE_DYNAMIC_CLASS(wxAnimationCtrl)
158 DECLARE_EVENT_TABLE()
159};
160
161#endif // _WX_GENERIC_ANIMATEH__