]> git.saurik.com Git - iphone-api.git/blob - WebCore/RenderListBox.h
Add support for new WinterBoard Settings features.
[iphone-api.git] / WebCore / RenderListBox.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 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
20 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #ifndef RenderListBox_h
32 #define RenderListBox_h
33
34 #include "RenderBlock.h"
35 #include "ScrollbarClient.h"
36
37 namespace WebCore {
38
39 class HTMLSelectElement;
40
41 class RenderListBox : public RenderBlock, private ScrollbarClient {
42 public:
43 RenderListBox(HTMLSelectElement*);
44 ~RenderListBox();
45
46 virtual const char* renderName() const { return "RenderListBox"; }
47
48 virtual bool isListBox() const { return true; }
49
50 virtual void updateFromElement();
51
52 virtual bool canHaveChildren() const { return false; }
53
54 virtual bool hasControlClip() const { return true; }
55 virtual void paintObject(PaintInfo&, int tx, int ty);
56 virtual IntRect controlClipRect(int tx, int ty) const;
57
58 virtual bool isPointInOverflowControl(HitTestResult&, int x, int y, int tx, int ty);
59
60 virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1.0f);
61
62 virtual void calcPrefWidths();
63 virtual int baselinePosition(bool firstLine, bool isRootLineBox) const;
64 virtual void calcHeight();
65
66 virtual void layout();
67
68 void selectionChanged();
69
70 void setOptionsChanged(bool changed) { m_optionsChanged = changed; }
71
72 int listIndexAtOffset(int x, int y);
73 IntRect itemBoundingBoxRect(int tx, int ty, int index);
74
75 bool scrollToRevealElementAtListIndex(int index);
76 bool listIndexIsVisible(int index);
77
78 virtual bool canBeProgramaticallyScrolled(bool) const { return true; }
79 virtual void autoscroll();
80 virtual void stopAutoscroll();
81
82 virtual bool shouldPanScroll() const { return true; }
83 virtual void panScroll(const IntPoint&);
84
85 int scrollToward(const IntPoint&); // Returns the new index or -1 if no scroll occurred
86
87 virtual int verticalScrollbarWidth() const;
88 virtual int scrollLeft() const;
89 virtual int scrollTop() const;
90 virtual int scrollWidth() const;
91 virtual int scrollHeight() const;
92 virtual void setScrollLeft(int);
93 virtual void setScrollTop(int);
94
95 protected:
96 virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
97
98 private:
99 // ScrollbarClient interface.
100 virtual void valueChanged(Scrollbar*);
101 virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&);
102 virtual bool isActive() const;
103 virtual bool scrollbarCornerPresent() const { return false; } // We don't support resize on list boxes yet. If we did this would have to change.
104
105 void setHasVerticalScrollbar(bool hasScrollbar);
106 PassRefPtr<Scrollbar> createScrollbar();
107 void destroyScrollbar();
108
109 int itemHeight() const;
110 void valueChanged(unsigned listIndex);
111 int size() const;
112 int numVisibleItems() const;
113 int numItems() const;
114 int listHeight() const;
115 void paintScrollbar(PaintInfo&, int tx, int ty);
116 void paintItemForeground(PaintInfo&, int tx, int ty, int listIndex);
117 void paintItemBackground(PaintInfo&, int tx, int ty, int listIndex);
118 void scrollToRevealSelection();
119
120 bool m_optionsChanged;
121 bool m_scrollToRevealSelectionAfterLayout;
122 bool m_inAutoscroll;
123 int m_optionsWidth;
124 int m_indexOffset;
125
126 RefPtr<Scrollbar> m_vBar;
127 };
128
129 } // namepace WebCore
130
131 #endif // RenderListBox_h