42#include <OgreBitwise.h>
47SFlashWidget::SFlashWidget(
SScene* targetScene,
const std::string& flashWidgetName,
const int& xPos,
const int& yPos,
const unsigned short& widgetWidth,
const unsigned short& widgetHeight,
SViewPort* targetViewport,
const unsigned int& widgetZOrder) :
SWidget(targetScene, flashWidgetName, xPos, yPos, widgetWidth, widgetHeight, targetViewport, widgetZOrder, SO3_FLASH_WIDGET_TYPE)
54SFlashWidget::SFlashWidget(
SScene* targetScene,
const std::string& flashWidgetName,
const int& xPos,
const int& yPos,
const unsigned short& widgetWidth,
const unsigned short& widgetHeight,
SViewPort* targetViewport) :
SWidget(targetScene, flashWidgetName, xPos, yPos, widgetWidth, widgetHeight, targetViewport, SO3_FLASH_WIDGET_TYPE)
61SFlashWidget::SFlashWidget(
SScene* targetScene,
const std::string& flashWidgetName,
const unsigned short& widgetWidth,
const unsigned short& widgetHeight,
SMaterial* targetMaterial,
const unsigned short& targetTechnique,
const unsigned short& targetPass,
const unsigned short& targetTextureUnit) :
SWidget(targetScene, flashWidgetName, widgetWidth, widgetHeight, targetMaterial, targetTechnique, targetPass, targetTextureUnit, SO3_FLASH_WIDGET_TYPE)
86 IFlashControl::isOverlay = overlayedFlashControl;
100 IClassFactory* factory = 0;
101 GetClassObject getClassFunc = (GetClassObject)GetProcAddress(flashLib,
"DllGetClassObject");
102 HRESULT result = getClassFunc(ShockwaveFlashObjects::CLSID_ShockwaveFlash, IID_IClassFactory, (
void**)&factory);
103 if(SUCCEEDED(result))
106 factory->CreateInstance(NULL, IID_IOleObject, (
void**)&
oleObject);
114 HRESULT result = CoCreateInstance(ShockwaveFlashObjects::CLSID_ShockwaveFlash, 0, CLSCTX_INPROC_SERVER, IID_IOleObject, (
void**)&
oleObject);
116 OGRE_EXCEPT(Ogre::Exception::ERR_RT_ASSERTION_FAILED,
"Unable to load the Flash ActiveX control.",
"SFlashWidget::CommonConstructorSequence");
120 IOleClientSite* clientSite = 0;
125 IOleInPlaceObject* inPlaceObject = 0;
126 HRESULT result =
oleObject->QueryInterface(__uuidof(IOleInPlaceObject), (LPVOID*)&inPlaceObject);
128 OGRE_EXCEPT(Ogre::Exception::ERR_RT_ASSERTION_FAILED,
"Unable to load the Flash ActiveX control.",
"SFlashWidget::CommonConstructorSequence");
134 inPlaceObject->Release();
137 result =
oleObject->QueryInterface(__uuidof(ShockwaveFlashObjects::IShockwaveFlash), (LPVOID*)&
flashInterface);
139 OGRE_EXCEPT(Ogre::Exception::ERR_RT_ASSERTION_FAILED,
"Unable to load the Flash ActiveX control.",
"SFlashWidget::CommonConstructorSequence");
144 oleObject->DoVerb(OLEIVERB_INPLACEACTIVATE, 0, clientSite, 0, 0, 0);
145 clientSite->Release();
150 OGRE_EXCEPT(Ogre::Exception::ERR_RT_ASSERTION_FAILED,
"Unable to load the Flash ActiveX control.",
"SFlashWidget::CommonConstructorSequence");
157 IViewObject* curView = 0;
158 result =
flashInterface->QueryInterface(IID_IViewObject, (
void**)&curView);
160 OGRE_EXCEPT(Ogre::Exception::ERR_RT_ASSERTION_FAILED,
"Unable to load the Flash ActiveX control.",
"SFlashWidget::CommonConstructorSequence");
243 std::string urlString =
CheckUrl(url);
251 FILE* fileIndex = fopen((
char*)(file.c_str()),
"r");
262 OGRE_EXCEPT(Ogre::Exception::ERR_FILE_NOT_FOUND,
"Could not load '" + file +
"', the file was not found.",
"FlashControl::LoadFile");
323 return renderingQuality;
361ScolWindowHandle SFlashWidget::getTopWindow()
363 ScolWindowHandle olewin;
366 ScolWindowHandle oletop = GetWindow(olewin, GW_CHILD);
378 std::vector<wchar_t> functionNameUnicodeTab(functionName.length()+1);
379 int i = mbstowcs(&functionNameUnicodeTab[0], functionName.c_str(), functionName.length()+1);
380 const std::wstring functionNameUnicode = std::wstring(&functionNameUnicodeTab[0]);
384 std::vector<std::string>::const_iterator iArgumentList = argumentList.begin();
385 while (iArgumentList != argumentList.end())
387 std::string currentArgument = *iArgumentList;
388 std::vector<wchar_t> currentArgumentUnicodeTab(currentArgument.length()+1);
389 int i = mbstowcs(¤tArgumentUnicodeTab[0], currentArgument.c_str(), currentArgument.length()+1);
390 const std::wstring currentArgumentUnicode = std::wstring(¤tArgumentUnicodeTab[0]);
403 IFlashControl::keyBoardEnable = enableKeyboardOnWidget;
409 IFlashControl::mouseEnable = enableMouseOnWidget;
457 IOleInPlaceObject* inPlaceObject = 0;
458 oleObject->QueryInterface(__uuidof(IOleInPlaceObject), (LPVOID*)&inPlaceObject);
463 inPlaceObject->Release();
471 std::wstring funcName;
478 std::string invokeName;
479 invokeName.resize(funcName.size());
480 wcstombs(&invokeName[0], &funcName[0], funcName.size());
483 std::vector<std::string> arguments;
484 Hikari::Arguments::iterator iArguments = args.begin();
485 while(iArguments != args.end())
488 std::string argumentValue;
489 std::ostringstream oss;
490 switch((*iArguments).getType())
493 val =
static_cast<float> ((*iArguments).getNumber());
495 argumentValue = oss.str();
498 val =
static_cast<float>((*iArguments).getBool());
500 argumentValue = oss.str();
503 argumentValue = (*iArguments).getString();
506 std::wstring argumentValueUnicode = (*iArguments).getWString();
507 if (argumentValueUnicode.size() <= 0)
509 argumentValue.resize(argumentValueUnicode.size());
510 wcstombs(&argumentValue[0], &argumentValueUnicode[0], argumentValueUnicode.size());
515 arguments.push_back(argumentValue);
533 int dirtyBufSize = dirtyWidth * dirtyHeight * 4;
535 IViewObject* curView = 0;
536 flashInterface->QueryInterface(IID_IViewObject, (
void**)&curView);
541 if(!
mainContext || dirtyWidth != lastDirtyWidth || dirtyHeight != lastDirtyHeight)
569 lastDirtyWidth = dirtyWidth;
570 lastDirtyHeight = dirtyHeight;
572 HDC hdc = GetDC(NULL);
573 BITMAPINFOHEADER bih = {0};
574 bih.biSize =
sizeof(BITMAPINFOHEADER);
576 bih.biCompression = BI_RGB;
578 bih.biWidth = dirtyWidth;
579 bih.biHeight = -dirtyHeight;
582 mainBitmap = CreateDIBSection(hdc, (BITMAPINFO*)&bih, DIB_RGB_COLORS, (
void**)&
mainBuffer, 0, 0);
583 altBitmap = CreateDIBSection(hdc, (BITMAPINFO*)&bih, DIB_RGB_COLORS, (
void **)&
altBuffer, 0, 0);
600 OleDraw(curView, DVASPECT_TRANSPARENT,
mainContext, &local);
601 OleDraw(curView, DVASPECT_TRANSPARENT,
altContext, &local);
606 BYTE *blackBuffer, *whiteBuffer;
609 BYTE blackRed, whiteRed;
610 int size = dirtyWidth * dirtyHeight;
611 for(
int i = 0; i < size; i++)
613 blackRed = *blackBuffer;
614 whiteRed = *whiteBuffer;
617 *blackBuffer++ = (255 - (whiteRed - blackRed)) & 0xFF;
628 updateCurrentFrame =
true;
632 updateCurrentFrame =
true;
636 if(updateCurrentFrame)
639 Ogre::HardwarePixelBufferSharedPtr pixelBuffer =
renderingTexture->getBuffer();
640 pixelBuffer->lock(Ogre::HardwareBuffer::HBL_DISCARD);
641 const Ogre::PixelBox& pixelBox = pixelBuffer->getCurrentLock();
647 Ogre::Image::scale(scolPixelBox, pixelBox);
650 pixelBuffer->unlock();
691 IFlashControl::isTransparent = isWidgetTransparent;
692 if(isWidgetTransparent)
700 switch(renderQuality)
770 std::string stringFunctionName;
771 stringFunctionName.resize(funcName.size());
772 int ref = wcstombs(&stringFunctionName[0], &funcName[0], funcName.size());
773 OGRE_EXCEPT(Ogre::Exception::ERR_RT_ASSERTION_FAILED,
"Failed to call ActionScript function '" + stringFunctionName +
"' from FlashControl '" +
SWidget::name +
"'",
"SFlashWidget::callFunction");
803 ScolWindowHandle olewin = getTopWindow();
819 uScale = vScale = 1.0f;
830 windowlessObject->OnWindowMessage(WM_MOUSEMOVE, btn, MAKELPARAM(xPos, yPos), &result);
836 windowlessObject->OnWindowMessage(MouseButtonMessageConverter(index,
true), index, MAKELPARAM(xPos, yPos), &result);
842 windowlessObject->OnWindowMessage(MouseButtonMessageConverter(index,
false), index, MAKELPARAM(xPos, yPos), &result);
848 windowlessObject->OnWindowMessage(WM_MOUSEWHEEL, MAKEWPARAM(0, relScroll), MAKELPARAM(xPos, yPos), &result);
857UINT SFlashWidget::MouseButtonMessageConverter(
const int& button,
const bool& pressed)
859 UINT value = WM_NULL;
865 value = WM_LBUTTONDOWN;
868 value = WM_RBUTTONDOWN;
871 value = WM_MBUTTONDOWN;
880 value = WM_LBUTTONUP;
883 value = WM_RBUTTONUP;
886 value = WM_MBUTTONUP;
void setFlashControl(IFlashControl *flashControl)
static HikariManager & getSingleton()
static HikariManager * getSingletonPtr()
Hikari::Impl::RenderBuffer * renderBuffer
IOleInPlaceObjectWindowless * windowlessObject
ShockwaveFlashObjects::IShockwaveFlash * flashInterface
Hikari::Impl::FlashSite * site
Hikari::Impl::FlashHandler * handler
ULONG STDMETHODCALLTYPE Release()
HRESULT Init(IFlashControl *owner)
ULONG STDMETHODCALLTYPE AddRef()
ULONG STDMETHODCALLTYPE AddRef()
ULONG STDMETHODCALLTYPE Release()
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, LPVOID *ppv)
void Init(IFlashControl *owner, HWND hwnd)
unsigned char * getBuffer()
void copyArea(RECT srcRect, unsigned char *srcBuffer, int srcRowSpan)
FlashValue deserializeValue(const std::wstring &valueStr)
std::wstring serializeInvocation(const std::wstring &funcName, const Arguments &args)
bool deserializeInvocation(const std::wstring &xmlString, std::wstring &funcName, Arguments &args)
_HikariExport std::vector< FlashValue > Arguments
@ SO3_FLASH_SCALE_EXACTFIT
@ SO3_FLASH_SCALE_SHOWALL
@ SO3_FLASH_QUALITY_AUTOHIGH
@ SO3_FLASH_QUALITY_MEDIUM
@ SO3_FLASH_QUALITY_AUTOLOW