OLD | NEW |
1 // Copyright (c) 2010 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 SetEnabled(bool enabled); | 22 virtual void SetEnabled(bool enabled); |
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 |
28 | 38 |
29 // Called when the NativeControlGtk is attached to a View hierarchy with a | 39 // Called when the NativeControlGtk is attached to a View hierarchy with a |
30 // valid Widget. The NativeControlGtk should use this opportunity to create | 40 // valid Widget. The NativeControlGtk should use this opportunity to create |
31 // its associated GtkWidget. | 41 // its associated GtkWidget. |
32 virtual void CreateNativeControl() = 0; | 42 virtual void CreateNativeControl() = 0; |
33 | 43 |
34 // MUST be called by the subclass implementation of |CreateNativeControl| | 44 // MUST be called by the subclass implementation of |CreateNativeControl| |
35 // immediately after creating the control GtkWidget, otherwise it won't be | 45 // immediately after creating the control GtkWidget, otherwise it won't be |
36 // attached to the GtkView and will be effectively orphaned. | 46 // attached to the GtkView and will be effectively orphaned. |
37 virtual void NativeControlCreated(GtkWidget* widget); | 47 virtual void NativeControlCreated(GtkWidget* widget); |
38 | 48 |
39 private: | 49 private: |
40 static gboolean CallFocusIn(GtkWidget* widget, | 50 static gboolean CallFocusIn(GtkWidget* widget, |
41 GdkEventFocus* event, | 51 GdkEventFocus* event, |
42 NativeControlGtk* button); | 52 NativeControlGtk* button); |
43 | 53 |
44 DISALLOW_COPY_AND_ASSIGN(NativeControlGtk); | 54 DISALLOW_COPY_AND_ASSIGN(NativeControlGtk); |
45 }; | 55 }; |
46 | 56 |
47 } // namespace views | 57 } // namespace views |
48 | 58 |
49 #endif // #ifndef VIEWS_CONTROLS_NATIVE_CONTROL_GTK_H_ | 59 #endif // #ifndef VIEWS_CONTROLS_NATIVE_CONTROL_GTK_H_ |
OLD | NEW |