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 "skia/ext/platform_canvas.h"
11 #include "ui/native_theme/native_theme.h"
21 // Theme support for non-Windows toolkits.
22 class NATIVE_THEME_EXPORT NativeThemeBase
: public NativeTheme
{
24 // NativeTheme implementation:
25 virtual gfx::Size
GetPartSize(Part part
,
27 const ExtraParams
& extra
) const OVERRIDE
;
28 virtual void Paint(SkCanvas
* canvas
,
31 const gfx::Rect
& rect
,
32 const ExtraParams
& extra
) const OVERRIDE
;
36 virtual ~NativeThemeBase();
38 // Draw the arrow. Used by scrollbar and inner spin button.
39 virtual void PaintArrowButton(
41 const gfx::Rect
& rect
,
44 // Paint the scrollbar track. Done before the thumb so that it can contain
46 virtual void PaintScrollbarTrack(
50 const ScrollbarTrackExtraParams
& extra_params
,
51 const gfx::Rect
& rect
) const;
52 // Draw the scrollbar thumb over the track.
53 virtual void PaintScrollbarThumb(
57 const gfx::Rect
& rect
) const;
59 virtual void PaintCheckbox(
62 const gfx::Rect
& rect
,
63 const ButtonExtraParams
& button
) const;
65 virtual void PaintRadio(
68 const gfx::Rect
& rect
,
69 const ButtonExtraParams
& button
) const;
71 virtual void PaintButton(
74 const gfx::Rect
& rect
,
75 const ButtonExtraParams
& button
) const;
77 virtual void PaintTextField(
80 const gfx::Rect
& rect
,
81 const TextFieldExtraParams
& text
) const;
83 virtual void PaintMenuList(
86 const gfx::Rect
& rect
,
87 const MenuListExtraParams
& menu_list
) const;
89 virtual void PaintMenuPopupBackground(
91 const gfx::Size
& size
,
92 const MenuBackgroundExtraParams
& menu_background
) const;
94 virtual void PaintMenuItemBackground(
97 const gfx::Rect
& rect
,
98 const MenuListExtraParams
& menu_list
) const;
100 virtual void PaintSliderTrack(
103 const gfx::Rect
& rect
,
104 const SliderExtraParams
& slider
) const;
106 virtual void PaintSliderThumb(
109 const gfx::Rect
& rect
,
110 const SliderExtraParams
& slider
) const;
112 virtual void PaintInnerSpinButton(
115 const gfx::Rect
& rect
,
116 const InnerSpinButtonExtraParams
& spin_button
) const;
118 virtual void PaintProgressBar(
121 const gfx::Rect
& rect
,
122 const ProgressBarExtraParams
& progress_bar
) const;
125 void set_scrollbar_button_length(unsigned int length
) {
126 scrollbar_button_length_
= length
;
129 bool IntersectsClipRectInt(SkCanvas
* canvas
,
130 int x
, int y
, int w
, int h
) const;
132 void DrawImageInt(SkCanvas
* canvas
, const gfx::ImageSkia
& image
,
133 int src_x
, int src_y
, int src_w
, int src_h
,
134 int dest_x
, int dest_y
, int dest_w
, int dest_h
) const;
136 void DrawTiledImage(SkCanvas
* canvas
,
137 const gfx::ImageSkia
& image
,
138 int src_x
, int src_y
,
139 float tile_scale_x
, float tile_scale_y
,
140 int dest_x
, int dest_y
, int w
, int h
) const;
142 SkColor
SaturateAndBrighten(SkScalar
* hsv
,
143 SkScalar saturate_amount
,
144 SkScalar brighten_amount
) const;
146 void DrawVertLine(SkCanvas
* canvas
,
150 const SkPaint
& paint
) const;
151 void DrawHorizLine(SkCanvas
* canvas
,
155 const SkPaint
& paint
) const;
156 void DrawBox(SkCanvas
* canvas
,
157 const gfx::Rect
& rect
,
158 const SkPaint
& paint
) const;
159 SkScalar
Clamp(SkScalar value
,
162 SkColor
OutlineColor(SkScalar
* hsv1
, SkScalar
* hsv2
) const;
164 // Paint the common parts of the checkboxes and radio buttons.
165 // borderRadius specifies how rounded the corners should be.
166 SkRect
PaintCheckboxRadioCommon(
169 const gfx::Rect
& rect
,
170 const SkScalar borderRadius
) const;
172 unsigned int scrollbar_width_
;
173 unsigned int scrollbar_button_length_
;
175 DISALLOW_COPY_AND_ASSIGN(NativeThemeBase
);
180 #endif // UI_NATIVE_THEME_NATIVE_THEME_BASE_H_