OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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_BROWSER_UI_GTK_GTK_UTIL_H_ | 5 #ifndef CHROME_BROWSER_UI_GTK_GTK_UTIL_H_ |
6 #define CHROME_BROWSER_UI_GTK_GTK_UTIL_H_ | 6 #define CHROME_BROWSER_UI_GTK_GTK_UTIL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/string16.h" | 13 #include "base/string16.h" |
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragOperation.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragOperation.h" |
15 #include "ui/base/x/x11_util.h" | 15 #include "ui/base/x/x11_util.h" |
16 #include "ui/gfx/point.h" | 16 #include "ui/gfx/point.h" |
17 #include "ui/gfx/rect.h" | 17 #include "ui/gfx/rect.h" |
18 #include "webkit/glue/window_open_disposition.h" | 18 #include "webkit/glue/window_open_disposition.h" |
19 | 19 |
20 typedef struct _cairo cairo_t; | 20 typedef struct _cairo cairo_t; |
21 typedef struct _GdkColor GdkColor; | 21 typedef struct _GdkColor GdkColor; |
22 typedef struct _GtkWidget GtkWidget; | 22 typedef struct _GtkWidget GtkWidget; |
23 | 23 |
24 class BrowserWindow; | 24 class BrowserWindow; |
25 class GtkThemeService; | 25 class GtkThemeService; |
26 class GURL; | 26 class GURL; |
27 class Profile; | 27 class Profile; |
28 struct RendererPreferences; // from common/renderer_preferences.h | 28 struct RendererPreferences; // from common/renderer_preferences.h |
29 | 29 |
30 const int kSkiaToGDKMultiplier = 257; | |
31 | |
32 // Define a macro for creating GdkColors from RGB values. This is a macro to | |
33 // allow static construction of literals, etc. Use this like: | |
34 // GdkColor white = GDK_COLOR_RGB(0xff, 0xff, 0xff); | |
35 #define GDK_COLOR_RGB(r, g, b) {0, r * kSkiaToGDKMultiplier, \ | |
36 g * kSkiaToGDKMultiplier, b * kSkiaToGDKMultiplier} | |
37 | |
38 namespace event_utils { | 30 namespace event_utils { |
39 | 31 |
40 // Translates event flags into what kind of disposition they represent. | 32 // Translates event flags into what kind of disposition they represent. |
41 // For example, a middle click would mean to open a background tab. | 33 // For example, a middle click would mean to open a background tab. |
42 // event_flags are the state in the GdkEvent structure. | 34 // event_flags are the state in the GdkEvent structure. |
43 WindowOpenDisposition DispositionFromEventFlags(guint state); | 35 WindowOpenDisposition DispositionFromEventFlags(guint state); |
44 | 36 |
45 } // namespace event_utils | 37 } // namespace event_utils |
46 | 38 |
47 namespace gtk_util { | 39 namespace gtk_util { |
48 | 40 |
49 extern const GdkColor kGdkWhite; | |
50 extern const GdkColor kGdkGray; | |
51 extern const GdkColor kGdkBlack; | |
52 extern const GdkColor kGdkGreen; | |
53 | |
54 // Constants relating to the layout of dialog windows: | |
55 // (See http://library.gnome.org/devel/hig-book/stable/design-window.html.en) | |
56 | |
57 // Spacing between controls of the same group. | |
58 const int kControlSpacing = 6; | |
59 | |
60 // Horizontal spacing between a label and its control. | |
61 const int kLabelSpacing = 12; | |
62 | |
63 // Indent of the controls within each group. | |
64 const int kGroupIndent = 12; | |
65 | |
66 // Space around the outside of a dialog's contents. | |
67 const int kContentAreaBorder = 12; | |
68 | |
69 // Spacing between groups of controls. | |
70 const int kContentAreaSpacing = 18; | |
71 | |
72 // Horizontal Spacing between controls in a form. | |
73 const int kFormControlSpacing = 10; | |
74 | |
75 // Create a table of labeled controls, using proper spacing and alignment. | 41 // Create a table of labeled controls, using proper spacing and alignment. |
76 // Arguments should be pairs of const char*, GtkWidget*, concluding with a | 42 // Arguments should be pairs of const char*, GtkWidget*, concluding with a |
77 // NULL. The first argument is a vector in which to place all labels | 43 // NULL. The first argument is a vector in which to place all labels |
78 // produced. It can be NULL if you don't need to keep track of the label | 44 // produced. It can be NULL if you don't need to keep track of the label |
79 // widgets. The second argument is a color to force the label text to. It can | 45 // widgets. The second argument is a color to force the label text to. It can |
80 // be NULL to get the system default. | 46 // be NULL to get the system default. |
81 // | 47 // |
82 // For example: | 48 // For example: |
83 // controls = CreateLabeledControlsGroup(NULL, | 49 // controls = CreateLabeledControlsGroup(NULL, |
84 // "Name:", title_entry_, | 50 // "Name:", title_entry_, |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 void ApplyMessageDialogQuirks(GtkWidget* dialog); | 337 void ApplyMessageDialogQuirks(GtkWidget* dialog); |
372 | 338 |
373 // Performs Cut/Copy/Paste operation on the |window|. | 339 // Performs Cut/Copy/Paste operation on the |window|. |
374 void DoCut(BrowserWindow* window); | 340 void DoCut(BrowserWindow* window); |
375 void DoCopy(BrowserWindow* window); | 341 void DoCopy(BrowserWindow* window); |
376 void DoPaste(BrowserWindow* window); | 342 void DoPaste(BrowserWindow* window); |
377 | 343 |
378 } // namespace gtk_util | 344 } // namespace gtk_util |
379 | 345 |
380 #endif // CHROME_BROWSER_UI_GTK_GTK_UTIL_H_ | 346 #endif // CHROME_BROWSER_UI_GTK_GTK_UTIL_H_ |
OLD | NEW |