1
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2
#ifndef __ST_THEME_NODE_H__
3
#define __ST_THEME_NODE_H__
5
#include <clutter/clutter.h>
6
#include "st-border-image.h"
12
* @short_description: style information for one node in a tree of themed objects
14
* A #StThemeNode represents the CSS style information (the set of CSS properties) for one
15
* node in a tree of themed objects. In typical usage, it represents the style information
16
* for a single #ClutterActor. A #StThemeNode is immutable: attributes such as the
17
* CSS classes for the node are passed in at construction. If the attributes of the node
18
* or any parent node change, the node should be discarded and a new node created.
19
* #StThemeNode has generic accessors to look up properties by name and specific
20
* accessors for standard CSS properties that add caching and handling of various
21
* details of the CSS specification. #StThemeNode also has convenience functions to help
22
* in implementing a #ClutterActor with borders and padding.
25
typedef struct _StTheme StTheme;
26
typedef struct _StThemeContext StThemeContext;
28
typedef struct _StThemeNode StThemeNode;
29
typedef struct _StThemeNodeClass StThemeNodeClass;
31
#define ST_TYPE_THEME_NODE (st_theme_node_get_type ())
32
#define ST_THEME_NODE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), ST_TYPE_THEME_NODE, StThemeNode))
33
#define ST_THEME_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ST_TYPE_THEME_NODE, StThemeNodeClass))
34
#define ST_IS_THEME_NODE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), ST_TYPE_THEME_NODE))
35
#define ST_IS_THEME_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ST_TYPE_THEME_NODE))
36
#define ST_THEME_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ST_TYPE_THEME_NODE, StThemeNodeClass))
48
ST_CORNER_BOTTOMRIGHT,
52
/* These are the CSS values; that doesn't mean we have to implement blink... */
54
ST_TEXT_DECORATION_UNDERLINE = 1 << 0,
55
ST_TEXT_DECORATION_OVERLINE = 1 << 1,
56
ST_TEXT_DECORATION_LINE_THROUGH = 1 << 2,
57
ST_TEXT_DECORATION_BLINK = 1 << 3
60
GType st_theme_node_get_type (void) G_GNUC_CONST;
62
StThemeNode *st_theme_node_new (StThemeContext *context,
63
StThemeNode *parent_node, /* can be null */
64
StTheme *theme, /* can be null */
66
const char *element_id,
67
const char *element_class,
68
const char *pseudo_class,
69
const char *inline_style);
71
StThemeNode *st_theme_node_get_parent (StThemeNode *node);
73
StTheme *st_theme_node_get_theme (StThemeNode *node);
75
GType st_theme_node_get_element_type (StThemeNode *node);
76
const char *st_theme_node_get_element_id (StThemeNode *node);
77
const char *st_theme_node_get_element_class (StThemeNode *node);
78
const char *st_theme_node_get_pseudo_class (StThemeNode *node);
80
/* Generic getters ... these are not cached so are less efficient. The other
81
* reason for adding the more specific version is that we can handle the
82
* details of the actual CSS rules, which can be complicated, especially
85
gboolean st_theme_node_get_color (StThemeNode *node,
86
const char *property_name,
90
gboolean st_theme_node_get_double (StThemeNode *node,
91
const char *property_name,
95
gboolean st_theme_node_get_length (StThemeNode *node,
96
const char *property_name,
100
/* Specific getters for particular properties: cached
102
void st_theme_node_get_background_color (StThemeNode *node,
103
ClutterColor *color);
104
void st_theme_node_get_foreground_color (StThemeNode *node,
105
ClutterColor *color);
107
const char *st_theme_node_get_background_image (StThemeNode *node);
109
double st_theme_node_get_border_width (StThemeNode *node,
111
double st_theme_node_get_border_radius (StThemeNode *node,
113
void st_theme_node_get_border_color (StThemeNode *node,
115
ClutterColor *color);
117
double st_theme_node_get_padding (StThemeNode *node,
120
StTextDecoration st_theme_node_get_text_decoration (StThemeNode *node);
122
/* Font rule processing is pretty complicated, so we just hardcode it
123
* under the standard font/font-family/font-size/etc names. This means
124
* you can't have multiple separate styled fonts for a single item,
125
* but that should be OK.
127
const PangoFontDescription *st_theme_node_get_font (StThemeNode *node);
129
StBorderImage *st_theme_node_get_border_image (StThemeNode *node);
131
/* Helpers for get_preferred_width()/get_preferred_height() ClutterActor vfuncs */
132
void st_theme_node_adjust_for_height (StThemeNode *node,
134
void st_theme_node_adjust_preferred_width (StThemeNode *node,
136
float *natural_width_p);
137
void st_theme_node_adjust_for_width (StThemeNode *node,
139
void st_theme_node_adjust_preferred_height (StThemeNode *node,
141
float *natural_height_p);
143
/* Helper for allocate() ClutterActor vfunc */
144
void st_theme_node_get_content_box (StThemeNode *node,
145
const ClutterActorBox *actor_box,
146
ClutterActorBox *content_box);
148
gboolean st_theme_node_geometry_equal (StThemeNode *node,
153
#endif /* __ST_THEME_NODE_H__ */