Project

General

Profile

SO3Engine
FlashSite.h
Go to the documentation of this file.
1/*
2 This file is part of Hikari, a library that allows developers
3 to use Flash in their Ogre3D applications.
4
5 Copyright (C) 2008 Adam J. Simmons
6
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.
11
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.
16
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
20*/
21
22#ifndef __FlashSite_H__
23#define __FlashSite_H__
24
25#include <conio.h>
26//#import "PROGID:ShockwaveFlash.ShockwaveFlash" named_guids
27#import "../redist/bin/Flash.ocx" named_guids
28
29#ifndef max
30#define max(a,b) (((a) > (b)) ? (a) : (b))
31#endif
32#ifndef min
33#define min(a,b) (((a) < (b)) ? (a) : (b))
34#endif
35
36namespace Hikari {
37namespace Impl {
38
39class FlashSite : public IOleInPlaceSiteWindowless, public IOleClientSite
40{
41public:
44 HWND mHWND;
46
47public:
48 FlashSite() : refCount(0), owner(0), mHWND(0), mCapture(true)
49 {
50 }
51
52 virtual ~FlashSite()
53 {
54 if(owner)
55 owner->comCount--;
56 }
57
58 void Init(IFlashControl* owner, HWND hwnd)
59 {
60 this->owner = owner;
61 owner->comCount++;
62 mHWND = hwnd;
63 }
64 bool isCapturing() const
65 {
66 return mCapture;
67 }
68 HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, LPVOID* ppv)
69 {
70 *ppv = 0;
71
72 if(riid == IID_IUnknown)
73 {
74 *ppv = (IUnknown*)(IOleWindow*)this;
75 AddRef();
76 return S_OK;
77 }
78 else if(riid == IID_IOleWindow)
79 {
80 *ppv = (IOleWindow*)this;
81 AddRef();
82 return S_OK;
83 }
84 else if(riid == IID_IOleInPlaceSite)
85 {
86 *ppv = (IOleInPlaceSite*)this;
87 AddRef();
88 return S_OK;
89 }
90 else if(riid == IID_IOleInPlaceSiteEx)
91 {
92 *ppv = (IOleInPlaceSiteEx*)this;
93 AddRef();
94 return S_OK;
95 }
96 else if(riid == IID_IOleInPlaceSiteWindowless)
97 {
98 *ppv = (IOleInPlaceSiteWindowless*)this;
99 AddRef();
100 return S_OK;
101 }
102 else if(riid == IID_IOleClientSite)
103 {
104 *ppv = (IOleClientSite*)this;
105 AddRef();
106 return S_OK;
107 }
108 else if(riid == __uuidof(ShockwaveFlashObjects::_IShockwaveFlashEvents))
109 {
110 *ppv = (ShockwaveFlashObjects::_IShockwaveFlashEvents*) this;
111 AddRef();
112 return S_OK;
113 }
114 else
115 {
116 //return S_OK;
117 return E_NOTIMPL;
118 }
119 }
120
121 ULONG STDMETHODCALLTYPE AddRef()
122 {
123 return ++refCount;
124 }
125
126 ULONG STDMETHODCALLTYPE Release()
127 {
128 --refCount;
129 int localCount = refCount;
130
131 if(!refCount)
132 delete this;
133
134 return localCount;
135 }
136
137 virtual HRESULT STDMETHODCALLTYPE SaveObject(void)
138 {
139 return S_OK;
140 }
141
142 virtual HRESULT STDMETHODCALLTYPE GetMoniker(DWORD dwAssign, DWORD dwWhichMoniker, IMoniker** ppmk)
143 {
144 *ppmk = 0;
145 return E_NOTIMPL;
146 }
147
148 virtual HRESULT STDMETHODCALLTYPE GetContainer(IOleContainer ** theContainerP)
149 {
150 return E_NOINTERFACE;
151 }
152
153 virtual HRESULT STDMETHODCALLTYPE ShowObject(void)
154 {
155 //return E_NOTIMPL;
156 return S_OK;
157 }
158
159 virtual HRESULT STDMETHODCALLTYPE OnShowWindow(BOOL)
160 {
161 return E_NOTIMPL;
162 }
163
164 virtual HRESULT STDMETHODCALLTYPE RequestNewObjectLayout(void)
165 {
166 return E_NOTIMPL;
167 }
168
169 HRESULT STDMETHODCALLTYPE ContextSensitiveHelp(BOOL fEnterMode)
170 {
171 return S_OK;
172 }
173
174 HRESULT STDMETHODCALLTYPE GetWindow(HWND __RPC_FAR* theWnndow)
175 {
176 if(mHWND)
177 {
178 *theWnndow = mHWND;
179 return S_OK;
180 }
181 else
182 return E_FAIL;
183 }
184
185 HRESULT STDMETHODCALLTYPE CanInPlaceActivate(void)
186 {
187 return S_OK;
188 }
189
190 HRESULT STDMETHODCALLTYPE OnInPlaceActivate(void)
191 {
192 return S_OK;
193 }
194
195 HRESULT STDMETHODCALLTYPE OnUIActivate(void)
196 {
197 return S_OK;
198 }
199
200 HRESULT STDMETHODCALLTYPE GetWindowContext(IOleInPlaceFrame __RPC_FAR *__RPC_FAR *ppFrame, IOleInPlaceUIWindow __RPC_FAR *__RPC_FAR *ppDoc,
201 LPRECT lprcPosRect, LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
202 {
203 RECT rect;
204 rect.left = 0;
205 rect.top = 0;
206 rect.right = owner->width;
207 rect.bottom = owner->height;
208
209 *lprcPosRect = rect;
210 *lprcClipRect = rect;
211
212 *ppFrame = 0;
213 QueryInterface(__uuidof(IOleInPlaceFrame), (void**)ppFrame);
214 *ppDoc = 0;
215
216 lpFrameInfo->fMDIApp = FALSE;
217 lpFrameInfo->hwndFrame = 0;
218 lpFrameInfo->haccel = 0;
219 lpFrameInfo->cAccelEntries = 0;
220
221 return S_OK;
222 }
223
224 HRESULT STDMETHODCALLTYPE Scroll(SIZE scrollExtant)
225 {
226 return S_OK;
227 }
228
229 HRESULT STDMETHODCALLTYPE OnUIDeactivate(BOOL fUndoable)
230 {
231 return S_OK;
232 }
233
234 HRESULT STDMETHODCALLTYPE OnInPlaceDeactivate(void)
235 {
236 return S_OK;
237 }
238
239 HRESULT STDMETHODCALLTYPE DiscardUndoState(void)
240 {
241 return S_OK;
242 }
243
244 HRESULT STDMETHODCALLTYPE DeactivateAndUndo(void)
245 {
246 return S_OK;
247 }
248
249 HRESULT STDMETHODCALLTYPE OnPosRectChange(LPCRECT lprcPosRect)
250 {
251 return S_OK;
252 }
253
254 HRESULT STDMETHODCALLTYPE OnInPlaceActivateEx(BOOL __RPC_FAR *pfNoRedraw, DWORD dwFlags)
255 {
256 return S_OK;
257 }
258
259 HRESULT STDMETHODCALLTYPE OnInPlaceDeactivateEx(BOOL fNoRedraw)
260 {
261 return S_OK;
262 }
263
264 HRESULT STDMETHODCALLTYPE RequestUIActivate(void)
265 {
266 return S_FALSE;
267 }
268
269 HRESULT STDMETHODCALLTYPE CanWindowlessActivate(void)
270 {
271 return S_OK;
272 }
273
274 HRESULT STDMETHODCALLTYPE GetCapture(void)
275 {
276 return mCapture ? S_OK : S_FALSE;
277 }
278
279 HRESULT STDMETHODCALLTYPE SetCapture(BOOL fCapture)
280 {
281 if(mCapture != (fCapture != FALSE))
282 {
283 mCapture = (fCapture != FALSE);
284
285 if(fCapture)
287 else
288 ::ReleaseCapture();
289 }
290
291 return S_OK;
292 }
293
294 HRESULT STDMETHODCALLTYPE GetFocus(void)
295 {
296 return S_OK;
297 }
298
299 HRESULT STDMETHODCALLTYPE SetFocus(BOOL fFocus)
300 {
301 return S_OK;
302 }
303
304 HRESULT STDMETHODCALLTYPE GetDC(LPCRECT pRect, DWORD grfFlags, HDC __RPC_FAR *phDC)
305 {
306 return E_INVALIDARG;
307 }
308
309 HRESULT STDMETHODCALLTYPE ReleaseDC(HDC hDC)
310 {
311 return E_INVALIDARG;
312 }
313
314 HRESULT STDMETHODCALLTYPE InvalidateRect(LPCRECT pRect, BOOL fErase)
315 {
316
318 return S_OK;
319
320 if(pRect)
321 {
322 //_cprintf("pRect: x:%d, y:%d, w:%d, h:%d\n",pRect->left,pRect->top,pRect->right,pRect->bottom);
323 if(owner->isClean)
324 {
325 owner->dirtyBounds.left = pRect->left;
326 owner->dirtyBounds.right = pRect->right;
327 owner->dirtyBounds.top = pRect->top;
328 owner->dirtyBounds.bottom = pRect->bottom;
329 owner->isClean = false;
330 }
331 else
332 {
333 owner->dirtyBounds.left = min(owner->dirtyBounds.left, pRect->left);
334 owner->dirtyBounds.right = max(owner->dirtyBounds.right, pRect->right);
335 owner->dirtyBounds.top = min(owner->dirtyBounds.top, pRect->top);
336 owner->dirtyBounds.bottom = max(owner->dirtyBounds.bottom, pRect->bottom);
337 }
338 }
339
340 if(owner->dirtyBounds.left < 0 || owner->dirtyBounds.top < 0 ||
341 owner->dirtyBounds.right > owner->width || owner->dirtyBounds.bottom > owner->height || !pRect)
342 {
344 }
345
346 return S_OK;
347 }
348
349 HRESULT STDMETHODCALLTYPE InvalidateRgn(HRGN hRGN, BOOL fErase)
350 {
352
353 return S_OK;
354 }
355
356 HRESULT STDMETHODCALLTYPE ScrollRect(INT dx, INT dy, LPCRECT pRectScroll, LPCRECT pRectClip)
357 {
358 return S_OK;
359 }
360
361 HRESULT STDMETHODCALLTYPE AdjustRect(LPRECT prc)
362 {
363 if(!prc)
364 return E_INVALIDARG;
365
366 return S_OK;
367 }
368
369 HRESULT STDMETHODCALLTYPE OnDefWindowMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT __RPC_FAR *plResult)
370 {
371 return S_FALSE;
372 }
373};
374
375}
376}
377
378#endif
379
unsigned int UINT
Definition SO3Android.h:58
virtual void invalidateTotally()=0
HRESULT STDMETHODCALLTYPE InvalidateRect(LPCRECT pRect, BOOL fErase)
Definition FlashSite.h:314
virtual HRESULT STDMETHODCALLTYPE GetContainer(IOleContainer **theContainerP)
Definition FlashSite.h:148
IFlashControl * owner
Definition FlashSite.h:43
HRESULT STDMETHODCALLTYPE OnUIDeactivate(BOOL fUndoable)
Definition FlashSite.h:229
HRESULT STDMETHODCALLTYPE OnInPlaceDeactivateEx(BOOL fNoRedraw)
Definition FlashSite.h:259
HRESULT STDMETHODCALLTYPE ContextSensitiveHelp(BOOL fEnterMode)
Definition FlashSite.h:169
virtual HRESULT STDMETHODCALLTYPE OnShowWindow(BOOL)
Definition FlashSite.h:159
HRESULT STDMETHODCALLTYPE DiscardUndoState(void)
Definition FlashSite.h:239
HRESULT STDMETHODCALLTYPE InvalidateRgn(HRGN hRGN, BOOL fErase)
Definition FlashSite.h:349
virtual HRESULT STDMETHODCALLTYPE RequestNewObjectLayout(void)
Definition FlashSite.h:164
HRESULT STDMETHODCALLTYPE SetCapture(BOOL fCapture)
Definition FlashSite.h:279
HRESULT STDMETHODCALLTYPE GetFocus(void)
Definition FlashSite.h:294
bool isCapturing() const
Definition FlashSite.h:64
HRESULT STDMETHODCALLTYPE DeactivateAndUndo(void)
Definition FlashSite.h:244
HRESULT STDMETHODCALLTYPE ReleaseDC(HDC hDC)
Definition FlashSite.h:309
HRESULT STDMETHODCALLTYPE CanWindowlessActivate(void)
Definition FlashSite.h:269
ULONG STDMETHODCALLTYPE AddRef()
Definition FlashSite.h:121
HRESULT STDMETHODCALLTYPE GetCapture(void)
Definition FlashSite.h:274
HRESULT STDMETHODCALLTYPE GetWindow(HWND __RPC_FAR *theWnndow)
Definition FlashSite.h:174
HRESULT STDMETHODCALLTYPE OnInPlaceActivate(void)
Definition FlashSite.h:190
virtual HRESULT STDMETHODCALLTYPE ShowObject(void)
Definition FlashSite.h:153
HRESULT STDMETHODCALLTYPE RequestUIActivate(void)
Definition FlashSite.h:264
virtual HRESULT STDMETHODCALLTYPE SaveObject(void)
Definition FlashSite.h:137
HRESULT STDMETHODCALLTYPE GetWindowContext(IOleInPlaceFrame __RPC_FAR *__RPC_FAR *ppFrame, IOleInPlaceUIWindow __RPC_FAR *__RPC_FAR *ppDoc, LPRECT lprcPosRect, LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
Definition FlashSite.h:200
HRESULT STDMETHODCALLTYPE OnDefWindowMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT __RPC_FAR *plResult)
Definition FlashSite.h:369
HRESULT STDMETHODCALLTYPE SetFocus(BOOL fFocus)
Definition FlashSite.h:299
HRESULT STDMETHODCALLTYPE OnInPlaceDeactivate(void)
Definition FlashSite.h:234
HRESULT STDMETHODCALLTYPE CanInPlaceActivate(void)
Definition FlashSite.h:185
HRESULT STDMETHODCALLTYPE GetDC(LPCRECT pRect, DWORD grfFlags, HDC __RPC_FAR *phDC)
Definition FlashSite.h:304
HRESULT STDMETHODCALLTYPE OnUIActivate(void)
Definition FlashSite.h:195
HRESULT STDMETHODCALLTYPE OnPosRectChange(LPCRECT lprcPosRect)
Definition FlashSite.h:249
ULONG STDMETHODCALLTYPE Release()
Definition FlashSite.h:126
virtual HRESULT STDMETHODCALLTYPE GetMoniker(DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk)
Definition FlashSite.h:142
HRESULT STDMETHODCALLTYPE Scroll(SIZE scrollExtant)
Definition FlashSite.h:224
HRESULT STDMETHODCALLTYPE AdjustRect(LPRECT prc)
Definition FlashSite.h:361
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, LPVOID *ppv)
Definition FlashSite.h:68
HRESULT STDMETHODCALLTYPE OnInPlaceActivateEx(BOOL __RPC_FAR *pfNoRedraw, DWORD dwFlags)
Definition FlashSite.h:254
HRESULT STDMETHODCALLTYPE ScrollRect(INT dx, INT dy, LPCRECT pRectScroll, LPCRECT pRectClip)
Definition FlashSite.h:356
void Init(IFlashControl *owner, HWND hwnd)
Definition FlashSite.h:58