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/controls/button/text_button.h" | 5 #include "ui/views/controls/button/text_button.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "grit/ui_resources.h" | 10 #include "grit/ui_resources.h" |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 } else { | 192 } else { |
193 ui::NativeTheme::ExtraParams extra; | 193 ui::NativeTheme::ExtraParams extra; |
194 ui::NativeTheme::State state = delegate_->GetThemeState(&extra); | 194 ui::NativeTheme::State state = delegate_->GetThemeState(&extra); |
195 theme->Paint(canvas->sk_canvas(), part, state, rect, extra); | 195 theme->Paint(canvas->sk_canvas(), part, state, rect, extra); |
196 } | 196 } |
197 } | 197 } |
198 | 198 |
199 | 199 |
200 // TextButtonBase ------------------------------------------------------------- | 200 // TextButtonBase ------------------------------------------------------------- |
201 | 201 |
202 TextButtonBase::TextButtonBase(ButtonListener* listener, const string16& text) | 202 TextButtonBase::TextButtonBase(ButtonListener* listener, |
| 203 const base::string16& text) |
203 : CustomButton(listener), | 204 : CustomButton(listener), |
204 alignment_(ALIGN_LEFT), | 205 alignment_(ALIGN_LEFT), |
205 font_(ResourceBundle::GetSharedInstance().GetFont( | 206 font_(ResourceBundle::GetSharedInstance().GetFont( |
206 ResourceBundle::BaseFont)), | 207 ResourceBundle::BaseFont)), |
207 has_text_shadow_(false), | 208 has_text_shadow_(false), |
208 active_text_shadow_color_(0), | 209 active_text_shadow_color_(0), |
209 inactive_text_shadow_color_(0), | 210 inactive_text_shadow_color_(0), |
210 text_shadow_offset_(gfx::Point(1, 1)), | 211 text_shadow_offset_(gfx::Point(1, 1)), |
211 min_width_(0), | 212 min_width_(0), |
212 min_height_(0), | 213 min_height_(0), |
(...skipping 19 matching lines...) Expand all Loading... |
232 if (is_default == is_default_) | 233 if (is_default == is_default_) |
233 return; | 234 return; |
234 is_default_ = is_default; | 235 is_default_ = is_default; |
235 if (is_default_) | 236 if (is_default_) |
236 AddAccelerator(ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE)); | 237 AddAccelerator(ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE)); |
237 else | 238 else |
238 RemoveAccelerator(ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE)); | 239 RemoveAccelerator(ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE)); |
239 SchedulePaint(); | 240 SchedulePaint(); |
240 } | 241 } |
241 | 242 |
242 void TextButtonBase::SetText(const string16& text) { | 243 void TextButtonBase::SetText(const base::string16& text) { |
243 if (text == text_) | 244 if (text == text_) |
244 return; | 245 return; |
245 text_ = text; | 246 text_ = text; |
246 SetAccessibleName(text); | 247 SetAccessibleName(text); |
247 UpdateTextSize(); | 248 UpdateTextSize(); |
248 } | 249 } |
249 | 250 |
250 void TextButtonBase::SetFont(const gfx::Font& font) { | 251 void TextButtonBase::SetFont(const gfx::Font& font) { |
251 font_ = font; | 252 font_ = font; |
252 UpdateTextSize(); | 253 UpdateTextSize(); |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 | 603 |
603 ui::NativeTheme::State TextButtonBase::GetForegroundThemeState( | 604 ui::NativeTheme::State TextButtonBase::GetForegroundThemeState( |
604 ui::NativeTheme::ExtraParams* params) const { | 605 ui::NativeTheme::ExtraParams* params) const { |
605 GetExtraParams(params); | 606 GetExtraParams(params); |
606 return ui::NativeTheme::kHovered; | 607 return ui::NativeTheme::kHovered; |
607 } | 608 } |
608 | 609 |
609 | 610 |
610 // TextButton ----------------------------------------------------------------- | 611 // TextButton ----------------------------------------------------------------- |
611 | 612 |
612 TextButton::TextButton(ButtonListener* listener, const string16& text) | 613 TextButton::TextButton(ButtonListener* listener, const base::string16& text) |
613 : TextButtonBase(listener, text), | 614 : TextButtonBase(listener, text), |
614 icon_placement_(ICON_ON_LEFT), | 615 icon_placement_(ICON_ON_LEFT), |
615 has_hover_icon_(false), | 616 has_hover_icon_(false), |
616 has_pushed_icon_(false), | 617 has_pushed_icon_(false), |
617 icon_text_spacing_(kDefaultIconTextSpacing), | 618 icon_text_spacing_(kDefaultIconTextSpacing), |
618 ignore_minimum_size_(true) { | 619 ignore_minimum_size_(true) { |
619 set_border(new TextButtonDefaultBorder); | 620 set_border(new TextButtonDefaultBorder); |
620 SetFocusPainter(Painter::CreateDashedFocusPainterWithInsets( | 621 SetFocusPainter(Painter::CreateDashedFocusPainterWithInsets( |
621 gfx::Insets(kFocusRectInset, kFocusRectInset, | 622 gfx::Insets(kFocusRectInset, kFocusRectInset, |
622 kFocusRectInset, kFocusRectInset))); | 623 kFocusRectInset, kFocusRectInset))); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 if (show_multiple_icon_states_) { | 746 if (show_multiple_icon_states_) { |
746 if (has_hover_icon_ && (state() == STATE_HOVERED)) | 747 if (has_hover_icon_ && (state() == STATE_HOVERED)) |
747 return icon_hover_; | 748 return icon_hover_; |
748 if (has_pushed_icon_ && (state() == STATE_PRESSED)) | 749 if (has_pushed_icon_ && (state() == STATE_PRESSED)) |
749 return icon_pushed_; | 750 return icon_pushed_; |
750 } | 751 } |
751 return icon_; | 752 return icon_; |
752 } | 753 } |
753 | 754 |
754 } // namespace views | 755 } // namespace views |
OLD | NEW |