Project

General

Profile

SO3Engine
SO3FlashWidget.cpp
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OpenSpace3D
4For the latest info, see http://www.openspace3d.com
5
6Copyright (c) 2012 I-maginer
7
8This program is free software; you can redistribute it and/or modify it under
9the terms of the GNU Lesser General Public License as published by the Free Software
10Foundation; either version 2 of the License, or (at your option) any later
11version.
12
13This program is distributed in the hope that it will be useful, but WITHOUT
14ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16
17You should have received a copy of the GNU Lesser General Public License along with
18this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20http://www.gnu.org/copyleft/lesser.txt
21
22-----------------------------------------------------------------------------
23*/
24
37#include "SO3Renderer/SO3Root.h"
42#include <OgreBitwise.h>
43
44namespace SO3
45{
46
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)
48{
52}
53
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)
55{
59}
60
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)
62{
66}
67
68void SFlashWidget::CommonConstructorSequence(const bool& overlayedFlashControl)
69{
70 okayToDelete = false;
71 lastDirtyWidth = 0;
72 lastDirtyHeight = 0;
73 isTotallyDirty = false;
74 isInputListener = true;
75 isVisible = true;
76 comCount = 0;
81
82 // Make sure that IFlashControl and SWidget internal variable are synchronized.
83 IFlashControl::name = SWidget::name;
84 IFlashControl::width = SWidget::width;
85 IFlashControl::height = SWidget::height;
86 IFlashControl::isOverlay = overlayedFlashControl;
87
88 // Create the render buffer.
91 site->AddRef();
92 site->Init(this, NULL);
93
94 // Get a reference to the Flash ocx
96
97 // Try to load Flash ocx from our SO3 flash.ocx supplied file
98 if(flashLib)
99 {
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))
104 {
105 // Create the flash instance
106 factory->CreateInstance(NULL, IID_IOleObject, (void**)&oleObject);
107 factory->Release();
108 }
109 }
110
111 // If we still don't have the object, try loading the "ocx" from registry
112 if(!oleObject)
113 {
114 HRESULT result = CoCreateInstance(ShockwaveFlashObjects::CLSID_ShockwaveFlash, 0, CLSCTX_INPROC_SERVER, IID_IOleObject, (void**)&oleObject);
115 if(FAILED(result))
116 OGRE_EXCEPT(Ogre::Exception::ERR_RT_ASSERTION_FAILED, "Unable to load the Flash ActiveX control.", "SFlashWidget::CommonConstructorSequence");
117 }
118
119 // Need comments here...
120 IOleClientSite* clientSite = 0;
121 site->QueryInterface(__uuidof(IOleClientSite), (void**)&clientSite);
122 oleObject->SetClientSite(clientSite);
123
124 // Need comments here...
125 IOleInPlaceObject* inPlaceObject = 0;
126 HRESULT result = oleObject->QueryInterface(__uuidof(IOleInPlaceObject), (LPVOID*)&inPlaceObject);
127 if(FAILED(result))
128 OGRE_EXCEPT(Ogre::Exception::ERR_RT_ASSERTION_FAILED, "Unable to load the Flash ActiveX control.", "SFlashWidget::CommonConstructorSequence");
129
130 if(inPlaceObject)
131 {
133 inPlaceObject->SetObjectRects(&dirtyBounds, &dirtyBounds);
134 inPlaceObject->Release();
135 }
136
137 result = oleObject->QueryInterface(__uuidof(ShockwaveFlashObjects::IShockwaveFlash), (LPVOID*)&flashInterface);
138 if(FAILED(result))
139 OGRE_EXCEPT(Ogre::Exception::ERR_RT_ASSERTION_FAILED, "Unable to load the Flash ActiveX control.", "SFlashWidget::CommonConstructorSequence");
140
141 flashInterface->PutWMode("opaque");
142
143 // show the object and switch it to its running state.
144 oleObject->DoVerb(OLEIVERB_INPLACEACTIVATE, 0, clientSite, 0, 0, 0);
145 clientSite->Release();
146
147 // A windowless control is created, the container needs the IOleInPlaceObjectWindowless interface to dispatch messages to the object because the object does not have its own window.
148 result = oleObject->QueryInterface(__uuidof(IOleInPlaceObjectWindowless), (LPVOID*)&windowlessObject);
149 if(FAILED(result))
150 OGRE_EXCEPT(Ogre::Exception::ERR_RT_ASSERTION_FAILED, "Unable to load the Flash ActiveX control.", "SFlashWidget::CommonConstructorSequence");
151
152 // Flashhandler inherits from _IShockwaveFlashEvents, that permits to receive fscommand() events from the Flash movie.
154 handler->AddRef();
155 handler->Init(this);
156
157 IViewObject* curView = 0;
158 result = flashInterface->QueryInterface(IID_IViewObject, (void**)&curView);
159 if(FAILED(result))
160 OGRE_EXCEPT(Ogre::Exception::ERR_RT_ASSERTION_FAILED, "Unable to load the Flash ActiveX control.", "SFlashWidget::CommonConstructorSequence");
161
162 curView->Release();
163
164 // Enable keyboard and mouse
165 SetKeyboardEnable(true);
166 SetMouseEnable(true);
167
168 // To enable update, we have to had this instance to HikariManager list.
170}
171
173{
174 // Delete this instance from HikariManager list.
175 okayToDelete = true;
177
178 if(altContext)
179 {
180 SelectObject(altContext, hOldAltBmp);
181 DeleteDC(altContext);
182 altContext = 0;
183 }
184
185 if(altBitmap)
186 {
187 DeleteObject(altBitmap);
188 altBitmap = 0;
189 }
190
191 if(mainContext)
192 {
193 SelectObject(mainContext, hOldMainBmp);
194 DeleteDC(mainContext);
195 mainContext = 0;
196 }
197
198 if(mainBitmap)
199 {
200 DeleteObject(mainBitmap);
201 mainBitmap = 0;
202 }
203
204 // Delete Hikari's stuff instances. Cannot use "delete" due to the ugly implementation, so, meanwhile an ole expert comes here, there's memory leaks here...
206 {
207 windowlessObject->Release();
209 }
210
212 {
213 flashInterface->Release();
214 flashInterface = 0;
215 }
216
217 if(handler)
218 {
219 handler->Shutdown();
220 handler->Release();
221 handler = 0;
222 }
223
224 if(oleObject)
225 {
226 oleObject->Close(OLECLOSE_NOSAVE);
228 oleObject = 0;
229 }
230
231 if(site)
232 {
233 site->Release();
234 site = 0;
235 }
236
237 // Free render buffer memory
238 SO3_SAFE_DELETE(renderBuffer);
239}
240
241void SFlashWidget::LoadURL(const std::string& url)
242{
243 std::string urlString = CheckUrl(url);
245 flashInterface->PutMovie(urlString.c_str());
247}
248
249void SFlashWidget::LoadFile(const std::string& file)
250{
251 FILE* fileIndex = fopen((char*)(file.c_str()), "r");
252 if(fileIndex)
253 {
254 fclose(fileIndex);
256 flashInterface->PutMovie((char*)(file.c_str()));
258 }
259 else
260 {
262 OGRE_EXCEPT(Ogre::Exception::ERR_FILE_NOT_FOUND, "Could not load '" + file + "', the file was not found.", "FlashControl::LoadFile");
263 }
264}
265
266void SFlashWidget::InjectMouseMove(const int& xPos, const int& yPos, const MouseButtonId& button)
267{
268 injectMouseMove(xPos, yPos, static_cast<int> (button));
269}
270
271void SFlashWidget::InjectMouseWheel(const int& scrollX, const int& scrollY, const int& relativeScroll)
272{
273 injectMouseWheel(relativeScroll, scrollX, scrollY);
274}
275
276void SFlashWidget::InjectMouseDown(const int& xPos, const int& yPos, const MouseButtonId& button)
277{
278 injectMouseDown(xPos, yPos, static_cast<int> (button));
279}
280
281void SFlashWidget::InjectMouseUp(const int& xPos, const int& yPos, const MouseButtonId& button)
282{
283 injectMouseUp(xPos, yPos, static_cast<int> (button));
284}
285
286void SFlashWidget::InjectTouchAdd(const int& xPos, const int& yPos, const int& touchid)
287{
288 // Nothing to do
289}
290
291void SFlashWidget::InjectTouchRemove(const int& touchid)
292{
293 // Nothing to do
294}
295
296void SFlashWidget::InjectTouchUpdate(const int& xPos, const int& yPos, const int& vx, const int& vy, const int& touchid)
297{
298 // Nothing to do
299}
300
301void SFlashWidget::InjectKeyEvent(const UINT& msg, const ScolWindowHandle& hwnd, const WPARAM& wParam, const LPARAM& lParam)
302{
303 handleKeyEvent(msg, wParam, lParam);
304}
305
306void SFlashWidget::InjectTextEvent(const std::string& utf8)
307{
308}
309
310void SFlashWidget::SetFocusImpl(const bool& focusOnWidget)
311{
312 if (focusOnWidget)
313 focus();
314}
315
316void SFlashWidget::SetTransparencyImpl(const bool& enableTransparency)
317{
318 setTransparent(enableTransparency, enableTransparency);
319}
320
322{
323 return renderingQuality;
324}
325
327{
328 setQuality(newQuality);
329}
330
332{
333 play();
334}
335
337{
338 stop();
339}
340
342{
343 rewind();
344}
345
346void SFlashWidget::Seek(const long& seekFrame)
347{
348 gotoFrame(seekFrame);
349}
350
351void SFlashWidget::SetScaleMode(const FlashScaleMode& widgetScaleMode)
352{
353 setScaleMode(static_cast<short>(widgetScaleMode));
354}
355
357{
358 return scaleMode;
359}
360
361ScolWindowHandle SFlashWidget::getTopWindow()
362{
363 ScolWindowHandle olewin;
364 windowlessObject->GetWindow(&olewin);
365
366 ScolWindowHandle oletop = GetWindow(olewin, GW_CHILD);
367 if (oletop)
368 return oletop;
369 else
370 return olewin;
371}
372
373void SFlashWidget::RunScriptFunction(const std::string& functionName, const std::vector<std::string>& argumentList)
374{
375 string argumentStr;
376
377 // Convert function name to unicode.
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]);
381
382 // Convert each argument to unicode, and add to Hikari argument list.
383 Hikari::Arguments hikariArgumentList;
384 std::vector<std::string>::const_iterator iArgumentList = argumentList.begin();
385 while (iArgumentList != argumentList.end())
386 {
387 std::string currentArgument = *iArgumentList;
388 std::vector<wchar_t> currentArgumentUnicodeTab(currentArgument.length()+1);
389 int i = mbstowcs(&currentArgumentUnicodeTab[0], currentArgument.c_str(), currentArgument.length()+1);
390 const std::wstring currentArgumentUnicode = std::wstring(&currentArgumentUnicodeTab[0]);
391 hikariArgumentList.push_back(Hikari::FlashValue(currentArgumentUnicode));
392
393 iArgumentList++;
394 }
395
396 // Call action script function
397 // TODO if (isLoaded)
398 callFunction(functionNameUnicode, hikariArgumentList);
399}
400
401void SFlashWidget::SetKeyboardEnableImpl(const bool& enableKeyboardOnWidget)
402{
403 IFlashControl::keyBoardEnable = enableKeyboardOnWidget;
404 isBlocked = !enableKeyboardOnWidget;
405}
406
407void SFlashWidget::SetMouseEnableImpl(const bool& enableMouseOnWidget)
408{
409 IFlashControl::mouseEnable = enableMouseOnWidget;
410}
411
412void SFlashWidget::SetSizeImpl(const unsigned short& newWidth, const unsigned short& newHeight)
413{
414 SO3_SAFE_DELETE(renderBuffer);
415 renderBuffer = new Hikari::Impl::RenderBuffer(newWidth, newHeight);
417}
418
419void SFlashWidget::setZOrder(unsigned short zorder)
420{
421 // Nothing to do
422}
423
425{
426 // Nothing to do
427 return 0;
428}
429
431{
432 // Nothing to do
433 return -1;
434}
435
437{
438 // Nothing to do
439 return -1;
440}
441
442bool SFlashWidget::isPointOverMe(int screenX, int screenY)
443{
444 // Nothing to do
445 return false;
446}
447
449{
450 isClean = false;
451 isTotallyDirty = true;
452 dirtyBounds.left = 0;
453 dirtyBounds.top = 0;
454 dirtyBounds.right = IFlashControl::width = SWidget::width;
455 dirtyBounds.bottom = IFlashControl::height = SWidget::height;
456
457 IOleInPlaceObject* inPlaceObject = 0;
458 oleObject->QueryInterface(__uuidof(IOleInPlaceObject), (LPVOID*)&inPlaceObject);
459
460 if(inPlaceObject)
461 {
462 inPlaceObject->SetObjectRects(&dirtyBounds, &dirtyBounds);
463 inPlaceObject->Release();
464 }
465
467}
468
469void SFlashWidget::handleFlashCall(const std::wstring& xmlString)
470{
471 std::wstring funcName;
473
474 if(!Hikari::Impl::deserializeInvocation(xmlString, funcName, args))
475 return;
476
477 // Convert function name.
478 std::string invokeName;
479 invokeName.resize(funcName.size());
480 wcstombs(&invokeName[0], &funcName[0], funcName.size());
481
482 // Convert each argument value to string
483 std::vector<std::string> arguments;
484 Hikari::Arguments::iterator iArguments = args.begin();
485 while(iArguments != args.end())
486 {
487 float val;
488 std::string argumentValue;
489 std::ostringstream oss;
490 switch((*iArguments).getType())
491 {
493 val = static_cast<float> ((*iArguments).getNumber());
494 oss << val;
495 argumentValue = oss.str();
496 break;
498 val = static_cast<float>((*iArguments).getBool());
499 oss << val;
500 argumentValue = oss.str();
501 break;
503 argumentValue = (*iArguments).getString();
504 break;
506 std::wstring argumentValueUnicode = (*iArguments).getWString();
507 if (argumentValueUnicode.size() <= 0)
508 break;
509 argumentValue.resize(argumentValueUnicode.size());
510 wcstombs(&argumentValue[0], &argumentValueUnicode[0], argumentValueUnicode.size());
511 break;
512 }
513
514 // Add to list, and convert next argument
515 arguments.push_back(argumentValue);
516 iArguments++;
517 }
518
519 // Structure containing action script function information
520 SScriptFunction functionCalled(invokeName.c_str(), arguments);
521
522 // Send event information
524}
525
527{
529 return;
530
531 int dirtyWidth = dirtyBounds.right - dirtyBounds.left;
532 int dirtyHeight = dirtyBounds.bottom - dirtyBounds.top;
533 int dirtyBufSize = dirtyWidth * dirtyHeight * 4;
534
535 IViewObject* curView = 0;
536 flashInterface->QueryInterface(IID_IViewObject, (void**)&curView);
537
538 if(!oleObject || !curView)
539 return;
540
541 if(!mainContext || dirtyWidth != lastDirtyWidth || dirtyHeight != lastDirtyHeight)
542 {
543 if(altContext)
544 {
545 SelectObject(altContext, hOldAltBmp);
546 DeleteDC(altContext);
547 altContext = 0;
548 }
549
550 if(altBitmap)
551 {
552 DeleteObject(altBitmap);
553 altBitmap = 0;
554 }
555
556 if(mainContext)
557 {
558 SelectObject(mainContext, hOldMainBmp);
559 DeleteDC(mainContext);
560 mainContext = 0;
561 }
562
563 if(mainBitmap)
564 {
565 DeleteObject(mainBitmap);
566 mainBitmap = 0;
567 }
568
569 lastDirtyWidth = dirtyWidth;
570 lastDirtyHeight = dirtyHeight;
571
572 HDC hdc = GetDC(NULL);
573 BITMAPINFOHEADER bih = {0};
574 bih.biSize = sizeof(BITMAPINFOHEADER);
575 bih.biBitCount = 32;
576 bih.biCompression = BI_RGB;
577 bih.biPlanes = 1;
578 bih.biWidth = dirtyWidth;
579 bih.biHeight = -dirtyHeight;
580 mainContext = CreateCompatibleDC(hdc);
581 altContext = CreateCompatibleDC(hdc);
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);
584
585 hOldMainBmp = SelectObject(mainContext, mainBitmap);
586 hOldAltBmp = SelectObject(altContext, altBitmap);
587
588 ReleaseDC(0, hdc);
589 }
590
591 RECT local;
592 local.left = -dirtyBounds.left;
593 local.top = -dirtyBounds.top;
594 local.right = local.left + dirtyBounds.right;
595 local.bottom = local.top + dirtyBounds.bottom;
596
597 memset(mainBuffer, 0, dirtyBufSize);
598 memset(altBuffer, 255, dirtyBufSize);
599
600 OleDraw(curView, DVASPECT_TRANSPARENT, mainContext, &local);
601 OleDraw(curView, DVASPECT_TRANSPARENT, altContext, &local);
602
603 // We've rendered the dirty area twice: once on black and once
604 // on white. Now we compare the red channels of each to determine
605 // the alpha value of each pixel.
606 BYTE *blackBuffer, *whiteBuffer;
607 blackBuffer = mainBuffer;
608 whiteBuffer = altBuffer;
609 BYTE blackRed, whiteRed;
610 int size = dirtyWidth * dirtyHeight;
611 for(int i = 0; i < size; i++)
612 {
613 blackRed = *blackBuffer;
614 whiteRed = *whiteBuffer;
615 blackBuffer += 3;
616 whiteBuffer += 4;
617 *blackBuffer++ = (255 - (whiteRed - blackRed)) & 0xFF;
618 }
619
620 renderBuffer->copyArea(dirtyBounds, mainBuffer, dirtyWidth * 4);
621
622 bool updateCurrentFrame = forceRenderingUpdate;
623 if(GetVisible())
624 {
626 {
627 if(HasFocus())
628 updateCurrentFrame = true;
629 }
630 else
631 {
632 updateCurrentFrame = true;
633 }
634 }
635
636 if(updateCurrentFrame)
637 {
638 // Lock the pixel buffer and get a pixel box
639 Ogre::HardwarePixelBufferSharedPtr pixelBuffer = renderingTexture->getBuffer();
640 pixelBuffer->lock(Ogre::HardwareBuffer::HBL_DISCARD);
641 const Ogre::PixelBox& pixelBox = pixelBuffer->getCurrentLock();
642
643 // Create an Ogre pixel box with flash data for easy streching.
644 const Ogre::PixelBox scolPixelBox(renderBuffer->width, renderBuffer->height, 1, Ogre::PF_BYTE_BGRA, renderBuffer->getBuffer());
645
646 // Streching flash bitmap data to Ogre texture size. Nb that the scale function takes an optional filter parameter if we wants other filtering than bilinear
647 Ogre::Image::scale(scolPixelBox, pixelBox);
648
649 // No mipmap generation with widget.
650 pixelBuffer->unlock();
651 }
652
653 curView->Release();
654 isClean = true;
655 isTotallyDirty = false;
656 forceRenderingUpdate = false;
657}
658
659void SFlashWidget::load(const std::string& movieFilename, Hikari::HikariManager* hikariMgr, int type)
660{
661 // Nothing to do
662}
663
665{
666 flashInterface->Play();
667}
668
670{
671 flashInterface->Stop();
672}
673
675{
676 flashInterface->Rewind();
677}
678
679void SFlashWidget::gotoFrame(long frameNum)
680{
681 flashInterface->raw_GotoFrame(frameNum);
682}
683
684void SFlashWidget::setLoop(bool shouldLoop)
685{
686 flashInterface->PutLoop(shouldLoop);
687}
688
689void SFlashWidget::setTransparent(bool isWidgetTransparent, bool useAlphaHack)
690{
691 IFlashControl::isTransparent = isWidgetTransparent;
692 if(isWidgetTransparent)
693 flashInterface->PutWMode("transparent");
694 else
695 flashInterface->PutWMode("opaque");
696}
697
698void SFlashWidget::setQuality(short renderQuality)
699{
700 switch(renderQuality)
701 {
703 flashInterface->PutQuality2("low");
704 break;
706 flashInterface->PutQuality2("medium");
707 break;
709 flashInterface->PutQuality2("high");
710 break;
712 flashInterface->PutQuality2("best");
713 break;
715 flashInterface->PutQuality2("autolow");
716 break;
718 flashInterface->PutQuality2("autohigh");
719 break;
720 }
721 renderingQuality = static_cast <FlashRenderQuality> (renderQuality);
722}
723
724void SFlashWidget::setScaleMode(short widgetScaleMode)
725{
726 flashInterface->PutScaleMode(widgetScaleMode);
727 scaleMode = static_cast <FlashScaleMode> (widgetScaleMode);
728
729 //TODO updateTexture();
730}
731
732void SFlashWidget::setDraggable(bool widgetDraggable)
733{
734 // Nothing to do
735}
736
737void SFlashWidget::setIgnoreTransparentPixels(bool shouldIgnore, float threshold)
738{
739 // Nothing to do
740}
741
742const std::string& SFlashWidget::getName() const
743{
744 return SData::name;
745}
746
747const std::string& SFlashWidget::getMaterialName() const
748{
749 // TODO
750 return SData::name;
751}
752
753void SFlashWidget::bind(const std::wstring& funcName, const Hikari::FlashDelegate& callback)
754{
755 // Nothing to do
756}
757
758void SFlashWidget::unbind(const std::wstring& funcName)
759{
760 // Nothing to do
761}
762
763Hikari::FlashValue SFlashWidget::callFunction(const std::wstring& funcName, const Hikari::Arguments& args)
764{
765 BSTR returnVal = 0;
766 HRESULT result = flashInterface->raw_CallFunction(_bstr_t(Hikari::Impl::serializeInvocation(funcName, args).c_str()), &returnVal);
767 if(FAILED(result))
768 {
769 // Convert function name.
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");
774 }
775
776 if (returnVal == 0)
777 return FLASH_VOID;
778 else
779 return Hikari::Impl::deserializeValue((wchar_t*)returnVal);
780}
781
783{
784 // Nothing to do
785}
786
788{
789 // Nothing to do
790}
791
793{
794 return const_cast<SFlashWidget*> (this)->GetVisible();
795}
796
797void SFlashWidget::setOpacity(float opacity)
798{
799}
800
802{
803 ScolWindowHandle olewin = getTopWindow();
804 SetFocus(olewin);
805}
806
807void SFlashWidget::move(int deltaX, int deltaY)
808{
809 // Nothing to do
810}
811
812void SFlashWidget::getExtents(unsigned short& width, unsigned short& height) const
813{
814 // Nothing to do
815}
816
817void SFlashWidget::getUVScale(float& uScale, float& vScale) const
818{
819 uScale = vScale = 1.0f;
820 if(IsCompensateNPOT())
821 {
822 uScale = (float)SWidget::width/(float)mTextureWidth;
823 vScale = (float)SWidget::height/(float)mTextureHeight;
824 }
825}
826
827void SFlashWidget::injectMouseMove(int xPos, int yPos, int btn)
828{
829 LRESULT result;
830 windowlessObject->OnWindowMessage(WM_MOUSEMOVE, btn, MAKELPARAM(xPos, yPos), &result);
831}
832
833void SFlashWidget::injectMouseDown(int xPos, int yPos, int index)
834{
835 LRESULT result;
836 windowlessObject->OnWindowMessage(MouseButtonMessageConverter(index, true), index, MAKELPARAM(xPos, yPos), &result);
837}
838
839void SFlashWidget::injectMouseUp(int xPos, int yPos, int index)
840{
841 LRESULT result;
842 windowlessObject->OnWindowMessage(MouseButtonMessageConverter(index, false), index, MAKELPARAM(xPos, yPos), &result);
843}
844
845void SFlashWidget::injectMouseWheel(int relScroll, int xPos, int yPos)
846{
847 LRESULT result;
848 windowlessObject->OnWindowMessage(WM_MOUSEWHEEL, MAKEWPARAM(0, relScroll), MAKELPARAM(xPos, yPos), &result);
849}
850
851void SFlashWidget::handleKeyEvent(UINT msg, WPARAM wParam, LPARAM lParam)
852{
853 LRESULT aResult;
854 windowlessObject->OnWindowMessage(msg, wParam, lParam, &aResult);
855}
856
857UINT SFlashWidget::MouseButtonMessageConverter(const int& button, const bool& pressed)
858{
859 UINT value = WM_NULL;
860 if(pressed)
861 {
862 switch(button)
863 {
864 case MK_LBUTTON:
865 value = WM_LBUTTONDOWN;
866 break;
867 case MK_RBUTTON:
868 value = WM_RBUTTONDOWN;
869 break;
870 case MK_MBUTTON:
871 value = WM_MBUTTONDOWN;
872 break;
873 }
874 }
875 else
876 {
877 switch(button)
878 {
879 case MK_LBUTTON:
880 value = WM_LBUTTONUP;
881 break;
882 case MK_RBUTTON:
883 value = WM_RBUTTONUP;
884 break;
885 case MK_MBUTTON:
886 value = WM_MBUTTONUP;
887 break;
888 }
889 }
890 return value;
891};
892
893bool SFlashWidget::CheckPixelAlpha(const int& posX, const int& posY)
894{
895 if((posX <= SWidget::width) && (posY <= SWidget::height))
896 {
897 int color = renderBuffer->getBuffer()[posY*renderBuffer->rowSpan + posX*4 + 3];
898 if (color > transparentTresholdColor * 255)
899 return true;
900 }
901 return false;
902}
903
904}
unsigned int UINT
Definition SO3Android.h:58
void setFlashControl(IFlashControl *flashControl)
Definition Hikari.cpp:514
static HikariManager & getSingleton()
Definition Hikari.cpp:118
static HikariManager * getSingletonPtr()
Definition Hikari.cpp:126
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()
Definition FlashSite.h:121
ULONG STDMETHODCALLTYPE Release()
Definition FlashSite.h:126
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, LPVOID *ppv)
Definition FlashSite.h:68
void Init(IFlashControl *owner, HWND hwnd)
Definition FlashSite.h:58
unsigned char * getBuffer()
void copyArea(RECT srcRect, unsigned char *srcBuffer, int srcRowSpan)
std::string name
Definition SO3DataScol.h:44
virtual void InjectMouseWheel(const int &scrollX, const int &scrollY, const int &relativeScroll)
virtual void setZOrder(unsigned short zorder)
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)
virtual void setIgnoreTransparentPixels(bool shouldIgnore, float threshold=0.04)
virtual void load(const std::string &movieFilename, Hikari::HikariManager *hikariMgr, int type)
virtual void LoadFile(const std::string &file)
virtual void focus()
void SetScaleMode(const FlashScaleMode &widgetScaleMode)
virtual void setLoop(bool shouldLoop)
virtual void injectMouseUp(int xPos, int yPos, int index)
virtual const std::string & getMaterialName() const
virtual void injectMouseWheel(int relScroll, int xPos, int yPos)
virtual void play()
FlashScaleMode GetScaleMode()
virtual void injectMouseDown(int xPos, int yPos, int index)
virtual bool getVisibility() const
virtual void InjectTouchAdd(const int &xPos, const int &yPos, const int &touchid)
virtual void setTransparent(bool isWidgetTransparent, bool useAlphaHack=false)
virtual void unbind(const std::wstring &funcName)
virtual bool CheckPixelAlpha(const int &posX, const int &posY)
virtual int getRelativeX(int absX)
virtual const std::string & getName() const
virtual void InjectTouchRemove(const int &touchid)
virtual void setQuality(short renderQuality)
virtual void setOpacity(float opacity)
virtual void InjectTextEvent(const std::string &utf8)
virtual void InjectTouchUpdate(const int &xPos, const int &yPos, const int &vx, const int &vy, const int &touchid)
virtual int getRelativeY(int absY)
virtual bool isPointOverMe(int screenX, int screenY)
FlashRenderQuality GetRenderingQuality()
virtual void LoadURL(const std::string &url)
virtual void SetSizeImpl(const unsigned short &newWidth, const unsigned short &newHeight)
virtual void setScaleMode(short widgetScaleMode)
virtual void InjectMouseMove(const int &xPos, const int &yPos, const MouseButtonId &button)
virtual void show()
virtual void InjectKeyEvent(const UINT &msg, const ScolWindowHandle &hwnd, const WPARAM &wParam, const LPARAM &lParam)
void SetRenderingQuality(const FlashRenderQuality &newQuality)
virtual Hikari::FlashValue callFunction(const std::wstring &funcName, const Hikari::Arguments &args=Hikari::Args())
virtual void InjectMouseUp(const int &xPos, const int &yPos, const MouseButtonId &button)
virtual void handleFlashCall(const std::wstring &xmlString)
virtual void update()
virtual void InjectMouseDown(const int &xPos, const int &yPos, const MouseButtonId &button)
void CommonConstructorSequence(const bool &overlayedFlashControl)
virtual void bind(const std::wstring &funcName, const Hikari::FlashDelegate &callback)
virtual void SetMouseEnableImpl(const bool &enableMouseOnWidget)
void Seek(const long &seekFrame)
virtual void rewind()
virtual void handleKeyEvent(UINT msg, WPARAM wParam, LPARAM lParam)
virtual unsigned short getZOrder()
virtual void getUVScale(float &uScale, float &vScale) const
virtual void invalidateTotally()
virtual void move(int deltaX, int deltaY)
virtual void SetTransparencyImpl(const bool &enableTransparency)
virtual void getExtents(unsigned short &width, unsigned short &height) const
virtual void hide()
virtual void SetFocusImpl(const bool &focusOnWidget)
virtual void setDraggable(bool widgetDraggable)
virtual void stop()
virtual void injectMouseMove(int xPos, int yPos, int btn)
virtual void RunScriptFunction(const std::string &functionName, const std::vector< std::string > &argumentList)
virtual void SetKeyboardEnableImpl(const bool &enableKeyboardOnWidget)
virtual void gotoFrame(long frameNum)
bool forceRenderingUpdate
Definition SO3Widget.h:89
float transparentTresholdColor
Definition SO3Widget.h:90
bool HasFocus()
void SetMouseEnable(const bool &enableMouseOnWidget)
std::string CheckUrl(const std::string &url)
unsigned short width
Definition SO3Widget.h:80
Ogre::TexturePtr renderingTexture
Definition SO3Widget.h:88
unsigned short height
Definition SO3Widget.h:81
void SetKeyboardEnable(const bool &enableKeyboardOnWidget)
bool IsCompensateNPOT() const
unsigned short mTextureWidth
The actual texture width allocated in ogre.
Definition SO3Widget.h:82
bool GetVisible()
unsigned short mTextureHeight
The actual texture height allocated in ogre.
Definition SO3Widget.h:83
bool GetUpdateOnFocusOnly()
void _FireOnLoadStart(SWidget *targetedWidget)
void _FireScriptWidgetEvent(SWidget *targetedWidget, const SScriptFunction &functionCalled)
void _FireOnLoadError(SWidget *targetedWidget, const int &errorCode, const std::string &failedUrl)
void _FireOnLoadEnd(SWidget *targetedWidget)
static SWidgetManager & getSingleton()
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)
@ FT_WSTRING
Definition FlashValue.h:55
@ FT_STRING
Definition FlashValue.h:54
@ FT_NUMBER
Definition FlashValue.h:53
@ FT_BOOLEAN
Definition FlashValue.h:52
_HikariExport std::vector< FlashValue > Arguments
Definition FlashValue.h:188
@ SO3_FLASH_SCALE_EXACTFIT
@ SO3_FLASH_SCALE_SHOWALL
FlashRenderQuality
@ SO3_FLASH_QUALITY_LOW
@ SO3_FLASH_QUALITY_AUTOHIGH
@ SO3_FLASH_QUALITY_MEDIUM
@ SO3_FLASH_QUALITY_BEST
@ SO3_FLASH_QUALITY_HIGH
@ SO3_FLASH_QUALITY_AUTOLOW