1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_BASE_NATIVE_THEME_NATIVE_THEME_BASE_H_
#define UI_BASE_NATIVE_THEME_NATIVE_THEME_BASE_H_
#pragma once
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "skia/ext/platform_canvas.h"
#include "ui/base/native_theme/native_theme.h"
namespace gfx {
class ImageSkia;
class Rect;
class Size;
}
namespace ui {
// Theme support for non-Windows toolkits.
class NativeThemeBase : public NativeTheme {
public:
// NativeTheme implementation:
virtual gfx::Size GetPartSize(Part part,
State state,
const ExtraParams& extra) const OVERRIDE;
virtual void Paint(SkCanvas* canvas,
Part part,
State state,
const gfx::Rect& rect,
const ExtraParams& extra) const OVERRIDE;
protected:
NativeThemeBase();
virtual ~NativeThemeBase();
// Draw the arrow. Used by scrollbar and inner spin button.
virtual void PaintArrowButton(
SkCanvas* gc,
const gfx::Rect& rect,
Part direction,
State state) const;
// Paint the scrollbar track. Done before the thumb so that it can contain
// alpha.
virtual void PaintScrollbarTrack(
SkCanvas* canvas,
Part part,
State state,
const ScrollbarTrackExtraParams& extra_params,
const gfx::Rect& rect) const;
// Draw the scrollbar thumb over the track.
virtual void PaintScrollbarThumb(
SkCanvas* canvas,
Part part,
State state,
const gfx::Rect& rect) const;
virtual void PaintCheckbox(
SkCanvas* canvas,
State state,
const gfx::Rect& rect,
const ButtonExtraParams& button) const;
virtual void PaintRadio(
SkCanvas* canvas,
State state,
const gfx::Rect& rect,
const ButtonExtraParams& button) const;
virtual void PaintButton(
SkCanvas* canvas,
State state,
const gfx::Rect& rect,
const ButtonExtraParams& button) const;
virtual void PaintTextField(
SkCanvas* canvas,
State state,
const gfx::Rect& rect,
const TextFieldExtraParams& text) const;
virtual void PaintMenuList(
SkCanvas* canvas,
State state,
const gfx::Rect& rect,
const MenuListExtraParams& menu_list) const;
virtual void PaintMenuPopupBackground(SkCanvas* canvas,
const gfx::Size& size) const;
virtual void PaintMenuItemBackground(
SkCanvas* canvas,
State state,
const gfx::Rect& rect,
const MenuListExtraParams& menu_list) const;
virtual void PaintSliderTrack(
SkCanvas* canvas,
State state,
const gfx::Rect& rect,
const SliderExtraParams& slider) const;
virtual void PaintSliderThumb(
SkCanvas* canvas,
State state,
const gfx::Rect& rect,
const SliderExtraParams& slider) const;
virtual void PaintInnerSpinButton(
SkCanvas* canvas,
State state,
const gfx::Rect& rect,
const InnerSpinButtonExtraParams& spin_button) const;
virtual void PaintProgressBar(
SkCanvas* canvas,
State state,
const gfx::Rect& rect,
const ProgressBarExtraParams& progress_bar) const;
protected:
void set_scrollbar_button_length(unsigned int length) {
scrollbar_button_length_ = length;
}
bool IntersectsClipRectInt(SkCanvas* canvas,
int x, int y, int w, int h) const;
void DrawBitmapInt(SkCanvas* canvas, const gfx::ImageSkia& image,
int src_x, int src_y, int src_w, int src_h,
int dest_x, int dest_y, int dest_w, int dest_h) const;
void DrawTiledImage(SkCanvas* canvas,
const gfx::ImageSkia& image,
int src_x, int src_y,
float tile_scale_x, float tile_scale_y,
int dest_x, int dest_y, int w, int h) const;
SkColor SaturateAndBrighten(SkScalar* hsv,
SkScalar saturate_amount,
SkScalar brighten_amount) const;
private:
void DrawVertLine(SkCanvas* canvas,
int x,
int y1,
int y2,
const SkPaint& paint) const;
void DrawHorizLine(SkCanvas* canvas,
int x1,
int x2,
int y,
const SkPaint& paint) const;
void DrawBox(SkCanvas* canvas,
const gfx::Rect& rect,
const SkPaint& paint) const;
SkScalar Clamp(SkScalar value,
SkScalar min,
SkScalar max) const;
SkColor OutlineColor(SkScalar* hsv1, SkScalar* hsv2) const;
unsigned int scrollbar_width_;
unsigned int scrollbar_button_length_;
DISALLOW_COPY_AND_ASSIGN(NativeThemeBase);
};
} // namespace ui
#endif // UI_BASE_NATIVE_THEME_NATIVE_THEME_BASE_H_
|