OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 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. | |
4 | |
5 #ifndef VIEWS_CONTROLS_TEXTFIELD_TEXT_STYLE_H_ | |
6 #define VIEWS_CONTROLS_TEXTFIELD_TEXT_STYLE_H_ | |
7 #pragma once | |
8 | |
9 #include "base/basictypes.h" | |
10 #include "base/gtest_prod_util.h" | |
11 #include "base/string16.h" | |
12 #include "third_party/skia/include/core/SkColor.h" | |
13 | |
14 namespace gfx { | |
15 class Canvas; | |
16 class Font; | |
17 } | |
18 | |
19 namespace views { | |
20 | |
21 // A class that specifies text style for TextfieldViews. | |
22 // TODO(suzhe|oshima): support underline color and thick style. | |
23 class TextStyle { | |
24 public: | |
25 // Foreground color for the text. | |
26 void set_foreground(SkColor color) { foreground_ = color; } | |
27 | |
28 // Draws diagnoal strike acrosss the text. | |
29 void set_strike(bool strike) { strike_ = strike; } | |
30 | |
31 // Adds underline to the text. | |
32 void set_underline(bool underline) { underline_ = underline; } | |
33 | |
34 private: | |
35 friend class NativeTextfieldViews; | |
36 friend class TextfieldViewsModel; | |
37 | |
38 FRIEND_TEST_ALL_PREFIXES(TextfieldViewsModelTest, TextStyleTest); | |
39 FRIEND_TEST_ALL_PREFIXES(TextfieldViewsModelTest, UndoRedo_CompositionText); | |
40 FRIEND_TEST_ALL_PREFIXES(TextfieldViewsModelTest, CompositionTextTest); | |
41 | |
42 TextStyle(); | |
43 virtual ~TextStyle(); | |
44 | |
45 SkColor foreground() const { return foreground_; } | |
46 bool underline() const { return underline_; } | |
47 | |
48 // Draw string to the canvas within the region given | |
49 // by |x|,|y|,|width|,|height|. | |
50 void DrawString(gfx::Canvas* canvas, | |
51 string16& text, | |
52 gfx::Font& base_font, | |
53 bool read_only, | |
54 int x, int y, int width, int height) const; | |
55 | |
56 SkColor foreground_; | |
57 bool strike_; | |
58 bool underline_; | |
59 | |
60 DISALLOW_COPY_AND_ASSIGN(TextStyle); | |
61 }; | |
62 | |
63 } // namespace views | |
64 | |
65 #endif // VIEWS_CONTROLS_TEXTFIELD_TEXT_STYLE_H_ | |
OLD | NEW |