| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_UI_GTK_BUBBLE_BUBBLE_GTK_H_ | 5 #ifndef CHROME_BROWSER_UI_GTK_BUBBLE_BUBBLE_GTK_H_ |
| 6 #define CHROME_BROWSER_UI_GTK_BUBBLE_BUBBLE_GTK_H_ | 6 #define CHROME_BROWSER_UI_GTK_BUBBLE_BUBBLE_GTK_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
| 10 | 10 |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 15 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
| 16 #include "content/public/browser/notification_observer.h" | 16 #include "content/public/browser/notification_observer.h" |
| 17 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
| 18 #include "ui/base/gtk/gtk_signal.h" | 18 #include "ui/base/gtk/gtk_signal.h" |
| 19 #include "ui/base/gtk/gtk_signal_registrar.h" | 19 #include "ui/base/gtk/gtk_signal_registrar.h" |
| 20 #include "ui/gfx/point.h" | 20 #include "ui/gfx/point.h" |
| 21 #include "ui/gfx/rect.h" | 21 #include "ui/gfx/rect.h" |
| 22 | 22 |
| 23 class BubbleGtk; | 23 class BubbleGtk; |
| 24 class GtkThemeService; | 24 class ThemeServiceGtk; |
| 25 | 25 |
| 26 namespace gfx { | 26 namespace gfx { |
| 27 class Rect; | 27 class Rect; |
| 28 } | 28 } |
| 29 | 29 |
| 30 class BubbleDelegateGtk { | 30 class BubbleDelegateGtk { |
| 31 public: | 31 public: |
| 32 // Called when the bubble is closing and is about to be deleted. | 32 // Called when the bubble is closing and is about to be deleted. |
| 33 // |closed_by_escape| is true if the close is the result of pressing escape. | 33 // |closed_by_escape| is true if the close is the result of pressing escape. |
| 34 virtual void BubbleClosing(BubbleGtk* bubble, bool closed_by_escape) = 0; | 34 virtual void BubbleClosing(BubbleGtk* bubble, bool closed_by_escape) = 0; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 // will be drawn at |arrow_location| if possible. The |delegate| will be | 66 // will be drawn at |arrow_location| if possible. The |delegate| will be |
| 67 // notified when the bubble is closed. The bubble will perform an X grab of | 67 // notified when the bubble is closed. The bubble will perform an X grab of |
| 68 // the pointer and keyboard, and will close itself if a click is received | 68 // the pointer and keyboard, and will close itself if a click is received |
| 69 // outside of the bubble. | 69 // outside of the bubble. |
| 70 static BubbleGtk* Show(GtkWidget* anchor_widget, | 70 static BubbleGtk* Show(GtkWidget* anchor_widget, |
| 71 const gfx::Rect* rect, | 71 const gfx::Rect* rect, |
| 72 GtkWidget* content, | 72 GtkWidget* content, |
| 73 ArrowLocationGtk arrow_location, | 73 ArrowLocationGtk arrow_location, |
| 74 bool match_system_theme, | 74 bool match_system_theme, |
| 75 bool grab_input, | 75 bool grab_input, |
| 76 GtkThemeService* provider, | 76 ThemeServiceGtk* provider, |
| 77 BubbleDelegateGtk* delegate); | 77 BubbleDelegateGtk* delegate); |
| 78 | 78 |
| 79 // Close the bubble if it's open. This will delete the widgets and object, | 79 // Close the bubble if it's open. This will delete the widgets and object, |
| 80 // so you shouldn't hold a BubbleGtk pointer after calling Close(). | 80 // so you shouldn't hold a BubbleGtk pointer after calling Close(). |
| 81 void Close(); | 81 void Close(); |
| 82 | 82 |
| 83 // content::NotificationObserver implementation. | 83 // content::NotificationObserver implementation. |
| 84 virtual void Observe(int type, | 84 virtual void Observe(int type, |
| 85 const content::NotificationSource& source, | 85 const content::NotificationSource& source, |
| 86 const content::NotificationDetails& details) OVERRIDE; | 86 const content::NotificationDetails& details) OVERRIDE; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 103 | 103 |
| 104 private: | 104 private: |
| 105 FRIEND_TEST_ALL_PREFIXES(BubbleGtkTest, ArrowLocation); | 105 FRIEND_TEST_ALL_PREFIXES(BubbleGtkTest, ArrowLocation); |
| 106 FRIEND_TEST_ALL_PREFIXES(BubbleGtkTest, NoArrow); | 106 FRIEND_TEST_ALL_PREFIXES(BubbleGtkTest, NoArrow); |
| 107 | 107 |
| 108 enum FrameType { | 108 enum FrameType { |
| 109 FRAME_MASK, | 109 FRAME_MASK, |
| 110 FRAME_STROKE, | 110 FRAME_STROKE, |
| 111 }; | 111 }; |
| 112 | 112 |
| 113 BubbleGtk(GtkThemeService* provider, bool match_system_theme); | 113 BubbleGtk(ThemeServiceGtk* provider, bool match_system_theme); |
| 114 virtual ~BubbleGtk(); | 114 virtual ~BubbleGtk(); |
| 115 | 115 |
| 116 // Creates the Bubble. | 116 // Creates the Bubble. |
| 117 void Init(GtkWidget* anchor_widget, | 117 void Init(GtkWidget* anchor_widget, |
| 118 const gfx::Rect* rect, | 118 const gfx::Rect* rect, |
| 119 GtkWidget* content, | 119 GtkWidget* content, |
| 120 ArrowLocationGtk arrow_location, | 120 ArrowLocationGtk arrow_location, |
| 121 bool grab_input); | 121 bool grab_input); |
| 122 | 122 |
| 123 // Make the points for our polygon frame, either for fill (the mask), or for | 123 // Make the points for our polygon frame, either for fill (the mask), or for |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 CHROMEGTK_CALLBACK_1(BubbleGtk, void, OnAnchorAllocate, GtkAllocation*); | 177 CHROMEGTK_CALLBACK_1(BubbleGtk, void, OnAnchorAllocate, GtkAllocation*); |
| 178 | 178 |
| 179 // The caller supplied delegate, can be NULL. | 179 // The caller supplied delegate, can be NULL. |
| 180 BubbleDelegateGtk* delegate_; | 180 BubbleDelegateGtk* delegate_; |
| 181 | 181 |
| 182 // Our GtkWindow popup window, we don't technically "own" the widget, since | 182 // Our GtkWindow popup window, we don't technically "own" the widget, since |
| 183 // it deletes us when it is destroyed. | 183 // it deletes us when it is destroyed. |
| 184 GtkWidget* window_; | 184 GtkWidget* window_; |
| 185 | 185 |
| 186 // Provides colors and stuff. | 186 // Provides colors and stuff. |
| 187 GtkThemeService* theme_service_; | 187 ThemeServiceGtk* theme_service_; |
| 188 | 188 |
| 189 // The accel group attached to |window_|, to handle closing with escape. | 189 // The accel group attached to |window_|, to handle closing with escape. |
| 190 GtkAccelGroup* accel_group_; | 190 GtkAccelGroup* accel_group_; |
| 191 | 191 |
| 192 // The window for which we're being shown (and to which |rect_| is relative). | 192 // The window for which we're being shown (and to which |rect_| is relative). |
| 193 // Note that it's possible for |toplevel_window_| to be NULL if the | 193 // Note that it's possible for |toplevel_window_| to be NULL if the |
| 194 // window is destroyed before this object is destroyed, so it's important | 194 // window is destroyed before this object is destroyed, so it's important |
| 195 // to check for that case. | 195 // to check for that case. |
| 196 GtkWidget* toplevel_window_; | 196 GtkWidget* toplevel_window_; |
| 197 | 197 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 224 bool closed_by_escape_; | 224 bool closed_by_escape_; |
| 225 | 225 |
| 226 content::NotificationRegistrar registrar_; | 226 content::NotificationRegistrar registrar_; |
| 227 | 227 |
| 228 ui::GtkSignalRegistrar signals_; | 228 ui::GtkSignalRegistrar signals_; |
| 229 | 229 |
| 230 DISALLOW_COPY_AND_ASSIGN(BubbleGtk); | 230 DISALLOW_COPY_AND_ASSIGN(BubbleGtk); |
| 231 }; | 231 }; |
| 232 | 232 |
| 233 #endif // CHROME_BROWSER_UI_GTK_BUBBLE_BUBBLE_GTK_H_ | 233 #endif // CHROME_BROWSER_UI_GTK_BUBBLE_BUBBLE_GTK_H_ |
| OLD | NEW |