]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/generic/animate.h
add HDF_SORTUP/DOWN definitions
[wxWidgets.git] / include / wx / generic / animate.h
... / ...
CommitLineData
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
15#include "wx/bitmap.h"
16
17// ----------------------------------------------------------------------------
18// wxAnimation
19// ----------------------------------------------------------------------------
20
21WX_DECLARE_LIST_WITH_DECL(wxAnimationDecoder, wxAnimationDecoderList, class WXDLLIMPEXP_ADV);
22
23class WXDLLIMPEXP_ADV wxAnimation : public wxAnimationBase
24{
25public:
26 virtual bool IsOk() const
27 { return m_refData != NULL; }
28
29 virtual unsigned int GetFrameCount() const;
30 virtual int GetDelay(unsigned int i) const;
31 virtual wxImage GetFrame(unsigned int i) const;
32 virtual wxSize GetSize() const;
33
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);
38
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;
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
58 DECLARE_DYNAMIC_CLASS(wxAnimation)
59};
60
61
62// ----------------------------------------------------------------------------
63// wxAnimationCtrl
64// ----------------------------------------------------------------------------
65
66class WXDLLIMPEXP_ADV wxAnimationCtrl: public wxAnimationCtrlBase
67{
68public:
69 wxAnimationCtrl() { Init(); }
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 Init();
79
80 Create(parent, id, anim, pos, size, style, name);
81 }
82
83 void Init();
84
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
107 virtual void SetInactiveBitmap(const wxBitmap &bmp);
108
109 // override base class method
110 virtual bool SetBackgroundColour(const wxColour& col);
111
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.
144 void DisposeToBackground();
145 void DisposeToBackground(wxDC& dc);
146 void DisposeToBackground(wxDC& dc, const wxPoint &pos, const wxSize &sz);
147
148 void IncrementalUpdateBackingStore();
149 bool RebuildBackingStoreUpToFrame(unsigned int);
150 void DrawFrame(wxDC &dc, unsigned int);
151
152 virtual void DisplayStaticImage();
153 virtual wxSize DoGetBestSize() const;
154
155protected:
156 unsigned int m_currentFrame; // Current frame
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:
168 typedef wxAnimationCtrlBase base_type;
169 DECLARE_DYNAMIC_CLASS(wxAnimationCtrl)
170 DECLARE_EVENT_TABLE()
171};
172
173#endif // _WX_GENERIC_ANIMATEH__