#ifndef ListBox_h
#define ListBox_h
#include "DeprecatedValueList.h"
#include "DeprecatedString.h"
#include "ScrollView.h"
#include "TextDirection.h"
namespace WebCore {
enum ListBoxItemType {
ListBoxOption,
ListBoxGroupLabel,
ListBoxSeparator
};
struct ListBoxItem
{
DeprecatedString string;
ListBoxItemType type;
bool enabled;
ListBoxItem(const DeprecatedString &s, ListBoxItemType t, bool e) : string(s), type(t), enabled(e) { }
};
class ListBox : public ScrollView {
public:
enum SelectionMode { Single, Extended };
ListBox();
~ListBox();
IntSize sizeForNumberOfLines(int numLines) const;
unsigned count() const { return _items.count(); }
void setSelectionMode(SelectionMode);
void clear();
void appendItem(const DeprecatedString &s, bool enabled) { appendItem(s, ListBoxOption, enabled); }
void appendGroupLabel(const DeprecatedString &s, bool enabled) { appendItem(s, ListBoxGroupLabel, enabled); }
void doneAppendingItems();
void setSelected(int, bool);
bool isSelected(int) const;
void setEnabled(bool enabled);
bool isEnabled();
const ListBoxItem &itemAtIndex(int index) const { return _items[index]; }
void setWritingDirection(TextDirection);
bool changingSelection() { return _changingSelection; }
virtual FocusPolicy focusPolicy() const;
virtual bool checksDescendantsForFocus() const;
static void clearCachedTextRenderers();
void setFont(const Font&);
private:
void appendItem(const DeprecatedString &, ListBoxItemType, bool);
DeprecatedValueList<ListBoxItem> _items;
bool _changingSelection;
bool _enabled;
mutable float _width;
mutable bool _widthGood;
};
}
#endif