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