riched20: Use ME_PointFromChar to calculate the caret position.
[wine] / dlls / ieframe / view.c
1 /*
2  * Copyright 2005 Jacek Caban
3  * Copyright 2010 Ilya Shpigor
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18  */
19
20 #include "ieframe.h"
21
22 #include "wine/debug.h"
23
24 WINE_DEFAULT_DEBUG_CHANNEL(ieframe);
25
26 /**********************************************************************
27  * Implement the IViewObject interface
28  */
29
30 static inline WebBrowser *impl_from_IViewObject2(IViewObject2 *iface)
31 {
32     return CONTAINING_RECORD(iface, WebBrowser, IViewObject2_iface);
33 }
34
35 static HRESULT WINAPI ViewObject_QueryInterface(IViewObject2 *iface, REFIID riid, void **ppv)
36 {
37     WebBrowser *This = impl_from_IViewObject2(iface);
38     return IWebBrowser2_QueryInterface(&This->IWebBrowser2_iface, riid, ppv);
39 }
40
41 static ULONG WINAPI ViewObject_AddRef(IViewObject2 *iface)
42 {
43     WebBrowser *This = impl_from_IViewObject2(iface);
44     return IWebBrowser2_AddRef(&This->IWebBrowser2_iface);
45 }
46
47 static ULONG WINAPI ViewObject_Release(IViewObject2 *iface)
48 {
49     WebBrowser *This = impl_from_IViewObject2(iface);
50     return IWebBrowser2_Release(&This->IWebBrowser2_iface);
51 }
52
53 static HRESULT WINAPI ViewObject_Draw(IViewObject2 *iface, DWORD dwDrawAspect,
54         LONG lindex, void *pvAspect, DVTARGETDEVICE *ptd, HDC hdcTargetDev,
55         HDC hdcDraw, LPCRECTL lprcBounds, LPCRECTL lprcWBounds,
56         BOOL (STDMETHODCALLTYPE *pfnContinue)(ULONG_PTR),
57         ULONG_PTR dwContinue)
58 {
59     WebBrowser *This = impl_from_IViewObject2(iface);
60     FIXME("(%p)->(%d %d %p %p %p %p %p %p %p %08lx)\n", This, dwDrawAspect, lindex,
61             pvAspect, ptd, hdcTargetDev, hdcDraw, lprcBounds, lprcWBounds, pfnContinue,
62             dwContinue);
63     return E_NOTIMPL;
64 }
65
66 static HRESULT WINAPI ViewObject_GetColorSet(IViewObject2 *iface, DWORD dwAspect,
67         LONG lindex, void *pvAspect, DVTARGETDEVICE *ptd, HDC hicTargetDev,
68         LOGPALETTE **ppColorSet)
69 {
70     WebBrowser *This = impl_from_IViewObject2(iface);
71     FIXME("(%p)->(%d %d %p %p %p %p)\n", This, dwAspect, lindex, pvAspect, ptd,
72             hicTargetDev, ppColorSet);
73     return E_NOTIMPL;
74 }
75
76 static HRESULT WINAPI ViewObject_Freeze(IViewObject2 *iface, DWORD dwDrawAspect, LONG lindex,
77                                         void *pvAspect, DWORD *pdwFreeze)
78 {
79     WebBrowser *This = impl_from_IViewObject2(iface);
80     FIXME("(%p)->(%d %d %p %p)\n", This, dwDrawAspect, lindex, pvAspect, pdwFreeze);
81     return E_NOTIMPL;
82 }
83
84 static HRESULT WINAPI ViewObject_Unfreeze(IViewObject2 *iface, DWORD dwFreeze)
85 {
86     WebBrowser *This = impl_from_IViewObject2(iface);
87     FIXME("(%p)->(%d)\n", This, dwFreeze);
88     return E_NOTIMPL;
89 }
90
91 static HRESULT WINAPI ViewObject_SetAdvise(IViewObject2 *iface, DWORD aspects, DWORD advf,
92         IAdviseSink *pAdvSink)
93 {
94     WebBrowser *This = impl_from_IViewObject2(iface);
95     FIXME("(%p)->(%d %08x %p)\n", This, aspects, advf, pAdvSink);
96     return E_NOTIMPL;
97 }
98
99 static HRESULT WINAPI ViewObject_GetAdvise(IViewObject2 *iface, DWORD *pAspects,
100         DWORD *pAdvf, IAdviseSink **ppAdvSink)
101 {
102     WebBrowser *This = impl_from_IViewObject2(iface);
103     FIXME("(%p)->(%p %p %p)\n", This, pAspects, pAdvf, ppAdvSink);
104     return E_NOTIMPL;
105 }
106
107 static HRESULT WINAPI ViewObject_GetExtent(IViewObject2 *iface, DWORD dwAspect, LONG lindex,
108         DVTARGETDEVICE *ptd, LPSIZEL lpsizel)
109 {
110     WebBrowser *This = impl_from_IViewObject2(iface);
111     FIXME("(%p)->(%d %d %p %p)\n", This, dwAspect, lindex, ptd, lpsizel);
112     return E_NOTIMPL;
113 }
114
115 static const IViewObject2Vtbl ViewObjectVtbl = {
116     ViewObject_QueryInterface,
117     ViewObject_AddRef,
118     ViewObject_Release,
119     ViewObject_Draw,
120     ViewObject_GetColorSet,
121     ViewObject_Freeze,
122     ViewObject_Unfreeze,
123     ViewObject_SetAdvise,
124     ViewObject_GetAdvise,
125     ViewObject_GetExtent
126 };
127
128 /**********************************************************************
129  * Implement the IDataObject interface
130  */
131
132 static inline WebBrowser *impl_from_IDataObject(IDataObject *iface)
133 {
134     return CONTAINING_RECORD(iface, WebBrowser, IDataObject_iface);
135 }
136
137 static HRESULT WINAPI DataObject_QueryInterface(LPDATAOBJECT iface, REFIID riid, LPVOID * ppvObj)
138 {
139     WebBrowser *This = impl_from_IDataObject(iface);
140     return IWebBrowser2_QueryInterface(&This->IWebBrowser2_iface, riid, ppvObj);
141 }
142
143 static ULONG WINAPI DataObject_AddRef(LPDATAOBJECT iface)
144 {
145     WebBrowser *This = impl_from_IDataObject(iface);
146     return IWebBrowser2_AddRef(&This->IWebBrowser2_iface);
147 }
148
149 static ULONG WINAPI DataObject_Release(LPDATAOBJECT iface)
150 {
151     WebBrowser *This = impl_from_IDataObject(iface);
152     return IWebBrowser2_Release(&This->IWebBrowser2_iface);
153 }
154
155 static HRESULT WINAPI DataObject_GetData(LPDATAOBJECT iface, LPFORMATETC pformatetcIn, STGMEDIUM *pmedium)
156 {
157     WebBrowser *This = impl_from_IDataObject(iface);
158     FIXME("(%p)->()\n", This);
159     return E_NOTIMPL;
160 }
161
162 static HRESULT WINAPI DataObject_GetDataHere(LPDATAOBJECT iface, LPFORMATETC pformatetc, STGMEDIUM *pmedium)
163 {
164     WebBrowser *This = impl_from_IDataObject(iface);
165     FIXME("(%p)->()\n", This);
166     return E_NOTIMPL;
167 }
168
169 static HRESULT WINAPI DataObject_QueryGetData(LPDATAOBJECT iface, LPFORMATETC pformatetc)
170 {
171     WebBrowser *This = impl_from_IDataObject(iface);
172     FIXME("(%p)->()\n", This);
173     return E_NOTIMPL;
174 }
175
176 static HRESULT WINAPI DataObject_GetCanonicalFormatEtc(LPDATAOBJECT iface, LPFORMATETC pformatectIn, LPFORMATETC pformatetcOut)
177 {
178     WebBrowser *This = impl_from_IDataObject(iface);
179     FIXME("(%p)->()\n", This);
180     return E_NOTIMPL;
181 }
182
183 static HRESULT WINAPI DataObject_SetData(LPDATAOBJECT iface, LPFORMATETC pformatetc, STGMEDIUM *pmedium, BOOL fRelease)
184 {
185     WebBrowser *This = impl_from_IDataObject(iface);
186     FIXME("(%p)->()\n", This);
187     return E_NOTIMPL;
188 }
189
190 static HRESULT WINAPI DataObject_EnumFormatEtc(LPDATAOBJECT iface, DWORD dwDirection, IEnumFORMATETC **ppenumFormatEtc)
191 {
192     WebBrowser *This = impl_from_IDataObject(iface);
193     FIXME("(%p)->()\n", This);
194     return E_NOTIMPL;
195 }
196
197 static HRESULT WINAPI DataObject_DAdvise(LPDATAOBJECT iface, FORMATETC *pformatetc, DWORD advf, IAdviseSink *pAdvSink, DWORD *pdwConnection)
198 {
199     WebBrowser *This = impl_from_IDataObject(iface);
200     FIXME("(%p)->()\n", This);
201     return E_NOTIMPL;
202 }
203
204 static HRESULT WINAPI DataObject_DUnadvise(LPDATAOBJECT iface, DWORD dwConnection)
205 {
206     WebBrowser *This = impl_from_IDataObject(iface);
207     FIXME("(%p)->()\n", This);
208     return E_NOTIMPL;
209 }
210
211 static HRESULT WINAPI DataObject_EnumDAdvise(LPDATAOBJECT iface, IEnumSTATDATA **ppenumAdvise)
212 {
213     WebBrowser *This = impl_from_IDataObject(iface);
214     FIXME("(%p)->()\n", This);
215     return E_NOTIMPL;
216 }
217
218 static const IDataObjectVtbl DataObjectVtbl = {
219     DataObject_QueryInterface,
220     DataObject_AddRef,
221     DataObject_Release,
222     DataObject_GetData,
223     DataObject_GetDataHere,
224     DataObject_QueryGetData,
225     DataObject_GetCanonicalFormatEtc,
226     DataObject_SetData,
227     DataObject_EnumFormatEtc,
228     DataObject_DAdvise,
229     DataObject_DUnadvise,
230     DataObject_EnumDAdvise
231 };
232
233 void WebBrowser_ViewObject_Init(WebBrowser *This)
234 {
235     This->IViewObject2_iface.lpVtbl = &ViewObjectVtbl;
236     This->IDataObject_iface.lpVtbl  = &DataObjectVtbl;
237 }