1 // Copyright (c) 2011 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.
5 #ifndef CHROME_BROWSER_UI_GTK_INFOBARS_INFOBAR_CONTAINER_GTK_H_
6 #define CHROME_BROWSER_UI_GTK_INFOBARS_INFOBAR_CONTAINER_GTK_H_
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "chrome/browser/infobars/infobar_container.h"
13 #include "ui/base/gtk/owned_widget_gtk.h"
17 class InfoBarDelegate
;
24 typedef struct _GdkColor GdkColor
;
25 typedef struct _GdkEventExpose GdkEventExpose
;
26 typedef struct _GtkWidget GtkWidget
;
28 // Container that both contains the currently displaying infobars, and does
29 // drawing of infobar arrows on other widgets.
31 // Due to how X11/GTK+ works, this class owns the methods to draw arrows on top
32 // of other widgets. Since most bars in the top of the window have their own
33 // event boxes, we can't just draw over the coordinates in the toplevel window
34 // as event boxes get their own canvases (and they need to have their own event
35 // boxes for a mixture of handling mouse events and themeing). And because they
36 // have their own event boxes and event boxes can't be partially transparent,
37 // we can't just overlap the widgets.
38 class InfoBarContainerGtk
: public InfoBarContainer
{
40 InfoBarContainerGtk(InfoBarContainer::Delegate
* delegate
,
42 virtual ~InfoBarContainerGtk();
44 // Get the native widget.
45 GtkWidget
* widget() const { return container_
.get(); }
47 // Remove the specified InfoBarDelegate from the selected WebContents. This
48 // will notify us back and cause us to close the View. This is called from
49 // the InfoBar's close button handler.
50 void RemoveDelegate(InfoBarDelegate
* delegate
);
52 // Returns the total pixel height of all infobars in this container that
53 // are currently animating.
54 int TotalHeightOfAnimatingBars() const;
56 // True if we are displaying any infobars.
57 bool ContainsInfobars() const;
59 // Paints parts of infobars that aren't inside the infobar's widget. This
60 // method is called with |widget|/|expose| pairs for both infobars and
61 // toolbars. All infobars starting from |infobar| (NULL for the first) to the
62 // end of the list will be rendered.
63 void PaintInfobarBitsOn(GtkWidget
* widget
,
64 GdkEventExpose
* expose
,
69 virtual void PlatformSpecificAddInfoBar(InfoBar
* infobar
,
70 size_t position
) OVERRIDE
;
71 virtual void PlatformSpecificRemoveInfoBar(InfoBar
* infobar
) OVERRIDE
;
72 virtual void PlatformSpecificInfoBarStateChanged(bool is_animating
) OVERRIDE
;
75 // Performs the actual painting of the arrow in an expose event.
76 void PaintArrowOn(GtkWidget
* widget
,
77 GdkEventExpose
* expose
,
78 const gfx::Rect
& bounds
,
81 // The profile for the browser that hosts this InfoBarContainer.
84 // A list of the InfoBarGtk* instances. Used during drawing to determine
85 // which InfoBarGtk supplies information about drawing the arrows.
86 std::vector
<InfoBarGtk
*> infobars_gtk_
;
88 // VBox that holds the info bars.
89 ui::OwnedWidgetGtk container_
;
91 DISALLOW_COPY_AND_ASSIGN(InfoBarContainerGtk
);
94 #endif // CHROME_BROWSER_UI_GTK_INFOBARS_INFOBAR_CONTAINER_GTK_H_