| OLD | NEW |
| 1 // #ifndef CHROME_VIEWS_NATIVE_CONTROL_WIN_H_// Copyright (c) 2009 The Chromium
Authors. All rights reserved. Use of this | 1 // #ifndef CHROME_VIEWS_NATIVE_CONTROL_WIN_H_// 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 "views/controls/native_control_gtk.h" | 5 #include "views/controls/native_control_gtk.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 | 10 |
| 11 namespace views { | 11 namespace views { |
| 12 | 12 |
| 13 NativeControlGtk::NativeControlGtk() : NativeViewHostGtk() { | 13 NativeControlGtk::NativeControlGtk() { |
| 14 } | 14 } |
| 15 | 15 |
| 16 NativeControlGtk::~NativeControlGtk() { | 16 NativeControlGtk::~NativeControlGtk() { |
| 17 if (native_view()) | 17 if (native_view()) |
| 18 gtk_widget_destroy(native_view()); | 18 gtk_widget_destroy(native_view()); |
| 19 } | 19 } |
| 20 | 20 |
| 21 //////////////////////////////////////////////////////////////////////////////// | 21 //////////////////////////////////////////////////////////////////////////////// |
| 22 // NativeControlGtk, View overrides: | 22 // NativeControlGtk, View overrides: |
| 23 | 23 |
| 24 void NativeControlGtk::SetEnabled(bool enabled) { | 24 void NativeControlGtk::SetEnabled(bool enabled) { |
| 25 NOTIMPLEMENTED(); | 25 NOTIMPLEMENTED(); |
| 26 if (IsEnabled() != enabled) { | 26 if (IsEnabled() != enabled) { |
| 27 View::SetEnabled(enabled); | 27 View::SetEnabled(enabled); |
| 28 if (native_view()) | 28 if (native_view()) |
| 29 gtk_widget_set_sensitive(native_view(), IsEnabled()); | 29 gtk_widget_set_sensitive(native_view(), IsEnabled()); |
| 30 } | 30 } |
| 31 } | 31 } |
| 32 | 32 |
| 33 void NativeControlGtk::ViewHierarchyChanged(bool is_add, View* parent, | 33 void NativeControlGtk::ViewHierarchyChanged(bool is_add, View* parent, |
| 34 View* child) { | 34 View* child) { |
| 35 // Create the widget when we're added to a valid Widget. Many controls need a | 35 // Create the widget when we're added to a valid Widget. Many controls need a |
| 36 // parent widget to function properly. | 36 // parent widget to function properly. |
| 37 if (is_add && GetWidget() && !native_view()) | 37 if (is_add && GetWidget() && !native_view()) |
| 38 CreateNativeControl(); | 38 CreateNativeControl(); |
| 39 | 39 |
| 40 // Call the base class to hide the view if we're being removed. | 40 // Call the base class to hide the view if we're being removed. |
| 41 NativeViewHostGtk::ViewHierarchyChanged(is_add, parent, child); | 41 NativeViewHost::ViewHierarchyChanged(is_add, parent, child); |
| 42 } | 42 } |
| 43 | 43 |
| 44 void NativeControlGtk::VisibilityChanged(View* starting_from, bool is_visible) { | 44 void NativeControlGtk::VisibilityChanged(View* starting_from, bool is_visible) { |
| 45 if (!is_visible) { | 45 if (!is_visible) { |
| 46 // We destroy the child widget when we become invisible because of the | 46 // We destroy the child widget when we become invisible because of the |
| 47 // performance cost of maintaining widgets that aren't currently needed. | 47 // performance cost of maintaining widgets that aren't currently needed. |
| 48 Detach(); | 48 Detach(); |
| 49 } else if (!native_view()) { | 49 } else if (!native_view()) { |
| 50 CreateNativeControl(); | 50 CreateNativeControl(); |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 | 53 |
| 54 void NativeControlGtk::Focus() { | 54 void NativeControlGtk::Focus() { |
| 55 DCHECK(native_view()); | 55 DCHECK(native_view()); |
| 56 NOTIMPLEMENTED(); | 56 NOTIMPLEMENTED(); |
| 57 } | 57 } |
| 58 | 58 |
| 59 void NativeControlGtk::NativeControlCreated(GtkWidget* native_control) { | 59 void NativeControlGtk::NativeControlCreated(GtkWidget* native_control) { |
| 60 Attach(native_control); | 60 Attach(native_control); |
| 61 | 61 |
| 62 // Update the newly created GtkWdigetwith any resident enabled state. | 62 // Update the newly created GtkWdigetwith any resident enabled state. |
| 63 gtk_widget_set_sensitive(native_view(), IsEnabled()); | 63 gtk_widget_set_sensitive(native_view(), IsEnabled()); |
| 64 } | 64 } |
| 65 | 65 |
| 66 } // namespace views | 66 } // namespace views |
| OLD | NEW |