OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/views/examples/text_example.h" | 5 #include "ui/views/examples/text_example.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "ui/base/resource/resource_bundle.h" | 8 #include "ui/base/resource/resource_bundle.h" |
9 #include "ui/gfx/canvas.h" | 9 #include "ui/gfx/canvas.h" |
10 #include "ui/gfx/font_list.h" | 10 #include "ui/gfx/font_list.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 SK_ColorWHITE, bounds, text_flags_); | 101 SK_ColorWHITE, bounds, text_flags_); |
102 } else { | 102 } else { |
103 canvas->DrawStringRectWithFlags(text_, font_list_, SK_ColorDKGRAY, bounds, | 103 canvas->DrawStringRectWithFlags(text_, font_list_, SK_ColorDKGRAY, bounds, |
104 text_flags_); | 104 text_flags_); |
105 } | 105 } |
106 } | 106 } |
107 | 107 |
108 int text_flags() const { return text_flags_; } | 108 int text_flags() const { return text_flags_; } |
109 void set_text_flags(int text_flags) { text_flags_ = text_flags; } | 109 void set_text_flags(int text_flags) { text_flags_ = text_flags; } |
110 | 110 |
111 const string16& text() const { return text_; } | 111 const base::string16& text() const { return text_; } |
112 void set_text(const string16& text) { text_ = text; } | 112 void set_text(const base::string16& text) { text_ = text; } |
113 | 113 |
114 bool halo() const { return halo_; } | 114 bool halo() const { return halo_; } |
115 void set_halo(bool halo) { halo_ = halo; } | 115 void set_halo(bool halo) { halo_ = halo; } |
116 | 116 |
117 bool fade() const { return fade_; } | 117 bool fade() const { return fade_; } |
118 void set_fade(bool fade) { fade_ = fade; } | 118 void set_fade(bool fade) { fade_ = fade; } |
119 | 119 |
120 gfx::Canvas::TruncateFadeMode fade_mode() const { return fade_mode_; } | 120 gfx::Canvas::TruncateFadeMode fade_mode() const { return fade_mode_; } |
121 void set_fade_mode(gfx::Canvas::TruncateFadeMode mode) { fade_mode_ = mode; } | 121 void set_fade_mode(gfx::Canvas::TruncateFadeMode mode) { fade_mode_ = mode; } |
122 | 122 |
123 int GetFontStyle() const { | 123 int GetFontStyle() const { |
124 return font_list_.GetFontStyle(); | 124 return font_list_.GetFontStyle(); |
125 } | 125 } |
126 void SetFontStyle(int style) { | 126 void SetFontStyle(int style) { |
127 font_list_ = font_list_.DeriveFontList(style); | 127 font_list_ = font_list_.DeriveFontList(style); |
128 } | 128 } |
129 | 129 |
130 private: | 130 private: |
131 // The font used for drawing the text. | 131 // The font used for drawing the text. |
132 gfx::FontList font_list_; | 132 gfx::FontList font_list_; |
133 | 133 |
134 // The text to draw. | 134 // The text to draw. |
135 string16 text_; | 135 base::string16 text_; |
136 | 136 |
137 // Text flags for passing to |DrawStringInt()|. | 137 // Text flags for passing to |DrawStringInt()|. |
138 int text_flags_; | 138 int text_flags_; |
139 | 139 |
140 // If |true|, specifies to call |DrawStringWithHalo()| instead of | 140 // If |true|, specifies to call |DrawStringWithHalo()| instead of |
141 // |DrawStringInt()|. | 141 // |DrawStringInt()|. |
142 bool halo_; | 142 bool halo_; |
143 | 143 |
144 // If |true|, specifies to call |DrawFadeTruncatingString()| instead of | 144 // If |true|, specifies to call |DrawFadeTruncatingString()| instead of |
145 // |DrawStringInt()|. | 145 // |DrawStringInt()|. |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 text_flags |= gfx::Canvas::HIDE_PREFIX; | 321 text_flags |= gfx::Canvas::HIDE_PREFIX; |
322 break; | 322 break; |
323 } | 323 } |
324 } | 324 } |
325 text_view_->set_text_flags(text_flags); | 325 text_view_->set_text_flags(text_flags); |
326 text_view_->SchedulePaint(); | 326 text_view_->SchedulePaint(); |
327 } | 327 } |
328 | 328 |
329 } // namespace examples | 329 } // namespace examples |
330 } // namespace views | 330 } // namespace views |
OLD | NEW |