wined3d: Pass explicit texcoords to depth blt.
[wine/multimedia.git] / dlls / mshtml / htmlselect.c
blob3a414cfcbcf618552295a0babcb447d62791bfbb
1 /*
2 * Copyright 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>
21 #define COBJMACROS
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winuser.h"
26 #include "ole2.h"
28 #include "wine/debug.h"
30 #include "mshtml_private.h"
31 #include "htmlevent.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
35 typedef struct {
36 HTMLElement element;
38 const IHTMLSelectElementVtbl *lpHTMLSelectElementVtbl;
40 nsIDOMHTMLSelectElement *nsselect;
41 } HTMLSelectElement;
43 #define HTMLSELECT(x) ((IHTMLSelectElement*) &(x)->lpHTMLSelectElementVtbl)
45 #define HTMLSELECT_THIS(iface) DEFINE_THIS(HTMLSelectElement, HTMLSelectElement, iface)
47 static HRESULT WINAPI HTMLSelectElement_QueryInterface(IHTMLSelectElement *iface,
48 REFIID riid, void **ppv)
50 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
52 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->element.node), riid, ppv);
55 static ULONG WINAPI HTMLSelectElement_AddRef(IHTMLSelectElement *iface)
57 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
59 return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->element.node));
62 static ULONG WINAPI HTMLSelectElement_Release(IHTMLSelectElement *iface)
64 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
66 return IHTMLDOMNode_Release(HTMLDOMNODE(&This->element.node));
69 static HRESULT WINAPI HTMLSelectElement_GetTypeInfoCount(IHTMLSelectElement *iface, UINT *pctinfo)
71 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
73 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->element.node.dispex), pctinfo);
76 static HRESULT WINAPI HTMLSelectElement_GetTypeInfo(IHTMLSelectElement *iface, UINT iTInfo,
77 LCID lcid, ITypeInfo **ppTInfo)
79 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
81 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->element.node.dispex), iTInfo, lcid, ppTInfo);
84 static HRESULT WINAPI HTMLSelectElement_GetIDsOfNames(IHTMLSelectElement *iface, REFIID riid,
85 LPOLESTR *rgszNames, UINT cNames,
86 LCID lcid, DISPID *rgDispId)
88 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
90 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->element.node.dispex), riid, rgszNames, cNames, lcid, rgDispId);
93 static HRESULT WINAPI HTMLSelectElement_Invoke(IHTMLSelectElement *iface, DISPID dispIdMember,
94 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
95 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
97 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
99 return IDispatchEx_Invoke(DISPATCHEX(&This->element.node.dispex), dispIdMember, riid, lcid,
100 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
103 static HRESULT WINAPI HTMLSelectElement_put_size(IHTMLSelectElement *iface, long v)
105 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
106 FIXME("(%p)->(%ld)\n", This, v);
107 return E_NOTIMPL;
110 static HRESULT WINAPI HTMLSelectElement_get_size(IHTMLSelectElement *iface, long *p)
112 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
113 FIXME("(%p)->(%p)\n", This, p);
114 return E_NOTIMPL;
117 static HRESULT WINAPI HTMLSelectElement_put_multiple(IHTMLSelectElement *iface, VARIANT_BOOL v)
119 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
120 FIXME("(%p)->(%x)\n", This, v);
121 return E_NOTIMPL;
124 static HRESULT WINAPI HTMLSelectElement_get_multiple(IHTMLSelectElement *iface, VARIANT_BOOL *p)
126 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
127 FIXME("(%p)->(%p)\n", This, p);
128 return E_NOTIMPL;
131 static HRESULT WINAPI HTMLSelectElement_put_name(IHTMLSelectElement *iface, BSTR v)
133 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
134 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
135 return E_NOTIMPL;
138 static HRESULT WINAPI HTMLSelectElement_get_name(IHTMLSelectElement *iface, BSTR *p)
140 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
141 nsAString name_str;
142 const PRUnichar *name = NULL;
143 nsresult nsres;
145 TRACE("(%p)->(%p)\n", This, p);
147 nsAString_Init(&name_str, NULL);
149 nsres = nsIDOMHTMLSelectElement_GetName(This->nsselect, &name_str);
150 if(NS_SUCCEEDED(nsres)) {
151 static const WCHAR wszGarbage[] = {'g','a','r','b','a','g','e',0};
153 nsAString_GetData(&name_str, &name);
156 * Native never returns empty string here. If an element has no name,
157 * name of previous element or ramdom data is returned.
159 *p = SysAllocString(*name ? name : wszGarbage);
160 }else {
161 ERR("GetName failed: %08x\n", nsres);
164 nsAString_Finish(&name_str);
166 TRACE("name=%s\n", debugstr_w(*p));
167 return S_OK;
170 static HRESULT WINAPI HTMLSelectElement_get_options(IHTMLSelectElement *iface, IDispatch **p)
172 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
173 FIXME("(%p)->(%p)\n", This, p);
174 return E_NOTIMPL;
177 static HRESULT WINAPI HTMLSelectElement_put_onchange(IHTMLSelectElement *iface, VARIANT v)
179 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
181 TRACE("(%p)->()\n", This);
183 return set_node_event(&This->element.node, EVENTID_CHANGE, &v);
186 static HRESULT WINAPI HTMLSelectElement_get_onchange(IHTMLSelectElement *iface, VARIANT *p)
188 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
189 FIXME("(%p)->(%p)\n", This, p);
190 return E_NOTIMPL;
193 static HRESULT WINAPI HTMLSelectElement_put_selectedIndex(IHTMLSelectElement *iface, long v)
195 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
196 nsresult nsres;
198 TRACE("(%p)->(%ld)\n", This, v);
200 nsres = nsIDOMHTMLSelectElement_SetSelectedIndex(This->nsselect, v);
201 if(NS_FAILED(nsres))
202 ERR("SetSelectedIndex failed: %08x\n", nsres);
204 return S_OK;
207 static HRESULT WINAPI HTMLSelectElement_get_selectedIndex(IHTMLSelectElement *iface, long *p)
209 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
210 PRInt32 idx = 0;
211 nsresult nsres;
213 TRACE("(%p)->(%p)\n", This, p);
215 nsres = nsIDOMHTMLSelectElement_GetSelectedIndex(This->nsselect, &idx);
216 if(NS_FAILED(nsres))
217 ERR("GetSelectedIndex failed: %08x\n", nsres);
219 *p = idx;
220 return S_OK;
223 static HRESULT WINAPI HTMLSelectElement_get_type(IHTMLSelectElement *iface, BSTR *p)
225 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
226 const PRUnichar *type;
227 nsAString type_str;
228 nsresult nsres;
229 HRESULT hres = S_OK;
231 TRACE("(%p)->(%p)\n", This, p);
233 nsAString_Init(&type_str, NULL);
234 nsres = nsIDOMHTMLSelectElement_GetType(This->nsselect, &type_str);
235 if(NS_SUCCEEDED(nsres)) {
236 nsAString_GetData(&type_str, &type);
237 *p = *type ? SysAllocString(type) : NULL;
238 }else {
239 ERR("GetType failed: %08x\n", nsres);
240 hres = E_FAIL;
243 nsAString_Finish(&type_str);
245 return hres;
248 static HRESULT WINAPI HTMLSelectElement_put_value(IHTMLSelectElement *iface, BSTR v)
250 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
251 nsAString value_str;
252 nsresult nsres;
254 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
256 nsAString_Init(&value_str, v);
257 nsres = nsIDOMHTMLSelectElement_SetValue(This->nsselect, &value_str);
258 nsAString_Finish(&value_str);
259 if(NS_FAILED(nsres))
260 ERR("SetValue failed: %08x\n", nsres);
262 return S_OK;
265 static HRESULT WINAPI HTMLSelectElement_get_value(IHTMLSelectElement *iface, BSTR *p)
267 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
268 nsAString value_str;
269 const PRUnichar *value = NULL;
270 nsresult nsres;
272 TRACE("(%p)->(%p)\n", This, p);
274 nsAString_Init(&value_str, NULL);
276 nsres = nsIDOMHTMLSelectElement_GetValue(This->nsselect, &value_str);
277 if(NS_SUCCEEDED(nsres)) {
278 nsAString_GetData(&value_str, &value);
279 *p = *value ? SysAllocString(value) : NULL;
280 }else {
281 ERR("GetValue failed: %08x\n", nsres);
284 nsAString_Finish(&value_str);
286 TRACE("value=%s\n", debugstr_w(*p));
287 return S_OK;
290 static HRESULT WINAPI HTMLSelectElement_put_disabled(IHTMLSelectElement *iface, VARIANT_BOOL v)
292 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
293 nsresult nsres;
295 TRACE("(%p)->(%x)\n", This, v);
297 nsres = nsIDOMHTMLSelectElement_SetDisabled(This->nsselect, v != VARIANT_FALSE);
298 if(NS_FAILED(nsres)) {
299 ERR("SetDisabled failed: %08x\n", nsres);
300 return E_FAIL;
303 return S_OK;
306 static HRESULT WINAPI HTMLSelectElement_get_disabled(IHTMLSelectElement *iface, VARIANT_BOOL *p)
308 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
309 PRBool disabled = FALSE;
310 nsresult nsres;
312 TRACE("(%p)->(%p)\n", This, p);
314 nsres = nsIDOMHTMLSelectElement_GetDisabled(This->nsselect, &disabled);
315 if(NS_FAILED(nsres)) {
316 ERR("GetDisabled failed: %08x\n", nsres);
317 return E_FAIL;
320 *p = disabled ? VARIANT_TRUE : VARIANT_FALSE;
321 return S_OK;
324 static HRESULT WINAPI HTMLSelectElement_get_form(IHTMLSelectElement *iface, IHTMLFormElement **p)
326 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
327 FIXME("(%p)->(%p)\n", This, p);
328 return E_NOTIMPL;
331 static HRESULT WINAPI HTMLSelectElement_add(IHTMLSelectElement *iface, IHTMLElement *element,
332 VARIANT before)
334 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
335 FIXME("(%p)->(%p v)\n", This, element);
336 return E_NOTIMPL;
339 static HRESULT WINAPI HTMLSelectElement_remove(IHTMLSelectElement *iface, long index)
341 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
342 FIXME("(%p)->(%ld)\n", This, index);
343 return E_NOTIMPL;
346 static HRESULT WINAPI HTMLSelectElement_put_length(IHTMLSelectElement *iface, long v)
348 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
349 FIXME("(%p)->(%ld)\n", This, v);
350 return E_NOTIMPL;
353 static HRESULT WINAPI HTMLSelectElement_get_length(IHTMLSelectElement *iface, long *p)
355 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
356 PRUint32 length = 0;
357 nsresult nsres;
359 TRACE("(%p)->(%p)\n", This, p);
361 nsres = nsIDOMHTMLSelectElement_GetLength(This->nsselect, &length);
362 if(NS_FAILED(nsres))
363 ERR("GetLength failed: %08x\n", nsres);
365 *p = length;
367 TRACE("ret %ld\n", *p);
368 return S_OK;
371 static HRESULT WINAPI HTMLSelectElement_get__newEnum(IHTMLSelectElement *iface, IUnknown **p)
373 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
374 FIXME("(%p)->(%p)\n", This, p);
375 return E_NOTIMPL;
378 static HRESULT WINAPI HTMLSelectElement_item(IHTMLSelectElement *iface, VARIANT name,
379 VARIANT index, IDispatch **pdisp)
381 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
382 FIXME("(%p)->(v v %p)\n", This, pdisp);
383 return E_NOTIMPL;
386 static HRESULT WINAPI HTMLSelectElement_tags(IHTMLSelectElement *iface, VARIANT tagName,
387 IDispatch **pdisp)
389 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
390 FIXME("(%p)->(v %p)\n", This, pdisp);
391 return E_NOTIMPL;
394 #undef HTMLSELECT_THIS
396 static const IHTMLSelectElementVtbl HTMLSelectElementVtbl = {
397 HTMLSelectElement_QueryInterface,
398 HTMLSelectElement_AddRef,
399 HTMLSelectElement_Release,
400 HTMLSelectElement_GetTypeInfoCount,
401 HTMLSelectElement_GetTypeInfo,
402 HTMLSelectElement_GetIDsOfNames,
403 HTMLSelectElement_Invoke,
404 HTMLSelectElement_put_size,
405 HTMLSelectElement_get_size,
406 HTMLSelectElement_put_multiple,
407 HTMLSelectElement_get_multiple,
408 HTMLSelectElement_put_name,
409 HTMLSelectElement_get_name,
410 HTMLSelectElement_get_options,
411 HTMLSelectElement_put_onchange,
412 HTMLSelectElement_get_onchange,
413 HTMLSelectElement_put_selectedIndex,
414 HTMLSelectElement_get_selectedIndex,
415 HTMLSelectElement_get_type,
416 HTMLSelectElement_put_value,
417 HTMLSelectElement_get_value,
418 HTMLSelectElement_put_disabled,
419 HTMLSelectElement_get_disabled,
420 HTMLSelectElement_get_form,
421 HTMLSelectElement_add,
422 HTMLSelectElement_remove,
423 HTMLSelectElement_put_length,
424 HTMLSelectElement_get_length,
425 HTMLSelectElement_get__newEnum,
426 HTMLSelectElement_item,
427 HTMLSelectElement_tags
430 #define HTMLSELECT_NODE_THIS(iface) DEFINE_THIS2(HTMLSelectElement, element.node, iface)
432 static HRESULT HTMLSelectElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
434 HTMLSelectElement *This = HTMLSELECT_NODE_THIS(iface);
436 *ppv = NULL;
438 if(IsEqualGUID(&IID_IUnknown, riid)) {
439 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
440 *ppv = HTMLSELECT(This);
441 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
442 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
443 *ppv = HTMLSELECT(This);
444 }else if(IsEqualGUID(&IID_IHTMLSelectElement, riid)) {
445 TRACE("(%p)->(IID_IHTMLSelectElement %p)\n", This, ppv);
446 *ppv = HTMLSELECT(This);
449 if(*ppv) {
450 IUnknown_AddRef((IUnknown*)*ppv);
451 return S_OK;
454 return HTMLElement_QI(&This->element.node, riid, ppv);
457 static void HTMLSelectElement_destructor(HTMLDOMNode *iface)
459 HTMLSelectElement *This = HTMLSELECT_NODE_THIS(iface);
461 nsIDOMHTMLSelectElement_Release(This->nsselect);
463 HTMLElement_destructor(&This->element.node);
466 static HRESULT HTMLSelectElementImpl_put_disabled(HTMLDOMNode *iface, VARIANT_BOOL v)
468 HTMLSelectElement *This = HTMLSELECT_NODE_THIS(iface);
469 return IHTMLSelectElement_put_disabled(HTMLSELECT(This), v);
472 static HRESULT HTMLSelectElementImpl_get_disabled(HTMLDOMNode *iface, VARIANT_BOOL *p)
474 HTMLSelectElement *This = HTMLSELECT_NODE_THIS(iface);
475 return IHTMLSelectElement_get_disabled(HTMLSELECT(This), p);
478 #undef HTMLSELECT_NODE_THIS
480 static const NodeImplVtbl HTMLSelectElementImplVtbl = {
481 HTMLSelectElement_QI,
482 HTMLSelectElement_destructor,
483 HTMLSelectElementImpl_put_disabled,
484 HTMLSelectElementImpl_get_disabled
487 static const tid_t HTMLSelectElement_tids[] = {
488 IHTMLDOMNode_tid,
489 IHTMLDOMNode2_tid,
490 IHTMLElement_tid,
491 IHTMLElement2_tid,
492 IHTMLElement3_tid,
493 IHTMLSelectElement_tid,
497 static dispex_static_data_t HTMLSelectElement_dispex = {
498 NULL,
499 DispHTMLSelectElement_tid,
500 NULL,
501 HTMLSelectElement_tids
504 HTMLElement *HTMLSelectElement_Create(nsIDOMHTMLElement *nselem)
506 HTMLSelectElement *ret = heap_alloc_zero(sizeof(HTMLSelectElement));
507 nsresult nsres;
509 ret->lpHTMLSelectElementVtbl = &HTMLSelectElementVtbl;
510 ret->element.node.vtbl = &HTMLSelectElementImplVtbl;
512 init_dispex(&ret->element.node.dispex, (IUnknown*)HTMLSELECT(ret), &HTMLSelectElement_dispex);
513 HTMLElement_Init(&ret->element);
515 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLSelectElement,
516 (void**)&ret->nsselect);
517 if(NS_FAILED(nsres))
518 ERR("Could not get nsIDOMHTMLSelectElement interfce: %08x\n", nsres);
520 return &ret->element;