winebus.sys: Support setting SDL controller mapping through environment variable.
[wine.git] / dlls / mshtml / view.c
blobbb24335cdc68d1ada7a056a14db3e6a07868862f
1 /*
2 * Copyright 2005-2006 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include <stdarg.h>
20 #include <stdio.h>
22 #define COBJMACROS
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "commctrl.h"
28 #include "ole2.h"
29 #include "resource.h"
31 #include "wine/debug.h"
33 #include "mshtml_private.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
37 #define TIMER_ID 0x1000
39 static const WCHAR wszInternetExplorer_Server[] =
40 {'I','n','t','e','r','n','e','t',' ','E','x','p','l','o','r','e','r','_','S','e','r','v','e','r',0};
42 static const WCHAR wszTooltipData[] = {'t','o','o','l','t','i','p','_','d','a','t','a',0};
44 static ATOM serverwnd_class = 0;
46 typedef struct {
47 HTMLDocumentObj *doc;
48 WNDPROC proc;
49 } tooltip_data;
51 static void paint_document(HTMLDocumentObj *This)
53 PAINTSTRUCT ps;
54 RECT rect;
55 HDC hdc;
57 GetClientRect(This->hwnd, &rect);
59 hdc = BeginPaint(This->hwnd, &ps);
61 if(!(This->hostinfo.dwFlags & (DOCHOSTUIFLAG_NO3DOUTERBORDER|DOCHOSTUIFLAG_NO3DBORDER)))
62 DrawEdge(hdc, &rect, EDGE_SUNKEN, BF_RECT|BF_ADJUST);
64 EndPaint(This->hwnd, &ps);
67 static void activate_gecko(GeckoBrowser *This)
69 TRACE("(%p) %p\n", This, This->window);
71 SetParent(This->hwnd, This->doc->hwnd);
72 ShowWindow(This->hwnd, SW_SHOW);
74 nsIBaseWindow_SetVisibility(This->window, TRUE);
75 nsIBaseWindow_SetEnabled(This->window, TRUE);
78 void update_doc(HTMLDocumentObj *This, DWORD flags)
80 if(!This->update && This->hwnd)
81 SetTimer(This->hwnd, TIMER_ID, 100, NULL);
83 This->update |= flags;
86 void update_title(HTMLDocumentObj *This)
88 IOleCommandTarget *olecmd;
89 HRESULT hres;
91 if(!(This->update & UPDATE_TITLE))
92 return;
94 This->update &= ~UPDATE_TITLE;
96 if(!This->client)
97 return;
99 hres = IOleClientSite_QueryInterface(This->client, &IID_IOleCommandTarget, (void**)&olecmd);
100 if(SUCCEEDED(hres)) {
101 static const WCHAR empty[] = {0};
102 VARIANT title;
104 V_VT(&title) = VT_BSTR;
105 V_BSTR(&title) = SysAllocString(empty);
106 IOleCommandTarget_Exec(olecmd, NULL, OLECMDID_SETTITLE, OLECMDEXECOPT_DONTPROMPTUSER,
107 &title, NULL);
108 SysFreeString(V_BSTR(&title));
110 IOleCommandTarget_Release(olecmd);
114 static LRESULT on_timer(HTMLDocumentObj *This)
116 TRACE("(%p) %x\n", This, This->update);
118 KillTimer(This->hwnd, TIMER_ID);
120 if(!This->update)
121 return 0;
123 if(This->update & UPDATE_UI) {
124 if(This->hostui)
125 IDocHostUIHandler_UpdateUI(This->hostui);
127 if(This->client) {
128 IOleCommandTarget *cmdtrg;
129 HRESULT hres;
131 hres = IOleClientSite_QueryInterface(This->client, &IID_IOleCommandTarget,
132 (void**)&cmdtrg);
133 if(SUCCEEDED(hres)) {
134 IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_UPDATECOMMANDS,
135 OLECMDEXECOPT_DONTPROMPTUSER, NULL, NULL);
136 IOleCommandTarget_Release(cmdtrg);
141 update_title(This);
142 This->update = 0;
143 return 0;
146 void notif_focus(HTMLDocumentObj *This)
148 IOleControlSite *site;
149 HRESULT hres;
151 if(!This->client)
152 return;
154 hres = IOleClientSite_QueryInterface(This->client, &IID_IOleControlSite, (void**)&site);
155 if(FAILED(hres))
156 return;
158 IOleControlSite_OnFocus(site, This->focus);
159 IOleControlSite_Release(site);
162 static LRESULT WINAPI serverwnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
164 HTMLDocumentObj *This;
166 static const WCHAR wszTHIS[] = {'T','H','I','S',0};
168 if(msg == WM_CREATE) {
169 This = *(HTMLDocumentObj**)lParam;
170 SetPropW(hwnd, wszTHIS, This);
171 }else {
172 This = GetPropW(hwnd, wszTHIS);
175 switch(msg) {
176 case WM_CREATE:
177 This->hwnd = hwnd;
178 break;
179 case WM_PAINT:
180 paint_document(This);
181 break;
182 case WM_SIZE:
183 TRACE("(%p)->(WM_SIZE)\n", This);
184 if(This->nscontainer) {
185 INT ew=0, eh=0;
187 if(!(This->hostinfo.dwFlags & (DOCHOSTUIFLAG_NO3DOUTERBORDER|DOCHOSTUIFLAG_NO3DBORDER))) {
188 ew = GetSystemMetrics(SM_CXEDGE);
189 eh = GetSystemMetrics(SM_CYEDGE);
192 SetWindowPos(This->nscontainer->hwnd, NULL, ew, eh,
193 LOWORD(lParam) - 2*ew, HIWORD(lParam) - 2*eh,
194 SWP_NOZORDER | SWP_NOACTIVATE);
196 break;
197 case WM_TIMER:
198 return on_timer(This);
199 case WM_SETFOCUS:
200 TRACE("(%p) WM_SETFOCUS\n", This);
201 nsIWebBrowserFocus_Activate(This->nscontainer->focus);
202 break;
203 case WM_MOUSEACTIVATE:
204 return MA_ACTIVATE;
207 return DefWindowProcW(hwnd, msg, wParam, lParam);
210 static void register_serverwnd_class(void)
212 static WNDCLASSEXW wndclass = {
213 sizeof(WNDCLASSEXW),
214 CS_DBLCLKS,
215 serverwnd_proc,
216 0, 0, NULL, NULL, NULL, NULL, NULL,
217 wszInternetExplorer_Server,
218 NULL,
220 wndclass.hInstance = hInst;
221 serverwnd_class = RegisterClassExW(&wndclass);
224 static HRESULT activate_window(HTMLDocumentObj *This)
226 IOleInPlaceFrame *pIPFrame;
227 IOleCommandTarget *cmdtrg;
228 IOleInPlaceSiteEx *ipsiteex;
229 RECT posrect, cliprect;
230 OLEINPLACEFRAMEINFO frameinfo;
231 HWND parent_hwnd;
232 HRESULT hres;
234 if(!serverwnd_class)
235 register_serverwnd_class();
237 hres = IOleInPlaceSite_CanInPlaceActivate(This->ipsite);
238 if(hres != S_OK) {
239 WARN("CanInPlaceActivate returned: %08x\n", hres);
240 return FAILED(hres) ? hres : E_FAIL;
243 frameinfo.cb = sizeof(OLEINPLACEFRAMEINFO);
244 hres = IOleInPlaceSite_GetWindowContext(This->ipsite, &pIPFrame, &This->ip_window,
245 &posrect, &cliprect, &frameinfo);
246 if(FAILED(hres)) {
247 WARN("GetWindowContext failed: %08x\n", hres);
248 return hres;
251 TRACE("got window context: %p %p %s %s {%d %x %p %p %d}\n",
252 pIPFrame, This->ip_window, wine_dbgstr_rect(&posrect), wine_dbgstr_rect(&cliprect),
253 frameinfo.cb, frameinfo.fMDIApp, frameinfo.hwndFrame, frameinfo.haccel, frameinfo.cAccelEntries);
255 hres = IOleInPlaceSite_GetWindow(This->ipsite, &parent_hwnd);
256 if(FAILED(hres)) {
257 WARN("GetWindow failed: %08x\n", hres);
258 return hres;
261 TRACE("got parent window %p\n", parent_hwnd);
263 if(This->hwnd) {
264 if(GetParent(This->hwnd) != parent_hwnd)
265 SetParent(This->hwnd, parent_hwnd);
266 SetWindowPos(This->hwnd, HWND_TOP,
267 posrect.left, posrect.top, posrect.right-posrect.left, posrect.bottom-posrect.top,
268 SWP_NOACTIVATE | SWP_SHOWWINDOW);
269 }else {
270 CreateWindowExW(0, wszInternetExplorer_Server, NULL,
271 WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
272 posrect.left, posrect.top, posrect.right-posrect.left, posrect.bottom-posrect.top,
273 parent_hwnd, NULL, hInst, This);
275 TRACE("Created window %p\n", This->hwnd);
277 SetWindowPos(This->hwnd, NULL, 0, 0, 0, 0,
278 SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW | SWP_NOACTIVATE | SWP_SHOWWINDOW);
279 RedrawWindow(This->hwnd, NULL, NULL, RDW_INVALIDATE | RDW_NOERASE | RDW_ALLCHILDREN);
280 SetTimer(This->hwnd, TIMER_ID, 100, NULL);
283 if(This->nscontainer)
284 activate_gecko(This->nscontainer);
286 This->in_place_active = TRUE;
287 hres = IOleInPlaceSite_QueryInterface(This->ipsite, &IID_IOleInPlaceSiteEx, (void**)&ipsiteex);
288 if(SUCCEEDED(hres)) {
289 BOOL redraw = FALSE;
291 hres = IOleInPlaceSiteEx_OnInPlaceActivateEx(ipsiteex, &redraw, 0);
292 IOleInPlaceSiteEx_Release(ipsiteex);
293 if(redraw)
294 FIXME("unsupported redraw\n");
295 }else{
296 hres = IOleInPlaceSite_OnInPlaceActivate(This->ipsite);
298 if(FAILED(hres)) {
299 WARN("OnInPlaceActivate failed: %08x\n", hres);
300 This->in_place_active = FALSE;
301 return hres;
304 hres = IOleClientSite_QueryInterface(This->client, &IID_IOleCommandTarget, (void**)&cmdtrg);
305 if(SUCCEEDED(hres)) {
306 VARIANT var;
308 IOleInPlaceFrame_SetStatusText(pIPFrame, NULL);
310 V_VT(&var) = VT_I4;
311 V_I4(&var) = 0;
312 IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_SETPROGRESSMAX,
313 OLECMDEXECOPT_DONTPROMPTUSER, &var, NULL);
314 IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_SETPROGRESSPOS,
315 OLECMDEXECOPT_DONTPROMPTUSER, &var, NULL);
317 IOleCommandTarget_Release(cmdtrg);
320 if(This->frame)
321 IOleInPlaceFrame_Release(This->frame);
322 This->frame = pIPFrame;
324 if(!This->request_uiactivate) {
325 hres = IOleInPlaceSite_QueryInterface(This->ipsite, &IID_IOleInPlaceSiteEx, (void**)&ipsiteex);
326 if(SUCCEEDED(hres)) {
327 IOleInPlaceSiteEx_RequestUIActivate(ipsiteex);
328 IOleInPlaceSiteEx_Release(ipsiteex);
332 This->window_active = TRUE;
334 return S_OK;
337 static LRESULT WINAPI tooltips_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
339 tooltip_data *data = GetPropW(hwnd, wszTooltipData);
341 TRACE("%d %p\n", msg, data);
343 if(msg == TTM_WINDOWFROMPOINT) {
344 RECT rect;
345 POINT *pt = (POINT*)lParam;
347 TRACE("TTM_WINDOWFROMPOINT (%d,%d)\n", pt->x, pt->y);
349 GetWindowRect(data->doc->hwnd, &rect);
351 if(rect.left <= pt->x && pt->x <= rect.right
352 && rect.top <= pt->y && pt->y <= rect.bottom)
353 return (LPARAM)data->doc->hwnd;
356 return CallWindowProcW(data->proc, hwnd, msg, wParam, lParam);
359 static void create_tooltips_window(HTMLDocumentObj *This)
361 tooltip_data *data = heap_alloc(sizeof(*data));
363 This->tooltips_hwnd = CreateWindowExW(0, TOOLTIPS_CLASSW, NULL, TTS_NOPREFIX | WS_POPUP,
364 CW_USEDEFAULT, CW_USEDEFAULT, 10, 10, This->hwnd, NULL, hInst, NULL);
366 data->doc = This;
367 data->proc = (WNDPROC)GetWindowLongPtrW(This->tooltips_hwnd, GWLP_WNDPROC);
369 SetPropW(This->tooltips_hwnd, wszTooltipData, data);
371 SetWindowLongPtrW(This->tooltips_hwnd, GWLP_WNDPROC, (LONG_PTR)tooltips_proc);
373 SetWindowPos(This->tooltips_hwnd, HWND_TOPMOST,0, 0, 0, 0,
374 SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
378 void show_tooltip(HTMLDocumentObj *This, DWORD x, DWORD y, LPCWSTR text)
380 TTTOOLINFOW toolinfo = {
381 sizeof(TTTOOLINFOW), 0, This->hwnd, 0xdeadbeef,
382 {x>2 ? x-2 : 0, y>0 ? y-2 : 0, x+2, y+2}, /* FIXME */
383 NULL, (LPWSTR)text, 0};
384 MSG msg = {This->hwnd, WM_MOUSEMOVE, 0, MAKELPARAM(x,y), 0, {x,y}};
386 TRACE("(%p)->(%d %d %s)\n", This, x, y, debugstr_w(text));
388 if(!This->tooltips_hwnd)
389 create_tooltips_window(This);
391 SendMessageW(This->tooltips_hwnd, TTM_ADDTOOLW, 0, (LPARAM)&toolinfo);
392 SendMessageW(This->tooltips_hwnd, TTM_ACTIVATE, TRUE, 0);
393 SendMessageW(This->tooltips_hwnd, TTM_RELAYEVENT, 0, (LPARAM)&msg);
396 void hide_tooltip(HTMLDocumentObj *This)
398 TTTOOLINFOW toolinfo = {
399 sizeof(TTTOOLINFOW), 0, This->hwnd, 0xdeadbeef,
400 {0,0,0,0}, NULL, NULL, 0};
402 TRACE("(%p)\n", This);
404 SendMessageW(This->tooltips_hwnd, TTM_DELTOOLW, 0, (LPARAM)&toolinfo);
405 SendMessageW(This->tooltips_hwnd, TTM_ACTIVATE, FALSE, 0);
408 HRESULT call_set_active_object(IOleInPlaceUIWindow *window, IOleInPlaceActiveObject *act_obj)
410 static WCHAR html_documentW[30];
412 if(act_obj && !html_documentW[0])
413 LoadStringW(hInst, IDS_HTMLDOCUMENT, html_documentW, ARRAY_SIZE(html_documentW));
415 return IOleInPlaceUIWindow_SetActiveObject(window, act_obj, act_obj ? html_documentW : NULL);
418 /**********************************************************
419 * IOleDocumentView implementation
422 static inline HTMLDocumentObj *impl_from_IOleDocumentView(IOleDocumentView *iface)
424 return CONTAINING_RECORD(iface, HTMLDocumentObj, IOleDocumentView_iface);
427 static HRESULT WINAPI OleDocumentView_QueryInterface(IOleDocumentView *iface, REFIID riid, void **ppvObject)
429 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
430 return htmldoc_query_interface(&This->basedoc, riid, ppvObject);
433 static ULONG WINAPI OleDocumentView_AddRef(IOleDocumentView *iface)
435 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
436 return htmldoc_addref(&This->basedoc);
439 static ULONG WINAPI OleDocumentView_Release(IOleDocumentView *iface)
441 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
442 return htmldoc_release(&This->basedoc);
445 static HRESULT WINAPI OleDocumentView_SetInPlaceSite(IOleDocumentView *iface, IOleInPlaceSite *pIPSite)
447 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
448 TRACE("(%p)->(%p)\n", This, pIPSite);
450 if(pIPSite)
451 IOleInPlaceSite_AddRef(pIPSite);
453 if(This->ipsite)
454 IOleInPlaceSite_Release(This->ipsite);
456 This->ipsite = pIPSite;
457 This->request_uiactivate = TRUE;
458 return S_OK;
461 static HRESULT WINAPI OleDocumentView_GetInPlaceSite(IOleDocumentView *iface, IOleInPlaceSite **ppIPSite)
463 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
464 TRACE("(%p)->(%p)\n", This, ppIPSite);
466 if(!ppIPSite)
467 return E_INVALIDARG;
469 if(This->ipsite)
470 IOleInPlaceSite_AddRef(This->ipsite);
472 *ppIPSite = This->ipsite;
473 return S_OK;
476 static HRESULT WINAPI OleDocumentView_GetDocument(IOleDocumentView *iface, IUnknown **ppunk)
478 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
479 TRACE("(%p)->(%p)\n", This, ppunk);
481 if(!ppunk)
482 return E_INVALIDARG;
484 *ppunk = (IUnknown*)&This->basedoc.IHTMLDocument2_iface;
485 IUnknown_AddRef(*ppunk);
486 return S_OK;
489 static HRESULT WINAPI OleDocumentView_SetRect(IOleDocumentView *iface, LPRECT prcView)
491 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
492 RECT rect;
494 TRACE("(%p)->(%p)\n", This, prcView);
496 if(!prcView)
497 return E_INVALIDARG;
499 if(This->hwnd) {
500 GetClientRect(This->hwnd, &rect);
501 if(!EqualRect(prcView, &rect)) {
502 InvalidateRect(This->hwnd, NULL, TRUE);
503 SetWindowPos(This->hwnd, NULL, prcView->left, prcView->top, prcView->right - prcView->left,
504 prcView->bottom - prcView->top, SWP_NOZORDER | SWP_NOACTIVATE);
508 return S_OK;
511 static HRESULT WINAPI OleDocumentView_GetRect(IOleDocumentView *iface, LPRECT prcView)
513 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
515 TRACE("(%p)->(%p)\n", This, prcView);
517 if(!prcView)
518 return E_INVALIDARG;
520 GetClientRect(This->hwnd, prcView);
521 MapWindowPoints(This->hwnd, GetParent(This->hwnd), (POINT*)prcView, 2);
522 return S_OK;
525 static HRESULT WINAPI OleDocumentView_SetRectComplex(IOleDocumentView *iface, LPRECT prcView,
526 LPRECT prcHScroll, LPRECT prcVScroll, LPRECT prcSizeBox)
528 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
529 FIXME("(%p)->(%p %p %p %p)\n", This, prcView, prcHScroll, prcVScroll, prcSizeBox);
530 return E_NOTIMPL;
533 static HRESULT WINAPI OleDocumentView_Show(IOleDocumentView *iface, BOOL fShow)
535 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
536 HRESULT hres;
538 TRACE("(%p)->(%x)\n", This, fShow);
540 if(fShow) {
541 if(!This->ui_active) {
542 hres = activate_window(This);
543 if(FAILED(hres))
544 return hres;
546 update_doc(This, UPDATE_UI);
547 ShowWindow(This->hwnd, SW_SHOW);
548 }else {
549 ShowWindow(This->hwnd, SW_HIDE);
551 if(This->in_place_active)
552 IOleInPlaceObjectWindowless_InPlaceDeactivate(&This->basedoc.IOleInPlaceObjectWindowless_iface);
554 if(This->ip_window) {
555 IOleInPlaceUIWindow_Release(This->ip_window);
556 This->ip_window = NULL;
560 return S_OK;
563 static HRESULT WINAPI OleDocumentView_UIActivate(IOleDocumentView *iface, BOOL fUIActivate)
565 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
566 HRESULT hres;
568 TRACE("(%p)->(%x)\n", This, fUIActivate);
570 if(!This->ipsite) {
571 IOleClientSite *cs = This->client;
572 IOleInPlaceSite *ips;
574 if(!cs) {
575 WARN("this->ipsite = NULL\n");
576 return E_UNEXPECTED;
579 hres = IOleClientSite_QueryInterface(cs, &IID_IOleInPlaceSiteWindowless, (void**)&ips);
580 if(SUCCEEDED(hres))
581 This->ipsite = ips;
582 else {
583 hres = IOleClientSite_QueryInterface(cs, &IID_IOleInPlaceSiteEx, (void**)&ips);
584 if(SUCCEEDED(hres))
585 This->ipsite = ips;
586 else {
587 hres = IOleClientSite_QueryInterface(cs, &IID_IOleInPlaceSite, (void**)&ips);
588 if(SUCCEEDED(hres))
589 This->ipsite = ips;
590 else {
591 WARN("this->ipsite = NULL\n");
592 return E_NOINTERFACE;
597 IOleInPlaceSite_AddRef(This->ipsite);
598 This->request_uiactivate = FALSE;
599 HTMLDocument_LockContainer(This, TRUE);
602 if(fUIActivate) {
603 RECT rcBorderWidths;
605 if(This->ui_active)
606 return S_OK;
608 if(!This->window_active) {
609 hres = activate_window(This);
610 if(FAILED(hres))
611 return hres;
614 This->focus = TRUE;
615 if(This->nscontainer)
616 nsIWebBrowserFocus_Activate(This->nscontainer->focus);
617 notif_focus(This);
619 update_doc(This, UPDATE_UI);
621 hres = IOleInPlaceSite_OnUIActivate(This->ipsite);
622 if(SUCCEEDED(hres)) {
623 call_set_active_object((IOleInPlaceUIWindow*)This->frame,
624 &This->basedoc.IOleInPlaceActiveObject_iface);
625 }else {
626 FIXME("OnUIActivate failed: %08x\n", hres);
627 IOleInPlaceFrame_Release(This->frame);
628 This->frame = NULL;
629 This->ui_active = FALSE;
630 return hres;
633 if(This->hostui) {
634 hres = IDocHostUIHandler_ShowUI(This->hostui,
635 This->nscontainer->usermode == EDITMODE ? DOCHOSTUITYPE_AUTHOR : DOCHOSTUITYPE_BROWSE,
636 &This->basedoc.IOleInPlaceActiveObject_iface, &This->basedoc.IOleCommandTarget_iface,
637 This->frame, This->ip_window);
638 if(FAILED(hres))
639 IDocHostUIHandler_HideUI(This->hostui);
642 if(This->ip_window)
643 call_set_active_object(This->ip_window, &This->basedoc.IOleInPlaceActiveObject_iface);
645 SetRectEmpty(&rcBorderWidths);
646 IOleInPlaceFrame_SetBorderSpace(This->frame, &rcBorderWidths);
648 This->ui_active = TRUE;
649 }else {
650 This->focus = FALSE;
651 nsIWebBrowserFocus_Deactivate(This->nscontainer->focus);
652 if(This->ui_active) {
653 This->ui_active = FALSE;
654 if(This->ip_window)
655 call_set_active_object(This->ip_window, NULL);
656 if(This->frame)
657 call_set_active_object((IOleInPlaceUIWindow*)This->frame, NULL);
658 if(This->hostui)
659 IDocHostUIHandler_HideUI(This->hostui);
660 if(This->ipsite)
661 IOleInPlaceSite_OnUIDeactivate(This->ipsite, FALSE);
664 return S_OK;
667 static HRESULT WINAPI OleDocumentView_Open(IOleDocumentView *iface)
669 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
670 FIXME("(%p)\n", This);
671 return E_NOTIMPL;
674 static HRESULT WINAPI OleDocumentView_CloseView(IOleDocumentView *iface, DWORD dwReserved)
676 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
677 TRACE("(%p)->(%x)\n", This, dwReserved);
679 if(dwReserved)
680 WARN("dwReserved = %d\n", dwReserved);
682 IOleDocumentView_Show(iface, FALSE);
683 return S_OK;
686 static HRESULT WINAPI OleDocumentView_SaveViewState(IOleDocumentView *iface, IStream *pstm)
688 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
689 FIXME("(%p)->(%p)\n", This, pstm);
690 return E_NOTIMPL;
693 static HRESULT WINAPI OleDocumentView_ApplyViewState(IOleDocumentView *iface, IStream *pstm)
695 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
696 FIXME("(%p)->(%p)\n", This, pstm);
697 return E_NOTIMPL;
700 static HRESULT WINAPI OleDocumentView_Clone(IOleDocumentView *iface, IOleInPlaceSite *pIPSiteNew,
701 IOleDocumentView **ppViewNew)
703 HTMLDocumentObj *This = impl_from_IOleDocumentView(iface);
704 FIXME("(%p)->(%p %p)\n", This, pIPSiteNew, ppViewNew);
705 return E_NOTIMPL;
708 static const IOleDocumentViewVtbl OleDocumentViewVtbl = {
709 OleDocumentView_QueryInterface,
710 OleDocumentView_AddRef,
711 OleDocumentView_Release,
712 OleDocumentView_SetInPlaceSite,
713 OleDocumentView_GetInPlaceSite,
714 OleDocumentView_GetDocument,
715 OleDocumentView_SetRect,
716 OleDocumentView_GetRect,
717 OleDocumentView_SetRectComplex,
718 OleDocumentView_Show,
719 OleDocumentView_UIActivate,
720 OleDocumentView_Open,
721 OleDocumentView_CloseView,
722 OleDocumentView_SaveViewState,
723 OleDocumentView_ApplyViewState,
724 OleDocumentView_Clone
727 /**********************************************************
728 * IViewObject implementation
731 static inline HTMLDocumentObj *impl_from_IViewObjectEx(IViewObjectEx *iface)
733 return CONTAINING_RECORD(iface, HTMLDocumentObj, IViewObjectEx_iface);
736 static HRESULT WINAPI ViewObject_QueryInterface(IViewObjectEx *iface, REFIID riid, void **ppv)
738 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
739 return htmldoc_query_interface(&This->basedoc, riid, ppv);
742 static ULONG WINAPI ViewObject_AddRef(IViewObjectEx *iface)
744 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
745 return htmldoc_addref(&This->basedoc);
748 static ULONG WINAPI ViewObject_Release(IViewObjectEx *iface)
750 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
751 return htmldoc_release(&This->basedoc);
754 static HRESULT WINAPI ViewObject_Draw(IViewObjectEx *iface, DWORD dwDrawAspect, LONG lindex, void *pvAspect,
755 DVTARGETDEVICE *ptd, HDC hdcTargetDev, HDC hdcDraw, LPCRECTL lprcBounds,
756 LPCRECTL lprcWBounds, BOOL (CALLBACK *pfnContinue)(ULONG_PTR dwContinue), ULONG_PTR dwContinue)
758 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
759 FIXME("(%p)->(%d %d %p %p %p %p %p %p %p %ld)\n", This, dwDrawAspect, lindex, pvAspect,
760 ptd, hdcTargetDev, hdcDraw, lprcBounds, lprcWBounds, pfnContinue, dwContinue);
761 return E_NOTIMPL;
764 static HRESULT WINAPI ViewObject_GetColorSet(IViewObjectEx *iface, DWORD dwDrawAspect, LONG lindex, void *pvAspect,
765 DVTARGETDEVICE *ptd, HDC hicTargetDev, LOGPALETTE **ppColorSet)
767 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
768 FIXME("(%p)->(%d %d %p %p %p %p)\n", This, dwDrawAspect, lindex, pvAspect, ptd, hicTargetDev, ppColorSet);
769 return E_NOTIMPL;
772 static HRESULT WINAPI ViewObject_Freeze(IViewObjectEx *iface, DWORD dwDrawAspect, LONG lindex,
773 void *pvAspect, DWORD *pdwFreeze)
775 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
776 FIXME("(%p)->(%d %d %p %p)\n", This, dwDrawAspect, lindex, pvAspect, pdwFreeze);
777 return E_NOTIMPL;
780 static HRESULT WINAPI ViewObject_Unfreeze(IViewObjectEx *iface, DWORD dwFreeze)
782 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
783 FIXME("(%p)->(%d)\n", This, dwFreeze);
784 return E_NOTIMPL;
787 static HRESULT WINAPI ViewObject_SetAdvise(IViewObjectEx *iface, DWORD aspects, DWORD advf, IAdviseSink *pAdvSink)
789 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
791 TRACE("(%p)->(%d %d %p)\n", This, aspects, advf, pAdvSink);
793 if(aspects != DVASPECT_CONTENT || advf != ADVF_PRIMEFIRST)
794 FIXME("unsupported arguments\n");
796 if(This->view_sink)
797 IAdviseSink_Release(This->view_sink);
798 if(pAdvSink)
799 IAdviseSink_AddRef(pAdvSink);
801 This->view_sink = pAdvSink;
802 return S_OK;
805 static HRESULT WINAPI ViewObject_GetAdvise(IViewObjectEx *iface, DWORD *pAspects, DWORD *pAdvf, IAdviseSink **ppAdvSink)
807 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
808 FIXME("(%p)->(%p %p %p)\n", This, pAspects, pAdvf, ppAdvSink);
809 return E_NOTIMPL;
812 static HRESULT WINAPI ViewObject_GetExtent(IViewObjectEx *iface, DWORD dwDrawAspect, LONG lindex,
813 DVTARGETDEVICE* ptd, LPSIZEL lpsizel)
815 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
816 FIXME("(%p)->(%d %d %p %p)\n", This, dwDrawAspect, lindex, ptd, lpsizel);
817 return E_NOTIMPL;
820 static HRESULT WINAPI ViewObject_GetRect(IViewObjectEx *iface, DWORD dwAspect, LPRECTL pRect)
822 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
823 FIXME("(%p)->(%d %p)\n", This, dwAspect, pRect);
824 return E_NOTIMPL;
827 static HRESULT WINAPI ViewObject_GetViewStatus(IViewObjectEx *iface, DWORD *pdwStatus)
829 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
830 FIXME("(%p)->(%p)\n", This, pdwStatus);
831 return E_NOTIMPL;
834 static HRESULT WINAPI ViewObject_QueryHitPoint(IViewObjectEx* iface, DWORD dwAspect,
835 LPCRECT pRectBounds, POINT ptlLoc, LONG lCloseHint, DWORD *pHitResult)
837 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
838 FIXME("(%p)->(%d %p (%d %d) %d %p)\n", This, dwAspect, pRectBounds, ptlLoc.x,
839 ptlLoc.y, lCloseHint, pHitResult);
840 return E_NOTIMPL;
843 static HRESULT WINAPI ViewObject_QueryHitRect(IViewObjectEx *iface, DWORD dwAspect,
844 LPCRECT pRectBounds, LPCRECT pRectLoc, LONG lCloseHint, DWORD *pHitResult)
846 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
847 FIXME("(%p)->(%d %p %p %d %p)\n", This, dwAspect, pRectBounds, pRectLoc, lCloseHint, pHitResult);
848 return E_NOTIMPL;
851 static HRESULT WINAPI ViewObject_GetNaturalExtent(IViewObjectEx *iface, DWORD dwAspect, LONG lindex,
852 DVTARGETDEVICE *ptd, HDC hicTargetDev, DVEXTENTINFO *pExtentInfo, LPSIZEL pSizel)
854 HTMLDocumentObj *This = impl_from_IViewObjectEx(iface);
855 FIXME("(%p)->(%d %d %p %p %p %p\n", This, dwAspect,lindex, ptd,
856 hicTargetDev, pExtentInfo, pSizel);
857 return E_NOTIMPL;
860 static const IViewObjectExVtbl ViewObjectVtbl = {
861 ViewObject_QueryInterface,
862 ViewObject_AddRef,
863 ViewObject_Release,
864 ViewObject_Draw,
865 ViewObject_GetColorSet,
866 ViewObject_Freeze,
867 ViewObject_Unfreeze,
868 ViewObject_SetAdvise,
869 ViewObject_GetAdvise,
870 ViewObject_GetExtent,
871 ViewObject_GetRect,
872 ViewObject_GetViewStatus,
873 ViewObject_QueryHitPoint,
874 ViewObject_QueryHitRect,
875 ViewObject_GetNaturalExtent
878 static inline HTMLDocumentObj *impl_from_IWindowForBindingUI(IWindowForBindingUI *iface)
880 return CONTAINING_RECORD(iface, HTMLDocumentObj, IWindowForBindingUI_iface);
883 static HRESULT WINAPI WindowForBindingUI_QueryInterface(IWindowForBindingUI *iface, REFIID riid, void **ppv)
885 HTMLDocumentObj *This = impl_from_IWindowForBindingUI(iface);
887 if(IsEqualGUID(&IID_IUnknown, riid)) {
888 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
889 *ppv = &This->IWindowForBindingUI_iface;
890 }else if(IsEqualGUID(&IID_IWindowForBindingUI, riid)) {
891 TRACE("(%p)->(IID_IWindowForBindingUI %p)\n", This, ppv);
892 *ppv = &This->IWindowForBindingUI_iface;
893 }else {
894 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
895 *ppv = NULL;
896 return E_NOINTERFACE;
899 IUnknown_AddRef((IUnknown*)*ppv);
900 return S_OK;
903 static ULONG WINAPI WindowForBindingUI_AddRef(IWindowForBindingUI *iface)
905 HTMLDocumentObj *This = impl_from_IWindowForBindingUI(iface);
906 return htmldoc_addref(&This->basedoc);
909 static ULONG WINAPI WindowForBindingUI_Release(IWindowForBindingUI *iface)
911 HTMLDocumentObj *This = impl_from_IWindowForBindingUI(iface);
912 return htmldoc_release(&This->basedoc);
915 static HRESULT WINAPI WindowForBindingUI_GetWindow(IWindowForBindingUI *iface, REFGUID rguidReason, HWND *phwnd)
917 HTMLDocumentObj *This = impl_from_IWindowForBindingUI(iface);
919 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(rguidReason), phwnd);
921 *phwnd = This->hwnd;
922 return S_OK;
925 static const IWindowForBindingUIVtbl WindowForBindingUIVtbl = {
926 WindowForBindingUI_QueryInterface,
927 WindowForBindingUI_AddRef,
928 WindowForBindingUI_Release,
929 WindowForBindingUI_GetWindow
932 void HTMLDocument_View_Init(HTMLDocumentObj *doc)
934 doc->IOleDocumentView_iface.lpVtbl = &OleDocumentViewVtbl;
935 doc->IViewObjectEx_iface.lpVtbl = &ViewObjectVtbl;
936 doc->IWindowForBindingUI_iface.lpVtbl = &WindowForBindingUIVtbl;