1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Anatomy of a Formatting Object area source code file</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
<meta name="description" content="Anatomy of a Formatting Object area source code file">
<link rel="start" href="index.html" title="xmlroff Reference Manual">
<link rel="up" href="developers.html" title="Developers' Guide">
<link rel="prev" href="fo-c-file.html" title="Anatomy of a Formatting Object C source code file">
<link rel="next" href="generating-source.html" title="Generating Source">
<meta name="generator" content="GTK-Doc V1.10 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="chapter" href="users.html" title="Users' Guide">
<link rel="chapter" href="developers.html" title="Developers' Guide">
<link rel="chapter" href="object-hierarchy.html" title="Object Hierarchy">
<link rel="chapter" href="object.html" title="FoObject is wonderful">
<link rel="chapter" href="node.html" title="FoNode is wonderful">
<link rel="chapter" href="interfaces.html" title="Interfaces are truly wonderful">
<link rel="chapter" href="formatting-objects.html" title="Formatting Objects are truly wonderful">
<link rel="chapter" href="properties.html" title="Properties">
<link rel="chapter" href="areas.html" title="Area Objects">
<link rel="chapter" href="datatypes.html" title="Datatype Objects">
<link rel="chapter" href="context.html" title="Property Context Object">
<link rel="chapter" href="other-objects.html" title="Other Objects">
<link rel="chapter" href="utility-objects.html" title="Utility Objects">
<link rel="chapter" href="utility-modules.html" title="Utility Modules">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle">
<td><a accesskey="p" href="fo-c-file.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="developers.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">xmlroff Reference Manual</th>
<td><a accesskey="n" href="generating-source.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr></table>
<div class="section" lang="en">
<div class="titlepage"><div>
<div><h2 class="title" style="clear: both">
<a name="fo-area-c-file"></a>Anatomy of a Formatting Object area source code file</h2></div>
<div><h2 class="subtitle">FO -area.c File</h2></div>
<div><div class="abstract">
<p class="title"><b>Abstract</b></p>
<p>Anatomy of a Formatting Object area source code file</p>
</div></div>
</div></div>
<p>These files are not autogenerated.</p>
<p>Some, but not all, formatting objects generate areas. Those that
do generate areas and are implemented in xmlroff have an -area.c and
area.h file.</p>
<p>The -area.[ch] files exist to implement fo_fo_area_new2() for
the GObject class for the formatting object (or, for formatting
objects implemented early and not yet brought up to date, to implement
fo_fo_area_new()).</p>
<p>The _area_new2() or _area_new() function creates an area of the
type appropriate for the formatting object and adds it to the
formatting object tree.</p>
<p>The differences between the _area_new2() and _area_new()
functions are really just in their interface: the _area_new2()
functions get most of their inputs in a FoFoAreaNew2Context structure
rather than as individual arguments. The _area_new2() functions also
have a GError argument for error reporting.</p>
<p>The least straightforward -area.c file is fo-block-area.c, since
that's where FoText and inline formatting objects are made into Pango
layouts. The rest are mostly straightforward.</p>
<div class="section" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="fo-area-initial-comment"></a>Initial comment</h3></div></div></div>
<pre class="programlisting">/* Fo
* fo-table-body-area.c: Generate area for 'table-body' formatting object
*
* Copyright (C) 2001 Sun Microsystems
*
* $Id: fo-area-c-file.xml,v 1.1 2006/03/14 19:42:57 tonygraham Exp $
*
* See Copying for the status of this software.
*/</pre>
</div>
<div class="section" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="fo-area-includes"></a>#includes</h3></div></div></div>
<pre class="programlisting">#include <fo-area-table-body.h></pre>
<p>The public interface for the type of area generated by this formatting object.</p>
<pre class="programlisting">#include <fo-table-body-private.h></pre>
<p>The private interface of this formatting object type.</p>
</div>
<div class="section" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="fo-area-area-new2"></a>FoFo _area_new2()</h3></div></div></div>
<p>Add the area generated by the formatting object to the area tree.</p>
<pre class="programlisting"> /**
* fo_table_body_area_new2:
* @fo: #FoTableBody
* @context: #FoFoAreaNew2Context
* @error: #GError
*
* Create a new area for @fo and add it to the parent area.
*
* A pointer to the parent area is in @context.
**/
void
fo_table_body_area_new2 (FoFo *fo,
FoFoAreaNew2Context *context,
GError **error)
{
FoTableBody *table_body = (FoTableBody *) fo;
FoArea *use_parent_area;
FoArea *new_area;
g_return_if_fail (table_body != NULL);
g_return_if_fail (FO_IS_TABLE_BODY (table_body));
g_return_if_fail (context != NULL);
g_return_if_fail (error == NULL || *error == NULL);
new_area = fo_area_table_body_new ();
use_parent_area = context->parent_area;
#if defined(LIBFO_DEBUG) && 0
g_warning ("*** table-body parent before new area:");
fo_object_debug_dump (parent_area, 0);
g_warning ("*** end table-body parent");
#endif
FO_AREA (new_area)->generated_by = fo;</pre>
<p>Areas keep track of which FO generated them so they can get some
property values, e.g., colors, from the FO rather than loading the
area objects with duplicates of all the applicable formatting object
property values.</p>
<pre class="programlisting"> FO_FO (fo)->areas = g_list_append (FO_FO (fo)->areas, new_area);</pre>
<p>FOs keep track of which areas they've generated</p>
<pre class="programlisting"> fo_area_add_child (use_parent_area, new_area);</pre>
<p>Attach the new area to the area tree.</p>
<pre class="programlisting"> new_area = fo_area_size_request (new_area);</pre>
<p>The new area asks its parent to allocate space for it. Anything
could happen at this point: the area might not fit in the space
remaining for it on the current page, so the new area, the parent
area, and all containing areas up the page area may need to be split
so one part of the new area is on the current page and the rest on the
next page (or on multiple pages if it is big enough).</p>
<p>Consequently, the area returned by fo_area_size_request() might
not be the same area that was passed to it. The return value is the
last area resulting from the original new_area.</p>
<pre class="programlisting"> fo_area_area_set_width (new_area, fo_area_get_available_width (new_area));
#if defined(LIBFO_DEBUG) && 0
g_warning ("*** table-body parent after new area:");
fo_object_debug_dump (parent_area, 0);
g_warning ("*** end table-body parent");
#endif
*(context->new_area) = new_area;</pre>
<p>'Return' the new area so there's somewhere to hang the areas
generated by the children of the current formatting object.</p>
<pre class="programlisting">}</pre>
</div>
</div>
<div class="footer">
<hr>
Generated by GTK-Doc V1.10</div>
</body>
</html>
|