Libcroco
cr-style.h
Go to the documentation of this file.
1 /* -*- Mode: C; indent-tabs-mode:nil; c-basic-offset: 8-*- */
2 
3 /*
4  * This file is part of The Croco Library
5  *
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of version 2.1 of the GNU Lesser General Public
9  * License as published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * Author: Dodji Seketeli.
22  * See COPYRIGHTS file for copyright information.
23  */
24 
25 #ifndef __CR_STYLE_H__
26 #define __CR_STYLE_H__
27 
28 #include "cr-utils.h"
29 #include "cr-statement.h"
30 #include "cr-fonts.h"
31 
32 /**
33  *@file
34  *The declaration of the #CRStyle class.
35  */
36 G_BEGIN_DECLS
37 
38 typedef struct _CRStyle CRStyle ;
39 
41 {
53 } ;
54 
56 {
75 } ;
76 
78 {
84 } ;
85 
87 {
92 } ;
93 
95 {
100 } ;
101 
102 
103 #define BORDER_THIN 2
104 #define BORDER_MEDIUM 4
105 #define BORDER_THICK 6
106 
107 
108 /**
109  *A numerical css property value.
110  *This data type is actually split in 3 parts:
111  *1/the specified value
112  *2/the computed value
113  *3/the actual value.
114  *To understand the semantic of these three parts,
115  *see css2 spec chap 6.1 ("Specified, computed and actual values.").
116  */
117 typedef struct _CRNumPropVal CRNumPropVal ;
119 {
120  /**specified value*/
122  /**computed value*/
124  /**actual value*/
126 } ;
127 
128 /**
129  *An rgb css property value.
130  *This data type is actually split in 3 parts:
131  *1/the specified value
132  *2/the computed value
133  *3/the actual value.
134  *To understand the semantic of these three parts,
135  *see css2 spec chap 6.1 ("Specified, computed and actual values.").
136  */
137 typedef struct _CRRgbPropVal CRRgbPropVal ;
139 {
140  /**specified value*/
142  /**computed value*/
144  /**actual value*/
146 } ;
147 
148 
150 {
155 
160 
165 
170 
172 
173  /*must be last*/
175 } ;
176 
178 {
185 
186  /*must be last*/
188 } ;
189 
190 
192 {
197 
198  /*must be last*/
200 } ;
201 
203 {
208 
209  /*must be last*/
211 } ;
212 
213 typedef struct _CRFontSizeVal CRFontSizeVal ;
215  /*specified value*/
217  /*computed value*/
219  /*actual value*/
221 } ;
222 
223 /**
224  *The css2 style class.
225  *Contains computed and actual values
226  *inferred from the declarations found
227  *in the stylesheets.
228  *See css2 spec chapter 6.
229  */
230 struct _CRStyle
231 {
232  /**
233  *numerical properties.
234  *the properties are indexed by
235  *enum #CRNumProp.
236  */
238 
239  /**
240  *color properties.
241  *They are indexed by enum #CRRgbProp .
242  */
244 
245  /**
246  *border style properties.
247  *They are indexed by enum #CRBorderStyleProp .
248  */
250 
251  /**box display type*/
252  enum CRDisplayType display ;
253 
254  /**the positioning scheme*/
255  enum CRPositionType position ;
256 
257  /**the float property*/
258  enum CRFloatType float_type ;
259 
260  /*
261  *the 'font-family' property.
262  */
264 
265  /**
266  *the 'font-size' property.
267  */
270  enum CRFontStyle font_style ;
274 
275  /**
276  * the 'tex' properties
277  */
279 
282  gulong ref_count ;
283 } ;
284 
286  GString * a_str, guint a_nb_indent) ;
287 
289  GString *a_str,
290  guint a_nb_indent) ;
291 
293  GString *a_str,
294  guint a_nb_indent) ;
295 
297  GString *a_str,
298  guint a_nb_indent) ;
299 
301  GString *a_str,
302  guint a_nb_indent) ;
303 
305  GString *a_str,
306  guint a_nb_indent) ;
307 
309  GString *a_str,
310  guint a_nb_indent) ;
311 
312 CRStyle * cr_style_new (gboolean a_set_props_to_initial_values) ;
313 
318 
320  CRDeclaration *a_decl) ;
321 
322 
323 enum CRStatus cr_style_copy (CRStyle *a_dest, CRStyle *a_src) ;
324 
325 enum CRStatus cr_style_ref (CRStyle *a_this) ;
326 
327 gboolean cr_style_unref (CRStyle *a_this) ;
328 
329 void cr_style_destroy (CRStyle *a_this) ;
330 
331 CRStyle * cr_style_dup (CRStyle *a_this) ;
332 
333 enum CRStatus cr_style_to_string (CRStyle *a_this,
334  GString **a_str,
335  guint a_nb_indent) ;
336 
337 G_END_DECLS
338 
339 #endif /*__CR_STYLE_H__*/
Various type declarations about font selection related properties.
CRFontVariant
Definition: cr-fonts.h:186
CRFontStretch
Definition: cr-fonts.h:212
CRFontStyle
Definition: cr-fonts.h:178
CRFontWeight
Definition: cr-fonts.h:193
typedefG_BEGIN_DECLS struct _CRRgb CRRgb
Definition: cr-rgb.h:34
Declaration of the CRStatement class.
enum CRStatus cr_style_set_style_from_decl(CRStyle *a_this, CRDeclaration *a_decl)
Walks through a css2 property declaration, and populated the according field(s) in the CRStyle struct...
Definition: cr-style.c:2012
CRStyle * cr_style_new(gboolean a_set_props_to_initial_values)
Default constructor of CRStyle.
Definition: cr-style.c:1712
enum CRStatus cr_style_propagate_from_parent(CRStyle *a_this)
typedefG_BEGIN_DECLS struct _CRStyle CRStyle
Definition: cr-style.h:38
CRBorderStyleProp
Definition: cr-style.h:192
@ BORDER_STYLE_PROP_LEFT
Definition: cr-style.h:196
@ BORDER_STYLE_PROP_TOP
Definition: cr-style.h:193
@ BORDER_STYLE_PROP_BOTTOM
Definition: cr-style.h:195
@ BORDER_STYLE_PROP_RIGHT
Definition: cr-style.h:194
@ NB_BORDER_STYLE_PROPS
Definition: cr-style.h:199
enum CRStatus cr_style_set_props_to_initial_values(CRStyle *a_this)
Sets the style properties to their initial value according to the css2 spec.
Definition: cr-style.c:1845
CRFloatType
Definition: cr-style.h:87
@ FLOAT_NONE
Definition: cr-style.h:88
@ FLOAT_LEFT
Definition: cr-style.h:89
@ FLOAT_INHERIT
Definition: cr-style.h:91
@ FLOAT_RIGHT
Definition: cr-style.h:90
void cr_style_destroy(CRStyle *a_this)
Destructor of the CRStyle class.
Definition: cr-style.c:2845
CRNumProp
Definition: cr-style.h:150
@ NUM_PROP_LEFT
Definition: cr-style.h:154
@ NUM_PROP_MARGIN_BOTTOM
Definition: cr-style.h:168
@ NUM_PROP_WIDTH
Definition: cr-style.h:171
@ NUM_PROP_BOTTOM
Definition: cr-style.h:153
@ NUM_PROP_BORDER_RIGHT
Definition: cr-style.h:162
@ NUM_PROP_MARGIN_RIGHT
Definition: cr-style.h:167
@ NUM_PROP_BORDER_TOP
Definition: cr-style.h:161
@ NUM_PROP_PADDING_RIGHT
Definition: cr-style.h:157
@ NB_NUM_PROPS
Definition: cr-style.h:174
@ NUM_PROP_MARGIN_LEFT
Definition: cr-style.h:169
@ NUM_PROP_RIGHT
Definition: cr-style.h:152
@ NUM_PROP_PADDING_LEFT
Definition: cr-style.h:159
@ NUM_PROP_MARGIN_TOP
Definition: cr-style.h:166
@ NUM_PROP_TOP
Definition: cr-style.h:151
@ NUM_PROP_BORDER_BOTTOM
Definition: cr-style.h:163
@ NUM_PROP_PADDING_BOTTOM
Definition: cr-style.h:158
@ NUM_PROP_PADDING_TOP
Definition: cr-style.h:156
@ NUM_PROP_BORDER_LEFT
Definition: cr-style.h:164
enum CRStatus cr_style_ref(CRStyle *a_this)
Increases the reference count of the current instance of CRStyle.
Definition: cr-style.c:2246
enum CRStatus cr_style_display_type_to_string(enum CRDisplayType a_code, GString *a_str, guint a_nb_indent)
Definition: cr-style.c:2484
CRRgbProp
Definition: cr-style.h:178
@ RGB_PROP_BACKGROUND_COLOR
Definition: cr-style.h:184
@ RGB_PROP_BORDER_BOTTOM_COLOR
Definition: cr-style.h:181
@ NB_RGB_PROPS
Definition: cr-style.h:187
@ RGB_PROP_BORDER_LEFT_COLOR
Definition: cr-style.h:182
@ RGB_PROP_BORDER_TOP_COLOR
Definition: cr-style.h:179
@ RGB_PROP_COLOR
Definition: cr-style.h:183
@ RGB_PROP_BORDER_RIGHT_COLOR
Definition: cr-style.h:180
enum CRStatus cr_style_resolve_inherited_properties(CRStyle *a_this)
Resolves the inherited properties.
Definition: cr-style.c:1937
CRWhiteSpaceType
Definition: cr-style.h:95
@ WHITE_SPACE_NOWRAP
Definition: cr-style.h:98
@ WHITE_SPACE_INHERIT
Definition: cr-style.h:99
@ WHITE_SPACE_NORMAL
Definition: cr-style.h:96
@ WHITE_SPACE_PRE
Definition: cr-style.h:97
enum CRStatus cr_style_to_string(CRStyle *a_this, GString **a_str, guint a_nb_indent)
Serializes in instance of CRStyle into a string.
Definition: cr-style.c:2659
enum CRStatus cr_style_border_style_to_string(enum CRBorderStyle a_prop, GString *a_str, guint a_nb_indent)
Definition: cr-style.c:2436
enum CRStatus cr_style_float_type_to_string(enum CRFloatType a_code, GString *a_str, guint a_nb_indent)
Definition: cr-style.c:2589
enum CRStatus cr_style_copy(CRStyle *a_dest, CRStyle *a_src)
Copies a style data structure into another.
Definition: cr-style.c:2312
CRStyle * cr_style_dup(CRStyle *a_this)
Duplicates the current instance of CRStyle .
Definition: cr-style.c:2287
CRBorderStyle
Definition: cr-style.h:41
@ BORDER_STYLE_DOTTED
Definition: cr-style.h:44
@ BORDER_STYLE_INHERIT
Definition: cr-style.h:52
@ BORDER_STYLE_DOUBLE
Definition: cr-style.h:47
@ BORDER_STYLE_NONE
Definition: cr-style.h:42
@ BORDER_STYLE_OUTSET
Definition: cr-style.h:51
@ BORDER_STYLE_DASHED
Definition: cr-style.h:45
@ BORDER_STYLE_GROOVE
Definition: cr-style.h:48
@ BORDER_STYLE_HIDDEN
Definition: cr-style.h:43
@ BORDER_STYLE_SOLID
Definition: cr-style.h:46
@ BORDER_STYLE_INSET
Definition: cr-style.h:50
@ BORDER_STYLE_RIDGE
Definition: cr-style.h:49
CRBoxOffsetProp
Definition: cr-style.h:203
@ BOX_OFFSET_PROP_TOP
Definition: cr-style.h:204
@ BOX_OFFSET_PROP_BOTTOM
Definition: cr-style.h:206
@ BOX_OFFSET_PROP_RIGHT
Definition: cr-style.h:205
@ BOX_OFFSET_PROP_LEFT
Definition: cr-style.h:207
@ NB_BOX_OFFSET_PROPS
Definition: cr-style.h:210
CRPositionType
Definition: cr-style.h:78
@ POSITION_FIXED
Definition: cr-style.h:82
@ POSITION_RELATIVE
Definition: cr-style.h:80
@ POSITION_STATIC
Definition: cr-style.h:79
@ POSITION_ABSOLUTE
Definition: cr-style.h:81
@ POSITION_INHERIT
Definition: cr-style.h:83
gboolean cr_style_unref(CRStyle *a_this)
Decreases the reference count of the current instance of CRStyle.
Definition: cr-style.c:2264
enum CRStatus cr_style_set_props_to_default_values(CRStyle *a_this)
Sets the style properties to their default values according to the css2 spec i.e inherit if the prope...
Definition: cr-style.c:1740
CRDisplayType
Definition: cr-style.h:56
@ DISPLAY_LIST_ITEM
Definition: cr-style.h:60
@ DISPLAY_TABLE
Definition: cr-style.h:64
@ DISPLAY_TABLE_COLUMN
Definition: cr-style.h:71
@ DISPLAY_INLINE
Definition: cr-style.h:58
@ DISPLAY_TABLE_CELL
Definition: cr-style.h:72
@ DISPLAY_TABLE_COLUMN_GROUP
Definition: cr-style.h:70
@ DISPLAY_TABLE_ROW_GROUP
Definition: cr-style.h:66
@ DISPLAY_TABLE_ROW
Definition: cr-style.h:69
@ DISPLAY_INHERIT
Definition: cr-style.h:74
@ DISPLAY_COMPACT
Definition: cr-style.h:62
@ DISPLAY_TABLE_FOOTER_GROUP
Definition: cr-style.h:68
@ DISPLAY_INLINE_TABLE
Definition: cr-style.h:65
@ DISPLAY_MARKER
Definition: cr-style.h:63
@ DISPLAY_BLOCK
Definition: cr-style.h:59
@ DISPLAY_TABLE_HEADER_GROUP
Definition: cr-style.h:67
@ DISPLAY_RUN_IN
Definition: cr-style.h:61
@ DISPLAY_NONE
Definition: cr-style.h:57
@ DISPLAY_TABLE_CAPTION
Definition: cr-style.h:73
enum CRStatus cr_style_white_space_type_to_string(enum CRWhiteSpaceType a_code, GString *a_str, guint a_nb_indent)
Definition: cr-style.c:2619
enum CRStatus cr_style_num_prop_val_to_string(CRNumPropVal *a_prop_val, GString *a_str, guint a_nb_indent)
dump a CRNumpPropVal in a string.
Definition: cr-style.c:2328
enum CRStatus cr_style_rgb_prop_val_to_string(CRRgbPropVal *a_prop_val, GString *a_str, guint a_nb_indent)
Definition: cr-style.c:2382
enum CRStatus cr_style_position_type_to_string(enum CRPositionType a_code, GString *a_str, guint a_nb_indent)
Definition: cr-style.c:2557
The Croco library basic types definitions And global definitions.
CRStatus
The status type returned by the methods of the croco library.
Definition: cr-utils.h:43
CRFontSize cv
Definition: cr-style.h:218
CRFontSize sv
Definition: cr-style.h:216
CRFontSize av
Definition: cr-style.h:220
CRNum cv
computed value
Definition: cr-style.h:123
CRNum av
actual value
Definition: cr-style.h:125
CRNum sv
specified value
Definition: cr-style.h:121
An abstraction of a number (num) as defined in the css2 spec.
Definition: cr-num.h:91
CRRgb av
actual value
Definition: cr-style.h:145
CRRgb sv
specified value
Definition: cr-style.h:141
CRRgb cv
computed value
Definition: cr-style.h:143
The css2 style class.
Definition: cr-style.h:231
CRFontSizeAdjust * font_size_adjust
Definition: cr-style.h:269
enum CRFloatType float_type
the float property
Definition: cr-style.h:258
enum CRBorderStyle border_style_props[NB_BORDER_STYLE_PROPS]
border style properties.
Definition: cr-style.h:249
enum CRPositionType position
the positioning scheme
Definition: cr-style.h:255
CRRgbPropVal rgb_props[NB_RGB_PROPS]
color properties.
Definition: cr-style.h:243
enum CRDisplayType display
box display type
Definition: cr-style.h:252
CRFontSizeVal font_size
the 'font-size' property.
Definition: cr-style.h:268
CRStyle * parent_style
Definition: cr-style.h:281
enum CRFontStyle font_style
Definition: cr-style.h:270
gulong ref_count
Definition: cr-style.h:282
CRNumPropVal num_props[NB_NUM_PROPS]
numerical properties.
Definition: cr-style.h:237
enum CRWhiteSpaceType white_space
the 'tex' properties
Definition: cr-style.h:278
enum CRFontWeight font_weight
Definition: cr-style.h:272
enum CRFontStretch font_stretch
Definition: cr-style.h:273
enum CRFontVariant font_variant
Definition: cr-style.h:271
gboolean inherited_props_resolved
Definition: cr-style.h:280
CRFontFamily * font_family
Definition: cr-style.h:263