2 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 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 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
21 #ifndef WMLSelectElement_h
22 #define WMLSelectElement_h
25 #include "WMLFormControlElement.h"
26 #include "SelectElement.h"
30 class WMLSelectElement : public WMLFormControlElement, public SelectElement {
32 static PassRefPtr<WMLSelectElement> create(const QualifiedName&, Document*);
34 WMLSelectElement(const QualifiedName&, Document*);
35 virtual ~WMLSelectElement();
37 virtual const AtomicString& formControlName() const;
38 virtual const AtomicString& formControlType() const;
40 virtual bool isKeyboardFocusable(KeyboardEvent*) const;
41 virtual bool isMouseFocusable() const;
42 virtual bool canSelectAll() const { return !m_data.usesMenuList(); }
43 virtual void selectAll();
45 virtual void recalcStyle(StyleChange);
47 virtual void dispatchFocusEvent();
48 virtual void dispatchBlurEvent();
50 virtual bool canStartSelection() const { return false; }
52 virtual int selectedIndex() const;
53 virtual void setSelectedIndex(int index, bool deselect = true);
54 virtual void setSelectedIndexByUser(int index, bool deselect = true, bool fireOnChangeNow = false, bool allowMultipleSelection = false);
56 virtual int size() const { return m_data.size(); }
57 virtual bool multiple() const { return m_data.multiple(); }
59 virtual bool saveFormControlState(String& value) const;
60 virtual void restoreFormControlState(const String&);
62 virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
64 virtual void parseMappedAttribute(Attribute*);
66 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
67 virtual bool appendFormData(FormDataList&, bool);
68 virtual int optionToListIndex(int optionIndex) const;
69 virtual int listToOptionIndex(int listIndex) const;
71 virtual const Vector<Element*>& listItems() const { return m_data.listItems(this); }
74 virtual void defaultEventHandler(Event*);
75 virtual void accessKeyAction(bool sendToAnyElement);
76 virtual void setActiveSelectionAnchorIndex(int index);
77 virtual void setActiveSelectionEndIndex(int index);
78 virtual void updateListBoxSelection(bool deselectOtherOptions);
79 virtual void listBoxOnChange();
80 virtual void menuListOnChange();
82 virtual int activeSelectionStartListIndex() const;
83 virtual int activeSelectionEndListIndex() const;
85 void accessKeySetSelectedIndex(int);
86 void setRecalcListItems();
87 void scrollToSelection();
88 void selectInitialOptions();
90 bool initialized() const { return m_initialized; }
92 virtual void listBoxSelectItem(int listIndex, bool allowMultiplySelections, bool shift, bool fireOnChangeNow = true);
94 virtual void insertedIntoTree(bool);
96 void calculateDefaultOptionIndices();
97 void selectDefaultOptions();
98 void initializeVariables();
99 void updateVariables();
101 Vector<unsigned> parseIndexValueString(const String&) const;
102 Vector<unsigned> valueStringToOptionIndices(const String&) const;
103 String optionIndicesToValueString() const;
104 String optionIndicesToString() const;
107 String value() const;
108 String iname() const;
109 String ivalue() const;
111 SelectElementData m_data;
113 Vector<unsigned> m_defaultOptionIndices;