gdi32: Clip solid pen regions to the DIB rectangle to avoid overflows.
[wine.git] / dlls / mshtml / olewnd.c
blob2a52c0217655776b18a140cd93d4795241f37d22
1 /*
2 * Copyright 2005 Jacek Caban
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 "config.h"
21 #include <stdarg.h>
22 #include <stdio.h>
24 #define COBJMACROS
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "ole2.h"
31 #include "wine/debug.h"
33 #include "mshtml_private.h"
34 #include "resource.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
38 /**********************************************************
39 * IOleInPlaceActiveObject implementation
42 static inline HTMLDocument *impl_from_IOleInPlaceActiveObject(IOleInPlaceActiveObject *iface)
44 return CONTAINING_RECORD(iface, HTMLDocument, IOleInPlaceActiveObject_iface);
47 static HRESULT WINAPI OleInPlaceActiveObject_QueryInterface(IOleInPlaceActiveObject *iface, REFIID riid, void **ppv)
49 HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
50 return htmldoc_query_interface(This, riid, ppv);
53 static ULONG WINAPI OleInPlaceActiveObject_AddRef(IOleInPlaceActiveObject *iface)
55 HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
56 return htmldoc_addref(This);
59 static ULONG WINAPI OleInPlaceActiveObject_Release(IOleInPlaceActiveObject *iface)
61 HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
62 return htmldoc_release(This);
65 static HRESULT WINAPI OleInPlaceActiveObject_GetWindow(IOleInPlaceActiveObject *iface, HWND *phwnd)
67 HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
69 TRACE("(%p)->(%p)\n", This, phwnd);
71 if(!phwnd)
72 return E_INVALIDARG;
74 if(!This->doc_obj->in_place_active) {
75 *phwnd = NULL;
76 return E_FAIL;
79 *phwnd = This->doc_obj->hwnd;
80 return S_OK;
83 static HRESULT WINAPI OleInPlaceActiveObject_ContextSensitiveHelp(IOleInPlaceActiveObject *iface, BOOL fEnterMode)
85 HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
86 FIXME("(%p)->(%x)\n", This, fEnterMode);
87 return E_NOTIMPL;
90 static HRESULT WINAPI OleInPlaceActiveObject_TranslateAccelerator(IOleInPlaceActiveObject *iface, LPMSG lpmsg)
92 HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
93 FIXME("(%p)->(%p)\n", This, lpmsg);
94 return E_NOTIMPL;
97 static HRESULT WINAPI OleInPlaceActiveObject_OnFrameWindowActivate(IOleInPlaceActiveObject *iface,
98 BOOL fActivate)
100 HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
102 TRACE("(%p)->(%x)\n", This, fActivate);
104 if(This->doc_obj->hostui)
105 IDocHostUIHandler_OnFrameWindowActivate(This->doc_obj->hostui, fActivate);
107 return S_OK;
110 static HRESULT WINAPI OleInPlaceActiveObject_OnDocWindowActivate(IOleInPlaceActiveObject *iface, BOOL fActivate)
112 HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
113 FIXME("(%p)->(%x)\n", This, fActivate);
114 return E_NOTIMPL;
117 static HRESULT WINAPI OleInPlaceActiveObject_ResizeBorder(IOleInPlaceActiveObject *iface, LPCRECT prcBorder,
118 IOleInPlaceUIWindow *pUIWindow, BOOL fFrameWindow)
120 HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
121 FIXME("(%p)->(%p %p %x)\n", This, prcBorder, pUIWindow, fFrameWindow);
122 return E_NOTIMPL;
125 static HRESULT WINAPI OleInPlaceActiveObject_EnableModeless(IOleInPlaceActiveObject *iface, BOOL fEnable)
127 HTMLDocument *This = impl_from_IOleInPlaceActiveObject(iface);
128 FIXME("(%p)->(%x)\n", This, fEnable);
129 return E_NOTIMPL;
132 static const IOleInPlaceActiveObjectVtbl OleInPlaceActiveObjectVtbl = {
133 OleInPlaceActiveObject_QueryInterface,
134 OleInPlaceActiveObject_AddRef,
135 OleInPlaceActiveObject_Release,
136 OleInPlaceActiveObject_GetWindow,
137 OleInPlaceActiveObject_ContextSensitiveHelp,
138 OleInPlaceActiveObject_TranslateAccelerator,
139 OleInPlaceActiveObject_OnFrameWindowActivate,
140 OleInPlaceActiveObject_OnDocWindowActivate,
141 OleInPlaceActiveObject_ResizeBorder,
142 OleInPlaceActiveObject_EnableModeless
145 /**********************************************************
146 * IOleInPlaceObjectWindowless implementation
149 static inline HTMLDocument *impl_from_IOleInPlaceObjectWindowless(IOleInPlaceObjectWindowless *iface)
151 return CONTAINING_RECORD(iface, HTMLDocument, IOleInPlaceObjectWindowless_iface);
154 static HRESULT WINAPI OleInPlaceObjectWindowless_QueryInterface(IOleInPlaceObjectWindowless *iface,
155 REFIID riid, void **ppv)
157 HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
158 return htmldoc_query_interface(This, riid, ppv);
161 static ULONG WINAPI OleInPlaceObjectWindowless_AddRef(IOleInPlaceObjectWindowless *iface)
163 HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
164 return htmldoc_addref(This);
167 static ULONG WINAPI OleInPlaceObjectWindowless_Release(IOleInPlaceObjectWindowless *iface)
169 HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
170 return htmldoc_release(This);
173 static HRESULT WINAPI OleInPlaceObjectWindowless_GetWindow(IOleInPlaceObjectWindowless *iface,
174 HWND *phwnd)
176 HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
177 return IOleInPlaceActiveObject_GetWindow(&This->IOleInPlaceActiveObject_iface, phwnd);
180 static HRESULT WINAPI OleInPlaceObjectWindowless_ContextSensitiveHelp(IOleInPlaceObjectWindowless *iface,
181 BOOL fEnterMode)
183 HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
184 return IOleInPlaceActiveObject_ContextSensitiveHelp(&This->IOleInPlaceActiveObject_iface, fEnterMode);
187 static HRESULT WINAPI OleInPlaceObjectWindowless_InPlaceDeactivate(IOleInPlaceObjectWindowless *iface)
189 HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
191 TRACE("(%p)\n", This);
193 if(This->doc_obj->ui_active)
194 IOleDocumentView_UIActivate(&This->IOleDocumentView_iface, FALSE);
195 This->doc_obj->window_active = FALSE;
197 if(!This->doc_obj->in_place_active)
198 return S_OK;
200 if(This->doc_obj->frame) {
201 IOleInPlaceFrame_Release(This->doc_obj->frame);
202 This->doc_obj->frame = NULL;
205 if(This->doc_obj->hwnd) {
206 ShowWindow(This->doc_obj->hwnd, SW_HIDE);
207 SetWindowPos(This->doc_obj->hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
210 This->doc_obj->focus = FALSE;
211 notif_focus(This->doc_obj);
213 This->doc_obj->in_place_active = FALSE;
214 if(This->doc_obj->ipsite) {
215 IOleInPlaceSiteEx *ipsiteex;
216 HRESULT hres;
218 hres = IOleInPlaceSite_QueryInterface(This->doc_obj->ipsite, &IID_IOleInPlaceSiteEx, (void**)&ipsiteex);
219 if(SUCCEEDED(hres)) {
220 IOleInPlaceSiteEx_OnInPlaceDeactivateEx(ipsiteex, TRUE);
221 IOleInPlaceSiteEx_Release(ipsiteex);
222 }else {
223 IOleInPlaceSite_OnInPlaceDeactivate(This->doc_obj->ipsite);
227 return S_OK;
230 static HRESULT WINAPI OleInPlaceObjectWindowless_UIDeactivate(IOleInPlaceObjectWindowless *iface)
232 HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
233 FIXME("(%p)\n", This);
234 return E_NOTIMPL;
237 static HRESULT WINAPI OleInPlaceObjectWindowless_SetObjectRects(IOleInPlaceObjectWindowless *iface,
238 LPCRECT lprcPosRect, LPCRECT lprcClipRect)
240 HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
241 FIXME("(%p)->(%p %p)\n", This, lprcPosRect, lprcClipRect);
242 return E_NOTIMPL;
245 static HRESULT WINAPI OleInPlaceObjectWindowless_ReactivateAndUndo(IOleInPlaceObjectWindowless *iface)
247 HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
248 FIXME("(%p)\n", This);
249 return E_NOTIMPL;
252 static HRESULT WINAPI OleInPlaceObjectWindowless_OnWindowMessage(IOleInPlaceObjectWindowless *iface,
253 UINT msg, WPARAM wParam, LPARAM lParam, LRESULT *lpResult)
255 HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
256 FIXME("(%p)->(%u %lu %lu %p)\n", This, msg, wParam, lParam, lpResult);
257 return E_NOTIMPL;
260 static HRESULT WINAPI OleInPlaceObjectWindowless_GetDropTarget(IOleInPlaceObjectWindowless *iface,
261 IDropTarget **ppDropTarget)
263 HTMLDocument *This = impl_from_IOleInPlaceObjectWindowless(iface);
264 FIXME("(%p)->(%p)\n", This, ppDropTarget);
265 return E_NOTIMPL;
268 static const IOleInPlaceObjectWindowlessVtbl OleInPlaceObjectWindowlessVtbl = {
269 OleInPlaceObjectWindowless_QueryInterface,
270 OleInPlaceObjectWindowless_AddRef,
271 OleInPlaceObjectWindowless_Release,
272 OleInPlaceObjectWindowless_GetWindow,
273 OleInPlaceObjectWindowless_ContextSensitiveHelp,
274 OleInPlaceObjectWindowless_InPlaceDeactivate,
275 OleInPlaceObjectWindowless_UIDeactivate,
276 OleInPlaceObjectWindowless_SetObjectRects,
277 OleInPlaceObjectWindowless_ReactivateAndUndo,
278 OleInPlaceObjectWindowless_OnWindowMessage,
279 OleInPlaceObjectWindowless_GetDropTarget
282 void HTMLDocument_Window_Init(HTMLDocument *This)
284 This->IOleInPlaceActiveObject_iface.lpVtbl = &OleInPlaceActiveObjectVtbl;
285 This->IOleInPlaceObjectWindowless_iface.lpVtbl = &OleInPlaceObjectWindowlessVtbl;