|
1 /** |
|
2 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/) |
|
3 * |
|
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. |
|
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 * Library General Public License for more details. |
|
13 * |
|
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. |
|
18 * |
|
19 */ |
|
20 |
|
21 #ifndef WMLSelectElement_h |
|
22 #define WMLSelectElement_h |
|
23 |
|
24 #if ENABLE(WML) |
|
25 #include "WMLFormControlElement.h" |
|
26 #include "SelectElement.h" |
|
27 |
|
28 namespace WebCore { |
|
29 |
|
30 class WMLSelectElement : public WMLFormControlElement, public SelectElement { |
|
31 public: |
|
32 WMLSelectElement(const QualifiedName&, Document*); |
|
33 virtual ~WMLSelectElement(); |
|
34 |
|
35 virtual const AtomicString& formControlName() const; |
|
36 virtual const AtomicString& formControlType() const; |
|
37 |
|
38 virtual bool isKeyboardFocusable(KeyboardEvent*) const; |
|
39 virtual bool isMouseFocusable() const; |
|
40 virtual bool canSelectAll() const { return !m_data.usesMenuList(); } |
|
41 virtual void selectAll(); |
|
42 |
|
43 virtual void recalcStyle(StyleChange); |
|
44 |
|
45 virtual void dispatchFocusEvent(); |
|
46 virtual void dispatchBlurEvent(); |
|
47 |
|
48 virtual bool canStartSelection() const { return false; } |
|
49 |
|
50 virtual int selectedIndex() const; |
|
51 virtual void setSelectedIndex(int index, bool deselect = true); |
|
52 virtual void setSelectedIndexByUser(int index, bool deselect = true, bool fireOnChangeNow = false); |
|
53 |
|
54 virtual int size() const { return m_data.size(); } |
|
55 virtual bool multiple() const { return m_data.multiple(); } |
|
56 |
|
57 virtual bool saveFormControlState(String& value) const; |
|
58 virtual void restoreFormControlState(const String&); |
|
59 |
|
60 virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0); |
|
61 |
|
62 virtual void parseMappedAttribute(Attribute*); |
|
63 |
|
64 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); |
|
65 virtual bool appendFormData(FormDataList&, bool); |
|
66 virtual int optionToListIndex(int optionIndex) const; |
|
67 virtual int listToOptionIndex(int listIndex) const; |
|
68 |
|
69 virtual const Vector<Element*>& listItems() const { return m_data.listItems(this); } |
|
70 virtual void reset(); |
|
71 |
|
72 virtual void defaultEventHandler(Event*); |
|
73 virtual void accessKeyAction(bool sendToAnyElement); |
|
74 virtual void setActiveSelectionAnchorIndex(int index); |
|
75 virtual void setActiveSelectionEndIndex(int index); |
|
76 virtual void updateListBoxSelection(bool deselectOtherOptions); |
|
77 virtual void listBoxOnChange(); |
|
78 virtual void menuListOnChange(); |
|
79 |
|
80 virtual int activeSelectionStartListIndex() const; |
|
81 virtual int activeSelectionEndListIndex() const; |
|
82 |
|
83 void accessKeySetSelectedIndex(int); |
|
84 void setRecalcListItems(); |
|
85 void scrollToSelection(); |
|
86 void selectInitialOptions(); |
|
87 |
|
88 bool initialized() const { return m_initialized; } |
|
89 |
|
90 virtual void listBoxSelectItem(int listIndex, bool allowMultiplySelections, bool shift, bool fireOnChangeNow = true); |
|
91 private: |
|
92 virtual void insertedIntoTree(bool); |
|
93 |
|
94 void calculateDefaultOptionIndices(); |
|
95 void selectDefaultOptions(); |
|
96 void initializeVariables(); |
|
97 void updateVariables(); |
|
98 |
|
99 Vector<unsigned> parseIndexValueString(const String&) const; |
|
100 Vector<unsigned> valueStringToOptionIndices(const String&) const; |
|
101 String optionIndicesToValueString() const; |
|
102 String optionIndicesToString() const; |
|
103 |
|
104 String name() const; |
|
105 String value() const; |
|
106 String iname() const; |
|
107 String ivalue() const; |
|
108 |
|
109 SelectElementData m_data; |
|
110 bool m_initialized; |
|
111 Vector<unsigned> m_defaultOptionIndices; |
|
112 }; |
|
113 |
|
114 } |
|
115 |
|
116 #endif |
|
117 #endif |