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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_UI_GTK_ROUNDED_WINDOW_H_ 6 #define CHROME_BROWSER_UI_GTK_ROUNDED_WINDOW_H_ 7 8 #include <gtk/gtk.h> 9 10 namespace gtk_util { 11 12 // Symbolic names for arguments to |rounded_edges| in ActAsRoundedWindow(). 13 enum RoundedBorders { 14 ROUNDED_NONE = 0, 15 ROUNDED_BOTTOM_LEFT = 1 << 0, 16 ROUNDED_TOP_LEFT = 1 << 1, 17 ROUNDED_TOP_RIGHT = 1 << 2, 18 ROUNDED_TOP = (1 << 1) | (1 << 2), 19 ROUNDED_BOTTOM_RIGHT = 1 << 3, 20 ROUNDED_ALL = 0xF 21 }; 22 23 // Symbolic names for arguments to |drawn_borders| in ActAsRoundedWindow(). 24 enum BorderEdge { 25 BORDER_NONE = 0, 26 BORDER_LEFT = 1 << 0, 27 BORDER_TOP = 1 << 1, 28 BORDER_RIGHT = 1 << 2, 29 BORDER_BOTTOM = 1 << 3, 30 BORDER_ALL = 0xF 31 }; 32 33 // Sets up the passed in widget that has its own GdkWindow with an expose 34 // handler that forces the window shape into roundness. Caller should not set 35 // an "expose-event" handler on |widget|; if caller needs to do custom 36 // rendering, use SetRoundedWindowExposeFunction() instead. |rounded_edges| 37 // control which corners are rounded. |drawn_borders| border control which 38 // sides have a visible border drawn in |color|. 39 void ActAsRoundedWindow( 40 GtkWidget* widget, const GdkColor& color, int corner_size, 41 int rounded_edges, int drawn_borders); 42 43 // Undoes most of the actions of ActAsRoundedWindow(). 44 void StopActingAsRoundedWindow(GtkWidget* widget); 45 46 // Returns true if the window is rounded. 47 bool IsActingAsRoundedWindow(GtkWidget* widget); 48 49 // Sets edge and border properties on a widget that has already been configured 50 // with ActAsRoundedWindow(). 51 void SetRoundedWindowEdgesAndBorders(GtkWidget* widget, 52 int corner_size, 53 int rounded_edges, 54 int drawn_borders); 55 56 // Sets the color of the border on a widget that has already been configured 57 // with ActAsRoundedWindow(). 58 void SetRoundedWindowBorderColor(GtkWidget* widget, GdkColor color); 59 60 61 } // namespace gtk_util 62 63 #endif // CHROME_BROWSER_UI_GTK_ROUNDED_WINDOW_H_ 64