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

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

Issue 24012002: Move Range code to gfx. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: d Created 7 years, 3 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
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/gfx/font.h" 10 #include "ui/gfx/font.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 service_name, 48 service_name,
49 link, 49 link,
50 &offsets); 50 &offsets);
51 51
52 label_ = new views::StyledLabel(text, this); 52 label_ = new views::StyledLabel(text, this);
53 53
54 views::StyledLabel::RangeStyleInfo service_name_style; 54 views::StyledLabel::RangeStyleInfo service_name_style;
55 service_name_style.font_style = gfx::Font::UNDERLINE; 55 service_name_style.font_style = gfx::Font::UNDERLINE;
56 service_name_style.tooltip = origin; 56 service_name_style.tooltip = origin;
57 label_->AddStyleRange( 57 label_->AddStyleRange(
58 ui::Range(offsets[0], offsets[0] + service_name.length()), 58 gfx::Range(offsets[0], offsets[0] + service_name.length()),
59 service_name_style); 59 service_name_style);
60 60
61 views::StyledLabel::RangeStyleInfo link_style = 61 views::StyledLabel::RangeStyleInfo link_style =
62 views::StyledLabel::RangeStyleInfo::CreateForLink(); 62 views::StyledLabel::RangeStyleInfo::CreateForLink();
63 link_style.font_style = gfx::Font::NORMAL; 63 link_style.font_style = gfx::Font::NORMAL;
64 label_->AddStyleRange(ui::Range(offsets[1], offsets[1] + link.length()), 64 label_->AddStyleRange(gfx::Range(offsets[1], offsets[1] + link.length()),
65 link_style); 65 link_style);
66 66
67 SetLabelBorderAndBounds(); 67 SetLabelBorderAndBounds();
68 68
69 AddChildView(label_); 69 AddChildView(label_);
70 } 70 }
71 71
72 void EchoDialogView::InitForDisabledEcho() { 72 void EchoDialogView::InitForDisabledEcho() {
73 ok_button_label_id_ = 0; 73 ok_button_label_id_ = 0;
74 cancel_button_label_id_ = IDS_ECHO_CONSENT_DISMISS_BUTTON; 74 cancel_button_label_id_ = IDS_ECHO_CONSENT_DISMISS_BUTTON;
75 75
76 string16 link = 76 string16 link =
77 l10n_util::GetStringUTF16(IDS_OFFERS_CONSENT_INFOBAR_LABEL_LEARN_MORE); 77 l10n_util::GetStringUTF16(IDS_OFFERS_CONSENT_INFOBAR_LABEL_LEARN_MORE);
78 78
79 size_t offset; 79 size_t offset;
80 string16 text = l10n_util::GetStringFUTF16( 80 string16 text = l10n_util::GetStringFUTF16(
81 IDS_ECHO_DISABLED_CONSENT_DIALOG_TEXT, link, &offset); 81 IDS_ECHO_DISABLED_CONSENT_DIALOG_TEXT, link, &offset);
82 82
83 label_ = new views::StyledLabel(text, this); 83 label_ = new views::StyledLabel(text, this);
84 84
85 views::StyledLabel::RangeStyleInfo link_style = 85 views::StyledLabel::RangeStyleInfo link_style =
86 views::StyledLabel::RangeStyleInfo::CreateForLink(); 86 views::StyledLabel::RangeStyleInfo::CreateForLink();
87 link_style.font_style = gfx::Font::NORMAL; 87 link_style.font_style = gfx::Font::NORMAL;
88 label_->AddStyleRange(ui::Range(offset, offset + link.length()), link_style); 88 label_->AddStyleRange(gfx::Range(offset, offset + link.length()), link_style);
89 89
90 SetLabelBorderAndBounds(); 90 SetLabelBorderAndBounds();
91 91
92 AddChildView(label_); 92 AddChildView(label_);
93 } 93 }
94 94
95 void EchoDialogView::Show(gfx::NativeWindow parent) { 95 void EchoDialogView::Show(gfx::NativeWindow parent) {
96 DCHECK(cancel_button_label_id_); 96 DCHECK(cancel_button_label_id_);
97 97
98 views::DialogDelegate::CreateDialogWidget(this, parent, parent); 98 views::DialogDelegate::CreateDialogWidget(this, parent, parent);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 } 142 }
143 143
144 bool EchoDialogView::ShouldShowWindowTitle() const { 144 bool EchoDialogView::ShouldShowWindowTitle() const {
145 return false; 145 return false;
146 } 146 }
147 147
148 bool EchoDialogView::ShouldShowWindowIcon() const { 148 bool EchoDialogView::ShouldShowWindowIcon() const {
149 return false; 149 return false;
150 } 150 }
151 151
152 void EchoDialogView::StyledLabelLinkClicked(const ui::Range& range, 152 void EchoDialogView::StyledLabelLinkClicked(const gfx::Range& range,
153 int event_flags) { 153 int event_flags) {
154 if (!listener_) 154 if (!listener_)
155 return; 155 return;
156 listener_->OnMoreInfoLinkClicked(); 156 listener_->OnMoreInfoLinkClicked();
157 } 157 }
158 158
159 gfx::Size EchoDialogView::GetPreferredSize() { 159 gfx::Size EchoDialogView::GetPreferredSize() {
160 gfx::Size size = 160 gfx::Size size =
161 gfx::Size(kDialogLabelPreferredWidth, 161 gfx::Size(kDialogLabelPreferredWidth,
162 label_->GetHeightForWidth(kDialogLabelPreferredWidth)); 162 label_->GetHeightForWidth(kDialogLabelPreferredWidth));
163 gfx::Insets insets = GetInsets(); 163 gfx::Insets insets = GetInsets();
164 size.Enlarge(insets.width(), insets.height()); 164 size.Enlarge(insets.width(), insets.height());
165 return size; 165 return size;
166 } 166 }
167 167
168 void EchoDialogView::SetLabelBorderAndBounds() { 168 void EchoDialogView::SetLabelBorderAndBounds() {
169 label_->set_border(views::Border::CreateEmptyBorder( 169 label_->set_border(views::Border::CreateEmptyBorder(
170 kDialogLabelTopInset, 170 kDialogLabelTopInset,
171 kDialogLabelLeftInset, 171 kDialogLabelLeftInset,
172 kDialogLabelBottomInset, 172 kDialogLabelBottomInset,
173 kDialogLabelRightInset)); 173 kDialogLabelRightInset));
174 174
175 label_->SetBounds(label_->x(), 175 label_->SetBounds(label_->x(),
176 label_->y(), 176 label_->y(),
177 kDialogLabelPreferredWidth, 177 kDialogLabelPreferredWidth,
178 label_->GetHeightForWidth(kDialogLabelPreferredWidth)); 178 label_->GetHeightForWidth(kDialogLabelPreferredWidth));
179 } 179 }
180 180
181 } // namespace chromeos 181 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/ui/echo_dialog_view.h ('k') | chrome/browser/ui/app_list/search/tokenized_string.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698