| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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_NATIVE_CONTROL_GTK_H_ | 5 #ifndef VIEWS_CONTROLS_NATIVE_CONTROL_GTK_H_ |
| 6 #define VIEWS_CONTROLS_NATIVE_CONTROL_GTK_H_ | 6 #define VIEWS_CONTROLS_NATIVE_CONTROL_GTK_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
| 10 | 10 |
| 11 #include "views/controls/native/native_view_host.h" | 11 #include "views/controls/native/native_view_host.h" |
| 12 | 12 |
| 13 namespace views { | 13 namespace views { |
| 14 | 14 |
| 15 // A View that hosts a native control. | 15 // A View that hosts a native control. |
| 16 class NativeControlGtk : public NativeViewHost { | 16 class NativeControlGtk : public NativeViewHost { |
| 17 public: | 17 public: |
| 18 NativeControlGtk(); | 18 NativeControlGtk(); |
| 19 virtual ~NativeControlGtk(); | 19 virtual ~NativeControlGtk(); |
| 20 | 20 |
| 21 // Overridden from View: | 21 // Overridden from View: |
| 22 virtual void OnEnabledChanged(); | 22 virtual void OnEnabledChanged(); |
| 23 | 23 |
| 24 protected: | 24 protected: |
| 25 virtual void ViewHierarchyChanged(bool is_add, View *parent, View *child); | 25 virtual void ViewHierarchyChanged(bool is_add, View *parent, View *child); |
| 26 virtual void VisibilityChanged(View* starting_from, bool is_visible); | 26 virtual void VisibilityChanged(View* starting_from, bool is_visible); |
| 27 virtual void OnFocus(); | 27 virtual void OnFocus(); |
| 28 #if defined(TOUCH_UI) | |
| 29 virtual bool OnMousePressed(const MouseEvent& event); | |
| 30 virtual void OnMouseReleased(const MouseEvent& event); | |
| 31 virtual void OnMouseMoved(const MouseEvent& event); | |
| 32 virtual void OnMouseExited(const MouseEvent& event); | |
| 33 virtual void OnMouseEntered(const MouseEvent& event); | |
| 34 | |
| 35 // Fake a mouse event. | |
| 36 void FakeNativeMouseEvent(const MouseEvent& event); | |
| 37 #endif | |
| 38 | 28 |
| 39 // Called when the NativeControlGtk is attached to a View hierarchy with a | 29 // Called when the NativeControlGtk is attached to a View hierarchy with a |
| 40 // valid Widget. The NativeControlGtk should use this opportunity to create | 30 // valid Widget. The NativeControlGtk should use this opportunity to create |
| 41 // its associated GtkWidget. | 31 // its associated GtkWidget. |
| 42 virtual void CreateNativeControl() = 0; | 32 virtual void CreateNativeControl() = 0; |
| 43 | 33 |
| 44 // MUST be called by the subclass implementation of |CreateNativeControl| | 34 // MUST be called by the subclass implementation of |CreateNativeControl| |
| 45 // immediately after creating the control GtkWidget, otherwise it won't be | 35 // immediately after creating the control GtkWidget, otherwise it won't be |
| 46 // attached to the GtkView and will be effectively orphaned. | 36 // attached to the GtkView and will be effectively orphaned. |
| 47 virtual void NativeControlCreated(GtkWidget* widget); | 37 virtual void NativeControlCreated(GtkWidget* widget); |
| 48 | 38 |
| 49 private: | 39 private: |
| 50 static gboolean CallFocusIn(GtkWidget* gtk_widget, | 40 static gboolean CallFocusIn(GtkWidget* gtk_widget, |
| 51 GdkEventFocus* event, | 41 GdkEventFocus* event, |
| 52 NativeControlGtk* button); | 42 NativeControlGtk* button); |
| 53 | 43 |
| 54 DISALLOW_COPY_AND_ASSIGN(NativeControlGtk); | 44 DISALLOW_COPY_AND_ASSIGN(NativeControlGtk); |
| 55 }; | 45 }; |
| 56 | 46 |
| 57 } // namespace views | 47 } // namespace views |
| 58 | 48 |
| 59 #endif // #ifndef VIEWS_CONTROLS_NATIVE_CONTROL_GTK_H_ | 49 #endif // #ifndef VIEWS_CONTROLS_NATIVE_CONTROL_GTK_H_ |
| OLD | NEW |