1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // WebTestThemeControlWin implements the generic rendering of controls
6 // needed by WebThemeEngineDRTWin. See the comments in that class
7 // header file for why this class is needed and used.
9 // This class implements a generic set of widgets using Skia. The widgets
10 // are optimized for testability, not a pleasing appearance.
13 #ifndef CONTENT_SHELL_RENDERER_TEST_RUNNER_WEBTESTTHEMECONTROLWIN_H_
14 #define CONTENT_SHELL_RENDERER_TEST_RUNNER_WEBTESTTHEMECONTROLWIN_H_
16 #include "base/basictypes.h"
17 #include "third_party/skia/include/core/SkColor.h"
18 #include "third_party/skia/include/core/SkRect.h"
20 // Skia forward declarations
23 namespace WebTestRunner {
25 class WebTestThemeControlWin {
27 // This list of states mostly mirrors the list in WebCore/platform/ThemeTypes.h
28 // but is maintained separately since that isn't public and also to minimize
30 // Note that the WebKit ThemeTypes seem to imply that a control can be
31 // in multiple states simultaneously but WebThemeEngine only allows for
32 // a single state at a time.
34 // Some definitions for the various states:
35 // Disabled - indicates that a control can't be modified or selected
36 // (corresponds to HTML 'disabled' attribute)
37 // ReadOnly - indicates that a control can't be modified but can be
39 // Normal - the normal state of control on the page when it isn't
40 // focused or otherwise active
41 // Hot - when the mouse is hovering over a part of the control,
42 // all the other parts are considered "hot"
43 // Hover - when the mouse is directly over a control (the CSS
44 // :hover pseudo-class)
45 // Focused - when the control has the keyboard focus
46 // Pressed - when the control is being triggered (by a mousedown or
48 // Indeterminate - when set to indeterminate (only for progress bar)
61 // This list of types mostly mirrors the list in
62 // WebCore/platform/ThemeTypes.h but is maintained
63 // separately since that isn't public and also to minimize dependencies.
65 // Note that what the user might think of as a single control can be
66 // made up of multiple parts. For example, a single scroll bar contains
67 // six clickable parts - two arrows, the "thumb" indicating the current
68 // position on the bar, the other two parts of the bar (before and after
69 // the thumb) and the "gripper" on the thumb itself.
77 IndeterminateCheckboxType,
80 HorizontalScrollTrackBackType,
81 HorizontalScrollTrackForwardType,
82 HorizontalScrollThumbType,
83 HorizontalScrollGripType,
84 VerticalScrollTrackBackType,
85 VerticalScrollTrackForwardType,
86 VerticalScrollThumbType,
87 VerticalScrollGripType,
92 HorizontalSliderTrackType,
93 HorizontalSliderThumbType,
94 VerticalSliderTrackType,
95 VerticalSliderThumbType,
100 // Constructs a control of the given size, type and state to draw
101 // on to the given canvas.
102 WebTestThemeControlWin(SkCanvas*, const SkIRect&, Type, State);
103 ~WebTestThemeControlWin();
105 // Draws the control.
108 // Use this for TextField controls instead, because the logic
109 // for drawing them is dependent on what WebKit tells us to do.
110 // If drawEdges is true, draw an edge around the control. If
111 // fillContentArea is true, fill the content area with the given color.
112 void drawTextField(bool drawEdges, bool fillContentArea, SkColor);
114 // Use this for drawing ProgressBar controls instead, since we
115 // need to know the rect to fill inside the bar.
116 void drawProgressBar(const SkIRect& fillRect);
119 // Draws a box of size specified by irect, filled with the given color.
120 // The box will have a border drawn in the default edge color.
121 void box(const SkIRect& irect, SkColor);
124 // Draws a triangle of size specified by the three pairs of coordinates,
125 // filled with the given color. The box will have an edge drawn in the
126 // default edge color.
127 void triangle(int x0, int y0, int x1, int y1, int x2, int y2, SkColor);
129 // Draws a rectangle the size of the control with rounded corners, filled
130 // with the specified color (and with a border in the default edge color).
131 void roundRect(SkColor);
133 // Draws an oval the size of the control, filled with the specified color
134 // and with a border in the default edge color.
137 // Draws a circle centered in the control with the specified radius,
138 // filled with the specified color, and with a border draw in the
139 // default edge color.
140 void circle(SkScalar radius, SkColor);
142 // Draws a box the size of the control, filled with the outerColor and
143 // with a border in the default edge color, and then draws another box
144 // indented on all four sides by the specified amounts, filled with the
145 // inner color and with a border in the default edge color.
146 void nestedBoxes(int indentLeft, int indentTop, int indentRight, int indentBottom, SkColor outerColor, SkColor innerColor);
148 // Draws a line between the two points in the given color.
149 void line(int x0, int y0, int x1, int y1, SkColor);
151 // Draws a distinctive mark on the control for each state, so that the
152 // state of the control can be determined without needing to know which
157 const SkIRect m_irect;
160 const SkColor m_edgeColor;
161 const SkColor m_bgColor;
162 const SkColor m_fgColor;
164 // The following are convenience accessors for m_irect.
172 DISALLOW_COPY_AND_ASSIGN(WebTestThemeControlWin);
177 #endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_WEBTESTTHEMECONTROLWIN_H_