]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/animate.i
use "StrokeLineSegements" for the second overload of StrokeLines
[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
80 virtual int GetDelay(size_t i) const;
81
82 virtual size_t GetFrameCount() const;
83
84 %newobject GetFrame;
85 virtual wxImage GetFrame(size_t i) const;
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__
115 wxPoint GetFramePosition(size_t frame) const;
116 wxAnimationDisposal GetDisposalMethod(size_t frame) const;
117 wxColour GetBackgroundColour() const;
118#else
119 %extend {
120 wxPoint GetFramePosition(size_t frame) const { return wxDefaultPosition; }
121 wxAnimationDisposal GetDisposalMethod(size_t frame) const { return wxANIM_UNSPECIFIED; }
122 wxColour GetBackgroundColour() const { return wxNullColour; }
123 }
124#endif
125
126// public:
127// static inline wxAnimationDecoderList& GetHandlers() { return sm_handlers; }
128// static void AddHandler(wxAnimationDecoder *handler);
129// static void InsertHandler(wxAnimationDecoder *handler);
130// static const wxAnimationDecoder *FindHandler( wxAnimationType animType );
131// static void CleanUpHandlers();
132// static void InitStandardHandlers();
133};
134
135
136
137%immutable;
138%threadWrapperOff;
139
140const wxAnimation wxNullAnimation;
141
142%threadWrapperOn;
143%mutable;
144
145
146
147%{// for backwards compatibility
148#ifndef wxAN_FIT_ANIMATION
149#define wxAN_FIT_ANIMATION 0x0010
150#endif
151%}
152
153
154enum {
155 wxAC_NO_AUTORESIZE,
156 wxAC_DEFAULT_STYLE,
157
158 wxAN_FIT_ANIMATION
159};
160
161
162class wxAnimationCtrlBase : public wxControl
163{
164public:
165 // wxAnimationCtrlBase() {} *** It's an ABC
166
167 virtual bool LoadFile(const wxString& filename, wxAnimationType type = wxANIMATION_TYPE_ANY);
168
169 virtual void SetAnimation(const wxAnimation &anim);
170 virtual wxAnimation GetAnimation() const;
171 %property(Animation, GetAnimation, SetAnimation);
172
173 virtual bool Play();
174 virtual void Stop();
175
176 virtual bool IsPlaying() const;
177};
178
179
180
181MustHaveApp(wxAnimationCtrl);
182
183class wxAnimationCtrl: public wxAnimationCtrlBase
184{
185public:
186 %pythonAppend wxAnimationCtrl "self._setOORInfo(self)"
187 %pythonAppend wxAnimationCtrl() ""
188
189 wxAnimationCtrl(wxWindow *parent,
190 wxWindowID id=-1,
191 const wxAnimation& anim = wxNullAnimation,
192 const wxPoint& pos = wxDefaultPosition,
193 const wxSize& size = wxDefaultSize,
194 long style = wxAC_DEFAULT_STYLE,
195 const wxString& name = wxPyAnimationCtrlNameStr);
196
197 %RenameCtor(PreAnimationCtrl, wxAnimationCtrl());
198
199
200 bool Create(wxWindow *parent, wxWindowID id,
201 const wxAnimation& anim = wxNullAnimation,
202 const wxPoint& pos = wxDefaultPosition,
203 const wxSize& size = wxDefaultSize,
204 long style = wxAC_DEFAULT_STYLE,
205 const wxString& name = wxPyAnimationCtrlNameStr);
206
207
208
209
210public: // extended API specific to this implementation of wxAnimateCtrl
211
212#ifndef __WXGTK__
213 // Specify whether the animation's background colour is to be shown (the default),
214 // or whether the window background should show through
215 void SetUseWindowBackgroundColour(bool useWinBackground = true);
216 bool IsUsingWindowBackgroundColour() const;
217
218// // This overload of Play() lets you specify if the animation must loop or not
219// bool Play(bool looped);
220
221 // Draw the current frame of the animation into given DC.
222 // This is fast as current frame is always cached.
223 void DrawCurrentFrame(wxDC& dc);
224
225 // Returns a wxBitmap with the current frame drawn in it
226 wxBitmap& GetBackingStore();
227#else
228 %extend {
229 void SetUseWindowBackgroundColour(bool useWinBackground = true) {}
230 bool IsUsingWindowBackgroundColour() const { return false; }
231 void DrawCurrentFrame(wxDC& dc) {}
232 wxBitmap& GetBackingStore() { return wxNullBitmap; }
233 }
234#endif
235
236};
237
238
239
240%pythoncode {
241
242 class GIFAnimationCtrl(AnimationCtrl):
243 """
244 Backwards compatibility class for AnimationCtrl.
245 """
246 def __init__(self, parent, id=-1, filename="",
247 pos=wx.DefaultPosition, size=wx.DefaultSize,
248 style=AC_DEFAULT_STYLE,
249 name="gifAnimation"):
250 AnimationCtrl.__init__(self, parent, id, NullAnimation, pos, size, style, name)
251 self.LoadFile(filename)
252
253 def GetPlayer(self):
254 return self
255
256 def UseBackgroundColour(self, useBackground=True):
257 self.SetUseWindowBackgroundColour(useBackground)
258}
259
260//---------------------------------------------------------------------------
261//---------------------------------------------------------------------------
262