Libcroco
|
00001 /* -*- Mode: C; indent-tabs-mode:nil; c-basic-offset: 8-*- */ 00002 00003 /* 00004 * This file is part of The Croco Library 00005 * 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of version 2.1 of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00019 * USA 00020 * 00021 * Author: Dodji Seketeli. 00022 * See COPYRIGHTS file for copyright information. 00023 */ 00024 00025 #ifndef __CR_STYLE_H__ 00026 #define __CR_STYLE_H__ 00027 00028 #include "cr-utils.h" 00029 #include "cr-statement.h" 00030 #include "cr-fonts.h" 00031 00032 /** 00033 *@file 00034 *The declaration of the #CRStyle class. 00035 */ 00036 G_BEGIN_DECLS 00037 00038 typedef struct _CRStyle CRStyle ; 00039 00040 enum CRBorderStyle 00041 { 00042 BORDER_STYLE_NONE = 0, 00043 BORDER_STYLE_HIDDEN, 00044 BORDER_STYLE_DOTTED, 00045 BORDER_STYLE_DASHED, 00046 BORDER_STYLE_SOLID, 00047 BORDER_STYLE_DOUBLE, 00048 BORDER_STYLE_GROOVE, 00049 BORDER_STYLE_RIDGE, 00050 BORDER_STYLE_INSET, 00051 BORDER_STYLE_OUTSET, 00052 BORDER_STYLE_INHERIT 00053 } ; 00054 00055 enum CRDisplayType 00056 { 00057 DISPLAY_NONE, 00058 DISPLAY_INLINE, 00059 DISPLAY_BLOCK, 00060 DISPLAY_LIST_ITEM, 00061 DISPLAY_RUN_IN, 00062 DISPLAY_COMPACT, 00063 DISPLAY_MARKER, 00064 DISPLAY_TABLE, 00065 DISPLAY_INLINE_TABLE, 00066 DISPLAY_TABLE_ROW_GROUP, 00067 DISPLAY_TABLE_HEADER_GROUP, 00068 DISPLAY_TABLE_FOOTER_GROUP, 00069 DISPLAY_TABLE_ROW, 00070 DISPLAY_TABLE_COLUMN_GROUP, 00071 DISPLAY_TABLE_COLUMN, 00072 DISPLAY_TABLE_CELL, 00073 DISPLAY_TABLE_CAPTION, 00074 DISPLAY_INHERIT 00075 } ; 00076 00077 enum CRPositionType 00078 { 00079 POSITION_STATIC, 00080 POSITION_RELATIVE, 00081 POSITION_ABSOLUTE, 00082 POSITION_FIXED, 00083 POSITION_INHERIT 00084 } ; 00085 00086 enum CRFloatType 00087 { 00088 FLOAT_NONE, 00089 FLOAT_LEFT, 00090 FLOAT_RIGHT, 00091 FLOAT_INHERIT 00092 } ; 00093 00094 enum CRWhiteSpaceType 00095 { 00096 WHITE_SPACE_NORMAL, 00097 WHITE_SPACE_PRE, 00098 WHITE_SPACE_NOWRAP, 00099 WHITE_SPACE_INHERIT 00100 } ; 00101 00102 00103 #define BORDER_THIN 2 00104 #define BORDER_MEDIUM 4 00105 #define BORDER_THICK 6 00106 00107 00108 /** 00109 *A numerical css property value. 00110 *This data type is actually split in 3 parts: 00111 *1/the specified value 00112 *2/the computed value 00113 *3/the actual value. 00114 *To understand the semantic of these three parts, 00115 *see css2 spec chap 6.1 ("Specified, computed and actual values."). 00116 */ 00117 typedef struct _CRNumPropVal CRNumPropVal ; 00118 struct _CRNumPropVal 00119 { 00120 /**specified value*/ 00121 CRNum sv ; 00122 /**computed value*/ 00123 CRNum cv ; 00124 /**actual value*/ 00125 CRNum av ; 00126 } ; 00127 00128 /** 00129 *An rgb css property value. 00130 *This data type is actually split in 3 parts: 00131 *1/the specified value 00132 *2/the computed value 00133 *3/the actual value. 00134 *To understand the semantic of these three parts, 00135 *see css2 spec chap 6.1 ("Specified, computed and actual values."). 00136 */ 00137 typedef struct _CRRgbPropVal CRRgbPropVal ; 00138 struct _CRRgbPropVal 00139 { 00140 /**specified value*/ 00141 CRRgb sv ; 00142 /**computed value*/ 00143 CRRgb cv ; 00144 /**actual value*/ 00145 CRRgb av ; 00146 } ; 00147 00148 00149 enum CRNumProp 00150 { 00151 NUM_PROP_TOP=0, 00152 NUM_PROP_RIGHT, 00153 NUM_PROP_BOTTOM, 00154 NUM_PROP_LEFT,/*3*/ 00155 00156 NUM_PROP_PADDING_TOP, 00157 NUM_PROP_PADDING_RIGHT, 00158 NUM_PROP_PADDING_BOTTOM, 00159 NUM_PROP_PADDING_LEFT,/*7*/ 00160 00161 NUM_PROP_BORDER_TOP, 00162 NUM_PROP_BORDER_RIGHT, 00163 NUM_PROP_BORDER_BOTTOM, 00164 NUM_PROP_BORDER_LEFT,/*11*/ 00165 00166 NUM_PROP_MARGIN_TOP, 00167 NUM_PROP_MARGIN_RIGHT, 00168 NUM_PROP_MARGIN_BOTTOM, 00169 NUM_PROP_MARGIN_LEFT,/*15*/ 00170 00171 NUM_PROP_WIDTH, 00172 00173 /*must be last*/ 00174 NB_NUM_PROPS 00175 } ; 00176 00177 enum CRRgbProp 00178 { 00179 RGB_PROP_BORDER_TOP_COLOR = 0, 00180 RGB_PROP_BORDER_RIGHT_COLOR, 00181 RGB_PROP_BORDER_BOTTOM_COLOR, 00182 RGB_PROP_BORDER_LEFT_COLOR, 00183 RGB_PROP_COLOR, 00184 RGB_PROP_BACKGROUND_COLOR, 00185 00186 /*must be last*/ 00187 NB_RGB_PROPS 00188 } ; 00189 00190 00191 enum CRBorderStyleProp 00192 { 00193 BORDER_STYLE_PROP_TOP = 0, 00194 BORDER_STYLE_PROP_RIGHT, 00195 BORDER_STYLE_PROP_BOTTOM, 00196 BORDER_STYLE_PROP_LEFT, 00197 00198 /*must be last*/ 00199 NB_BORDER_STYLE_PROPS 00200 } ; 00201 00202 enum CRBoxOffsetProp 00203 { 00204 BOX_OFFSET_PROP_TOP = 0, 00205 BOX_OFFSET_PROP_RIGHT, 00206 BOX_OFFSET_PROP_BOTTOM, 00207 BOX_OFFSET_PROP_LEFT, 00208 00209 /*must be last*/ 00210 NB_BOX_OFFSET_PROPS 00211 } ; 00212 00213 typedef struct _CRFontSizeVal CRFontSizeVal ; 00214 struct _CRFontSizeVal { 00215 /*specified value*/ 00216 CRFontSize sv ; 00217 /*computed value*/ 00218 CRFontSize cv ; 00219 /*actual value*/ 00220 CRFontSize av ; 00221 } ; 00222 00223 /** 00224 *The css2 style class. 00225 *Contains computed and actual values 00226 *inferred from the declarations found 00227 *in the stylesheets. 00228 *See css2 spec chapter 6. 00229 */ 00230 struct _CRStyle 00231 { 00232 /** 00233 *numerical properties. 00234 *the properties are indexed by 00235 *enum #CRNumProp. 00236 */ 00237 CRNumPropVal num_props[NB_NUM_PROPS] ; 00238 00239 /** 00240 *color properties. 00241 *They are indexed by enum #CRRgbProp . 00242 */ 00243 CRRgbPropVal rgb_props[NB_RGB_PROPS] ; 00244 00245 /** 00246 *border style properties. 00247 *They are indexed by enum #CRBorderStyleProp . 00248 */ 00249 enum CRBorderStyle border_style_props[NB_BORDER_STYLE_PROPS] ; 00250 00251 /**box display type*/ 00252 enum CRDisplayType display ; 00253 00254 /**the positioning scheme*/ 00255 enum CRPositionType position ; 00256 00257 /**the float property*/ 00258 enum CRFloatType float_type ; 00259 00260 /* 00261 *the 'font-family' property. 00262 */ 00263 CRFontFamily *font_family ; 00264 00265 /** 00266 *the 'font-size' property. 00267 */ 00268 CRFontSizeVal font_size ; 00269 CRFontSizeAdjust *font_size_adjust ; 00270 enum CRFontStyle font_style ; 00271 enum CRFontVariant font_variant ; 00272 enum CRFontWeight font_weight ; 00273 enum CRFontStretch font_stretch ; 00274 00275 /** 00276 * the 'tex' properties 00277 */ 00278 enum CRWhiteSpaceType white_space; 00279 00280 gboolean inherited_props_resolved ; 00281 CRStyle *parent_style ; 00282 gulong ref_count ; 00283 } ; 00284 00285 enum CRStatus cr_style_white_space_type_to_string (enum CRWhiteSpaceType a_code, 00286 GString * a_str, guint a_nb_indent) ; 00287 00288 enum CRStatus cr_style_num_prop_val_to_string (CRNumPropVal *a_prop_val, 00289 GString *a_str, 00290 guint a_nb_indent) ; 00291 00292 enum CRStatus cr_style_rgb_prop_val_to_string (CRRgbPropVal *a_prop_val, 00293 GString *a_str, 00294 guint a_nb_indent) ; 00295 00296 enum CRStatus cr_style_border_style_to_string (enum CRBorderStyle a_prop, 00297 GString *a_str, 00298 guint a_nb_indent) ; 00299 00300 enum CRStatus cr_style_display_type_to_string (enum CRDisplayType a_code, 00301 GString *a_str, 00302 guint a_nb_indent) ; 00303 00304 enum CRStatus cr_style_position_type_to_string (enum CRPositionType a_code, 00305 GString *a_str, 00306 guint a_nb_indent) ; 00307 00308 enum CRStatus cr_style_float_type_to_string (enum CRFloatType a_code, 00309 GString *a_str, 00310 guint a_nb_indent) ; 00311 00312 CRStyle * cr_style_new (gboolean a_set_props_to_initial_values) ; 00313 00314 enum CRStatus cr_style_set_props_to_default_values (CRStyle *a_this) ; 00315 enum CRStatus cr_style_set_props_to_initial_values (CRStyle *a_this) ; 00316 enum CRStatus cr_style_resolve_inherited_properties (CRStyle *a_this) ; 00317 enum CRStatus cr_style_propagate_from_parent (CRStyle *a_this); 00318 00319 enum CRStatus cr_style_set_style_from_decl (CRStyle *a_this, 00320 CRDeclaration *a_decl) ; 00321 00322 00323 enum CRStatus cr_style_copy (CRStyle *a_dest, CRStyle *a_src) ; 00324 00325 enum CRStatus cr_style_ref (CRStyle *a_this) ; 00326 00327 gboolean cr_style_unref (CRStyle *a_this) ; 00328 00329 void cr_style_destroy (CRStyle *a_this) ; 00330 00331 CRStyle * cr_style_dup (CRStyle *a_this) ; 00332 00333 enum CRStatus cr_style_to_string (CRStyle *a_this, 00334 GString **a_str, 00335 guint a_nb_indent) ; 00336 00337 G_END_DECLS 00338 00339 #endif /*__CR_STYLE_H__*/