Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

cr-box.h

Go to the documentation of this file.
00001 /* -*- Mode: C; indent-tabs-mode:nil; c-basic-offset: 8-*- */
00002 
00003 /*
00004  * This file is part of The Croco Library
00005  *
00006  * Copyright (C) 2002-2003 Dodji Seketeli <dodji@seketeli.org>
00007  *
00008  * This program is free software; you can redistribute it and/or
00009  * modify it under the terms of version 2.1 of the GNU Lesser General Public
00010  * License as published by the Free Software Foundation.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00020  * USA
00021  */
00022 
00023 #ifndef __CR_BOX_H__
00024 #define __CR_BOX_H__
00025 
00026 #include "cr-style.h"
00027 #include "libxml/tree.h"
00028 
00029 /*
00030  *$Id: cr-box.h,v 1.7 2003/07/05 21:08:56 dodji Exp $
00031  */
00032 
00033 G_BEGIN_DECLS
00034 
00035 /**
00036  *@file 
00037  *the declaration of the #CRBox class.
00038  */
00039 enum CRBoxContentType
00040 {
00041         NO_CONTENT_TYPE,
00042         TEXT_CONTENT_TYPE,
00043         IMAGE_CONTENT_TYPE
00044 } ;
00045 
00046 typedef struct _CRImageContentDesc CRImageContentDesc ;
00047 struct _CRImageContentDesc
00048 {
00049         guchar *img_buf ;
00050         gulong *len ;
00051         guchar *img_path ;
00052 } ;
00053 
00054 typedef struct _CRBoxContent CRBoxContent ;
00055 struct _CRBoxContent
00056 {
00057         enum CRBoxContentType type ;
00058         union 
00059         {
00060                 guchar *text ;
00061                 CRImageContentDesc *img_desc ;
00062         } u ;
00063 
00064         /*
00065          *a place where the rendered content can be cached.
00066          *This can be usefull because sometime, during the layout,
00067          *calculating the size of the content is better achieve by
00068          *rendering it. In this case, the rendered content is just cached
00069          *here so that the rendering stage can just pick it.
00070          */
00071         gpointer content_cache ;
00072 } ;
00073 
00074 typedef struct _CRBoxEdge CRBoxEdge ;
00075 
00076 /**
00077  *An internal data structure
00078  *used by #CRBox.
00079  *An edge is an rectangular area
00080  *defined by the coordinates of the it top left corner,
00081  *its width and height.
00082  */
00083 struct _CRBoxEdge
00084 {
00085         gulong x, y, width, max_width, 
00086                 height, x_offset, y_offset,
00087                 child_rmost_x ;
00088 } ;
00089 
00090 
00091 enum CRBoxType
00092 {
00093         BOX_TYPE_UNDEFINED,
00094         BOX_TYPE_BOX_MODEL,
00095         BOX_TYPE_BLOCK,
00096         BOX_TYPE_ANONYMOUS_BLOCK,
00097         BOX_TYPE_INLINE,
00098         BOX_TYPE_ANONYMOUS_INLINE,
00099         BOX_TYPE_COMPACT,
00100         BOX_TYPE_RUN_IN
00101 } ;
00102 
00103 typedef struct _CRBoxData CRBoxData ;
00104 
00105 /**
00106  *Some data stored in the box.
00107  *these data are about the node which
00108  *generated the current box.
00109  */
00110 struct _CRBoxData
00111 {
00112         /**
00113          *The xml node which generated
00114          *the css box. If NULL, it means
00115          *that this node is an anonymous node
00116          */
00117         xmlNode *xml_node ;
00118 } ;
00119 
00120 CRBoxData *
00121 cr_box_data_new (xmlNode *a_node)  ;
00122 
00123 void
00124 cr_box_data_destroy (CRBoxData *a_this) ;
00125 
00126 typedef struct _CRBoxModel CRBoxModel ;
00127 typedef struct _CRBox CRBox ;
00128 
00129 /**
00130  *The CRBox class.
00131  *Abstracts the css2 box as defined in the
00132  *css2 spec in chapter 8.
00133   *It is actually a tree of boxes, each being "generated"
00134  *by an xml document tree node.
00135  */
00136 struct _CRBox
00137 {
00138         enum CRBoxType type ;
00139 
00140         /**
00141          *The inner edge, or content edge.
00142          *Is the one that immediately wraps
00143          *the content of the box.
00144          *The content of the box may be
00145          *a text, an image, or a set of boxes.
00146          *If the content is a set of boxes, then
00147          *this set is inevitably the set of children
00148          *boxes of this current box.
00149          */
00150         CRBoxEdge inner_edge ;
00151 
00152         /**
00153          *The padding edge.
00154          *It includes the inner_edge plus a
00155          *a surrounding area called "padding".
00156          *When the padding is inexistent, the
00157          *padding edge equals the inner or content edge.
00158          */
00159         CRBoxEdge padding_edge ;
00160 
00161         /**
00162          *The border edge.
00163          *It includes the padding edge plus
00164          *a surrounding area called "border".
00165          *If the border is inexistant, the
00166          *border edge equals the padding edge.
00167          */
00168         CRBoxEdge border_edge ;
00169 
00170         /**
00171          *The outer edge aka margin edge.
00172          *It includes the border edge plus
00173          *a surrounding area called "margin".
00174          *If the border is inexistant, the outer
00175          *edge equals the border_edge.
00176          */
00177         CRBoxEdge outer_edge ;
00178 
00179         /**
00180          *The values of all the preceding
00181          *edges are infered from the value
00182          *of the 'style' field.
00183          */
00184 
00185         /**
00186          *The content (text or image) of this
00187          *box
00188          */
00189         CRBoxContent *content ;
00190 
00191         /**
00192          *if TRUE, it means that this box has
00193          *a simple content. Simple content means
00194          *either a text or image content.
00195          *Normally, to be logic, if this is
00196          *set to TRUE, the children pointer should
00197          *be NULL ... see what I mean ?
00198          */
00199         gboolean as_simple_content ;
00200 
00201         /**
00202          *The value infered from what has been found
00203          *in the css stylesheet.
00204          */
00205         CRStyle *style ;
00206 
00207         /**the containing box*/
00208         CRBox *parent ;
00209 
00210         /**the next box in the flow*/
00211         CRBox *next ;
00212 
00213         /**the previous box in the flow*/
00214         CRBox *prev ;
00215 
00216         /**the children (contained) boxes*/
00217         CRBox *children ;
00218 
00219         CRBoxModel * box_model ;
00220 
00221         /**some custom data used by libcroco*/
00222         CRBoxData *box_data ;
00223         /**some application data that will never 
00224          *be used by libcroco. Applications
00225          *are free to use it.
00226          */
00227         gpointer *app_data ;
00228         
00229         gulong ref_count ;
00230 } ;
00231 
00232 struct _CRBoxModel
00233 {
00234         CRBox box ;
00235         gulong viewport_width ;
00236         gulong viewport_height ;
00237         gulong ref_count ;
00238 } ;
00239 
00240 
00241 CRBoxModel *
00242 cr_box_model_new (void) ;
00243 
00244 void
00245 cr_box_model_destroy (CRBoxModel *a_this) ;
00246 
00247 void
00248 cr_box_model_ref (CRBoxModel *a_this) ;
00249 
00250 gboolean
00251 cr_box_model_unref (CRBoxModel *a_this) ;
00252 
00253 CRBoxContent *
00254 cr_box_content_new_from_text (guchar *a_text) ;
00255 
00256 void
00257 cr_box_content_destroy (CRBoxContent *a_this) ;
00258 
00259 CRBox *
00260 cr_box_new (CRStyle *a_this, gboolean a_set_default_style) ;
00261 
00262 enum CRStatus
00263 cr_box_insert_sibling (CRBox *a_prev,
00264                        CRBox *a_next,
00265                        CRBox *a_to_insert) ;
00266 enum CRStatus
00267 cr_box_to_string (CRBox *a_this, 
00268                   gulong a_nb_indent,
00269                   GString **a_string) ;
00270 
00271 enum CRStatus
00272 cr_box_dump_to_file (CRBox *a_this, 
00273                      gulong a_nb_indent,
00274                      FILE *a_filep) ;
00275 
00276 enum CRStatus
00277 cr_box_ref (CRBox *a_this) ;
00278 
00279 
00280 gboolean
00281 cr_box_unref (CRBox *a_this) ;
00282 
00283 enum CRStatus
00284 cr_box_append_child (CRBox *a_this, CRBox *a_to_append) ;
00285 
00286 void
00287 cr_box_destroy (CRBox *a_this) ;
00288 
00289 
00290 G_END_DECLS
00291 
00292 #endif /*__CR_BOX_H__*/
00293 

Generated on Wed Oct 1 01:36:45 2003 for Libcroco by doxygen 1.3.3