Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: views/controls/label.cc

Issue 113441: ChromeFont->gfx::Font... (Closed) Base URL: svn://chrome-svn.corp.google.com/chrome/trunk/src/
Patch Set: Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « views/controls/label.h ('k') | views/controls/label_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "views/controls/label.h" 5 #include "views/controls/label.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include "app/gfx/chrome_canvas.h" 9 #include "app/gfx/chrome_canvas.h"
10 #include "app/gfx/chrome_font.h" 10 #include "app/gfx/chrome_font.h"
(...skipping 14 matching lines...) Expand all
25 static const int kFocusBorderPadding = 1; 25 static const int kFocusBorderPadding = 1;
26 26
27 Label::Label() { 27 Label::Label() {
28 Init(L"", GetDefaultFont()); 28 Init(L"", GetDefaultFont());
29 } 29 }
30 30
31 Label::Label(const std::wstring& text) { 31 Label::Label(const std::wstring& text) {
32 Init(text, GetDefaultFont()); 32 Init(text, GetDefaultFont());
33 } 33 }
34 34
35 Label::Label(const std::wstring& text, const ChromeFont& font) { 35 Label::Label(const std::wstring& text, const gfx::Font& font) {
36 Init(text, font); 36 Init(text, font);
37 } 37 }
38 38
39 void Label::Init(const std::wstring& text, const ChromeFont& font) { 39 void Label::Init(const std::wstring& text, const gfx::Font& font) {
40 contains_mouse_ = false; 40 contains_mouse_ = false;
41 font_ = font; 41 font_ = font;
42 text_size_valid_ = false; 42 text_size_valid_ = false;
43 SetText(text); 43 SetText(text);
44 url_set_ = false; 44 url_set_ = false;
45 color_ = kEnabledColor; 45 color_ = kEnabledColor;
46 horiz_alignment_ = ALIGN_CENTER; 46 horiz_alignment_ = ALIGN_CENTER;
47 is_multi_line_ = false; 47 is_multi_line_ = false;
48 allow_character_break_ = false; 48 allow_character_break_ = false;
49 collapse_when_hidden_ = false; 49 collapse_when_hidden_ = false;
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 } 168 }
169 169
170 void Label::PaintBackground(ChromeCanvas* canvas) { 170 void Label::PaintBackground(ChromeCanvas* canvas) {
171 const Background* bg = contains_mouse_ ? GetMouseOverBackground() : NULL; 171 const Background* bg = contains_mouse_ ? GetMouseOverBackground() : NULL;
172 if (!bg) 172 if (!bg)
173 bg = background(); 173 bg = background();
174 if (bg) 174 if (bg)
175 bg->Paint(canvas, this); 175 bg->Paint(canvas, this);
176 } 176 }
177 177
178 void Label::SetFont(const ChromeFont& font) { 178 void Label::SetFont(const gfx::Font& font) {
179 font_ = font; 179 font_ = font;
180 text_size_valid_ = false; 180 text_size_valid_ = false;
181 SchedulePaint(); 181 SchedulePaint();
182 } 182 }
183 183
184 ChromeFont Label::GetFont() const { 184 gfx::Font Label::GetFont() const {
185 return font_; 185 return font_;
186 } 186 }
187 187
188 void Label::SetText(const std::wstring& text) { 188 void Label::SetText(const std::wstring& text) {
189 text_ = text; 189 text_ = text;
190 url_set_ = false; 190 url_set_ = false;
191 text_size_valid_ = false; 191 text_size_valid_ = false;
192 SchedulePaint(); 192 SchedulePaint();
193 } 193 }
194 194
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 gfx::Insets Label::GetInsets() const { 347 gfx::Insets Label::GetInsets() const {
348 gfx::Insets insets = View::GetInsets(); 348 gfx::Insets insets = View::GetInsets();
349 if (IsFocusable() || has_focus_border_) { 349 if (IsFocusable() || has_focus_border_) {
350 insets += gfx::Insets(kFocusBorderPadding, kFocusBorderPadding, 350 insets += gfx::Insets(kFocusBorderPadding, kFocusBorderPadding,
351 kFocusBorderPadding, kFocusBorderPadding); 351 kFocusBorderPadding, kFocusBorderPadding);
352 } 352 }
353 return insets; 353 return insets;
354 } 354 }
355 355
356 // static 356 // static
357 ChromeFont Label::GetDefaultFont() { 357 gfx::Font Label::GetDefaultFont() {
358 return ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont); 358 return ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont);
359 } 359 }
360 360
361 void Label::UpdateContainsMouse(const MouseEvent& event) { 361 void Label::UpdateContainsMouse(const MouseEvent& event) {
362 SetContainsMouse(GetTextBounds().Contains(event.x(), event.y())); 362 SetContainsMouse(GetTextBounds().Contains(event.x(), event.y()));
363 } 363 }
364 364
365 void Label::SetContainsMouse(bool contains_mouse) { 365 void Label::SetContainsMouse(bool contains_mouse) {
366 if (contains_mouse_ == contains_mouse) 366 if (contains_mouse_ == contains_mouse)
367 return; 367 return;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 } 435 }
436 436
437 bool Label::GetAccessibleState(AccessibilityTypes::State* state) { 437 bool Label::GetAccessibleState(AccessibilityTypes::State* state) {
438 DCHECK(state); 438 DCHECK(state);
439 439
440 *state = AccessibilityTypes::STATE_READONLY; 440 *state = AccessibilityTypes::STATE_READONLY;
441 return true; 441 return true;
442 } 442 }
443 443
444 } // namespace views 444 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/label.h ('k') | views/controls/label_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698