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 #ifndef VIEWS_CONTROLS_BUTTON_CUSTOM_BUTTON_H_ | 5 #ifndef VIEWS_CONTROLS_BUTTON_CUSTOM_BUTTON_H_ |
6 #define VIEWS_CONTROLS_BUTTON_CUSTOM_BUTTON_H_ | 6 #define VIEWS_CONTROLS_BUTTON_CUSTOM_BUTTON_H_ |
7 | 7 |
8 #include "app/animation.h" | 8 #include "app/animation.h" |
9 #include "views/controls/button/button.h" | 9 #include "views/controls/button/button.h" |
10 | 10 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 virtual bool IsFocusable() const; | 47 virtual bool IsFocusable() const; |
48 | 48 |
49 void set_triggerable_event_flags(int triggerable_event_flags) { | 49 void set_triggerable_event_flags(int triggerable_event_flags) { |
50 triggerable_event_flags_ = triggerable_event_flags; | 50 triggerable_event_flags_ = triggerable_event_flags; |
51 } | 51 } |
52 | 52 |
53 int triggerable_event_flags() const { | 53 int triggerable_event_flags() const { |
54 return triggerable_event_flags_; | 54 return triggerable_event_flags_; |
55 } | 55 } |
56 | 56 |
| 57 // Sets whether |RequestFocus| should be invoked on a mouse press. The default |
| 58 // is true. |
| 59 void set_request_focus_on_press(bool value) { |
| 60 request_focus_on_press_ = value; |
| 61 } |
| 62 bool request_focus_on_press() const { return request_focus_on_press_; } |
| 63 |
57 protected: | 64 protected: |
58 // Construct the Button with a Listener. See comment for Button's ctor. | 65 // Construct the Button with a Listener. See comment for Button's ctor. |
59 explicit CustomButton(ButtonListener* listener); | 66 explicit CustomButton(ButtonListener* listener); |
60 | 67 |
61 // Returns true if the event is one that can trigger notifying the listener. | 68 // Returns true if the event is one that can trigger notifying the listener. |
62 // This implementation returns true if the left mouse button is down. | 69 // This implementation returns true if the left mouse button is down. |
63 virtual bool IsTriggerableEvent(const MouseEvent& e); | 70 virtual bool IsTriggerableEvent(const MouseEvent& e); |
64 | 71 |
65 // Overridden from View: | 72 // Overridden from View: |
66 virtual bool AcceleratorPressed(const Accelerator& accelerator); | 73 virtual bool AcceleratorPressed(const Accelerator& accelerator); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 // Returns whether the button is pushed. | 108 // Returns whether the button is pushed. |
102 bool IsPushed() const; | 109 bool IsPushed() const; |
103 | 110 |
104 // Should we animate when the state changes? Defaults to true, but false while | 111 // Should we animate when the state changes? Defaults to true, but false while |
105 // throbbing. | 112 // throbbing. |
106 bool animate_on_state_change_; | 113 bool animate_on_state_change_; |
107 | 114 |
108 // Mouse event flags which can trigger button actions. | 115 // Mouse event flags which can trigger button actions. |
109 int triggerable_event_flags_; | 116 int triggerable_event_flags_; |
110 | 117 |
| 118 // See description above setter. |
| 119 bool request_focus_on_press_; |
| 120 |
111 DISALLOW_COPY_AND_ASSIGN(CustomButton); | 121 DISALLOW_COPY_AND_ASSIGN(CustomButton); |
112 }; | 122 }; |
113 | 123 |
114 } // namespace views | 124 } // namespace views |
115 | 125 |
116 #endif // VIEWS_CONTROLS_BUTTON_CUSTOM_BUTTON_H_ | 126 #endif // VIEWS_CONTROLS_BUTTON_CUSTOM_BUTTON_H_ |
OLD | NEW |