2
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3
* (C) 1999 Antti Koivisto (koivisto@kde.org)
4
* (C) 2000 Dirk Mueller (mueller@kde.org)
5
* Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
7
* This library is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Library General Public
9
* License as published by the Free Software Foundation; either
10
* version 2 of the License, or (at your option) any later version.
12
* This library is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Library General Public License for more details.
17
* You should have received a copy of the GNU Library General Public License
18
* along with this library; see the file COPYING.LIB. If not, write to
19
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20
* Boston, MA 02111-1307, USA.
24
#ifndef HTMLSelectElement_h
25
#define HTMLSelectElement_h
28
#include "HTMLCollection.h"
29
#include "HTMLGenericFormElement.h"
30
#include <wtf/Vector.h>
34
class HTMLOptionElement;
35
class HTMLOptionsCollection;
38
class HTMLSelectElement : public HTMLFormControlElementWithState {
40
HTMLSelectElement(Document*, HTMLFormElement* = 0);
41
HTMLSelectElement(const QualifiedName& tagName, Document*, HTMLFormElement* = 0);
43
virtual int tagPriority() const { return 6; }
44
virtual bool checkDTD(const Node* newChild);
46
virtual const AtomicString& type() const;
48
virtual bool isKeyboardFocusable(KeyboardEvent*) const;
49
virtual bool isMouseFocusable() const;
50
virtual bool canSelectAll() const;
51
virtual void selectAll();
53
virtual void recalcStyle(StyleChange);
55
virtual void dispatchFocusEvent();
56
virtual void dispatchBlurEvent();
58
int selectedIndex() const;
59
void setSelectedIndex(int index, bool deselect = true, bool fireOnChange = false);
60
int lastSelectedListIndex() const;
62
virtual bool isEnumeratable() const { return true; }
64
unsigned length() const;
66
int minWidth() const { return m_minwidth; }
68
int size() const { return m_size; }
70
bool multiple() const { return m_multiple; }
72
void add(HTMLElement* element, HTMLElement* before, ExceptionCode&);
73
void remove(int index);
76
void setValue(const String&);
78
PassRefPtr<HTMLOptionsCollection> options();
80
virtual bool saveState(String& value) const;
81
virtual void restoreState(const String&);
83
virtual bool insertBefore(PassRefPtr<Node> newChild, Node* refChild, ExceptionCode&);
84
virtual bool replaceChild(PassRefPtr<Node> newChild, Node* oldChild, ExceptionCode&);
85
virtual bool removeChild(Node* child, ExceptionCode&);
86
virtual bool appendChild(PassRefPtr<Node> newChild, ExceptionCode&);
87
virtual ContainerNode* addChild(PassRefPtr<Node>);
89
virtual void childrenChanged();
91
virtual void parseMappedAttribute(MappedAttribute*);
93
virtual RenderObject* createRenderer(RenderArena*, RenderStyle *);
94
virtual bool appendFormData(FormDataList&, bool);
96
// get the actual listbox index of the optionIndexth option
97
int optionToListIndex(int optionIndex) const;
98
// reverse of optionToListIndex - get optionIndex from listboxIndex
99
int listToOptionIndex(int listIndex) const;
101
void setRecalcListItems();
103
const Vector<HTMLElement*>& listItems() const
105
if (m_recalcListItems)
109
virtual void reset();
111
virtual void defaultEventHandler(Event*);
112
virtual void accessKeyAction(bool sendToAnyElement);
114
void setMultiple(bool);
118
void setOption(unsigned index, HTMLOptionElement*, ExceptionCode&);
119
void setLength(unsigned, ExceptionCode&);
121
Node* namedItem(const String& name, bool caseSensitive = true);
122
Node* item(unsigned index);
124
HTMLCollection::CollectionInfo* collectionInfo() { return &m_collectionInfo; }
126
void setActiveSelectionAnchorIndex(int index);
127
void setActiveSelectionEndIndex(int index) { m_activeSelectionEndIndex = index; }
128
void updateListBoxSelection(bool deselectOtherOptions);
129
void listBoxOnChange();
130
void menuListOnChange();
132
int activeSelectionStartListIndex() const;
133
int activeSelectionEndListIndex() const;
135
void scrollToSelection();
138
void recalcListItems() const;
139
void deselectItems(HTMLOptionElement* excludeElement = 0);
140
bool usesMenuList() const { return !m_multiple && m_size <= 1; }
141
int nextSelectableListIndex(int startIndex);
142
int previousSelectableListIndex(int startIndex);
143
void menuListDefaultEventHandler(Event*);
144
void listBoxDefaultEventHandler(Event*);
145
void typeAheadFind(KeyboardEvent*);
146
void saveLastSelection();
148
mutable Vector<HTMLElement*> m_listItems;
149
Vector<bool> m_cachedStateForActiveSelection;
150
Vector<bool> m_lastOnChangeSelection;
154
mutable bool m_recalcListItems;
155
mutable int m_lastOnChangeIndex;
157
int m_activeSelectionAnchorIndex;
158
int m_activeSelectionEndIndex;
159
bool m_activeSelectionState;
161
// Instance variables for type-ahead find
162
UChar m_repeatingChar;
163
DOMTimeStamp m_lastCharTime;
164
String m_typedString;
166
HTMLCollection::CollectionInfo m_collectionInfo;