OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 CHROME_BROWSER_GTK_CONSTRAINED_WINDOW_GTK_H_ | 5 #ifndef CHROME_BROWSER_GTK_CONSTRAINED_WINDOW_GTK_H_ |
6 #define CHROME_BROWSER_GTK_CONSTRAINED_WINDOW_GTK_H_ | 6 #define CHROME_BROWSER_GTK_CONSTRAINED_WINDOW_GTK_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
10 | 10 |
11 #include "app/gtk_signal.h" | 11 #include "app/gtk_signal.h" |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/task.h" | 13 #include "base/task.h" |
14 #include "chrome/browser/gtk/owned_widget_gtk.h" | 14 #include "chrome/browser/gtk/owned_widget_gtk.h" |
15 #include "chrome/browser/tab_contents/constrained_window.h" | 15 #include "chrome/browser/tab_contents/constrained_window.h" |
16 | 16 |
17 class TabContents; | 17 class TabContents; |
| 18 typedef struct _GdkColor GdkColor; |
| 19 #if defined(TOUCH_UI) |
| 20 class TabContentsViewViews; |
| 21 #else |
18 class TabContentsViewGtk; | 22 class TabContentsViewGtk; |
19 typedef struct _GdkColor GdkColor; | 23 #endif |
20 | 24 |
21 class ConstrainedWindowGtkDelegate { | 25 class ConstrainedWindowGtkDelegate { |
22 public: | 26 public: |
23 // Returns the widget that will be put in the constrained window's container. | 27 // Returns the widget that will be put in the constrained window's container. |
24 virtual GtkWidget* GetWidgetRoot() = 0; | 28 virtual GtkWidget* GetWidgetRoot() = 0; |
25 | 29 |
26 // Tells the delegate to either delete itself or set up a task to delete | 30 // Tells the delegate to either delete itself or set up a task to delete |
27 // itself later. | 31 // itself later. |
28 virtual void DeleteDelegate() = 0; | 32 virtual void DeleteDelegate() = 0; |
29 | 33 |
30 virtual bool GetBackgroundColor(GdkColor* color); | 34 virtual bool GetBackgroundColor(GdkColor* color); |
31 | 35 |
32 protected: | 36 protected: |
33 virtual ~ConstrainedWindowGtkDelegate(); | 37 virtual ~ConstrainedWindowGtkDelegate(); |
34 }; | 38 }; |
35 | 39 |
36 // Constrained window implementation for the GTK port. Unlike the Win32 system, | 40 // Constrained window implementation for the GTK port. Unlike the Win32 system, |
37 // ConstrainedWindowGtk doesn't draw draggable fake windows and instead just | 41 // ConstrainedWindowGtk doesn't draw draggable fake windows and instead just |
38 // centers the dialog. It is thus an order of magnitude simpler. | 42 // centers the dialog. It is thus an order of magnitude simpler. |
39 class ConstrainedWindowGtk : public ConstrainedWindow { | 43 class ConstrainedWindowGtk : public ConstrainedWindow { |
40 public: | 44 public: |
| 45 #if defined(TOUCH_UI) |
| 46 typedef TabContentsViewViews TabContentsViewType; |
| 47 #else |
| 48 typedef TabContentsViewGtk TabContentsViewType; |
| 49 #endif |
| 50 |
41 virtual ~ConstrainedWindowGtk(); | 51 virtual ~ConstrainedWindowGtk(); |
42 | 52 |
43 // Overridden from ConstrainedWindow: | 53 // Overridden from ConstrainedWindow: |
44 virtual void ShowConstrainedWindow(); | 54 virtual void ShowConstrainedWindow(); |
45 virtual void CloseConstrainedWindow(); | 55 virtual void CloseConstrainedWindow(); |
46 | 56 |
47 // Returns the TabContents that constrains this Constrained Window. | 57 // Returns the TabContents that constrains this Constrained Window. |
48 TabContents* owner() const { return owner_; } | 58 TabContents* owner() const { return owner_; } |
49 | 59 |
50 // Returns the toplevel widget that displays this "window". | 60 // Returns the toplevel widget that displays this "window". |
51 GtkWidget* widget() { return border_.get(); } | 61 GtkWidget* widget() { return border_.get(); } |
52 | 62 |
53 // Returns the View that we collaborate with to position ourselves. | 63 // Returns the View that we collaborate with to position ourselves. |
54 TabContentsViewGtk* ContainingView(); | 64 TabContentsViewType* ContainingView(); |
55 | 65 |
56 private: | 66 private: |
57 friend class ConstrainedWindow; | 67 friend class ConstrainedWindow; |
58 | 68 |
59 ConstrainedWindowGtk(TabContents* owner, | 69 ConstrainedWindowGtk(TabContents* owner, |
60 ConstrainedWindowGtkDelegate* delegate); | 70 ConstrainedWindowGtkDelegate* delegate); |
61 | 71 |
62 // Handler for Escape. | 72 // Handler for Escape. |
63 CHROMEGTK_CALLBACK_1(ConstrainedWindowGtk, gboolean, OnKeyPress, | 73 CHROMEGTK_CALLBACK_1(ConstrainedWindowGtk, gboolean, OnKeyPress, |
64 GdkEventKey*); | 74 GdkEventKey*); |
65 | 75 |
66 // The TabContents that owns and constrains this ConstrainedWindow. | 76 // The TabContents that owns and constrains this ConstrainedWindow. |
67 TabContents* owner_; | 77 TabContents* owner_; |
68 | 78 |
69 // The top level widget container that exports to our TabContentsViewGtk. | 79 // The top level widget container that exports to our TabContentsView. |
70 OwnedWidgetGtk border_; | 80 OwnedWidgetGtk border_; |
71 | 81 |
72 // Delegate that provides the contents of this constrained window. | 82 // Delegate that provides the contents of this constrained window. |
73 ConstrainedWindowGtkDelegate* delegate_; | 83 ConstrainedWindowGtkDelegate* delegate_; |
74 | 84 |
75 // Stores if |ShowConstrainedWindow()| has been called. | 85 // Stores if |ShowConstrainedWindow()| has been called. |
76 bool visible_; | 86 bool visible_; |
77 | 87 |
78 ScopedRunnableMethodFactory<ConstrainedWindowGtk> factory_; | 88 ScopedRunnableMethodFactory<ConstrainedWindowGtk> factory_; |
79 | 89 |
80 DISALLOW_COPY_AND_ASSIGN(ConstrainedWindowGtk); | 90 DISALLOW_COPY_AND_ASSIGN(ConstrainedWindowGtk); |
81 }; | 91 }; |
82 | 92 |
83 #endif // CHROME_BROWSER_GTK_CONSTRAINED_WINDOW_GTK_H_ | 93 #endif // CHROME_BROWSER_GTK_CONSTRAINED_WINDOW_GTK_H_ |
OLD | NEW |