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