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/button.h" | 5 #include "views/controls/button/button.h" |
6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
7 | 7 |
8 namespace views { | 8 namespace views { |
9 | 9 |
10 //////////////////////////////////////////////////////////////////////////////// | 10 //////////////////////////////////////////////////////////////////////////////// |
(...skipping 15 matching lines...) Expand all Loading... |
26 // Button, View overrides: | 26 // Button, View overrides: |
27 | 27 |
28 bool Button::GetTooltipText(const gfx::Point& p, std::wstring* tooltip) { | 28 bool Button::GetTooltipText(const gfx::Point& p, std::wstring* tooltip) { |
29 if (tooltip_text_.empty()) | 29 if (tooltip_text_.empty()) |
30 return false; | 30 return false; |
31 | 31 |
32 *tooltip = UTF16ToWideHack(tooltip_text_); | 32 *tooltip = UTF16ToWideHack(tooltip_text_); |
33 return true; | 33 return true; |
34 } | 34 } |
35 | 35 |
36 std::wstring Button::GetAccessibleKeyboardShortcut() { | 36 string16 Button::GetAccessibleKeyboardShortcut() { |
37 return UTF16ToWideHack(accessible_shortcut_); | 37 return accessible_shortcut_; |
38 } | 38 } |
39 | 39 |
40 AccessibilityTypes::Role Button::GetAccessibleRole() { | 40 AccessibilityTypes::Role Button::GetAccessibleRole() { |
41 return AccessibilityTypes::ROLE_PUSHBUTTON; | 41 return AccessibilityTypes::ROLE_PUSHBUTTON; |
42 } | 42 } |
43 | 43 |
44 //////////////////////////////////////////////////////////////////////////////// | 44 //////////////////////////////////////////////////////////////////////////////// |
45 // Button, protected: | 45 // Button, protected: |
46 | 46 |
47 Button::Button(ButtonListener* listener) | 47 Button::Button(ButtonListener* listener) |
48 : listener_(listener), | 48 : listener_(listener), |
49 tag_(-1), | 49 tag_(-1), |
50 mouse_event_flags_(0) { | 50 mouse_event_flags_(0) { |
51 set_accessibility_focusable(true); | 51 set_accessibility_focusable(true); |
52 } | 52 } |
53 | 53 |
54 void Button::NotifyClick(const views::Event& event) { | 54 void Button::NotifyClick(const views::Event& event) { |
55 mouse_event_flags_ = event.IsMouseEvent() ? event.GetFlags() : 0; | 55 mouse_event_flags_ = event.IsMouseEvent() ? event.GetFlags() : 0; |
56 // We can be called when there is no listener, in cases like double clicks on | 56 // We can be called when there is no listener, in cases like double clicks on |
57 // menu buttons etc. | 57 // menu buttons etc. |
58 if (listener_) | 58 if (listener_) |
59 listener_->ButtonPressed(this, event); | 59 listener_->ButtonPressed(this, event); |
60 // NOTE: don't attempt to reset mouse_event_flags_ as the listener may have | 60 // NOTE: don't attempt to reset mouse_event_flags_ as the listener may have |
61 // deleted us. | 61 // deleted us. |
62 } | 62 } |
63 | 63 |
64 } // namespace views | 64 } // namespace views |
OLD | NEW |