Home | History | Annotate | Download | only in default
      1 /*
      2  * Copyright (C) 2010 Google Inc. All rights reserved.
      3  *
      4  * Redistribution and use in source and binary forms, with or without
      5  * modification, are permitted provided that the following conditions are
      6  * met:
      7  *
      8  *     * Redistributions of source code must retain the above copyright
      9  * notice, this list of conditions and the following disclaimer.
     10  *     * Redistributions in binary form must reproduce the above
     11  * copyright notice, this list of conditions and the following disclaimer
     12  * in the documentation and/or other materials provided with the
     13  * distribution.
     14  *     * Neither the name of Google Inc. nor the names of its
     15  * contributors may be used to endorse or promote products derived from
     16  * this software without specific prior written permission.
     17  *
     18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     29  */
     30 
     31 #ifndef WebThemeEngine_h
     32 #define WebThemeEngine_h
     33 
     34 #include "../WebCanvas.h"
     35 #include "../WebColor.h"
     36 #include "../WebSize.h"
     37 
     38 namespace blink {
     39 
     40 struct WebRect;
     41 
     42 class WebThemeEngine {
     43 public:
     44     // The UI part which is being accessed.
     45     enum Part {
     46         // ScrollbarTheme parts
     47         PartScrollbarDownArrow,
     48         PartScrollbarLeftArrow,
     49         PartScrollbarRightArrow,
     50         PartScrollbarUpArrow,
     51         PartScrollbarHorizontalThumb,
     52         PartScrollbarVerticalThumb,
     53         PartScrollbarHorizontalTrack,
     54         PartScrollbarVerticalTrack,
     55 
     56         // RenderTheme parts
     57         PartCheckbox,
     58         PartRadio,
     59         PartButton,
     60         PartTextField,
     61         PartMenuList,
     62         PartSliderTrack,
     63         PartSliderThumb,
     64         PartInnerSpinButton,
     65         PartProgressBar
     66     };
     67 
     68     // The current state of the associated Part.
     69     enum State {
     70         StateDisabled,
     71         StateHover,
     72         StateNormal,
     73         StatePressed,
     74         StateFocused,
     75         StateReadonly,
     76     };
     77 
     78     // Extra parameters for drawing the PartScrollbarHorizontalTrack and
     79     // PartScrollbarVerticalTrack.
     80     struct ScrollbarTrackExtraParams {
     81         bool isBack; // Whether this is the 'back' part or the 'forward' part.
     82 
     83         // The bounds of the entire track, as opposed to the part being painted.
     84         int trackX;
     85         int trackY;
     86         int trackWidth;
     87         int trackHeight;
     88     };
     89 
     90     // Extra parameters for PartCheckbox, PartPushButton and PartRadio.
     91     struct ButtonExtraParams {
     92         bool checked;
     93         bool indeterminate; // Whether the button state is indeterminate.
     94         bool isDefault; // Whether the button is default button.
     95         bool hasBorder;
     96         WebColor backgroundColor;
     97     };
     98 
     99     // Extra parameters for PartTextField
    100     struct TextFieldExtraParams {
    101         bool isTextArea;
    102         bool isListbox;
    103         WebColor backgroundColor;
    104     };
    105 
    106     // Extra parameters for PartMenuList
    107     struct MenuListExtraParams {
    108         bool hasBorder;
    109         bool hasBorderRadius;
    110         int arrowX;
    111         int arrowY;
    112         int arrowHeight;
    113         WebColor backgroundColor;
    114         bool fillContentArea;
    115     };
    116 
    117     // Extra parameters for PartSliderTrack and PartSliderThumb
    118     struct SliderExtraParams {
    119         bool vertical;
    120         bool inDrag;
    121     };
    122 
    123     // Extra parameters for PartInnerSpinButton
    124     struct InnerSpinButtonExtraParams {
    125         bool spinUp;
    126         bool readOnly;
    127     };
    128 
    129     // Extra parameters for PartProgressBar
    130     struct ProgressBarExtraParams {
    131         bool determinate;
    132         int valueRectX;
    133         int valueRectY;
    134         int valueRectWidth;
    135         int valueRectHeight;
    136     };
    137 
    138     union ExtraParams {
    139         ScrollbarTrackExtraParams scrollbarTrack;
    140         ButtonExtraParams button;
    141         TextFieldExtraParams textField;
    142         MenuListExtraParams menuList;
    143         SliderExtraParams slider;
    144         InnerSpinButtonExtraParams innerSpin;
    145         ProgressBarExtraParams progressBar;
    146     };
    147 
    148     // Gets the size of the given theme part. For variable sized items
    149     // like vertical scrollbar thumbs, the width will be the required width of
    150     // the track while the height will be the minimum height.
    151     virtual WebSize getSize(Part) { return WebSize(); }
    152     // Paint the given the given theme part.
    153     virtual void paint(WebCanvas*, Part, State, const WebRect&, const ExtraParams*) { }
    154 };
    155 
    156 } // namespace blink
    157 
    158 #endif
    159