OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_COMMON_GTK_UTIL_H_ | 5 #ifndef CHROME_COMMON_GTK_UTIL_H_ |
6 #define CHROME_COMMON_GTK_UTIL_H_ | 6 #define CHROME_COMMON_GTK_UTIL_H_ |
7 | 7 |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 | 9 |
10 #include "base/gfx/point.h" | 10 #include "base/gfx/point.h" |
11 #include "base/gfx/rect.h" | 11 #include "base/gfx/rect.h" |
12 #include "webkit/glue/window_open_disposition.h" | 12 #include "webkit/glue/window_open_disposition.h" |
13 | 13 |
14 typedef struct _GtkWidget GtkWidget; | 14 typedef struct _GtkWidget GtkWidget; |
15 | 15 |
16 namespace event_utils { | 16 namespace event_utils { |
17 | 17 |
18 // Translates event flags into what kind of disposition they represent. | 18 // Translates event flags into what kind of disposition they represent. |
19 // For example, a middle click would mean to open a background tab. | 19 // For example, a middle click would mean to open a background tab. |
20 // event_flags are the state in the GdkEvent structure. | 20 // event_flags are the state in the GdkEvent structure. |
21 WindowOpenDisposition DispositionFromEventFlags(guint state); | 21 WindowOpenDisposition DispositionFromEventFlags(guint state); |
22 | 22 |
23 } // namespace event_utils | 23 } // namespace event_utils |
24 | 24 |
25 namespace gtk_util { | 25 namespace gtk_util { |
26 | 26 |
27 // Create a GtkBin with |child| as its child widget. This bin will paint a | 27 // Create a GtkBin with |child| as its child widget. This bin will paint a |
28 // border of color |color| with the sizes specified in pixels. | 28 // border of color |color| with the sizes specified in pixels. |
29 GtkWidget* CreateGtkBorderBin(GtkWidget* child, const GdkColor* color, | 29 GtkWidget* CreateGtkBorderBin(GtkWidget* child, const GdkColor* color, |
30 int top, int bottom, int left, int right); | 30 int top, int bottom, int left, int right); |
31 | 31 |
32 // Remove all children from this container. | 32 // Remove all children from this container. |
33 void RemoveAllChildren(GtkWidget* container); | 33 void RemoveAllChildren(GtkWidget* container); |
34 | 34 |
35 // Force the font size of the widget to |size_pixels|. | 35 // Force the font size of the widget to |size_pixels|. |
36 void ForceFontSizePixels(GtkWidget* widget, double size_pixels); | 36 void ForceFontSizePixels(GtkWidget* widget, double size_pixels); |
37 | 37 |
38 // Gets the position of a gtk widget in screen coordinates. | 38 // Gets the position of a gtk widget in screen coordinates. |
39 gfx::Point GetWidgetScreenPosition(GtkWidget* widget); | 39 gfx::Point GetWidgetScreenPosition(GtkWidget* widget); |
40 | 40 |
41 // Returns the bounds of the specified widget in screen coordinates. | 41 // Returns the bounds of the specified widget in screen coordinates. |
42 gfx::Rect GetWidgetScreenBounds(GtkWidget* widget); | 42 gfx::Rect GetWidgetScreenBounds(GtkWidget* widget); |
43 | 43 |
44 // Initialize some GTK settings so that our dialogs are consistent. | 44 // Initialize some GTK settings so that our dialogs are consistent. |
45 void InitRCStyles(); | 45 void InitRCStyles(); |
46 | 46 |
| 47 // Stick the widget in the given hbox without expanding vertically. The widget |
| 48 // is packed at the start of the hbox. This is useful for widgets that would |
| 49 // otherwise expand to fill the vertical space of the hbox (e.g. buttons). |
| 50 void CenterWidgetInHBox(GtkWidget* hbox, GtkWidget* widget, bool pack_at_end, |
| 51 int padding); |
| 52 |
47 } // namespace gtk_util | 53 } // namespace gtk_util |
48 | 54 |
49 #endif // CHROME_COMMON_GTK_UTIL_H_ | 55 #endif // CHROME_COMMON_GTK_UTIL_H_ |
OLD | NEW |