Add ICU message format support
[chromium-blink-merge.git] / ui / native_theme / native_theme_base.h
blob8ceed5a072de16d3d944ad6612d5715d25455c03
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 gfx::Size GetPartSize(Part part,
28 State state,
29 const ExtraParams& extra) const override;
30 void Paint(SkCanvas* canvas,
31 Part part,
32 State state,
33 const gfx::Rect& rect,
34 const ExtraParams& extra) const override;
36 void PaintStateTransition(SkCanvas* canvas,
37 Part part,
38 State startState,
39 State endState,
40 double progress,
41 const gfx::Rect& rect) const override;
43 protected:
44 NativeThemeBase();
45 ~NativeThemeBase() override;
47 // Draw the arrow. Used by scrollbar and inner spin button.
48 virtual void PaintArrowButton(
49 SkCanvas* gc,
50 const gfx::Rect& rect,
51 Part direction,
52 State state) const;
53 // Paint the scrollbar track. Done before the thumb so that it can contain
54 // alpha.
55 virtual void PaintScrollbarTrack(
56 SkCanvas* canvas,
57 Part part,
58 State state,
59 const ScrollbarTrackExtraParams& extra_params,
60 const gfx::Rect& rect) const;
61 // Draw the scrollbar thumb over the track.
62 virtual void PaintScrollbarThumb(
63 SkCanvas* canvas,
64 Part part,
65 State state,
66 const gfx::Rect& rect) const;
68 virtual void PaintScrollbarCorner(SkCanvas* canvas,
69 State state,
70 const gfx::Rect& rect) const;
72 virtual void PaintCheckbox(
73 SkCanvas* canvas,
74 State state,
75 const gfx::Rect& rect,
76 const ButtonExtraParams& button) const;
78 virtual void PaintRadio(
79 SkCanvas* canvas,
80 State state,
81 const gfx::Rect& rect,
82 const ButtonExtraParams& button) const;
84 virtual void PaintButton(
85 SkCanvas* canvas,
86 State state,
87 const gfx::Rect& rect,
88 const ButtonExtraParams& button) const;
90 virtual void PaintTextField(
91 SkCanvas* canvas,
92 State state,
93 const gfx::Rect& rect,
94 const TextFieldExtraParams& text) const;
96 virtual void PaintMenuList(
97 SkCanvas* canvas,
98 State state,
99 const gfx::Rect& rect,
100 const MenuListExtraParams& menu_list) const;
102 virtual void PaintMenuPopupBackground(
103 SkCanvas* canvas,
104 const gfx::Size& size,
105 const MenuBackgroundExtraParams& menu_background) const;
107 virtual void PaintMenuItemBackground(
108 SkCanvas* canvas,
109 State state,
110 const gfx::Rect& rect,
111 const MenuListExtraParams& menu_list) const;
113 virtual void PaintSliderTrack(
114 SkCanvas* canvas,
115 State state,
116 const gfx::Rect& rect,
117 const SliderExtraParams& slider) const;
119 virtual void PaintSliderThumb(
120 SkCanvas* canvas,
121 State state,
122 const gfx::Rect& rect,
123 const SliderExtraParams& slider) const;
125 virtual void PaintInnerSpinButton(
126 SkCanvas* canvas,
127 State state,
128 const gfx::Rect& rect,
129 const InnerSpinButtonExtraParams& spin_button) const;
131 virtual void PaintProgressBar(
132 SkCanvas* canvas,
133 State state,
134 const gfx::Rect& rect,
135 const ProgressBarExtraParams& progress_bar) const;
137 virtual void PaintScrollbarThumbStateTransition(
138 SkCanvas* canvas,
139 State startState,
140 State endState,
141 double progress,
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,
169 Part direction,
170 SkColor color) const;
172 // Returns the color used to draw the arrow.
173 SkColor GetArrowColor(State state) const;
175 private:
176 void DrawVertLine(SkCanvas* canvas,
177 int x,
178 int y1,
179 int y2,
180 const SkPaint& paint) const;
181 void DrawHorizLine(SkCanvas* canvas,
182 int x1,
183 int x2,
184 int y,
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,
190 SkScalar min,
191 SkScalar max) const;
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(
197 SkCanvas* canvas,
198 State state,
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);
210 } // namespace ui
212 #endif // UI_NATIVE_THEME_NATIVE_THEME_BASE_H_