]> git.saurik.com Git - iphone-api.git/blob - WebCore/RenderMenuList.h
Add support for new WinterBoard Settings features.
[iphone-api.git] / WebCore / RenderMenuList.h
1 /*
2 * This file is part of the select element renderer in WebCore.
3 *
4 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 *
21 */
22
23 #ifndef RenderMenuList_h
24 #define RenderMenuList_h
25
26 #include "PopupMenuClient.h"
27 #include "RenderFlexibleBox.h"
28
29 #if PLATFORM(MAC)
30 #define POPUP_MENU_PULLS_DOWN 0
31 #else
32 #define POPUP_MENU_PULLS_DOWN 1
33 #endif
34
35 namespace WebCore {
36
37 class HTMLSelectElement;
38 class PopupMenu;
39 class RenderText;
40
41 class RenderMenuList : public RenderFlexibleBox, private PopupMenuClient {
42 public:
43 RenderMenuList(HTMLSelectElement*);
44 ~RenderMenuList();
45
46 HTMLSelectElement* selectElement();
47
48 private:
49 virtual bool isMenuList() const { return true; }
50
51 virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0);
52 virtual void removeChild(RenderObject*);
53 virtual bool createsAnonymousWrapper() const { return true; }
54 virtual bool canHaveChildren() const { return false; }
55
56 virtual void updateFromElement();
57
58 virtual bool hasControlClip() const { return true; }
59 virtual IntRect controlClipRect(int tx, int ty) const;
60
61 virtual const char* renderName() const { return "RenderMenuList"; }
62
63 virtual void calcPrefWidths();
64
65 public:
66 void hidePopup();
67
68 void setOptionsChanged(bool changed) { m_optionsChanged = changed; }
69
70 String text() const;
71
72 bool multiple() const;
73
74 private:
75 virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
76
77 // PopupMenuClient methods
78 virtual String itemText(unsigned listIndex) const;
79 virtual bool itemIsEnabled(unsigned listIndex) const;
80 virtual PopupMenuStyle itemStyle(unsigned listIndex) const;
81 virtual PopupMenuStyle menuStyle() const;
82 virtual int clientInsetLeft() const;
83 virtual int clientInsetRight() const;
84 virtual int clientPaddingLeft() const;
85 virtual int clientPaddingRight() const;
86 virtual int listSize() const;
87 virtual int selectedIndex() const;
88 virtual bool itemIsSeparator(unsigned listIndex) const;
89 virtual bool itemIsLabel(unsigned listIndex) const;
90 virtual bool itemIsSelected(unsigned listIndex) const;
91 virtual void setTextFromItem(unsigned listIndex);
92 virtual bool valueShouldChangeOnHotTrack() const { return true; }
93 virtual bool shouldPopOver() const { return !POPUP_MENU_PULLS_DOWN; }
94 virtual void valueChanged(unsigned listIndex, bool fireOnChange = true);
95 virtual FontSelector* fontSelector() const;
96 virtual HostWindow* hostWindow() const;
97 virtual PassRefPtr<Scrollbar> createScrollbar(ScrollbarClient*, ScrollbarOrientation, ScrollbarControlSize);
98
99 virtual bool hasLineIfEmpty() const { return true; }
100
101 Color itemBackgroundColor(unsigned listIndex) const;
102
103 void createInnerBlock();
104 void adjustInnerStyle();
105 void setText(const String&);
106 void setTextFromOption(int optionIndex);
107 void updateOptionsWidth();
108
109 RenderText* m_buttonText;
110 RenderBlock* m_innerBlock;
111
112 bool m_optionsChanged;
113 int m_optionsWidth;
114
115 };
116
117 }
118
119 #endif