diff options
author | deanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-30 15:24:37 +0000 |
---|---|---|
committer | deanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-30 15:24:37 +0000 |
commit | 4d8c97a0fc89283697f3a580a6febad4c2fe972b (patch) | |
tree | 45641ce2e01861653f9b68842edd3e41781c82f3 /chrome/browser/gtk/info_bubble_gtk.h | |
parent | 900e7368646c6d45d62df9eb03f252cfacdf6111 (diff) | |
download | chromium_src-4d8c97a0fc89283697f3a580a6febad4c2fe972b.zip chromium_src-4d8c97a0fc89283697f3a580a6febad4c2fe972b.tar.gz chromium_src-4d8c97a0fc89283697f3a580a6febad4c2fe972b.tar.bz2 |
Implement a mostly working InfoBubble with a shim BookmarkBubble.
This ended up being implemented as a toplevel instead of a popup, to handle
things like virtual desktop switching. I imagine there are some other problems
we might hit, like the window getting decorated, etc. Although I think the
shape mask might prevent decorations from being visible. This is not pixel
perfect with Windows, since we're not anti-aliasing the frame border.
Review URL: http://codereview.chromium.org/100203
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14941 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/info_bubble_gtk.h')
-rw-r--r-- | chrome/browser/gtk/info_bubble_gtk.h | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/chrome/browser/gtk/info_bubble_gtk.h b/chrome/browser/gtk/info_bubble_gtk.h new file mode 100644 index 0000000..d5a3b7b --- /dev/null +++ b/chrome/browser/gtk/info_bubble_gtk.h @@ -0,0 +1,72 @@ +// Copyright (c) 2009 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_GTK_INFO_BUBBLE_GTK_H_ +#define CHROME_BROWSER_GTK_INFO_BUBBLE_GTK_H_ + +#include "base/basictypes.h" + +#include <gtk/gtk.h> + +namespace gfx { +class Rect; +} + +class InfoBubbleGtk { + public: + // Show an InfoBubble, pointing at the area |rect| (in screen coordinates). + // An infobubble will try to fit on the screen, so it can point to any edge + // of |rect|. The bubble will host |widget| as the content. + static InfoBubbleGtk* Show(const gfx::Rect& rect, GtkWidget* content); + + InfoBubbleGtk(); + virtual ~InfoBubbleGtk(); + + void Close(); + + private: + // Creates the InfoBubble. + void Init(const gfx::Rect& rect, GtkWidget* content); + + // Closes the window notifying the delegate. |closed_by_escape| is true if + // the close is the result of pressing escape. + void Close(bool closed_by_escape); + + static gboolean HandleConfigureThunk(GtkWidget* widget, + GdkEventConfigure* event, + gpointer user_data) { + return reinterpret_cast<InfoBubbleGtk*>(user_data)->HandleConfigure(event); + } + gboolean HandleConfigure(GdkEventConfigure* event); + + static gboolean HandleButtonPressThunk(GtkWidget* widget, + GdkEventButton* event, + gpointer userdata) { + return reinterpret_cast<InfoBubbleGtk*>(userdata)-> + HandleButtonPress(event); + } + gboolean HandleButtonPress(GdkEventButton* event); + + static gboolean HandleButtonReleaseThunk(GtkWidget* widget, + GdkEventButton* event, + gpointer userdata) { + return reinterpret_cast<InfoBubbleGtk*>(userdata)-> + HandleButtonRelease(event); + } + gboolean HandleButtonRelease(GdkEventButton* event); + + // Our GtkWindow popup window. + GtkWidget* window_; + + // Where we want our window to be positioned on the screen. + int screen_x_; + int screen_y_; + + // Have we been closed? + bool closed_; + + DISALLOW_COPY_AND_ASSIGN(InfoBubbleGtk); +}; + +#endif // CHROME_BROWSER_GTK_INFO_BUBBLE_GTK_H_ |