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

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

Issue 10829047: Deprecate unused views::Label::SetURL(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/controls/label.h ('k') | ui/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) 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/controls/label.h" 5 #include "ui/views/controls/label.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 #include <vector> 10 #include <vector>
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 void Label::SetFont(const gfx::Font& font) { 49 void Label::SetFont(const gfx::Font& font) {
50 font_ = font; 50 font_ = font;
51 text_size_valid_ = false; 51 text_size_valid_ = false;
52 PreferredSizeChanged(); 52 PreferredSizeChanged();
53 SchedulePaint(); 53 SchedulePaint();
54 } 54 }
55 55
56 void Label::SetText(const string16& text) { 56 void Label::SetText(const string16& text) {
57 text_ = text; 57 text_ = text;
58 url_ = GURL();
59 text_size_valid_ = false; 58 text_size_valid_ = false;
60 is_email_ = false; 59 is_email_ = false;
61 PreferredSizeChanged(); 60 PreferredSizeChanged();
62 SchedulePaint(); 61 SchedulePaint();
63 } 62 }
64 63
65 void Label::SetEmail(const string16& email) { 64 void Label::SetEmail(const string16& email) {
66 SetText(email); 65 SetText(email);
67 is_email_ = true; 66 is_email_ = true;
68 } 67 }
69 68
70 void Label::SetURL(const GURL& url) {
71 DCHECK(url.is_valid());
72 url_ = url;
73 text_ = UTF8ToUTF16(url_.spec());
74 text_size_valid_ = false;
75 is_email_ = false;
76 PreferredSizeChanged();
77 SchedulePaint();
78 }
79
80 void Label::SetAutoColorReadabilityEnabled(bool enabled) { 69 void Label::SetAutoColorReadabilityEnabled(bool enabled) {
81 auto_color_readability_ = enabled; 70 auto_color_readability_ = enabled;
82 RecalculateColors(); 71 RecalculateColors();
83 } 72 }
84 73
85 void Label::SetEnabledColor(SkColor color) { 74 void Label::SetEnabledColor(SkColor color) {
86 requested_enabled_color_ = color; 75 requested_enabled_color_ = color;
87 RecalculateColors(); 76 RecalculateColors();
88 } 77 }
89 78
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 gfx::Insets insets(GetInsets()); 476 gfx::Insets insets(GetInsets());
488 bounds.Inset(insets.left(), insets.top(), insets.right(), insets.bottom()); 477 bounds.Inset(insets.left(), insets.top(), insets.right(), insets.bottom());
489 return bounds; 478 return bounds;
490 } 479 }
491 480
492 void Label::CalculateDrawStringParams(string16* paint_text, 481 void Label::CalculateDrawStringParams(string16* paint_text,
493 gfx::Rect* text_bounds, 482 gfx::Rect* text_bounds,
494 int* flags) const { 483 int* flags) const {
495 DCHECK(paint_text && text_bounds && flags); 484 DCHECK(paint_text && text_bounds && flags);
496 485
497 if (!url_.is_empty()) { 486 if (is_email_) {
498 // TODO(jungshik) : Figure out how to get 'intl.accept_languages'
499 // preference and use it when calling ElideUrl.
500 *paint_text =
501 ui::ElideUrl(url_, font_, GetAvailableRect().width(), std::string());
502
503 // An URLs is always treated as an LTR text and therefore we should
504 // explicitly mark it as such if the locale is RTL so that URLs containing
505 // Hebrew or Arabic characters are displayed correctly.
506 //
507 // Note that we don't check the View's UI layout setting in order to
508 // determine whether or not to insert the special Unicode formatting
509 // characters. We use the locale settings because an URL is always treated
510 // as an LTR string, even if its containing view does not use an RTL UI
511 // layout.
512 *paint_text = base::i18n::GetDisplayStringInLTRDirectionality(
513 *paint_text);
514 } else if (is_email_) {
515 *paint_text = ui::ElideEmail(text_, font_, GetAvailableRect().width()); 487 *paint_text = ui::ElideEmail(text_, font_, GetAvailableRect().width());
516 } else if (elide_in_middle_) { 488 } else if (elide_in_middle_) {
517 *paint_text = ui::ElideText(text_, font_, GetAvailableRect().width(), 489 *paint_text = ui::ElideText(text_, font_, GetAvailableRect().width(),
518 ui::ELIDE_IN_MIDDLE); 490 ui::ELIDE_IN_MIDDLE);
519 } else { 491 } else {
520 *paint_text = text_; 492 *paint_text = text_;
521 } 493 }
522 494
523 *text_bounds = GetTextBounds(); 495 *text_bounds = GetTextBounds();
524 *flags = ComputeDrawStringFlags(); 496 *flags = ComputeDrawStringFlags();
525 } 497 }
526 498
527 } // namespace views 499 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/label.h ('k') | ui/views/controls/label_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698