2 * This file is part of the select element renderer in WebCore.
4 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
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.
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.
31 #ifndef RenderListBox_h
32 #define RenderListBox_h
34 #include "RenderBlock.h"
35 #include "ScrollbarClient.h"
39 class HTMLSelectElement
;
41 class RenderListBox
: public RenderBlock
, private ScrollbarClient
{
43 RenderListBox(HTMLSelectElement
*);
46 virtual const char* renderName() const { return "RenderListBox"; }
48 virtual bool isListBox() const { return true; }
50 virtual void updateFromElement();
52 virtual bool canHaveChildren() const { return false; }
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;
58 virtual bool isPointInOverflowControl(HitTestResult
&, int x
, int y
, int tx
, int ty
);
60 virtual bool scroll(ScrollDirection
, ScrollGranularity
, float multiplier
= 1.0f
);
62 virtual void calcPrefWidths();
63 virtual int baselinePosition(bool firstLine
, bool isRootLineBox
) const;
64 virtual void calcHeight();
66 virtual void layout();
68 void selectionChanged();
70 void setOptionsChanged(bool changed
) { m_optionsChanged
= changed
; }
72 int listIndexAtOffset(int x
, int y
);
73 IntRect
itemBoundingBoxRect(int tx
, int ty
, int index
);
75 bool scrollToRevealElementAtListIndex(int index
);
76 bool listIndexIsVisible(int index
);
78 virtual bool canBeProgramaticallyScrolled(bool) const { return true; }
79 virtual void autoscroll();
80 virtual void stopAutoscroll();
82 virtual bool shouldPanScroll() const { return true; }
83 virtual void panScroll(const IntPoint
&);
85 int scrollToward(const IntPoint
&); // Returns the new index or -1 if no scroll occurred
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);
96 virtual void styleDidChange(StyleDifference
, const RenderStyle
* oldStyle
);
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.
105 void setHasVerticalScrollbar(bool hasScrollbar
);
106 PassRefPtr
<Scrollbar
> createScrollbar();
107 void destroyScrollbar();
109 int itemHeight() const;
110 void valueChanged(unsigned listIndex
);
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();
120 bool m_optionsChanged
;
121 bool m_scrollToRevealSelectionAfterLayout
;
126 RefPtr
<Scrollbar
> m_vBar
;
129 } // namepace WebCore
131 #endif // RenderListBox_h