OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_UI_GTK_CONFIRM_BUBBLE_GTK_H_ | |
6 #define CHROME_BROWSER_UI_GTK_CONFIRM_BUBBLE_GTK_H_ | |
7 | |
8 #include "base/compiler_specific.h" | |
9 #include "base/gtest_prod_util.h" | |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h" | |
12 #include "ui/base/gtk/gtk_signal.h" | |
13 #include "ui/gfx/native_widget_types.h" | |
14 | |
15 typedef struct _GtkWidget GtkWidget; | |
16 | |
17 class ConfirmBubbleModel; | |
18 class CustomDrawButton; | |
19 | |
20 // A class that implements a bubble that consists of the following items: | |
21 // * one icon ("icon") | |
22 // * one title text ("title") | |
23 // * one close button ("x") | |
24 // * one message text ("message") | |
25 // * one optional link ("link") | |
26 // * two optional buttons ("ok" and "cancel") | |
27 // | |
28 // This bubble is convenient when we wish to ask transient, non-blocking | |
29 // questions. Unlike a dialog, a bubble menu disappears when we click outside of | |
30 // its window to avoid blocking user operations. A bubble is laid out as | |
31 // follows: | |
32 // | |
33 // +------------------------+ | |
34 // | icon title x | | |
35 // | message | | |
36 // | link | | |
37 // | [Cancel] [OK] | | |
38 // +------------------------+ | |
39 // | |
40 class ConfirmBubbleGtk : public BubbleDelegateGtk { | |
41 public: | |
42 ConfirmBubbleGtk(gfx::NativeView parent, | |
43 const gfx::Point& anchor_point, | |
44 ConfirmBubbleModel* model); | |
45 virtual ~ConfirmBubbleGtk(); | |
46 | |
47 // BubbleDelegateGtk implementation. | |
48 virtual void BubbleClosing(BubbleGtk* bubble, bool closed_by_escape) OVERRIDE; | |
49 | |
50 // Create a bubble and show it. | |
51 void Show(); | |
52 | |
53 private: | |
54 FRIEND_TEST_ALL_PREFIXES(ConfirmBubbleGtkTest, ClickCancel); | |
55 FRIEND_TEST_ALL_PREFIXES(ConfirmBubbleGtkTest, ClickOk); | |
56 FRIEND_TEST_ALL_PREFIXES(ConfirmBubbleGtkTest, ClickLink); | |
57 | |
58 // GTK event handlers. | |
59 CHROMEGTK_CALLBACK_0(ConfirmBubbleGtk, void, OnDestroy); | |
60 CHROMEGTK_CALLBACK_0(ConfirmBubbleGtk, void, OnCloseButton); | |
61 CHROMEGTK_CALLBACK_0(ConfirmBubbleGtk, void, OnOkButton); | |
62 CHROMEGTK_CALLBACK_0(ConfirmBubbleGtk, void, OnCancelButton); | |
63 CHROMEGTK_CALLBACK_0(ConfirmBubbleGtk, void, OnLinkButton); | |
64 | |
65 // The bubble. | |
66 BubbleGtk* bubble_; | |
67 | |
68 // The anchor window and the screen point where this bubble is anchored. This | |
69 // class shows a bubble under this point. | |
70 gfx::NativeView anchor_; | |
71 gfx::Point anchor_point_; | |
72 | |
73 // The model to customize this bubble view. | |
74 scoped_ptr<ConfirmBubbleModel> model_; | |
75 | |
76 // The x that closes this bubble. | |
77 scoped_ptr<CustomDrawButton> close_button_; | |
78 | |
79 DISALLOW_COPY_AND_ASSIGN(ConfirmBubbleGtk); | |
80 }; | |
81 | |
82 #endif // CHROME_BROWSER_UI_GTK_CONFIRM_BUBBLE_GTK_H_ | |
OLD | NEW |