1 // Copyright (c) 2012 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 #ifndef UI_NATIVE_THEME_NATIVE_THEME_BASE_H_
6 #define UI_NATIVE_THEME_NATIVE_THEME_BASE_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "skia/ext/platform_canvas.h"
12 #include "ui/native_theme/native_theme.h"
23 // Theme support for non-Windows toolkits.
24 class NATIVE_THEME_EXPORT NativeThemeBase
: public NativeTheme
{
26 // NativeTheme implementation:
27 gfx::Size
GetPartSize(Part part
,
29 const ExtraParams
& extra
) const override
;
30 void Paint(SkCanvas
* canvas
,
33 const gfx::Rect
& rect
,
34 const ExtraParams
& extra
) const override
;
36 void PaintStateTransition(SkCanvas
* canvas
,
41 const gfx::Rect
& rect
) const override
;
45 ~NativeThemeBase() override
;
47 // Draw the arrow. Used by scrollbar and inner spin button.
48 virtual void PaintArrowButton(
50 const gfx::Rect
& rect
,
53 // Paint the scrollbar track. Done before the thumb so that it can contain
55 virtual void PaintScrollbarTrack(
59 const ScrollbarTrackExtraParams
& extra_params
,
60 const gfx::Rect
& rect
) const;
61 // Draw the scrollbar thumb over the track.
62 virtual void PaintScrollbarThumb(
66 const gfx::Rect
& rect
) const;
68 virtual void PaintScrollbarCorner(SkCanvas
* canvas
,
70 const gfx::Rect
& rect
) const;
72 virtual void PaintCheckbox(
75 const gfx::Rect
& rect
,
76 const ButtonExtraParams
& button
) const;
78 virtual void PaintRadio(
81 const gfx::Rect
& rect
,
82 const ButtonExtraParams
& button
) const;
84 virtual void PaintButton(
87 const gfx::Rect
& rect
,
88 const ButtonExtraParams
& button
) const;
90 virtual void PaintTextField(
93 const gfx::Rect
& rect
,
94 const TextFieldExtraParams
& text
) const;
96 virtual void PaintMenuList(
99 const gfx::Rect
& rect
,
100 const MenuListExtraParams
& menu_list
) const;
102 virtual void PaintMenuPopupBackground(
104 const gfx::Size
& size
,
105 const MenuBackgroundExtraParams
& menu_background
) const;
107 virtual void PaintMenuItemBackground(
110 const gfx::Rect
& rect
,
111 const MenuListExtraParams
& menu_list
) const;
113 virtual void PaintSliderTrack(
116 const gfx::Rect
& rect
,
117 const SliderExtraParams
& slider
) const;
119 virtual void PaintSliderThumb(
122 const gfx::Rect
& rect
,
123 const SliderExtraParams
& slider
) const;
125 virtual void PaintInnerSpinButton(
128 const gfx::Rect
& rect
,
129 const InnerSpinButtonExtraParams
& spin_button
) const;
131 virtual void PaintProgressBar(
134 const gfx::Rect
& rect
,
135 const ProgressBarExtraParams
& progress_bar
) const;
137 virtual void PaintScrollbarThumbStateTransition(
142 const gfx::Rect
& rect
) const {}
144 void set_scrollbar_button_length(unsigned int length
) {
145 scrollbar_button_length_
= length
;
147 int scrollbar_button_length() const { return scrollbar_button_length_
; }
149 bool IntersectsClipRectInt(SkCanvas
* canvas
,
150 int x
, int y
, int w
, int h
) const;
152 void DrawImageInt(SkCanvas
* canvas
, const gfx::ImageSkia
& image
,
153 int src_x
, int src_y
, int src_w
, int src_h
,
154 int dest_x
, int dest_y
, int dest_w
, int dest_h
) const;
156 void DrawTiledImage(SkCanvas
* canvas
,
157 const gfx::ImageSkia
& image
,
158 int src_x
, int src_y
,
159 float tile_scale_x
, float tile_scale_y
,
160 int dest_x
, int dest_y
, int w
, int h
) const;
162 SkColor
SaturateAndBrighten(SkScalar
* hsv
,
163 SkScalar saturate_amount
,
164 SkScalar brighten_amount
) const;
166 // Paints the arrow used on the scrollbar and spinner.
167 void PaintArrow(SkCanvas
* canvas
,
168 const gfx::Rect
& rect
,
170 SkColor color
) const;
172 // Returns the color used to draw the arrow.
173 SkColor
GetArrowColor(State state
) const;
176 void DrawVertLine(SkCanvas
* canvas
,
180 const SkPaint
& paint
) const;
181 void DrawHorizLine(SkCanvas
* canvas
,
185 const SkPaint
& paint
) const;
186 void DrawBox(SkCanvas
* canvas
,
187 const gfx::Rect
& rect
,
188 const SkPaint
& paint
) const;
189 SkScalar
Clamp(SkScalar value
,
192 SkColor
OutlineColor(SkScalar
* hsv1
, SkScalar
* hsv2
) const;
194 // Paint the common parts of the checkboxes and radio buttons.
195 // borderRadius specifies how rounded the corners should be.
196 SkRect
PaintCheckboxRadioCommon(
199 const gfx::Rect
& rect
,
200 const SkScalar borderRadius
) const;
202 unsigned int scrollbar_width_
;
204 // The length of the arrow buttons, 0 means no buttons are drawn.
205 unsigned int scrollbar_button_length_
;
207 DISALLOW_COPY_AND_ASSIGN(NativeThemeBase
);
212 #endif // UI_NATIVE_THEME_NATIVE_THEME_BASE_H_