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 virtual gfx::Size
GetPartSize(Part part
,
29 const ExtraParams
& extra
) const OVERRIDE
;
30 virtual void Paint(SkCanvas
* canvas
,
33 const gfx::Rect
& rect
,
34 const ExtraParams
& extra
) const OVERRIDE
;
38 virtual ~NativeThemeBase();
40 // Creates a gfx::Canvas wrapping an SkCanvas.
41 static scoped_ptr
<gfx::Canvas
> CreateCanvas(SkCanvas
* sk_canvas
);
43 // Draw the arrow. Used by scrollbar and inner spin button.
44 virtual void PaintArrowButton(
46 const gfx::Rect
& rect
,
49 // Paint the scrollbar track. Done before the thumb so that it can contain
51 virtual void PaintScrollbarTrack(
55 const ScrollbarTrackExtraParams
& extra_params
,
56 const gfx::Rect
& rect
) const;
57 // Draw the scrollbar thumb over the track.
58 virtual void PaintScrollbarThumb(
62 const gfx::Rect
& rect
) const;
64 virtual void PaintScrollbarCorner(SkCanvas
* canvas
,
66 const gfx::Rect
& rect
) const;
68 virtual void PaintCheckbox(
71 const gfx::Rect
& rect
,
72 const ButtonExtraParams
& button
) const;
74 virtual void PaintRadio(
77 const gfx::Rect
& rect
,
78 const ButtonExtraParams
& button
) const;
80 virtual void PaintButton(
83 const gfx::Rect
& rect
,
84 const ButtonExtraParams
& button
) const;
86 virtual void PaintTextField(
89 const gfx::Rect
& rect
,
90 const TextFieldExtraParams
& text
) const;
92 virtual void PaintMenuList(
95 const gfx::Rect
& rect
,
96 const MenuListExtraParams
& menu_list
) const;
98 virtual void PaintMenuPopupBackground(
100 const gfx::Size
& size
,
101 const MenuBackgroundExtraParams
& menu_background
) const;
103 virtual void PaintMenuItemBackground(
106 const gfx::Rect
& rect
,
107 const MenuListExtraParams
& menu_list
) const;
109 virtual void PaintSliderTrack(
112 const gfx::Rect
& rect
,
113 const SliderExtraParams
& slider
) const;
115 virtual void PaintSliderThumb(
118 const gfx::Rect
& rect
,
119 const SliderExtraParams
& slider
) const;
121 virtual void PaintInnerSpinButton(
124 const gfx::Rect
& rect
,
125 const InnerSpinButtonExtraParams
& spin_button
) const;
127 virtual void PaintProgressBar(
130 const gfx::Rect
& rect
,
131 const ProgressBarExtraParams
& progress_bar
) const;
133 void set_scrollbar_button_length(unsigned int length
) {
134 scrollbar_button_length_
= length
;
136 int scrollbar_button_length() const { return scrollbar_button_length_
; }
138 bool IntersectsClipRectInt(SkCanvas
* canvas
,
139 int x
, int y
, int w
, int h
) const;
141 void DrawImageInt(SkCanvas
* canvas
, const gfx::ImageSkia
& image
,
142 int src_x
, int src_y
, int src_w
, int src_h
,
143 int dest_x
, int dest_y
, int dest_w
, int dest_h
) const;
145 void DrawTiledImage(SkCanvas
* canvas
,
146 const gfx::ImageSkia
& image
,
147 int src_x
, int src_y
,
148 float tile_scale_x
, float tile_scale_y
,
149 int dest_x
, int dest_y
, int w
, int h
) const;
151 SkColor
SaturateAndBrighten(SkScalar
* hsv
,
152 SkScalar saturate_amount
,
153 SkScalar brighten_amount
) const;
155 // Paints the arrow used on the scrollbar and spinner.
156 void PaintArrow(SkCanvas
* canvas
,
157 const gfx::Rect
& rect
,
159 SkColor color
) const;
161 // Returns the color used to draw the arrow.
162 SkColor
GetArrowColor(State state
) const;
165 void DrawVertLine(SkCanvas
* canvas
,
169 const SkPaint
& paint
) const;
170 void DrawHorizLine(SkCanvas
* canvas
,
174 const SkPaint
& paint
) const;
175 void DrawBox(SkCanvas
* canvas
,
176 const gfx::Rect
& rect
,
177 const SkPaint
& paint
) const;
178 SkScalar
Clamp(SkScalar value
,
181 SkColor
OutlineColor(SkScalar
* hsv1
, SkScalar
* hsv2
) const;
183 // Paint the common parts of the checkboxes and radio buttons.
184 // borderRadius specifies how rounded the corners should be.
185 SkRect
PaintCheckboxRadioCommon(
188 const gfx::Rect
& rect
,
189 const SkScalar borderRadius
) const;
191 unsigned int scrollbar_width_
;
192 unsigned int scrollbar_button_length_
;
194 DISALLOW_COPY_AND_ASSIGN(NativeThemeBase
);
199 #endif // UI_NATIVE_THEME_NATIVE_THEME_BASE_H_