1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 
7 #ifndef WidgetStyleCache_h
8 #define WidgetStyleCache_h
9 
10 #include <gtk/gtk.h>
11 #include "gtkdrawing.h"
12 
13 GtkWidget* GetWidget(WidgetNodeType aNodeType);
14 
15 cairo_surface_t* GetWidgetIconSurface(GtkWidget* aWidgetIcon, int aScale);
16 
17 /*
18  * Return a new style context based on aWidget, as a child of aParentStyle.
19  * If aWidget still has a floating reference, then it is sunk and released.
20  */
21 GtkStyleContext* CreateStyleForWidget(GtkWidget* aWidget,
22                                       GtkStyleContext* aParentStyle);
23 
24 GtkStyleContext* CreateCSSNode(const char* aName, GtkStyleContext* aParentStyle,
25                                GType aType = G_TYPE_NONE);
26 
27 /*
28  * Returns a pointer to a style context for the specified node and state.
29  * aStateFlags is applied only to last widget in css style path,
30  * for instance GetStyleContext(MOZ_GTK_BUTTON, .., GTK_STATE_FLAG_HOVER)
31  * you get "window button:hover" css selector.
32  * If you want aStateFlags applied to all path elements use
33  * CreateStyleContextWithStates().
34  *
35  * The context is owned by WidgetStyleCache. Do not unref.
36  */
37 GtkStyleContext* GetStyleContext(
38     WidgetNodeType aNodeType, int aScale = 1,
39     GtkTextDirection aDirection = GTK_TEXT_DIR_NONE,
40     GtkStateFlags aStateFlags = GTK_STATE_FLAG_NORMAL);
41 
42 /*
43  * Returns a pointer to a style context for the specified node
44  * and state applied to all elements at widget style path.
45  *
46  * The context is owned by caller and must be released by g_object_unref().
47  */
48 GtkStyleContext* CreateStyleContextWithStates(
49     WidgetNodeType aNodeType, int aScale = 1,
50     GtkTextDirection aDirection = GTK_TEXT_DIR_NONE,
51     GtkStateFlags aStateFlags = GTK_STATE_FLAG_NORMAL);
52 
53 void ResetWidgetCache(void);
54 
55 bool IsSolidCSDStyleUsed();
56 
57 void StyleContextSetScale(GtkStyleContext* style, gint aScaleFactor);
58 
59 #endif  // WidgetStyleCache_h
60