2
This file is part of Hikari, a library that allows developers
3
to use Flash in their Ogre3D applications.
5
Copyright (C) 2008 Adam J. Simmons
7
This library is free software; you can redistribute it and/or
8
modify it under the terms of the GNU Lesser General Public
9
License as published by the Free Software Foundation; either
10
version 2.1 of the License, or (at your option) any later version.
12
This library is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
Lesser General Public License for more details.
17
You should have received a copy of the GNU Lesser General Public
18
License along with this library; if not, write to the Free Software
19
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22
#ifndef __FlashControl_H__
23
#define __FlashControl_H__
26
#include "FlashValue.h"
29
namespace ShockwaveFlashObjects
31
struct IShockwaveFlash;
34
class IOleInPlaceObjectWindowless;
44
* Used by FlashControl::setQuality, defines the Flash rendering quality.
47
* <li>RQ_LOW - Favors playback speed over appearance and never uses anti-aliasing.
48
* <li>RQ_MEDIUM - Applies some anti-aliasing and does not smooth bitmaps. It produces a better quality than the Low setting, but lower quality than the High setting.
49
* <li>RQ_HIGH - Favors appearance over playback speed and always applies anti-aliasing. If the movie does not contain animation, bitmaps are smoothed; if the movie has animation, bitmaps are not smoothed.
50
* <li>RQ_BEST - Provides the best display quality and does not consider playback speed. All output is anti-aliased and all bitmaps are smoothed.
51
* <li>RQ_AUTOLOW - Emphasizes speed at first but improves appearance whenever possible. Playback begins with anti-aliasing turned off. If the Flash Player detects that the processor can handle it, anti-aliasing is turned on.
52
* <li>RQ_AUTOHIGH - Emphasizes playback speed and appearance equally at first but sacrifices appearance for playback speed if necessary. Playback begins with anti-aliasing turned on. If the actual frame rate drops below the specified frame rate, anti-aliasing is turned off to improve playback speed.
66
* Used by FlashControl::setScaleMode, defines the scaling mode to use when the aspect ratio of the control does not match that of the movie.
69
* <li>SM_SHOWALL - Preserves the movie's aspect ratio by adding borders. (Default)
70
* <li>SM_NOBORDER - Preserves the movie's aspect ratio by cropping the sides.
71
* <li>SM_EXACTFIT - Does not preserve the movie's aspect ratio, scales the movie to the dimensions of the control.
81
typedef MyGUI::delegates::CDelegate3<HikariWidget*, const Arguments&, FlashValue&> FlashDelegate;
84
* The FlashControl class is an instance of the Flash Player that is rendered dynamically to a texture and
85
* wrapped in an optional movable overlay using the Ogre3D engine.
89
friend class FlashSite;
90
friend class FlashHandler;
93
FlashControl(HikariWidget* _owner, HMODULE _lib);
97
* Loads a movie (a .swf file) into this FlashControl and begins playing.
99
* @param movieFilename The filename of the movie to load.
101
* @note The specified movie should reside in the "assetsDirectory" that
102
* was declared when the HikariManager was instantiated.
104
void load(const std::string& movieFilename);
107
* Sets whether or not the currently-loaded movie should use a
108
* transparent background instead of the default background-color.
110
* @param isTransparent Whether or not the movie should use "transparent" rendering.
111
* @param useAlphaHack With some Flash versions, there are certain glitches with
112
* transparent rendering (usually with text and aliased geometry).
113
* Set this parameter to 'true' to use an alternative alpha-rendering
114
* hack that may mitigate these issues at the cost of some performance.
116
void setTransparent(bool isTransparent);
119
* Sets the Flash rendering quality for the currently-loaded movie.
121
* @param renderQuality The RenderQuality to use.
123
void setQuality(short renderQuality);
126
* Sets the scaling mode to use when the aspect ratio of the movie and control do not match.
128
* @param scaleMode The ScaleMode to use.
130
void setScaleMode(short scaleMode);
133
* Injects a mouse-move event into this FlashControl (in the control's local coordinate-space).
135
* @param xPos The local X-coordinate.
136
* @param yPos The local Y-coordinate.
138
void injectMouseMove(int xPos, int yPos);
141
* Injects a mouse-down event into this FlashControl (in the control's local coordinate-space).
143
* @param xPos The local X-coordinate.
144
* @param yPos The local Y-coordinate.
146
void injectMouseDown(int xPos, int yPos);
149
* Injects a mouse-up event into this FlashControl (in the control's local coordinate-space).
151
* @param xPos The local X-coordinate.
152
* @param yPos The local Y-coordinate.
154
void injectMouseUp(int xPos, int yPos);
157
* Injects a mouse-wheel event into this FlashControl (in the control's local coordinate-space).
159
* @param relScroll The relative scroll amount of the mouse-wheel.
160
* @param xPos The local X-coordinate of the mouse.
161
* @param yPos The local Y-coordinate of the mouse.
163
void injectMouseWheel(int relScroll, int xPos, int yPos);
166
* Binds a local callback to a certain function name so that your Flash movie can call the function
167
* from ActionScript using ExternalInterface.call('functionName').
169
* @param funcName The name to bind this callback to.
170
* @param callback The local function to call, see below for examples of declaring a FlashDelegate.
173
* // Example declaration of a compatible function (static function):
174
* FlashValue myStaticFunction(FlashControl* caller, const Arguments& args)
176
* // Handle the callback here
180
* // Example declaration of a compatible function (member function):
181
* FlashValue MyClass::myMemberFunction(FlashControl* caller, const Arguments& args)
183
* // Handle the callback here
184
* return "Some return value!";
187
* // FlashDelegate (member function) instantiation:
188
* FlashDelegate callback(this, &MyClass::myMemberFunction); // within a class
189
* FlashDelegate callback2(pointerToClassInstance, &MyClass::myMemberFunction);
191
* // FlashDelegate (static function) instantiation:
192
* FlashDelegate callback(&myStaticFunction);
195
void bind(const MyGUI::UString& funcName, FlashDelegate::IDelegate* callback);
198
* Un-binds the specified callback.
200
* @param funcName The name that the callback was bound to.
202
void unbind(const MyGUI::UString& funcName);
205
* Attempts to call a function declared as a callback in the ActionScript of the currently-loaded movie.
207
* @param funcName The name of the callback that was declared using 'ExternalInterface.addCallback(funcName, function)'
208
* in the ActionScript of the currently-loaded movie.
209
* @param args The arguments to pass to the ActionScript function.
211
* @return If the invocation was successful and the ActionScript function returned a value, returns a FlashValue with a non-null type.
213
* @note It is highly recommended to use the 'Args(arg1)(arg2)(arg3)...' helper class to pass arguments.
216
FlashValue callFunction(MyGUI::UString funcName, const Arguments& args = Args());
218
void setSize(int _width, int _height);
224
int getHeight() const
229
void invalidateTotally();
232
ShockwaveFlashObjects::IShockwaveFlash* getFlashInterface()
234
return flashInterface;
237
void handleKeyEvent(UINT msg, WPARAM wParam, LPARAM lParam);
240
void createControl(HMODULE _lib);
241
void handleFlashCall(const std::wstring& xmlString);
245
FlashHandler* handler;
246
ShockwaveFlashObjects::IShockwaveFlash* flashInterface;
247
IOleObject* oleObject;
248
IOleInPlaceObjectWindowless* windowlessObject;
253
HDC mainContext, altContext;
254
HBITMAP mainBitmap, altBitmap;
255
BYTE* mainBuffer, *altBuffer;
256
RenderBuffer* renderBuffer;
258
bool isClean, isTotallyDirty;
262
HikariWidget* mOwner;
264
typedef std::map<MyGUI::UString, FlashDelegate> DelegateMap;
265
typedef DelegateMap::iterator DelegateIter;
266
DelegateMap delegateMap;
2
This file is part of Hikari, a library that allows developers
3
to use Flash in their Ogre3D applications.
5
Copyright (C) 2008 Adam J. Simmons
7
This library is free software; you can redistribute it and/or
8
modify it under the terms of the GNU Lesser General Public
9
License as published by the Free Software Foundation; either
10
version 2.1 of the License, or (at your option) any later version.
12
This library is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
Lesser General Public License for more details.
17
You should have received a copy of the GNU Lesser General Public
18
License along with this library; if not, write to the Free Software
19
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22
#ifndef __FlashControl_H__
23
#define __FlashControl_H__
26
#include "FlashValue.h"
29
namespace ShockwaveFlashObjects
31
struct IShockwaveFlash;
34
class IOleInPlaceObjectWindowless;
44
* Used by FlashControl::setQuality, defines the Flash rendering quality.
47
* <li>RQ_LOW - Favors playback speed over appearance and never uses anti-aliasing.
48
* <li>RQ_MEDIUM - Applies some anti-aliasing and does not smooth bitmaps. It produces a better quality than the Low setting, but lower quality than the High setting.
49
* <li>RQ_HIGH - Favors appearance over playback speed and always applies anti-aliasing. If the movie does not contain animation, bitmaps are smoothed; if the movie has animation, bitmaps are not smoothed.
50
* <li>RQ_BEST - Provides the best display quality and does not consider playback speed. All output is anti-aliased and all bitmaps are smoothed.
51
* <li>RQ_AUTOLOW - Emphasizes speed at first but improves appearance whenever possible. Playback begins with anti-aliasing turned off. If the Flash Player detects that the processor can handle it, anti-aliasing is turned on.
52
* <li>RQ_AUTOHIGH - Emphasizes playback speed and appearance equally at first but sacrifices appearance for playback speed if necessary. Playback begins with anti-aliasing turned on. If the actual frame rate drops below the specified frame rate, anti-aliasing is turned off to improve playback speed.
66
* Used by FlashControl::setScaleMode, defines the scaling mode to use when the aspect ratio of the control does not match that of the movie.
69
* <li>SM_SHOWALL - Preserves the movie's aspect ratio by adding borders. (Default)
70
* <li>SM_NOBORDER - Preserves the movie's aspect ratio by cropping the sides.
71
* <li>SM_EXACTFIT - Does not preserve the movie's aspect ratio, scales the movie to the dimensions of the control.
81
typedef MyGUI::delegates::CDelegate3<HikariWidget*, const Arguments&, FlashValue&> FlashDelegate;
84
* The FlashControl class is an instance of the Flash Player that is rendered dynamically to a texture and
85
* wrapped in an optional movable overlay using the Ogre3D engine.
89
friend class FlashSite;
90
friend class FlashHandler;
93
FlashControl(HikariWidget* _owner, HMODULE _lib);
97
* Loads a movie (a .swf file) into this FlashControl and begins playing.
99
* @param movieFilename The filename of the movie to load.
101
* @note The specified movie should reside in the "assetsDirectory" that
102
* was declared when the HikariManager was instantiated.
104
void load(const std::string& movieFilename);
107
* Sets whether or not the currently-loaded movie should use a
108
* transparent background instead of the default background-color.
110
* @param isTransparent Whether or not the movie should use "transparent" rendering.
111
* @param useAlphaHack With some Flash versions, there are certain glitches with
112
* transparent rendering (usually with text and aliased geometry).
113
* Set this parameter to 'true' to use an alternative alpha-rendering
114
* hack that may mitigate these issues at the cost of some performance.
116
void setTransparent(bool isTransparent);
119
* Sets the Flash rendering quality for the currently-loaded movie.
121
* @param renderQuality The RenderQuality to use.
123
void setQuality(short renderQuality);
126
* Sets the scaling mode to use when the aspect ratio of the movie and control do not match.
128
* @param scaleMode The ScaleMode to use.
130
void setScaleMode(short scaleMode);
133
* Injects a mouse-move event into this FlashControl (in the control's local coordinate-space).
135
* @param xPos The local X-coordinate.
136
* @param yPos The local Y-coordinate.
138
void injectMouseMove(int xPos, int yPos);
141
* Injects a mouse-down event into this FlashControl (in the control's local coordinate-space).
143
* @param xPos The local X-coordinate.
144
* @param yPos The local Y-coordinate.
146
void injectMouseDown(int xPos, int yPos);
149
* Injects a mouse-up event into this FlashControl (in the control's local coordinate-space).
151
* @param xPos The local X-coordinate.
152
* @param yPos The local Y-coordinate.
154
void injectMouseUp(int xPos, int yPos);
157
* Injects a mouse-wheel event into this FlashControl (in the control's local coordinate-space).
159
* @param relScroll The relative scroll amount of the mouse-wheel.
160
* @param xPos The local X-coordinate of the mouse.
161
* @param yPos The local Y-coordinate of the mouse.
163
void injectMouseWheel(int relScroll, int xPos, int yPos);
166
* Binds a local callback to a certain function name so that your Flash movie can call the function
167
* from ActionScript using ExternalInterface.call('functionName').
169
* @param funcName The name to bind this callback to.
170
* @param callback The local function to call, see below for examples of declaring a FlashDelegate.
173
* // Example declaration of a compatible function (static function):
174
* FlashValue myStaticFunction(FlashControl* caller, const Arguments& args)
176
* // Handle the callback here
180
* // Example declaration of a compatible function (member function):
181
* FlashValue MyClass::myMemberFunction(FlashControl* caller, const Arguments& args)
183
* // Handle the callback here
184
* return "Some return value!";
187
* // FlashDelegate (member function) instantiation:
188
* FlashDelegate callback(this, &MyClass::myMemberFunction); // within a class
189
* FlashDelegate callback2(pointerToClassInstance, &MyClass::myMemberFunction);
191
* // FlashDelegate (static function) instantiation:
192
* FlashDelegate callback(&myStaticFunction);
195
void bind(const MyGUI::UString& funcName, FlashDelegate::IDelegate* callback);
198
* Un-binds the specified callback.
200
* @param funcName The name that the callback was bound to.
202
void unbind(const MyGUI::UString& funcName);
205
* Attempts to call a function declared as a callback in the ActionScript of the currently-loaded movie.
207
* @param funcName The name of the callback that was declared using 'ExternalInterface.addCallback(funcName, function)'
208
* in the ActionScript of the currently-loaded movie.
209
* @param args The arguments to pass to the ActionScript function.
211
* @return If the invocation was successful and the ActionScript function returned a value, returns a FlashValue with a non-null type.
213
* @note It is highly recommended to use the 'Args(arg1)(arg2)(arg3)...' helper class to pass arguments.
216
FlashValue callFunction(MyGUI::UString funcName, const Arguments& args = Args());
218
void setSize(int _width, int _height);
224
int getHeight() const
229
void invalidateTotally();
232
ShockwaveFlashObjects::IShockwaveFlash* getFlashInterface()
234
return flashInterface;
237
void handleKeyEvent(UINT msg, WPARAM wParam, LPARAM lParam);
240
void createControl(HMODULE _lib);
241
void handleFlashCall(const std::wstring& xmlString);
245
FlashHandler* handler;
246
ShockwaveFlashObjects::IShockwaveFlash* flashInterface;
247
IOleObject* oleObject;
248
IOleInPlaceObjectWindowless* windowlessObject;
253
HDC mainContext, altContext;
254
HBITMAP mainBitmap, altBitmap;
255
BYTE* mainBuffer, *altBuffer;
256
RenderBuffer* renderBuffer;
258
bool isClean, isTotallyDirty;
262
HikariWidget* mOwner;
264
typedef std::map<MyGUI::UString, FlashDelegate> DelegateMap;
265
typedef DelegateMap::iterator DelegateIter;
266
DelegateMap delegateMap;