| 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 |
| 30 namespace event_utils { | 38 namespace event_utils { |
| 31 | 39 |
| 32 // Translates event flags into what kind of disposition they represent. | 40 // Translates event flags into what kind of disposition they represent. |
| 33 // For example, a middle click would mean to open a background tab. | 41 // For example, a middle click would mean to open a background tab. |
| 34 // event_flags are the state in the GdkEvent structure. | 42 // event_flags are the state in the GdkEvent structure. |
| 35 WindowOpenDisposition DispositionFromEventFlags(guint state); | 43 WindowOpenDisposition DispositionFromEventFlags(guint state); |
| 36 | 44 |
| 37 } // namespace event_utils | 45 } // namespace event_utils |
| 38 | 46 |
| 39 namespace gtk_util { | 47 namespace gtk_util { |
| 40 | 48 |
| 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 |
| 41 // Create a table of labeled controls, using proper spacing and alignment. | 75 // Create a table of labeled controls, using proper spacing and alignment. |
| 42 // Arguments should be pairs of const char*, GtkWidget*, concluding with a | 76 // Arguments should be pairs of const char*, GtkWidget*, concluding with a |
| 43 // NULL. The first argument is a vector in which to place all labels | 77 // NULL. The first argument is a vector in which to place all labels |
| 44 // produced. It can be NULL if you don't need to keep track of the label | 78 // produced. It can be NULL if you don't need to keep track of the label |
| 45 // widgets. The second argument is a color to force the label text to. It can | 79 // widgets. The second argument is a color to force the label text to. It can |
| 46 // be NULL to get the system default. | 80 // be NULL to get the system default. |
| 47 // | 81 // |
| 48 // For example: | 82 // For example: |
| 49 // controls = CreateLabeledControlsGroup(NULL, | 83 // controls = CreateLabeledControlsGroup(NULL, |
| 50 // "Name:", title_entry_, | 84 // "Name:", title_entry_, |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 void ApplyMessageDialogQuirks(GtkWidget* dialog); | 371 void ApplyMessageDialogQuirks(GtkWidget* dialog); |
| 338 | 372 |
| 339 // Performs Cut/Copy/Paste operation on the |window|. | 373 // Performs Cut/Copy/Paste operation on the |window|. |
| 340 void DoCut(BrowserWindow* window); | 374 void DoCut(BrowserWindow* window); |
| 341 void DoCopy(BrowserWindow* window); | 375 void DoCopy(BrowserWindow* window); |
| 342 void DoPaste(BrowserWindow* window); | 376 void DoPaste(BrowserWindow* window); |
| 343 | 377 |
| 344 } // namespace gtk_util | 378 } // namespace gtk_util |
| 345 | 379 |
| 346 #endif // CHROME_BROWSER_UI_GTK_GTK_UTIL_H_ | 380 #endif // CHROME_BROWSER_UI_GTK_GTK_UTIL_H_ |
| OLD | NEW |