1 /* 2 * Copyright 2009 Jacek Caban for CodeWeavers 3 * 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. 8 * 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. 13 * 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 17 */ 18 19 #include "mshtml_private.h" 20 21 typedef struct { 22 DispatchEx dispex; 23 IHTMLScreen IHTMLScreen_iface; 24 25 LONG ref; 26 } HTMLScreen; 27 28 static inline HTMLScreen *impl_from_IHTMLScreen(IHTMLScreen *iface) 29 { 30 return CONTAINING_RECORD(iface, HTMLScreen, IHTMLScreen_iface); 31 } 32 33 static HRESULT WINAPI HTMLScreen_QueryInterface(IHTMLScreen *iface, REFIID riid, void **ppv) 34 { 35 HTMLScreen *This = impl_from_IHTMLScreen(iface); 36 37 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv); 38 39 if(IsEqualGUID(&IID_IUnknown, riid)) { 40 *ppv = &This->IHTMLScreen_iface; 41 }else if(IsEqualGUID(&IID_IHTMLScreen, riid)) { 42 *ppv = &This->IHTMLScreen_iface; 43 }else if(dispex_query_interface(&This->dispex, riid, ppv)) { 44 return *ppv ? S_OK : E_NOINTERFACE; 45 }else { 46 *ppv = NULL; 47 WARN("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv); 48 return E_NOINTERFACE; 49 } 50 51 IUnknown_AddRef((IUnknown*)*ppv); 52 return S_OK; 53 } 54 55 static ULONG WINAPI HTMLScreen_AddRef(IHTMLScreen *iface) 56 { 57 HTMLScreen *This = impl_from_IHTMLScreen(iface); 58 LONG ref = InterlockedIncrement(&This->ref); 59 60 TRACE("(%p) ref=%d\n", This, ref); 61 62 return ref; 63 } 64 65 static ULONG WINAPI HTMLScreen_Release(IHTMLScreen *iface) 66 { 67 HTMLScreen *This = impl_from_IHTMLScreen(iface); 68 LONG ref = InterlockedDecrement(&This->ref); 69 70 TRACE("(%p) ref=%d\n", This, ref); 71 72 if(!ref) { 73 release_dispex(&This->dispex); 74 heap_free(This); 75 } 76 77 return ref; 78 } 79 80 static HRESULT WINAPI HTMLScreen_GetTypeInfoCount(IHTMLScreen *iface, UINT *pctinfo) 81 { 82 HTMLScreen *This = impl_from_IHTMLScreen(iface); 83 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo); 84 } 85 86 static HRESULT WINAPI HTMLScreen_GetTypeInfo(IHTMLScreen *iface, UINT iTInfo, 87 LCID lcid, ITypeInfo **ppTInfo) 88 { 89 HTMLScreen *This = impl_from_IHTMLScreen(iface); 90 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo); 91 } 92 93 static HRESULT WINAPI HTMLScreen_GetIDsOfNames(IHTMLScreen *iface, REFIID riid, 94 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId) 95 { 96 HTMLScreen *This = impl_from_IHTMLScreen(iface); 97 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames, 98 lcid, rgDispId); 99 } 100 101 static HRESULT WINAPI HTMLScreen_Invoke(IHTMLScreen *iface, DISPID dispIdMember, 102 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, 103 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) 104 { 105 HTMLScreen *This = impl_from_IHTMLScreen(iface); 106 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags, 107 pDispParams, pVarResult, pExcepInfo, puArgErr); 108 } 109 110 static HRESULT WINAPI HTMLScreen_get_colorDepth(IHTMLScreen *iface, LONG *p) 111 { 112 HTMLScreen *This = impl_from_IHTMLScreen(iface); 113 114 TRACE("(%p)->(%p)\n", This, p); 115 116 *p = GetDeviceCaps(get_display_dc(), BITSPIXEL); 117 return S_OK; 118 } 119 120 static HRESULT WINAPI HTMLScreen_put_bufferDepth(IHTMLScreen *iface, LONG v) 121 { 122 HTMLScreen *This = impl_from_IHTMLScreen(iface); 123 FIXME("(%p)->(%d)\n", This, v); 124 return E_NOTIMPL; 125 } 126 127 static HRESULT WINAPI HTMLScreen_get_bufferDepth(IHTMLScreen *iface, LONG *p) 128 { 129 HTMLScreen *This = impl_from_IHTMLScreen(iface); 130 FIXME("(%p)->(%p)\n", This, p); 131 return E_NOTIMPL; 132 } 133 134 static HRESULT WINAPI HTMLScreen_get_width(IHTMLScreen *iface, LONG *p) 135 { 136 HTMLScreen *This = impl_from_IHTMLScreen(iface); 137 138 TRACE("(%p)->(%p)\n", This, p); 139 140 *p = GetDeviceCaps(get_display_dc(), HORZRES); 141 return S_OK; 142 } 143 144 static HRESULT WINAPI HTMLScreen_get_height(IHTMLScreen *iface, LONG *p) 145 { 146 HTMLScreen *This = impl_from_IHTMLScreen(iface); 147 148 TRACE("(%p)->(%p)\n", This, p); 149 150 *p = GetDeviceCaps(get_display_dc(), VERTRES); 151 return S_OK; 152 } 153 154 static HRESULT WINAPI HTMLScreen_put_updateInterval(IHTMLScreen *iface, LONG v) 155 { 156 HTMLScreen *This = impl_from_IHTMLScreen(iface); 157 FIXME("(%p)->(%d)\n", This, v); 158 return E_NOTIMPL; 159 } 160 161 static HRESULT WINAPI HTMLScreen_get_updateInterval(IHTMLScreen *iface, LONG *p) 162 { 163 HTMLScreen *This = impl_from_IHTMLScreen(iface); 164 FIXME("(%p)->(%p)\n", This, p); 165 return E_NOTIMPL; 166 } 167 168 static HRESULT WINAPI HTMLScreen_get_availHeight(IHTMLScreen *iface, LONG *p) 169 { 170 HTMLScreen *This = impl_from_IHTMLScreen(iface); 171 RECT work_area; 172 173 TRACE("(%p)->(%p)\n", This, p); 174 175 if(!SystemParametersInfoW(SPI_GETWORKAREA, 0, &work_area, 0)) 176 return E_FAIL; 177 178 *p = work_area.bottom-work_area.top; 179 return S_OK; 180 } 181 182 static HRESULT WINAPI HTMLScreen_get_availWidth(IHTMLScreen *iface, LONG *p) 183 { 184 HTMLScreen *This = impl_from_IHTMLScreen(iface); 185 RECT work_area; 186 187 TRACE("(%p)->(%p)\n", This, p); 188 189 if(!SystemParametersInfoW(SPI_GETWORKAREA, 0, &work_area, 0)) 190 return E_FAIL; 191 192 *p = work_area.right-work_area.left; 193 return S_OK; 194 } 195 196 static HRESULT WINAPI HTMLScreen_get_fontSmoothingEnabled(IHTMLScreen *iface, VARIANT_BOOL *p) 197 { 198 HTMLScreen *This = impl_from_IHTMLScreen(iface); 199 FIXME("(%p)->(%p)\n", This, p); 200 return E_NOTIMPL; 201 } 202 203 static const IHTMLScreenVtbl HTMLSreenVtbl = { 204 HTMLScreen_QueryInterface, 205 HTMLScreen_AddRef, 206 HTMLScreen_Release, 207 HTMLScreen_GetTypeInfoCount, 208 HTMLScreen_GetTypeInfo, 209 HTMLScreen_GetIDsOfNames, 210 HTMLScreen_Invoke, 211 HTMLScreen_get_colorDepth, 212 HTMLScreen_put_bufferDepth, 213 HTMLScreen_get_bufferDepth, 214 HTMLScreen_get_width, 215 HTMLScreen_get_height, 216 HTMLScreen_put_updateInterval, 217 HTMLScreen_get_updateInterval, 218 HTMLScreen_get_availHeight, 219 HTMLScreen_get_availWidth, 220 HTMLScreen_get_fontSmoothingEnabled 221 }; 222 223 static const tid_t HTMLScreen_iface_tids[] = { 224 IHTMLScreen_tid, 225 0 226 }; 227 static dispex_static_data_t HTMLScreen_dispex = { 228 NULL, 229 DispHTMLScreen_tid, 230 NULL, 231 HTMLScreen_iface_tids 232 }; 233 234 HRESULT HTMLScreen_Create(IHTMLScreen **ret) 235 { 236 HTMLScreen *screen; 237 238 screen = heap_alloc_zero(sizeof(HTMLScreen)); 239 if(!screen) 240 return E_OUTOFMEMORY; 241 242 screen->IHTMLScreen_iface.lpVtbl = &HTMLSreenVtbl; 243 screen->ref = 1; 244 245 init_dispex(&screen->dispex, (IUnknown*)&screen->IHTMLScreen_iface, &HTMLScreen_dispex); 246 247 *ret = &screen->IHTMLScreen_iface; 248 return S_OK; 249 } 250