AttachmentDownloader implementation.
[chromium-blink-merge.git] / ui / native_theme / native_theme_base.h
blobd9c2fbadb3ba90bf8edd1cfafe916e5ac038320c
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"
14 namespace gfx {
15 class Canvas;
16 class ImageSkia;
17 class Rect;
18 class Size;
21 namespace ui {
23 // Theme support for non-Windows toolkits.
24 class NATIVE_THEME_EXPORT NativeThemeBase : public NativeTheme {
25 public:
26 // NativeTheme implementation:
27 virtual gfx::Size GetPartSize(Part part,
28 State state,
29 const ExtraParams& extra) const OVERRIDE;
30 virtual void Paint(SkCanvas* canvas,
31 Part part,
32 State state,
33 const gfx::Rect& rect,
34 const ExtraParams& extra) const OVERRIDE;
36 protected:
37 NativeThemeBase();
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(
45 SkCanvas* gc,
46 const gfx::Rect& rect,
47 Part direction,
48 State state) const;
49 // Paint the scrollbar track. Done before the thumb so that it can contain
50 // alpha.
51 virtual void PaintScrollbarTrack(
52 SkCanvas* canvas,
53 Part part,
54 State state,
55 const ScrollbarTrackExtraParams& extra_params,
56 const gfx::Rect& rect) const;
57 // Draw the scrollbar thumb over the track.
58 virtual void PaintScrollbarThumb(
59 SkCanvas* canvas,
60 Part part,
61 State state,
62 const gfx::Rect& rect) const;
64 virtual void PaintScrollbarCorner(SkCanvas* canvas,
65 State state,
66 const gfx::Rect& rect) const;
68 virtual void PaintCheckbox(
69 SkCanvas* canvas,
70 State state,
71 const gfx::Rect& rect,
72 const ButtonExtraParams& button) const;
74 virtual void PaintRadio(
75 SkCanvas* canvas,
76 State state,
77 const gfx::Rect& rect,
78 const ButtonExtraParams& button) const;
80 virtual void PaintButton(
81 SkCanvas* canvas,
82 State state,
83 const gfx::Rect& rect,
84 const ButtonExtraParams& button) const;
86 virtual void PaintTextField(
87 SkCanvas* canvas,
88 State state,
89 const gfx::Rect& rect,
90 const TextFieldExtraParams& text) const;
92 virtual void PaintMenuList(
93 SkCanvas* canvas,
94 State state,
95 const gfx::Rect& rect,
96 const MenuListExtraParams& menu_list) const;
98 virtual void PaintMenuPopupBackground(
99 SkCanvas* canvas,
100 const gfx::Size& size,
101 const MenuBackgroundExtraParams& menu_background) const;
103 virtual void PaintMenuItemBackground(
104 SkCanvas* canvas,
105 State state,
106 const gfx::Rect& rect,
107 const MenuListExtraParams& menu_list) const;
109 virtual void PaintSliderTrack(
110 SkCanvas* canvas,
111 State state,
112 const gfx::Rect& rect,
113 const SliderExtraParams& slider) const;
115 virtual void PaintSliderThumb(
116 SkCanvas* canvas,
117 State state,
118 const gfx::Rect& rect,
119 const SliderExtraParams& slider) const;
121 virtual void PaintInnerSpinButton(
122 SkCanvas* canvas,
123 State state,
124 const gfx::Rect& rect,
125 const InnerSpinButtonExtraParams& spin_button) const;
127 virtual void PaintProgressBar(
128 SkCanvas* canvas,
129 State state,
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,
158 Part direction,
159 SkColor color) const;
161 // Returns the color used to draw the arrow.
162 SkColor GetArrowColor(State state) const;
164 private:
165 void DrawVertLine(SkCanvas* canvas,
166 int x,
167 int y1,
168 int y2,
169 const SkPaint& paint) const;
170 void DrawHorizLine(SkCanvas* canvas,
171 int x1,
172 int x2,
173 int y,
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,
179 SkScalar min,
180 SkScalar max) const;
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(
186 SkCanvas* canvas,
187 State state,
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);
197 } // namespace ui
199 #endif // UI_NATIVE_THEME_NATIVE_THEME_BASE_H_