5e285d09e1cc95f313571b29ca5dbe60e84bfba8
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / public / platform / WebThemeEngine.h
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 current state of the associated Part.
45     enum State {
46         StateDisabled,
47         StateHover, // non-Apple
48         StateNormal, // non-Apple
49         StatePressed,
50         StateFocused, // non-Apple
51         StateReadonly, // non-Apple
52         StateInactive, // Apple-specific
53         StateActive, // Apple-specific
54     };
55
56     // The UI part which is being accessed.
57     enum Part {
58         // ScrollbarTheme parts
59         PartScrollbarDownArrow,
60         PartScrollbarLeftArrow,
61         PartScrollbarRightArrow,
62         PartScrollbarUpArrow,
63         PartScrollbarHorizontalThumb,
64         PartScrollbarVerticalThumb,
65         PartScrollbarHorizontalTrack,
66         PartScrollbarVerticalTrack,
67         PartScrollbarCorner,
68
69         // RenderTheme parts
70         PartCheckbox,
71         PartRadio,
72         PartButton,
73         PartTextField,
74         PartMenuList,
75         PartSliderTrack,
76         PartSliderThumb,
77         PartInnerSpinButton,
78         PartProgressBar
79     };
80
81     // Extra parameters for drawing the PartScrollbarHorizontalTrack and
82     // PartScrollbarVerticalTrack.
83     struct ScrollbarTrackExtraParams {
84         bool isBack; // Whether this is the 'back' part or the 'forward' part.
85
86         // The bounds of the entire track, as opposed to the part being painted.
87         int trackX;
88         int trackY;
89         int trackWidth;
90         int trackHeight;
91     };
92
93     // Extra parameters for PartCheckbox, PartPushButton and PartRadio.
94     struct ButtonExtraParams {
95         bool checked;
96         bool indeterminate; // Whether the button state is indeterminate.
97         bool isDefault; // Whether the button is default button.
98         bool hasBorder;
99         WebColor backgroundColor;
100     };
101
102     // Extra parameters for PartTextField
103     struct TextFieldExtraParams {
104         bool isTextArea;
105         bool isListbox;
106         WebColor backgroundColor;
107     };
108
109     // Extra parameters for PartMenuList
110     struct MenuListExtraParams {
111         bool hasBorder;
112         bool hasBorderRadius;
113         int arrowX;
114         int arrowY;
115         int arrowHeight;
116         WebColor backgroundColor;
117         bool fillContentArea;
118     };
119
120     // Extra parameters for PartSliderTrack and PartSliderThumb
121     struct SliderExtraParams {
122         bool vertical;
123         bool inDrag;
124     };
125
126     // Extra parameters for PartInnerSpinButton
127     struct InnerSpinButtonExtraParams {
128         bool spinUp;
129         bool readOnly;
130     };
131
132     // Extra parameters for PartProgressBar
133     struct ProgressBarExtraParams {
134         bool determinate;
135         int valueRectX;
136         int valueRectY;
137         int valueRectWidth;
138         int valueRectHeight;
139     };
140
141     union ExtraParams {
142         ScrollbarTrackExtraParams scrollbarTrack;
143         ButtonExtraParams button;
144         TextFieldExtraParams textField;
145         MenuListExtraParams menuList;
146         SliderExtraParams slider;
147         InnerSpinButtonExtraParams innerSpin;
148         ProgressBarExtraParams progressBar;
149     };
150
151     // Gets the size of the given theme part. For variable sized items
152     // like vertical scrollbar thumbs, the width will be the required width of
153     // the track while the height will be the minimum height.
154     virtual WebSize getSize(Part) { return WebSize(); }
155     // Paint the given the given theme part.
156     virtual void paint(WebCanvas*, Part, State, const WebRect&, const ExtraParams*) { }
157 };
158
159 } // namespace blink
160
161 #endif