<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE abiword PUBLIC "-//ABISOURCE//DTD AWML 1.0 Strict//EN" "http://www.abisource.com/awml.dtd">
<abiword template="false" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg" xmlns:dc="http://purl.org/dc/elements/1.1/" fileformat="1.1" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:awml="http://www.abisource.com/awml.dtd" xmlns="http://www.abisource.com/awml.dtd" xmlns:xlink="http://www.w3.org/1999/xlink" version="2.1.0" xml:space="preserve" props="lang:en-GB; dom-dir:ltr">
<!-- ======================================================================== -->
<!-- This file is an AbiWord document.                                        -->
<!-- AbiWord is a free, Open Source word processor.                           -->
<!-- More information about AbiWord is available at http://www.abisource.com/ -->
<!-- You should not edit this file by hand.                                   -->
<!-- ======================================================================== -->

<metadata>
<m key="dc.format">application/x-abiword</m>
<m key="abiword.generator">AbiWord</m>
</metadata>
<history version="30" edit-time="4576" last-saved="1078158219" uid="371719fa-6b4e-11d8-9439-00409545058b">
<version id="27" started="1078124525" uid="3851c998-6b56-11d8-9439-00409545058b" auto="0"/>
<version id="28" started="1078134693" uid="059b6292-6b66-11d8-80fc-8544bd93c730" auto="0"/>
<version id="30" started="1078158208" uid="cc4876ce-6b9c-11d8-9f84-b3079bf6aea0" auto="0"/>
</history>
<styles>
<s type="P" name="Heading 1" basedon="Normal" followedby="Normal" props="keep-with-next:1; margin-top:22pt; font-weight:bold; margin-bottom:3pt; font-family:Arial; font-size:17pt"/>
<s type="P" name="Normal" followedby="Current Settings" props="text-indent:0in; margin-top:0pt; margin-left:0pt; font-stretch:normal; line-height:1.0; text-align:left; font-variant:normal; lang:en-US; dom-dir:ltr; margin-bottom:0pt; text-decoration:none; font-weight:normal; bgcolor:transparent; color:000000; text-position:normal; font-size:12pt; margin-right:0pt; font-style:normal; widows:2; font-family:Times New Roman"/>
<s type="P" name="Heading 2" basedon="Normal" followedby="Normal" props="keep-with-next:1; margin-top:22pt; font-weight:bold; margin-bottom:3pt; font-family:Arial; font-size:14pt"/>
</styles>
<lists>
<l id="1000" parentid="0" type="5" start-value="0" list-delim="%L" list-decimal="NULL"/>
</lists>
<pagesize pagetype="A4" orientation="portrait" width="210.000000" height="297.000000" units="mm" page-scale="1.000000"/>
<section>
<p style="Heading 1" props="text-align:center; line-height:1.0"><c props="lang:en-GB">AbiWord Graphics Layer</c><c props="lang:en-GB"></c></p>
<p props="text-align:center"><c props="lang:en-GB">Tomas Frydrych &lt;</c><c props="lang:en-GB"></c><a xlink:href="mailto:tomasfrydrych@yahoo.co.uk"><c props="lang:en-GB">tomasfrydrych@yahoo.co.uk</c></a><c props="lang:en-GB">&gt;</c></p>
<p props="text-align:center; font-style:italic"><c props="font-style:italic; lang:en-GB">March 1, 2004</c><c props="font-style:italic; lang:en-GB"></c></p>
<p style="Heading 2"><c props="lang:en-GB">Overview</c><c props="lang:en-GB"></c></p>
<p><c props="lang:en-GB"></c><c props="lang:en-GB">Most of graphic operations are done in AbiWord through a portable graphics layer encapsulated by GR_Graphics. In itself, GR_Graphics is an abstract class providing only limited functionality; instead, a derrived class or classes, such as GR_Win32Graphics, is defined on each platform which implements the various virtual methods of GR_Graphics for both output to screen context and a printer context -- on some platforms (e.g., win32) both contexts are handled by a single class, on other platforms two different classes are need (e.g., on Unix GR_UnixGraphics for screen and PS_Graphics for printing).</c></p>
<p><c props="lang:en-GB"></c></p>
<p><c props="lang:en-GB">In addition to the main derrived classes on each platform, an unspecified number of specialised graphics classes may exist on any platform. These classes can implement functionality that goes beyond that to the platform base class, for example provide advanced shaping capabilities through a third-party library. Such additional classes can even be implemented as plugins. All of these additional classes must be derived from the the platform basic class, and must provide the same number of constructors as the basic class with signatures identical to the basic class constructor signatures (this allows for transparent replacement of the basic platform class with one of the additional classes).</c><c props="lang:en-GB"></c></p>
<p><c props="lang:en-GB"></c></p>
<p><c props="lang:en-GB">The allocation of instances of graphic classes is done through a graphics factory implemented in GR_GraphicsFactory which is made accessible to the outside world through XAP_App. The process looks as follows:</c><c props="lang:en-GB"></c></p>
<p level="1" listid="1000" parentid="0" props="start-value:0; text-indent:-0.3000in; list-style:Bullet List; field-font:Symbol; margin-left:0.5000in"><c props="list-tag:1001; lang:en-GB"></c><field type="list_label" props="width:0in; font-family:Times New Roman; display:inline; color:000000; font-weight:normal; text-position:normal; lang:en-GB; font-style:normal; font-variant:normal; text-decoration:none; bgcolor:transparent; list-style:Bullet List; homogeneous:1; height:0in; font-size:12pt; font-stretch:normal"></field><c props="width:0in; font-family:Times New Roman; display:inline; color:000000; font-weight:normal; text-position:normal; lang:en-GB; font-style:normal; font-variant:normal; text-decoration:none; bgcolor:transparent; list-style:Bullet List; homogeneous:1; height:0in; font-size:12pt; font-stretch:normal">	At start-up XAP_FEApp constructor registers all known graphic classes with the factory</c></p>
<p level="1" listid="1000" parentid="0" props="start-value:0; text-indent:-0.3000in; list-style:Bullet List; field-font:Symbol; margin-left:0.5000in"><c props="width:0in; list-tag:1002; font-family:Times New Roman; display:inline; font-variant:normal; font-weight:normal; lang:en-GB; font-style:normal; color:000000; homogeneous:1; bgcolor:transparent; font-size:12pt; text-decoration:none; list-style:Bullet List; height:0in; text-position:normal; font-stretch:normal"></c><field type="list_label" props="width:0in; font-family:Times New Roman; display:inline; color:000000; font-weight:normal; text-position:normal; lang:en-GB; font-style:normal; font-variant:normal; text-decoration:none; bgcolor:transparent; list-style:Bullet List; homogeneous:1; height:0in; font-size:12pt; font-stretch:normal"></field><c props="width:0in; font-family:Times New Roman; display:inline; color:000000; font-weight:normal; text-position:normal; lang:en-GB; font-style:normal; font-variant:normal; text-decoration:none; bgcolor:transparent; list-style:Bullet List; homogeneous:1; height:0in; font-size:12pt; font-stretch:normal">	Any graphics classes contained in plugins register themselves with the factory as they load.</c></p>
<p level="1" listid="1000" parentid="0" props="start-value:0; text-indent:-0.3000in; list-style:Bullet List; field-font:Symbol; margin-left:0.5000in"><c props="width:0in; list-tag:1003; font-family:Times New Roman; display:inline; font-variant:normal; font-weight:normal; lang:en-GB; font-style:normal; color:000000; homogeneous:1; bgcolor:transparent; font-size:12pt; text-decoration:none; list-style:Bullet List; height:0in; text-position:normal; font-stretch:normal"></c><field type="list_label" props="width:0in; font-family:Times New Roman; display:inline; color:000000; font-weight:normal; text-position:normal; lang:en-GB; font-style:normal; font-variant:normal; text-decoration:none; bgcolor:transparent; list-style:Bullet List; homogeneous:1; height:0in; font-size:12pt; font-stretch:normal"></field><c props="width:0in; font-family:Times New Roman; display:inline; color:000000; font-weight:normal; text-position:normal; lang:en-GB; font-style:normal; font-variant:normal; text-decoration:none; bgcolor:transparent; list-style:Bullet List; homogeneous:1; height:0in; font-size:12pt; font-stretch:normal">	On request XAP_App allocates transparently an instance of a graphics class.</c></p>
<p><c props="lang:en-GB"></c></p>
<p style="Heading 2"><c props="lang:en-GB">Class Registration</c><c props="lang:en-GB"></c></p>
<p><c props="lang:en-GB">Each built-in graphics class has to be registered with the graphics factory by call to GR_GraphicsFactory::registerClass(UT_uint32 id, GR_Allocator a, GR_Decsriptor d), where id defines numerical id assigned to the class in gr_graphics.h, GR_Allocator is a static function used to allocate instances of that class and GR_Descriptor is a static function providing human readeable description of the class.</c><c props="lang:en-GB"></c></p>
<p><c props="lang:en-GB"></c></p>
<p><c props="lang:en-GB">Each plugin class too has to register with the factory. It can either use the registerClass() function if it has a fixed id assigned which is found in gr_graphics.h, or it can use registerPluginClass(GR_Allocator, GR_Descriptor) which will allocate to it id dynamically. (There are advantages to plugin classes having a fixed id assigned to them, such making it possible to store such ids in preference files.)</c><c props="lang:en-GB"></c></p>
<p><c props="lang:en-GB"></c></p>
<p><c props="lang:en-GB">In addition to each class being registered as described above, the default screen and printer classes have to be registered with the ids GRID_DEFAULT and GRID_DEFAULT_PRINT respectively. The XAP_FEApp constructor does the initial registration, but different classes can be registered under these ids later (for example a plugin class might install itself as the default handler).</c><c props="lang:en-GB"></c></p>
<p style="Heading 2"><c props="lang:en-GB">Class Instance Allocation</c><c props="lang:en-GB"></c></p>
<p style="Normal"><c props="lang:en-GB">Instances of graphics classes are allocated through newGraphics() functions of XAP_App. Virtually all allocations should be done through XAP_App::newGraphics(GR_AllocInfo &amp; ai), to which the caller needs to supply an instance of GR_AllocInfo derrived class that is then passed by the factory to the class allocator GR_Allocator.</c><c props="lang:en-GB"></c></p>
<p style="Normal"><c props="lang:en-GB"></c></p>
<p style="Normal"><c props="lang:en-GB">The derrived class GR_FEAllocInfo is platform specific (not graphics specific!) and is capable of holding information needed by any of the graphics class constructors used on that platform. GR_AllocInfo also provides two virtual functions: getType() that allows the allocators to check that the actual instance it was passed is what it expects, and isPrinterGraphics() which is used by XAP_App to decide whether printer or screen graphics should be allocated by call to newGraphics().</c><c props="lang:en-GB"></c></p>
<p><c props="lang:en-GB"></c></p>
<p><c props="lang:en-GB">The call to XAP_App::newGraphics(GR_AllocInfo &amp;ai) will allocate a new instance of a graphics class registered with GRID_DEFAULT if screen graphics is needed or GRID_DEFAULT_PRINTER if printer graphics is needed.</c><c props="lang:en-GB"></c></p>
<p><c props="lang:en-GB"></c></p>
<p><c props="lang:en-GB">In addition to this function, there is also XAP_App::newGraphics(UT_uint id, GR_AllocInfo ) which will allocate an instance of the class registered with the given id. This function should only be used when there is a good reason why a specific class must be allocated; in the present AbiWord code, the only place it is needed is for allocation of UnixNull_Graphics.</c><c props="lang:en-GB"></c></p>
<p style="Heading 2"><c props="lang:en-GB">Notes on Shaping</c><c props="lang:en-GB"></c></p>
<p style="Normal"><c props="lang:en-GB">TO BE WRITTEN.</c><c props="lang:en-GB"></c></p>
</section>
</abiword>
