]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/animate.i
handle mouse capture lost event in grid windows and reset the grid to normal state...
[wxWidgets.git] / wxPython / src / animate.i
CommitLineData
e19b9131
RD
1/////////////////////////////////////////////////////////////////////////////
2// Name: animate.i
3// Purpose: Wrappers for the animation classes in wx/contrib
4//
5// Author: Robin Dunn
6//
7// Created: 4-April-2005
8// RCS-ID: $Id$
9// Copyright: (c) 2005 by Total Control Software
10// Licence: wxWindows license
11/////////////////////////////////////////////////////////////////////////////
12
13%define DOCSTRING
14"Simple animation player classes, including `GIFAnimationCtrl` for displaying
15animated GIF files
16"
17%enddef
18
19%module(package="wx", docstring=DOCSTRING) animate
20
21
22%{
23#include "wx/wxPython/wxPython.h"
24#include "wx/wxPython/pyclasses.h"
25#include "wx/wxPython/pyistream.h"
26#include <wx/animate.h>
27%}
28
29//---------------------------------------------------------------------------
30
31%import core.i
32%pythoncode { import wx }
33%pythoncode { __docfilter__ = wx._core.__DocFilter(globals()) }
34
35
36MAKE_CONST_WXSTRING(AnimationCtrlNameStr);
37MAKE_CONST_WXSTRING_NOSWIG(EmptyString);
38
39//---------------------------------------------------------------------------
40
41enum wxAnimationDisposal
42{
43 // No disposal specified. The decoder is not required to take any action.
44 wxANIM_UNSPECIFIED = -1,
45
46 // Do not dispose. The graphic is to be left in place.
47 wxANIM_DONOTREMOVE = 0,
48
49 // Restore to background color. The area used by the graphic must be
50 // restored to the background color.
51 wxANIM_TOBACKGROUND = 1,
52
53 // Restore to previous. The decoder is required to restore the area
54 // overwritten by the graphic with what was there prior to rendering the graphic.
55 wxANIM_TOPREVIOUS = 2
56};
57
58enum wxAnimationType
59{
60 wxANIMATION_TYPE_INVALID,
61 wxANIMATION_TYPE_GIF,
62 wxANIMATION_TYPE_ANI,
63
64 wxANIMATION_TYPE_ANY
65};
66
67
68//---------------------------------------------------------------------------
69
70
71class wxAnimationBase : public wxObject
72{
73public:
74 //wxAnimationBase() {}; // It's an ABC
75 ~wxAnimationBase() {};
76
77 virtual bool IsOk() const;
78
79 // can be -1
16ba9ea8 80 virtual int GetDelay(int i) const;
e19b9131 81
16ba9ea8 82 virtual int GetFrameCount() const;
e19b9131
RD
83
84 %newobject GetFrame;
16ba9ea8 85 virtual wxImage GetFrame(int i) const;
e19b9131
RD
86 virtual wxSize GetSize() const;
87
88 virtual bool LoadFile(const wxString &name, wxAnimationType type = wxANIMATION_TYPE_ANY);
89 virtual bool Load(wxInputStream &stream, wxAnimationType type = wxANIMATION_TYPE_ANY);
90
91};
92
93
94
95
96class wxAnimation : public wxAnimationBase
97{
98public:
99 %nokwargs wxAnimation;
100 wxAnimation();
101 %extend {
102 wxAnimation(const wxString &name, wxAnimationType type = wxANIMATION_TYPE_ANY) {
103 wxAnimation* ani = new wxAnimation();
104 ani->LoadFile(name, type);
105 return ani;
106 }
107 }
108
109 ~wxAnimation();
110
111
112public: // extended interface used by the generic implementation of wxAnimationCtrl
113
114#ifndef __WXGTK__
16ba9ea8
RD
115 wxPoint GetFramePosition(int frame) const;
116 wxSize GetFrameSize(int frame) const;
117 wxAnimationDisposal GetDisposalMethod(int frame) const;
118 wxColour GetTransparentColour(int frame) const;
e19b9131
RD
119 wxColour GetBackgroundColour() const;
120#else
121 %extend {
16ba9ea8
RD
122 wxPoint GetFramePosition(int frame) const { return wxDefaultPosition; }
123 wxSize GetFrameSize(int frame) const { return wxDefaultSize; }
124 wxAnimationDisposal GetDisposalMethod(int frame) const { return wxANIM_UNSPECIFIED; }
125 wxColour GetTransparentColour(int frame) const { return wxNullColour; }
e19b9131
RD
126 wxColour GetBackgroundColour() const { return wxNullColour; }
127 }
128#endif
129
130// public:
131// static inline wxAnimationDecoderList& GetHandlers() { return sm_handlers; }
132// static void AddHandler(wxAnimationDecoder *handler);
133// static void InsertHandler(wxAnimationDecoder *handler);
134// static const wxAnimationDecoder *FindHandler( wxAnimationType animType );
135// static void CleanUpHandlers();
136// static void InitStandardHandlers();
137};
138
139
140
141%immutable;
142%threadWrapperOff;
143
144const wxAnimation wxNullAnimation;
145
146%threadWrapperOn;
147%mutable;
148
149
150
151%{// for backwards compatibility
152#ifndef wxAN_FIT_ANIMATION
153#define wxAN_FIT_ANIMATION 0x0010
154#endif
155%}
156
157
158enum {
159 wxAC_NO_AUTORESIZE,
160 wxAC_DEFAULT_STYLE,
161
162 wxAN_FIT_ANIMATION
163};
164
165
166class wxAnimationCtrlBase : public wxControl
167{
168public:
169 // wxAnimationCtrlBase() {} *** It's an ABC
170
171 virtual bool LoadFile(const wxString& filename, wxAnimationType type = wxANIMATION_TYPE_ANY);
172
173 virtual void SetAnimation(const wxAnimation &anim);
174 virtual wxAnimation GetAnimation() const;
175 %property(Animation, GetAnimation, SetAnimation);
176
177 virtual bool Play();
178 virtual void Stop();
179
180 virtual bool IsPlaying() const;
8e8d11ee
RD
181 virtual void SetInactiveBitmap(const wxBitmap &bmp);
182 wxBitmap GetInactiveBitmap() const;
183
184 %property(InactiveBitmap, GetInactiveBitmap, SetInactiveBitmap);
e19b9131
RD
185};
186
187
188
189MustHaveApp(wxAnimationCtrl);
190
191class wxAnimationCtrl: public wxAnimationCtrlBase
192{
193public:
194 %pythonAppend wxAnimationCtrl "self._setOORInfo(self)"
195 %pythonAppend wxAnimationCtrl() ""
196
197 wxAnimationCtrl(wxWindow *parent,
198 wxWindowID id=-1,
199 const wxAnimation& anim = wxNullAnimation,
200 const wxPoint& pos = wxDefaultPosition,
201 const wxSize& size = wxDefaultSize,
202 long style = wxAC_DEFAULT_STYLE,
203 const wxString& name = wxPyAnimationCtrlNameStr);
204
205 %RenameCtor(PreAnimationCtrl, wxAnimationCtrl());
206
207
208 bool Create(wxWindow *parent, wxWindowID id,
209 const wxAnimation& anim = wxNullAnimation,
210 const wxPoint& pos = wxDefaultPosition,
211 const wxSize& size = wxDefaultSize,
212 long style = wxAC_DEFAULT_STYLE,
213 const wxString& name = wxPyAnimationCtrlNameStr);
214
215
216
217
218public: // extended API specific to this implementation of wxAnimateCtrl
219
220#ifndef __WXGTK__
221 // Specify whether the animation's background colour is to be shown (the default),
222 // or whether the window background should show through
223 void SetUseWindowBackgroundColour(bool useWinBackground = true);
224 bool IsUsingWindowBackgroundColour() const;
225
226// // This overload of Play() lets you specify if the animation must loop or not
227// bool Play(bool looped);
228
229 // Draw the current frame of the animation into given DC.
230 // This is fast as current frame is always cached.
231 void DrawCurrentFrame(wxDC& dc);
232
233 // Returns a wxBitmap with the current frame drawn in it
234 wxBitmap& GetBackingStore();
235#else
236 %extend {
237 void SetUseWindowBackgroundColour(bool useWinBackground = true) {}
238 bool IsUsingWindowBackgroundColour() const { return false; }
239 void DrawCurrentFrame(wxDC& dc) {}
240 wxBitmap& GetBackingStore() { return wxNullBitmap; }
241 }
242#endif
243
244};
245
246
247
248%pythoncode {
249
250 class GIFAnimationCtrl(AnimationCtrl):
251 """
252 Backwards compatibility class for AnimationCtrl.
253 """
254 def __init__(self, parent, id=-1, filename="",
255 pos=wx.DefaultPosition, size=wx.DefaultSize,
256 style=AC_DEFAULT_STYLE,
257 name="gifAnimation"):
258 AnimationCtrl.__init__(self, parent, id, NullAnimation, pos, size, style, name)
259 self.LoadFile(filename)
260
261 def GetPlayer(self):
262 return self
263
264 def UseBackgroundColour(self, useBackground=True):
265 self.SetUseWindowBackgroundColour(useBackground)
266}
267
268//---------------------------------------------------------------------------
269//---------------------------------------------------------------------------
270