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 #include <vector> |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 // NOTE: Make sure to realize |widget| before using this method, or a | 75 // NOTE: Make sure to realize |widget| before using this method, or a |
76 // default font size will be used instead of the actual font size. | 76 // default font size will be used instead of the actual font size. |
77 void GetWidgetSizeFromResources(GtkWidget* widget, int width_chars, | 77 void GetWidgetSizeFromResources(GtkWidget* widget, int width_chars, |
78 int height_lines, int* width, int* height); | 78 int height_lines, int* width, int* height); |
79 | 79 |
80 // As above, but uses number of characters/lines directly rather than looking | 80 // As above, but uses number of characters/lines directly rather than looking |
81 // up a resource. | 81 // up a resource. |
82 void GetWidgetSizeFromCharacters(GtkWidget* widget, double width_chars, | 82 void GetWidgetSizeFromCharacters(GtkWidget* widget, double width_chars, |
83 double height_lines, int* width, int* height); | 83 double height_lines, int* width, int* height); |
84 | 84 |
85 // As above, but a convenience method for configuring dialog width. | 85 // As above, but a convenience method for configuring dialog size. |
| 86 // |width_id| and |height_id| are resource IDs for the size. If either of these |
| 87 // are set to -1, the respective size will be set to the widget default. |
86 // |resizable| also controls whether the dialog will be resizable | 88 // |resizable| also controls whether the dialog will be resizable |
87 // (this info is also necessary for getting the width-setting code | 89 // (this info is also necessary for getting the width-setting code |
88 // right). | 90 // right). |
89 void SetWindowWidthFromResources(GtkWindow* window, int resource_id, | 91 void SetWindowSizeFromResources(GtkWindow* window, |
90 bool resizable); | 92 int width_id, int height_id, bool resizable); |
91 | 93 |
92 // Remove all children from this container. | 94 // Remove all children from this container. |
93 void RemoveAllChildren(GtkWidget* container); | 95 void RemoveAllChildren(GtkWidget* container); |
94 | 96 |
95 // Force the font size of the widget to |size_pixels| and the font to "Sans" if | 97 // Force the font size of the widget to |size_pixels| and the font to "Sans" if |
96 // we can't get |size_pixels| with the current font. We have to do this because | 98 // we can't get |size_pixels| with the current font. We have to do this because |
97 // GTK gets seriously confused as GTK's text layout system doesn't like our | 99 // GTK gets seriously confused as GTK's text layout system doesn't like our |
98 // constant gtk_widget_set_size_requests() calls. | 100 // constant gtk_widget_set_size_requests() calls. |
99 // | 101 // |
100 // This function should not be used for new code. | 102 // This function should not be used for new code. |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 // at the default width. | 240 // at the default width. |
239 // This is called a hack because the gtk docs state that it is logically | 241 // This is called a hack because the gtk docs state that it is logically |
240 // inconsistent for a widget to make its size request depend on its allocation. | 242 // inconsistent for a widget to make its size request depend on its allocation. |
241 // It does, however, have the intended effect of wrapping the label at the | 243 // It does, however, have the intended effect of wrapping the label at the |
242 // proper width. | 244 // proper width. |
243 void WrapLabelAtAllocationHack(GtkWidget* label); | 245 void WrapLabelAtAllocationHack(GtkWidget* label); |
244 | 246 |
245 } // namespace gtk_util | 247 } // namespace gtk_util |
246 | 248 |
247 #endif // CHROME_COMMON_GTK_UTIL_H_ | 249 #endif // CHROME_COMMON_GTK_UTIL_H_ |
OLD | NEW |