cr-style.h 8.5 KB

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