Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: ui/views/controls/button/button.cc

Issue 851853002: It is time. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Trying to reup because the last upload failed. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/views/controls/button/button.h ('k') | ui/views/controls/button/checkbox.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/views/controls/button/button.h"
6
7 #include "base/strings/utf_string_conversions.h"
8 #include "ui/accessibility/ax_view_state.h"
9
10 namespace views {
11
12 ////////////////////////////////////////////////////////////////////////////////
13 // Button, static public:
14
15 // static
16 Button::ButtonState Button::GetButtonStateFrom(ui::NativeTheme::State state) {
17 switch (state) {
18 case ui::NativeTheme::kDisabled: return Button::STATE_DISABLED;
19 case ui::NativeTheme::kHovered: return Button::STATE_HOVERED;
20 case ui::NativeTheme::kNormal: return Button::STATE_NORMAL;
21 case ui::NativeTheme::kPressed: return Button::STATE_PRESSED;
22 case ui::NativeTheme::kNumStates: NOTREACHED();
23 }
24 return Button::STATE_NORMAL;
25 }
26
27 ////////////////////////////////////////////////////////////////////////////////
28 // Button, public:
29
30 Button::~Button() {
31 }
32
33 void Button::SetTooltipText(const base::string16& tooltip_text) {
34 tooltip_text_ = tooltip_text;
35 if (accessible_name_.empty())
36 accessible_name_ = tooltip_text_;
37 TooltipTextChanged();
38 }
39
40 void Button::SetAccessibleName(const base::string16& name) {
41 accessible_name_ = name;
42 }
43
44 ////////////////////////////////////////////////////////////////////////////////
45 // Button, View overrides:
46
47 bool Button::GetTooltipText(const gfx::Point& p,
48 base::string16* tooltip) const {
49 if (tooltip_text_.empty())
50 return false;
51
52 *tooltip = tooltip_text_;
53 return true;
54 }
55
56 void Button::GetAccessibleState(ui::AXViewState* state) {
57 state->role = ui::AX_ROLE_BUTTON;
58 state->name = accessible_name_;
59 }
60
61 ////////////////////////////////////////////////////////////////////////////////
62 // Button, protected:
63
64 Button::Button(ButtonListener* listener)
65 : listener_(listener),
66 tag_(-1) {
67 SetAccessibilityFocusable(true);
68 }
69
70 void Button::NotifyClick(const ui::Event& event) {
71 // We can be called when there is no listener, in cases like double clicks on
72 // menu buttons etc.
73 if (listener_)
74 listener_->ButtonPressed(this, event);
75 }
76
77 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/button/button.h ('k') | ui/views/controls/button/checkbox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698