OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
3 // LICENSE file. | 3 // LICENSE file. |
4 | 4 |
5 #include <gtk/gtk.h> | 5 #include <gtk/gtk.h> |
6 | 6 |
7 #include "views/controls/button/native_button_gtk.h" | 7 #include "views/controls/button/native_button_gtk.h" |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
11 #include "views/controls/button/checkbox.h" | 11 #include "views/controls/button/checkbox.h" |
12 #include "views/controls/button/native_button.h" | 12 #include "views/controls/button/native_button.h" |
13 #include "views/controls/button/radio_button.h" | 13 #include "views/controls/button/radio_button.h" |
| 14 #include "views/controls/native/native_view_host_gtk.h" |
14 #include "views/widget/widget.h" | 15 #include "views/widget/widget.h" |
15 | 16 |
16 namespace views { | 17 namespace views { |
17 | 18 |
18 NativeButtonGtk::NativeButtonGtk(NativeButton* native_button) | 19 NativeButtonGtk::NativeButtonGtk(NativeButton* native_button) |
19 : NativeControlGtk(), | 20 : NativeControlGtk(), |
20 native_button_(native_button) { | 21 native_button_(native_button) { |
21 // Associates the actual GtkWidget with the native_button so the native_button | 22 // Associates the actual GtkWidget with the native_button so the native_button |
22 // is the one considered as having the focus (not the wrapper) when the | 23 // is the one considered as having the focus (not the wrapper) when the |
23 // GtkWidget is focused directly (with a click for example). | 24 // GtkWidget is focused directly (with a click for example). |
24 SetAssociatedFocusView(native_button); | 25 set_focus_view(native_button); |
25 } | 26 } |
26 | 27 |
27 NativeButtonGtk::~NativeButtonGtk() { | 28 NativeButtonGtk::~NativeButtonGtk() { |
28 } | 29 } |
29 | 30 |
30 void NativeButtonGtk::UpdateLabel() { | 31 void NativeButtonGtk::UpdateLabel() { |
31 if (!native_view()) | 32 if (!native_view()) |
32 return; | 33 return; |
33 | 34 |
34 gtk_button_set_label(GTK_BUTTON(native_view()), | 35 gtk_button_set_label(GTK_BUTTON(native_view()), |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 void NativeButtonGtk::NativeControlCreated(GtkWidget* widget) { | 84 void NativeButtonGtk::NativeControlCreated(GtkWidget* widget) { |
84 NativeControlGtk::NativeControlCreated(widget); | 85 NativeControlGtk::NativeControlCreated(widget); |
85 | 86 |
86 UpdateFont(); | 87 UpdateFont(); |
87 UpdateLabel(); | 88 UpdateLabel(); |
88 UpdateDefault(); | 89 UpdateDefault(); |
89 } | 90 } |
90 | 91 |
91 // static | 92 // static |
92 void NativeButtonGtk::CallClicked(GtkButton* widget) { | 93 void NativeButtonGtk::CallClicked(GtkButton* widget) { |
93 View* view = GetViewForNative(GTK_WIDGET(widget)); | 94 View* view = NativeViewHostGtk::GetViewForNative(GTK_WIDGET(widget)); |
94 if (view) | 95 if (view) |
95 static_cast<NativeButtonGtk*>(view)->OnClicked(); | 96 static_cast<NativeButtonGtk*>(view)->OnClicked(); |
96 } | 97 } |
97 | 98 |
98 void NativeButtonGtk::OnClicked() { | 99 void NativeButtonGtk::OnClicked() { |
99 native_button_->ButtonPressed(); | 100 native_button_->ButtonPressed(); |
100 } | 101 } |
101 | 102 |
102 NativeCheckboxGtk::NativeCheckboxGtk(Checkbox* checkbox) | 103 NativeCheckboxGtk::NativeCheckboxGtk(Checkbox* checkbox) |
103 : NativeButtonGtk(checkbox) { | 104 : NativeButtonGtk(checkbox) { |
(...skipping 16 matching lines...) Expand all Loading... |
120 return new NativeButtonGtk(native_button); | 121 return new NativeButtonGtk(native_button); |
121 } | 122 } |
122 | 123 |
123 // static | 124 // static |
124 NativeButtonWrapper* NativeButtonWrapper::CreateCheckboxWrapper( | 125 NativeButtonWrapper* NativeButtonWrapper::CreateCheckboxWrapper( |
125 Checkbox* checkbox) { | 126 Checkbox* checkbox) { |
126 return new NativeCheckboxGtk(checkbox); | 127 return new NativeCheckboxGtk(checkbox); |
127 } | 128 } |
128 | 129 |
129 } // namespace views | 130 } // namespace views |
OLD | NEW |