| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "views/controls/button/native_button.h" | 5 #include "views/controls/button/native_button.h" |
| 6 | 6 |
| 7 #include "app/keyboard_codes.h" | 7 #include "app/keyboard_codes.h" |
| 8 #include "base/i18n/rtl.h" | 8 #include "base/i18n/rtl.h" |
| 9 #include "views/controls/native/native_view_host.h" | 9 #include "views/controls/native/native_view_host.h" |
| 10 | 10 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 native_wrapper_->UpdateLabel(); | 80 native_wrapper_->UpdateLabel(); |
| 81 | 81 |
| 82 // Update the accessible name whenever the label changes. | 82 // Update the accessible name whenever the label changes. |
| 83 SetAccessibleName(label); | 83 SetAccessibleName(label); |
| 84 PreferredSizeChanged(); | 84 PreferredSizeChanged(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void NativeButton::SetIsDefault(bool is_default) { | 87 void NativeButton::SetIsDefault(bool is_default) { |
| 88 if (is_default == is_default_) | 88 if (is_default == is_default_) |
| 89 return; | 89 return; |
| 90 if (is_default) | 90 is_default_ = is_default; |
| 91 if (is_default_) |
| 91 AddAccelerator(Accelerator(app::VKEY_RETURN, false, false, false)); | 92 AddAccelerator(Accelerator(app::VKEY_RETURN, false, false, false)); |
| 92 else | 93 else |
| 93 RemoveAccelerator(Accelerator(app::VKEY_RETURN, false, false, false)); | 94 RemoveAccelerator(Accelerator(app::VKEY_RETURN, false, false, false)); |
| 94 SetAppearsAsDefault(is_default); | 95 if (native_wrapper_) |
| 96 native_wrapper_->UpdateDefault(); |
| 97 PreferredSizeChanged(); |
| 95 } | 98 } |
| 96 | 99 |
| 97 void NativeButton::SetNeedElevation(bool need_elevation) { | 100 void NativeButton::SetNeedElevation(bool need_elevation) { |
| 98 need_elevation_ = need_elevation; | 101 need_elevation_ = need_elevation; |
| 99 if (native_wrapper_) | 102 if (native_wrapper_) |
| 100 native_wrapper_->UpdateLabel(); | 103 native_wrapper_->UpdateLabel(); |
| 101 PreferredSizeChanged(); | 104 PreferredSizeChanged(); |
| 102 } | 105 } |
| 103 | 106 |
| 104 void NativeButton::SetAppearsAsDefault(bool appears_as_default) { | |
| 105 is_default_ = appears_as_default; | |
| 106 if (native_wrapper_) | |
| 107 native_wrapper_->UpdateDefault(); | |
| 108 PreferredSizeChanged(); | |
| 109 } | |
| 110 | |
| 111 void NativeButton::ButtonPressed() { | 107 void NativeButton::ButtonPressed() { |
| 112 RequestFocus(); | 108 RequestFocus(); |
| 113 | 109 |
| 114 // TODO(beng): obtain mouse event flags for native buttons someday. | 110 // TODO(beng): obtain mouse event flags for native buttons someday. |
| 115 #if defined(OS_WIN) | 111 #if defined(OS_WIN) |
| 116 DWORD pos = GetMessagePos(); | 112 DWORD pos = GetMessagePos(); |
| 117 POINTS points = MAKEPOINTS(pos); | 113 POINTS points = MAKEPOINTS(pos); |
| 118 gfx::Point cursor_point(points.x, points.y); | 114 gfx::Point cursor_point(points.x, points.y); |
| 119 #elif defined(OS_LINUX) | 115 #elif defined(OS_LINUX) |
| 120 gfx::Point cursor_point = Screen::GetCursorScreenPoint(); | 116 gfx::Point cursor_point = Screen::GetCursorScreenPoint(); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 native_wrapper->UpdateEnabled(); | 225 native_wrapper->UpdateEnabled(); |
| 230 return native_wrapper; | 226 return native_wrapper; |
| 231 } | 227 } |
| 232 | 228 |
| 233 void NativeButton::InitBorder() { | 229 void NativeButton::InitBorder() { |
| 234 set_border(Border::CreateEmptyBorder(0, kButtonBorderHWidth, 0, | 230 set_border(Border::CreateEmptyBorder(0, kButtonBorderHWidth, 0, |
| 235 kButtonBorderHWidth)); | 231 kButtonBorderHWidth)); |
| 236 } | 232 } |
| 237 | 233 |
| 238 } // namespace views | 234 } // namespace views |
| OLD | NEW |