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

Side by Side Diff: chrome/browser/chromeos/ui/echo_dialog_view.cc

Issue 12906002: Add ability to defined ranges with different styles in StyledLabel (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 8 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 | « no previous file | chrome/browser/ui/views/autofill/autofill_dialog_views.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/chromeos/ui/echo_dialog_view.h" 5 #include "chrome/browser/chromeos/ui/echo_dialog_view.h"
6 6
7 #include "chrome/browser/chromeos/ui/echo_dialog_listener.h" 7 #include "chrome/browser/chromeos/ui/echo_dialog_listener.h"
8 #include "grit/generated_resources.h" 8 #include "grit/generated_resources.h"
9 #include "ui/base/l10n/l10n_util.h" 9 #include "ui/base/l10n/l10n_util.h"
10 #include "ui/views/controls/styled_label.h" 10 #include "ui/views/controls/styled_label.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 std::vector<size_t> offsets; 45 std::vector<size_t> offsets;
46 string16 text = l10n_util::GetStringFUTF16(IDS_ECHO_CONSENT_DIALOG_TEXT, 46 string16 text = l10n_util::GetStringFUTF16(IDS_ECHO_CONSENT_DIALOG_TEXT,
47 service_name, 47 service_name,
48 link, 48 link,
49 &offsets); 49 &offsets);
50 50
51 // TODO(tbarzic): Set style for service_name substring. 51 // TODO(tbarzic): Set style for service_name substring.
52 52
53 label_ = new views::StyledLabel(text, this); 53 label_ = new views::StyledLabel(text, this);
54 label_->AddLink(ui::Range(offsets[1], offsets[1] + link.length())); 54 label_->AddStyleRange(ui::Range(offsets[1], offsets[1] + link.length()),
55 views:: StyledLabel::RangeStyleInfo::CreateForLink());
55 56
56 SetLabelBorderAndBounds(); 57 SetLabelBorderAndBounds();
57 58
58 AddChildView(label_); 59 AddChildView(label_);
59 } 60 }
60 61
61 void EchoDialogView::InitForDisabledEcho() { 62 void EchoDialogView::InitForDisabledEcho() {
62 ok_button_label_id_ = 0; 63 ok_button_label_id_ = 0;
63 cancel_button_label_id_ = IDS_ECHO_CONSENT_DISMISS_BUTTON; 64 cancel_button_label_id_ = IDS_ECHO_CONSENT_DISMISS_BUTTON;
64 65
65 string16 link = 66 string16 link =
66 l10n_util::GetStringUTF16(IDS_OFFERS_CONSENT_INFOBAR_LABEL_LEARN_MORE); 67 l10n_util::GetStringUTF16(IDS_OFFERS_CONSENT_INFOBAR_LABEL_LEARN_MORE);
67 68
68 size_t offset; 69 size_t offset;
69 string16 text = l10n_util::GetStringFUTF16( 70 string16 text = l10n_util::GetStringFUTF16(
70 IDS_ECHO_DISABLED_CONSENT_DIALOG_TEXT, link, &offset); 71 IDS_ECHO_DISABLED_CONSENT_DIALOG_TEXT, link, &offset);
71 72
72 label_ = new views::StyledLabel(text, this); 73 label_ = new views::StyledLabel(text, this);
73 label_->AddLink(ui::Range(offset, offset + link.length())); 74 label_->AddStyleRange(ui::Range(offset, offset + link.length()),
75 views::StyledLabel::RangeStyleInfo::CreateForLink());
74 76
75 SetLabelBorderAndBounds(); 77 SetLabelBorderAndBounds();
76 78
77 AddChildView(label_); 79 AddChildView(label_);
78 } 80 }
79 81
80 void EchoDialogView::Show(gfx::NativeWindow parent) { 82 void EchoDialogView::Show(gfx::NativeWindow parent) {
81 DCHECK(cancel_button_label_id_); 83 DCHECK(cancel_button_label_id_);
82 84
83 views::DialogDelegateView::CreateDialogWidget(this, parent, parent); 85 views::DialogDelegateView::CreateDialogWidget(this, parent, parent);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 kDialogLabelBottomInset, 159 kDialogLabelBottomInset,
158 kDialogLabelRightInset)); 160 kDialogLabelRightInset));
159 161
160 label_->SetBounds(label_->x(), 162 label_->SetBounds(label_->x(),
161 label_->y(), 163 label_->y(),
162 kDialogLabelPreferredWidth, 164 kDialogLabelPreferredWidth,
163 label_->GetHeightForWidth(kDialogLabelPreferredWidth)); 165 label_->GetHeightForWidth(kDialogLabelPreferredWidth));
164 } 166 }
165 167
166 } // namespace chromeos 168 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/autofill/autofill_dialog_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698