| 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 #include <string> | 9 #include <string> |
| 10 #include <vector> |
| 10 | 11 |
| 11 #include "base/gfx/point.h" | 12 #include "base/gfx/point.h" |
| 12 #include "base/gfx/rect.h" | 13 #include "base/gfx/rect.h" |
| 13 #include "chrome/common/x11_util.h" | 14 #include "chrome/common/x11_util.h" |
| 14 #include "webkit/glue/window_open_disposition.h" | 15 #include "webkit/glue/window_open_disposition.h" |
| 15 | 16 |
| 16 typedef struct _GtkWidget GtkWidget; | 17 typedef struct _GtkWidget GtkWidget; |
| 17 | 18 |
| 18 namespace event_utils { | 19 namespace event_utils { |
| 19 | 20 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 43 // Indent of the controls within each group. | 44 // Indent of the controls within each group. |
| 44 const int kGroupIndent = 12; | 45 const int kGroupIndent = 12; |
| 45 | 46 |
| 46 // Space around the outsides of a dialog's contents. | 47 // Space around the outsides of a dialog's contents. |
| 47 const int kContentAreaBorder = 12; | 48 const int kContentAreaBorder = 12; |
| 48 | 49 |
| 49 // Spacing between groups of controls. | 50 // Spacing between groups of controls. |
| 50 const int kContentAreaSpacing = 18; | 51 const int kContentAreaSpacing = 18; |
| 51 | 52 |
| 52 // Create a table of labeled controls, using proper spacing and alignment. | 53 // Create a table of labeled controls, using proper spacing and alignment. |
| 53 // Arguments should be pairs of const char*, GtkWidget*, concluding with a NULL. | 54 // Arguments should be pairs of const char*, GtkWidget*, concluding with a |
| 54 // The first argument is a color to force the label text to. It can be NULL to | 55 // NULL. The first argument is a vector in which to place all labels |
| 55 // get the system default. | 56 // produced. It can be NULL if you don't need to keep track of the label |
| 57 // widgets. The second argument is a color to force the label text to. It can |
| 58 // be NULL to get the system default. |
| 59 // |
| 56 // For example: | 60 // For example: |
| 57 // controls = CreateLabeledControlsGroup(&gfx::kGdkBlack, | 61 // controls = CreateLabeledControlsGroup(NULL, &gfx::kGdkBlack, |
| 58 // "Name:", title_entry_, | 62 // "Name:", title_entry_, |
| 59 // "Folder:", folder_combobox_, | 63 // "Folder:", folder_combobox_, |
| 60 // NULL); | 64 // NULL); |
| 61 GtkWidget* CreateLabeledControlsGroup(const GdkColor* color, | 65 GtkWidget* CreateLabeledControlsGroup( |
| 62 const char* text, ...); | 66 std::vector<GtkWidget*>* labels, |
| 67 const char* text, ...); |
| 63 | 68 |
| 64 // Create a GtkBin with |child| as its child widget. This bin will paint a | 69 // Create a GtkBin with |child| as its child widget. This bin will paint a |
| 65 // border of color |color| with the sizes specified in pixels. | 70 // border of color |color| with the sizes specified in pixels. |
| 66 GtkWidget* CreateGtkBorderBin(GtkWidget* child, const GdkColor* color, | 71 GtkWidget* CreateGtkBorderBin(GtkWidget* child, const GdkColor* color, |
| 67 int top, int bottom, int left, int right); | 72 int top, int bottom, int left, int right); |
| 68 | 73 |
| 69 // Calculates the size of given widget based on the size specified in | 74 // Calculates the size of given widget based on the size specified in |
| 70 // number of characters/lines (in locale specific resource file) and | 75 // number of characters/lines (in locale specific resource file) and |
| 71 // font metrics. | 76 // font metrics. |
| 72 bool GetWidgetSizeFromResources(GtkWidget* widget, int width_chars, | 77 bool GetWidgetSizeFromResources(GtkWidget* widget, int width_chars, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 // Returns true if the pointer is currently inside the widget. | 129 // Returns true if the pointer is currently inside the widget. |
| 125 bool WidgetContainsCursor(GtkWidget* widget); | 130 bool WidgetContainsCursor(GtkWidget* widget); |
| 126 | 131 |
| 127 // Sets the icon of |window| to the product icon (potentially used in window | 132 // Sets the icon of |window| to the product icon (potentially used in window |
| 128 // border or alt-tab list). | 133 // border or alt-tab list). |
| 129 void SetWindowIcon(GtkWindow* window); | 134 void SetWindowIcon(GtkWindow* window); |
| 130 | 135 |
| 131 } // namespace gtk_util | 136 } // namespace gtk_util |
| 132 | 137 |
| 133 #endif // CHROME_COMMON_GTK_UTIL_H_ | 138 #endif // CHROME_COMMON_GTK_UTIL_H_ |
| OLD | NEW |