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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
284 return; | 284 return; |
285 is_default_ = is_default; | 285 is_default_ = is_default; |
286 if (is_default_) | 286 if (is_default_) |
287 AddAccelerator(ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE)); | 287 AddAccelerator(ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE)); |
288 else | 288 else |
289 RemoveAccelerator(ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE)); | 289 RemoveAccelerator(ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE)); |
290 SchedulePaint(); | 290 SchedulePaint(); |
291 } | 291 } |
292 | 292 |
293 void TextButtonBase::SetText(const string16& text) { | 293 void TextButtonBase::SetText(const string16& text) { |
294 text_ = text; | 294 if (text != text_) { |
Daniel Erat
2012/09/11 20:53:37
nit: just:
if (text == text_)
return;
and
| |
295 SetAccessibleName(text); | 295 text_ = text; |
296 UpdateTextSize(); | 296 SetAccessibleName(text); |
297 UpdateTextSize(); | |
298 } | |
297 } | 299 } |
298 | 300 |
299 void TextButtonBase::SetFont(const gfx::Font& font) { | 301 void TextButtonBase::SetFont(const gfx::Font& font) { |
300 font_ = font; | 302 font_ = font; |
301 UpdateTextSize(); | 303 UpdateTextSize(); |
302 } | 304 } |
303 | 305 |
304 void TextButtonBase::SetEnabledColor(SkColor color) { | 306 void TextButtonBase::SetEnabledColor(SkColor color) { |
305 color_enabled_ = color; | 307 color_enabled_ = color; |
306 UpdateColor(); | 308 UpdateColor(); |
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
863 // Windows may paint a dotted focus rect in | 865 // Windows may paint a dotted focus rect in |
864 // NativeTextButton::OnPaintFocusBorder. To avoid getting two focus | 866 // NativeTextButton::OnPaintFocusBorder. To avoid getting two focus |
865 // indications (A dotted rect and a highlighted border) only set is_focused on | 867 // indications (A dotted rect and a highlighted border) only set is_focused on |
866 // non windows platforms. | 868 // non windows platforms. |
867 params->button.is_focused = HasFocus() && | 869 params->button.is_focused = HasFocus() && |
868 (focusable() || IsAccessibilityFocusable()); | 870 (focusable() || IsAccessibilityFocusable()); |
869 #endif | 871 #endif |
870 } | 872 } |
871 | 873 |
872 } // namespace views | 874 } // namespace views |
OLD | NEW |