]>
git.saurik.com Git - iphone-api.git/blob - WebCore/RenderMenuList.h
2 * This file is part of the select element renderer in WebCore.
4 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
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.
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.
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.
23 #ifndef RenderMenuList_h
24 #define RenderMenuList_h
26 #include "PopupMenuClient.h"
27 #include "RenderFlexibleBox.h"
30 #define POPUP_MENU_PULLS_DOWN 0
32 #define POPUP_MENU_PULLS_DOWN 1
37 class HTMLSelectElement
;
41 class RenderMenuList
: public RenderFlexibleBox
, private PopupMenuClient
{
43 RenderMenuList(HTMLSelectElement
*);
46 HTMLSelectElement
* selectElement();
49 virtual bool isMenuList() const { return true; }
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; }
56 virtual void updateFromElement();
58 virtual bool hasControlClip() const { return true; }
59 virtual IntRect
controlClipRect(int tx
, int ty
) const;
61 virtual const char* renderName() const { return "RenderMenuList"; }
63 virtual void calcPrefWidths();
68 void setOptionsChanged(bool changed
) { m_optionsChanged
= changed
; }
72 bool multiple() const;
75 virtual void styleDidChange(StyleDifference
, const RenderStyle
* oldStyle
);
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
);
99 virtual bool hasLineIfEmpty() const { return true; }
101 Color
itemBackgroundColor(unsigned listIndex
) const;
103 void createInnerBlock();
104 void adjustInnerStyle();
105 void setText(const String
&);
106 void setTextFromOption(int optionIndex
);
107 void updateOptionsWidth();
109 RenderText
* m_buttonText
;
110 RenderBlock
* m_innerBlock
;
112 bool m_optionsChanged
;