wined3d: Disable the SWAPEFFECT_DISCARD clear.
[wine.git] / dlls / mshtml / htmlselect.c
blob3a7faf859116eb897eeee19ad795efa0ed90bd5e
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 "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 "winnls.h"
30 #include "ole2.h"
32 #include "wine/debug.h"
34 #include "mshtml_private.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
38 typedef struct {
39 HTMLElement element;
41 const IHTMLSelectElementVtbl *lpHTMLSelectElementVtbl;
43 nsIDOMHTMLSelectElement *nsselect;
44 } HTMLSelectElement;
46 #define HTMLSELECT(x) ((IHTMLSelectElement*) &(x)->lpHTMLSelectElementVtbl)
48 #define HTMLSELECT_THIS(iface) DEFINE_THIS(HTMLSelectElement, HTMLSelectElement, iface)
50 static HRESULT WINAPI HTMLSelectElement_QueryInterface(IHTMLSelectElement *iface,
51 REFIID riid, void **ppv)
53 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
55 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->element.node), riid, ppv);
58 static ULONG WINAPI HTMLSelectElement_AddRef(IHTMLSelectElement *iface)
60 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
62 return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->element.node));
65 static ULONG WINAPI HTMLSelectElement_Release(IHTMLSelectElement *iface)
67 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
69 return IHTMLDOMNode_Release(HTMLDOMNODE(&This->element.node));
72 static HRESULT WINAPI HTMLSelectElement_GetTypeInfoCount(IHTMLSelectElement *iface, UINT *pctinfo)
74 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
75 FIXME("(%p)->(%p)\n", This, pctinfo);
76 return E_NOTIMPL;
79 static HRESULT WINAPI HTMLSelectElement_GetTypeInfo(IHTMLSelectElement *iface, UINT iTInfo,
80 LCID lcid, ITypeInfo **ppTInfo)
82 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
83 FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
84 return E_NOTIMPL;
87 static HRESULT WINAPI HTMLSelectElement_GetIDsOfNames(IHTMLSelectElement *iface, REFIID riid,
88 LPOLESTR *rgszNames, UINT cNames,
89 LCID lcid, DISPID *rgDispId)
91 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
92 FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
93 lcid, rgDispId);
94 return E_NOTIMPL;
97 static HRESULT WINAPI HTMLSelectElement_Invoke(IHTMLSelectElement *iface, DISPID dispIdMember,
98 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
99 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
101 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
102 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
103 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
104 return E_NOTIMPL;
107 static HRESULT WINAPI HTMLSelectElement_put_size(IHTMLSelectElement *iface, long v)
109 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
110 FIXME("(%p)->(%ld)\n", This, v);
111 return E_NOTIMPL;
114 static HRESULT WINAPI HTMLSelectElement_get_size(IHTMLSelectElement *iface, long *p)
116 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
117 FIXME("(%p)->(%p)\n", This, p);
118 return E_NOTIMPL;
121 static HRESULT WINAPI HTMLSelectElement_put_multiple(IHTMLSelectElement *iface, VARIANT_BOOL v)
123 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
124 FIXME("(%p)->(%x)\n", This, v);
125 return E_NOTIMPL;
128 static HRESULT WINAPI HTMLSelectElement_get_multiple(IHTMLSelectElement *iface, VARIANT_BOOL *p)
130 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
131 FIXME("(%p)->(%p)\n", This, p);
132 return E_NOTIMPL;
135 static HRESULT WINAPI HTMLSelectElement_put_name(IHTMLSelectElement *iface, BSTR v)
137 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
138 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
139 return E_NOTIMPL;
142 static HRESULT WINAPI HTMLSelectElement_get_name(IHTMLSelectElement *iface, BSTR *p)
144 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
145 nsAString name_str;
146 const PRUnichar *name = NULL;
147 nsresult nsres;
149 TRACE("(%p)->(%p)\n", This, p);
151 nsAString_Init(&name_str, NULL);
153 nsres = nsIDOMHTMLSelectElement_GetName(This->nsselect, &name_str);
154 if(NS_SUCCEEDED(nsres)) {
155 static const WCHAR wszGarbage[] = {'g','a','r','b','a','g','e',0};
157 nsAString_GetData(&name_str, &name);
160 * Native never returns empty string here. If an element has no name,
161 * name of previous element or ramdom data is returned.
163 *p = SysAllocString(*name ? name : wszGarbage);
164 }else {
165 ERR("GetName failed: %08x\n", nsres);
168 nsAString_Finish(&name_str);
170 TRACE("name=%s\n", debugstr_w(*p));
171 return S_OK;
174 static HRESULT WINAPI HTMLSelectElement_get_options(IHTMLSelectElement *iface, IDispatch **p)
176 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
177 FIXME("(%p)->(%p)\n", This, p);
178 return E_NOTIMPL;
181 static HRESULT WINAPI HTMLSelectElement_put_onchange(IHTMLSelectElement *iface, VARIANT v)
183 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
184 FIXME("(%p)->()\n", This);
185 return E_NOTIMPL;
188 static HRESULT WINAPI HTMLSelectElement_get_onchange(IHTMLSelectElement *iface, VARIANT *p)
190 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
191 FIXME("(%p)->(%p)\n", This, p);
192 return E_NOTIMPL;
195 static HRESULT WINAPI HTMLSelectElement_put_selectedIndex(IHTMLSelectElement *iface, long v)
197 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
198 nsresult nsres;
200 TRACE("(%p)->(%ld)\n", This, v);
202 nsres = nsIDOMHTMLSelectElement_SetSelectedIndex(This->nsselect, v);
203 if(NS_FAILED(nsres))
204 ERR("SetSelectedIndex failed: %08x\n", nsres);
206 return S_OK;
209 static HRESULT WINAPI HTMLSelectElement_get_selectedIndex(IHTMLSelectElement *iface, long *p)
211 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
212 PRInt32 idx = 0;
213 nsresult nsres;
215 TRACE("(%p)->(%p)\n", This, p);
217 nsres = nsIDOMHTMLSelectElement_GetSelectedIndex(This->nsselect, &idx);
218 if(NS_FAILED(nsres))
219 ERR("GetSelectedIndex failed: %08x\n", nsres);
221 *p = idx;
222 return S_OK;
225 static HRESULT WINAPI HTMLSelectElement_get_type(IHTMLSelectElement *iface, BSTR *p)
227 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
228 FIXME("(%p)->(%p)\n", This, p);
229 return E_NOTIMPL;
232 static HRESULT WINAPI HTMLSelectElement_put_value(IHTMLSelectElement *iface, BSTR v)
234 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
235 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
236 return E_NOTIMPL;
239 static HRESULT WINAPI HTMLSelectElement_get_value(IHTMLSelectElement *iface, BSTR *p)
241 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
242 nsAString value_str;
243 const PRUnichar *value = NULL;
244 nsresult nsres;
246 TRACE("(%p)->(%p)\n", This, p);
248 nsAString_Init(&value_str, NULL);
250 nsres = nsIDOMHTMLSelectElement_GetValue(This->nsselect, &value_str);
251 if(NS_SUCCEEDED(nsres)) {
252 nsAString_GetData(&value_str, &value);
253 *p = SysAllocString(value);
254 }else {
255 ERR("GetValue failed: %08x\n", nsres);
258 nsAString_Finish(&value_str);
260 TRACE("value=%s\n", debugstr_w(*p));
261 return S_OK;
264 static HRESULT WINAPI HTMLSelectElement_put_disabled(IHTMLSelectElement *iface, VARIANT_BOOL v)
266 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
267 FIXME("(%p)->(%x)\n", This, v);
268 return E_NOTIMPL;
271 static HRESULT WINAPI HTMLSelectElement_get_disabled(IHTMLSelectElement *iface, VARIANT_BOOL *p)
273 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
274 FIXME("(%p)->(%p)\n", This, p);
275 return E_NOTIMPL;
278 static HRESULT WINAPI HTMLSelectElement_get_form(IHTMLSelectElement *iface, IHTMLFormElement **p)
280 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
281 FIXME("(%p)->(%p)\n", This, p);
282 return E_NOTIMPL;
285 static HRESULT WINAPI HTMLSelectElement_add(IHTMLSelectElement *iface, IHTMLElement *element,
286 VARIANT before)
288 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
289 FIXME("(%p)->(%p v)\n", This, element);
290 return E_NOTIMPL;
293 static HRESULT WINAPI HTMLSelectElement_remove(IHTMLSelectElement *iface, long index)
295 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
296 FIXME("(%p)->(%ld)\n", This, index);
297 return E_NOTIMPL;
300 static HRESULT WINAPI HTMLSelectElement_put_length(IHTMLSelectElement *iface, long v)
302 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
303 FIXME("(%p)->(%ld)\n", This, v);
304 return E_NOTIMPL;
307 static HRESULT WINAPI HTMLSelectElement_get_length(IHTMLSelectElement *iface, long *p)
309 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
310 PRUint32 length = 0;
311 nsresult nsres;
313 TRACE("(%p)->(%p)\n", This, p);
315 nsres = nsIDOMHTMLSelectElement_GetLength(This->nsselect, &length);
316 if(NS_FAILED(nsres))
317 ERR("GetLength failed: %08x\n", nsres);
319 *p = length;
321 TRACE("ret %ld\n", *p);
322 return S_OK;
325 static HRESULT WINAPI HTMLSelectElement_get__newEnum(IHTMLSelectElement *iface, IUnknown **p)
327 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
328 FIXME("(%p)->(%p)\n", This, p);
329 return E_NOTIMPL;
332 static HRESULT WINAPI HTMLSelectElement_item(IHTMLSelectElement *iface, VARIANT name,
333 VARIANT index, IDispatch **pdisp)
335 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
336 FIXME("(%p)->(v v %p)\n", This, pdisp);
337 return E_NOTIMPL;
340 static HRESULT WINAPI HTMLSelectElement_tags(IHTMLSelectElement *iface, VARIANT tagName,
341 IDispatch **pdisp)
343 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
344 FIXME("(%p)->(v %p)\n", This, pdisp);
345 return E_NOTIMPL;
348 #undef HTMLSELECT_THIS
350 static const IHTMLSelectElementVtbl HTMLSelectElementVtbl = {
351 HTMLSelectElement_QueryInterface,
352 HTMLSelectElement_AddRef,
353 HTMLSelectElement_Release,
354 HTMLSelectElement_GetTypeInfoCount,
355 HTMLSelectElement_GetTypeInfo,
356 HTMLSelectElement_GetIDsOfNames,
357 HTMLSelectElement_Invoke,
358 HTMLSelectElement_put_size,
359 HTMLSelectElement_get_size,
360 HTMLSelectElement_put_multiple,
361 HTMLSelectElement_get_multiple,
362 HTMLSelectElement_put_name,
363 HTMLSelectElement_get_name,
364 HTMLSelectElement_get_options,
365 HTMLSelectElement_put_onchange,
366 HTMLSelectElement_get_onchange,
367 HTMLSelectElement_put_selectedIndex,
368 HTMLSelectElement_get_selectedIndex,
369 HTMLSelectElement_get_type,
370 HTMLSelectElement_put_value,
371 HTMLSelectElement_get_value,
372 HTMLSelectElement_put_disabled,
373 HTMLSelectElement_get_disabled,
374 HTMLSelectElement_get_form,
375 HTMLSelectElement_add,
376 HTMLSelectElement_remove,
377 HTMLSelectElement_put_length,
378 HTMLSelectElement_get_length,
379 HTMLSelectElement_get__newEnum,
380 HTMLSelectElement_item,
381 HTMLSelectElement_tags
384 #define HTMLSELECT_NODE_THIS(iface) DEFINE_THIS2(HTMLSelectElement, element.node, iface)
386 static HRESULT HTMLSelectElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
388 HTMLSelectElement *This = HTMLSELECT_NODE_THIS(iface);
390 *ppv = NULL;
392 if(IsEqualGUID(&IID_IUnknown, riid)) {
393 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
394 *ppv = HTMLSELECT(This);
395 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
396 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
397 *ppv = HTMLSELECT(This);
398 }else if(IsEqualGUID(&IID_IHTMLSelectElement, riid)) {
399 TRACE("(%p)->(IID_IHTMLSelectElement %p)\n", This, ppv);
400 *ppv = HTMLSELECT(This);
403 if(*ppv) {
404 IUnknown_AddRef((IUnknown*)*ppv);
405 return S_OK;
408 return HTMLElement_QI(&This->element.node, riid, ppv);
411 static void HTMLSelectElement_destructor(HTMLDOMNode *iface)
413 HTMLSelectElement *This = HTMLSELECT_NODE_THIS(iface);
415 nsIDOMHTMLSelectElement_Release(This->nsselect);
417 HTMLElement_destructor(&This->element.node);
420 #undef HTMLSELECT_NODE_THIS
422 static const NodeImplVtbl HTMLSelectElementImplVtbl = {
423 HTMLSelectElement_QI,
424 HTMLSelectElement_destructor
427 HTMLElement *HTMLSelectElement_Create(nsIDOMHTMLElement *nselem)
429 HTMLSelectElement *ret = heap_alloc(sizeof(HTMLSelectElement));
430 nsresult nsres;
432 HTMLElement_Init(&ret->element);
434 ret->lpHTMLSelectElementVtbl = &HTMLSelectElementVtbl;
435 ret->element.node.vtbl = &HTMLSelectElementImplVtbl;
437 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLSelectElement,
438 (void**)&ret->nsselect);
439 if(NS_FAILED(nsres))
440 ERR("Could not get nsIDOMHTMLSelectElement interfce: %08x\n", nsres);
442 return &ret->element;