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 #ifndef VIEWS_CONTROLS_BUTTON_NATIVE_BUTTON_GTK_H_ | 5 #ifndef VIEWS_CONTROLS_BUTTON_NATIVE_BUTTON_GTK_H_ |
6 #define VIEWS_CONTROLS_BUTTON_NATIVE_BUTTON_GTK_H_ | 6 #define VIEWS_CONTROLS_BUTTON_NATIVE_BUTTON_GTK_H_ |
7 | 7 |
8 #include "views/controls/button/native_button_wrapper.h" | 8 #include "views/controls/button/native_button_wrapper.h" |
9 #include "views/controls/native_control_gtk.h" | 9 #include "views/controls/native_control_gtk.h" |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... |
26 virtual bool UsesNativeLabel() const; | 26 virtual bool UsesNativeLabel() const; |
27 virtual gfx::NativeView GetTestingHandle() const; | 27 virtual gfx::NativeView GetTestingHandle() const; |
28 | 28 |
29 // Overridden from View: | 29 // Overridden from View: |
30 virtual gfx::Size GetPreferredSize(); | 30 virtual gfx::Size GetPreferredSize(); |
31 | 31 |
32 protected: | 32 protected: |
33 virtual void CreateNativeControl(); | 33 virtual void CreateNativeControl(); |
34 virtual void NativeControlCreated(GtkWidget* widget); | 34 virtual void NativeControlCreated(GtkWidget* widget); |
35 | 35 |
| 36 // Invoked when the user clicks on the button. |
| 37 virtual void OnClicked(); |
| 38 |
36 // Returns true if this button is actually a checkbox or radio button. | 39 // Returns true if this button is actually a checkbox or radio button. |
37 virtual bool IsCheckbox() const { return false; } | 40 virtual bool IsCheckbox() const { return false; } |
38 | 41 |
39 private: | 42 private: |
40 static void CallClicked(GtkButton* widget, NativeButtonGtk* button); | 43 static void CallClicked(GtkButton* widget, NativeButtonGtk* button); |
41 | 44 |
42 // Invoked when the user clicks on the button. | |
43 void OnClicked(); | |
44 | |
45 // The NativeButton we are bound to. | 45 // The NativeButton we are bound to. |
46 NativeButton* native_button_; | 46 NativeButton* native_button_; |
47 | 47 |
48 // The preferred size from the last size_request. We save this until we are | 48 // The preferred size from the last size_request. We save this until we are |
49 // notified that data may have caused the preferred size to change because | 49 // notified that data may have caused the preferred size to change because |
50 // otherwise it seems every time we call gtk_widget_size_request the size | 50 // otherwise it seems every time we call gtk_widget_size_request the size |
51 // returned is a little larger (?!). | 51 // returned is a little larger (?!). |
52 gfx::Size preferred_size_; | 52 gfx::Size preferred_size_; |
53 | 53 |
54 DISALLOW_COPY_AND_ASSIGN(NativeButtonGtk); | 54 DISALLOW_COPY_AND_ASSIGN(NativeButtonGtk); |
55 }; | 55 }; |
56 | 56 |
57 class NativeCheckboxGtk : public NativeButtonGtk { | 57 class NativeCheckboxGtk : public NativeButtonGtk { |
58 public: | 58 public: |
59 explicit NativeCheckboxGtk(Checkbox* checkbox); | 59 explicit NativeCheckboxGtk(Checkbox* checkbox); |
60 | 60 |
61 private: | 61 private: |
| 62 static void CallClicked(GtkButton* widget, NativeCheckboxGtk* button); |
| 63 |
62 virtual void CreateNativeControl(); | 64 virtual void CreateNativeControl(); |
63 | 65 |
| 66 // Invoked when the user clicks on the button. |
| 67 virtual void OnClicked(); |
| 68 |
| 69 // Overidden from NativeButtonWrapper |
| 70 virtual void UpdateChecked(); |
| 71 |
64 // Returns true if this button is actually a checkbox or radio button. | 72 // Returns true if this button is actually a checkbox or radio button. |
65 virtual bool IsCheckbox() const { return true; } | 73 virtual bool IsCheckbox() const { return true; } |
| 74 |
| 75 Checkbox* checkbox_; |
| 76 |
| 77 // a flag to prevent OnClicked event when updating |
| 78 // gtk control via API gtk_toggle_button_set_active. |
| 79 bool deliver_click_event_; |
| 80 |
66 DISALLOW_COPY_AND_ASSIGN(NativeCheckboxGtk); | 81 DISALLOW_COPY_AND_ASSIGN(NativeCheckboxGtk); |
67 }; | 82 }; |
68 | 83 |
69 } // namespace views | 84 } // namespace views |
70 | 85 |
71 #endif // #ifndef VIEWS_CONTROLS_BUTTON_NATIVE_BUTTON_GTK_H_ | 86 #endif // #ifndef VIEWS_CONTROLS_BUTTON_NATIVE_BUTTON_GTK_H_ |
OLD | NEW |