]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/animate.h
return const wxString& from wxFontMapper::GetDefaultConfigPath()
[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
42eba912
PC
15#include "wx/bitmap.h"
16
72045d57
VZ
17// ----------------------------------------------------------------------------
18// wxAnimation
19// ----------------------------------------------------------------------------
20
e07c1146 21WX_DECLARE_LIST_WITH_DECL(wxAnimationDecoder, wxAnimationDecoderList, class WXDLLIMPEXP_ADV);
72045d57
VZ
22
23class WXDLLIMPEXP_ADV wxAnimation : public wxAnimationBase
24{
25public:
8d1517ce 26 virtual bool IsOk() const
72045d57
VZ
27 { return m_refData != NULL; }
28
870cf35c
VZ
29 virtual unsigned int GetFrameCount() const;
30 virtual int GetDelay(unsigned int i) const;
31 virtual wxImage GetFrame(unsigned int i) const;
8d1517ce 32 virtual wxSize GetSize() const;
72045d57 33
8d1517ce
VZ
34 virtual bool LoadFile(const wxString& filename,
35 wxAnimationType type = wxANIMATION_TYPE_ANY);
36 virtual bool Load(wxInputStream& stream,
37 wxAnimationType type = wxANIMATION_TYPE_ANY);
72045d57 38
870cf35c
VZ
39 // extended interface used by the generic implementation of wxAnimationCtrl
40 wxPoint GetFramePosition(unsigned int frame) const;
41 wxSize GetFrameSize(unsigned int frame) const;
42 wxAnimationDisposal GetDisposalMethod(unsigned int frame) const;
43 wxColour GetTransparentColour(unsigned int frame) const;
72045d57
VZ
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:
05a98b6d 69 wxAnimationCtrl() { Init(); }
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 {
05a98b6d
RR
78 Init();
79
72045d57
VZ
80 Create(parent, id, anim, pos, size, style, name);
81 }
82
05a98b6d
RR
83 void Init();
84
72045d57
VZ
85 bool Create(wxWindow *parent, 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
92 ~wxAnimationCtrl();
93
94public:
95 virtual bool LoadFile(const wxString& filename, wxAnimationType type = wxANIMATION_TYPE_ANY);
96
97 virtual void Stop();
98 virtual bool Play()
99 { return Play(true /* looped */); }
100 virtual bool IsPlaying() const
101 { return m_isPlaying; }
102
103 void SetAnimation(const wxAnimation &animation);
104 wxAnimation GetAnimation() const
105 { return m_animation; }
106
1bd2ceb5 107 virtual void SetInactiveBitmap(const wxBitmap &bmp);
8e458bb5 108
1afdfc9d
VZ
109 // override base class method
110 virtual bool SetBackgroundColour(const wxColour& col);
111
72045d57
VZ
112public: // event handlers
113
114 void OnPaint(wxPaintEvent& event);
115 void OnTimer(wxTimerEvent& event);
116 void OnSize(wxSizeEvent& event);
117
118public: // extended API specific to this implementation of wxAnimateCtrl
119
120 // Specify whether the animation's background colour is to be shown (the default),
121 // or whether the window background should show through
122 void SetUseWindowBackgroundColour(bool useWinBackground = true)
123 { m_useWinBackgroundColour = useWinBackground; }
124 bool IsUsingWindowBackgroundColour() const
125 { return m_useWinBackgroundColour; }
126
127 // This overload of Play() lets you specify if the animation must loop or not
128 bool Play(bool looped);
129
130 // Draw the current frame of the animation into given DC.
131 // This is fast as current frame is always cached.
132 void DrawCurrentFrame(wxDC& dc);
133
134 // Returns a wxBitmap with the current frame drawn in it
135 wxBitmap& GetBackingStore()
136 { return m_backingStore; }
137
138protected: // internal utilities
139
140 // resize this control to fit m_animation
141 void FitToAnimation();
142
143 // Draw the background; use this when e.g. previous frame had wxANIM_TOBACKGROUND disposal.
8e458bb5 144 void DisposeToBackground();
72045d57 145 void DisposeToBackground(wxDC& dc);
05a98b6d 146 void DisposeToBackground(wxDC& dc, const wxPoint &pos, const wxSize &sz);
72045d57
VZ
147
148 void IncrementalUpdateBackingStore();
870cf35c
VZ
149 bool RebuildBackingStoreUpToFrame(unsigned int);
150 void DrawFrame(wxDC &dc, unsigned int);
72045d57 151
1bd2ceb5 152 virtual void DisplayStaticImage();
72045d57
VZ
153 virtual wxSize DoGetBestSize() const;
154
155protected:
870cf35c 156 unsigned int m_currentFrame; // Current frame
72045d57
VZ
157 bool m_looped; // Looped, or not
158 wxTimer m_timer; // The timer
159 wxAnimation m_animation; // The animation
160
161 bool m_isPlaying; // Is the animation playing?
162 bool m_useWinBackgroundColour; // Use animation bg colour or window bg colour?
163
164 wxBitmap m_backingStore; // The frames are drawn here and then blitted
165 // on the screen
166
167private:
c2f12218 168 typedef wxAnimationCtrlBase base_type;
72045d57
VZ
169 DECLARE_DYNAMIC_CLASS(wxAnimationCtrl)
170 DECLARE_EVENT_TABLE()
171};
172
173#endif // _WX_GENERIC_ANIMATEH__