webengine/osswebengine/WebCore/rendering/RenderListBox.h
changeset 0 dd21522fd290
child 27 60c5402cb945
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     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 "ScrollBar.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 setStyle(RenderStyle*);
       
    51     virtual void updateFromElement();
       
    52 
       
    53     virtual bool canHaveChildren() const { return false; }
       
    54 
       
    55     virtual bool hasControlClip() const { return true; }
       
    56     virtual void paintObject(PaintInfo&, int tx, int ty);
       
    57     virtual IntRect controlClipRect(int tx, int ty) const;
       
    58 
       
    59     virtual bool isPointInOverflowControl(HitTestResult&, int x, int y, int tx, int ty);
       
    60 
       
    61     virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1.0f);
       
    62     virtual bool isScrollable() const;
       
    63 
       
    64     virtual void calcPrefWidths();
       
    65     virtual short baselinePosition(bool firstLine, bool isRootLineBox) const;
       
    66     virtual void calcHeight();
       
    67 
       
    68     virtual void layout();
       
    69 
       
    70     void selectionChanged();
       
    71 
       
    72     void setOptionsChanged(bool changed) { m_optionsChanged = changed; }
       
    73 
       
    74     int listIndexAtOffset(int x, int y);
       
    75 
       
    76     bool scrollToRevealElementAtListIndex(int index);
       
    77 
       
    78     virtual bool shouldAutoscroll() const { return true; }
       
    79     virtual void autoscroll();
       
    80     virtual void stopAutoscroll();
       
    81 
       
    82     virtual int verticalScrollbarWidth() const;
       
    83     virtual int scrollLeft() const;
       
    84     virtual int scrollTop() const;
       
    85     virtual int scrollWidth() const;
       
    86     virtual int scrollHeight() const;
       
    87     virtual void setScrollLeft(int);
       
    88     virtual void setScrollTop(int);
       
    89 #if PLATFORM(SYMBIAN)
       
    90     IntRect itemRect(int tx, int ty, int index) { return itemBoundingBoxRect(tx, ty, index); }
       
    91     int indexOffset() {return m_indexOffset;}
       
    92 #endif
       
    93 
       
    94 private:
       
    95     // ScrollbarClient interface.
       
    96     virtual void valueChanged(Scrollbar*);
       
    97     virtual IntRect windowClipRect() const;
       
    98 
       
    99     int itemHeight() const;
       
   100     void valueChanged(unsigned listIndex);
       
   101     int size() const;
       
   102     int numVisibleItems() const;
       
   103     int numItems() const;
       
   104     int listHeight() const;
       
   105     IntRect itemBoundingBoxRect(int tx, int ty, int index);
       
   106     void paintScrollbar(PaintInfo&);
       
   107     void paintItemForeground(PaintInfo&, int tx, int ty, int listIndex);
       
   108     void paintItemBackground(PaintInfo&, int tx, int ty, int listIndex);
       
   109     bool listIndexIsVisible(int index);
       
   110     void scrollToRevealSelection();
       
   111 
       
   112     bool m_optionsChanged;
       
   113     bool m_scrollToRevealSelectionAfterLayout;
       
   114     bool m_inAutoscroll;
       
   115     int m_optionsWidth;
       
   116     int m_indexOffset;
       
   117 
       
   118     RefPtr<Scrollbar> m_vBar;
       
   119 };
       
   120 
       
   121 } // namepace WebCore
       
   122 
       
   123 #endif // RenderListBox_h