Go to TogaWare.com Home Page.
GNU/Linux Desktop Survival Guide
by Graham Williams

Simple Example

A shape consists of at least a name and a SVG element. That is, every shape, at a minimum, has a name and a description:

<?xml version="1.0"?>

<shape xmlns="http://www.daa.com.au/~james/dia-shape-ns"
  <name>Sample - Minimal Shape</name>
  <svg:svg width="10" height="10">
    <svg:polygon points="0,0 10,0 5,10"/>

Image dia-sheet-sample-min-canvas3

You can place this in a subdirectory of your own dia shapes directory, perhaps called Sample as in  /.dia/shapes/Sample/minimal.shape. The actual filename in which the shape is stored (minimal.shape) is not so important--dia will find the file.

Now you need to create a sheet into which this shape is placed. Again, a sheet is specified using XML. This example is placed in the file  /.dia/sheets/Sample.sheet:

<?xml version="1.0" encoding="iso-8859-1"?>

<sheet xmlns="http://www.lysator.liu.se/~alla/dia/dia-sheet-ns">
  <description>A collection of sample shapes.</description>
    <object name="Sample - Minimal Shape">
      <description>The most minimal of shapes</description>

Now start up dia and you should see this new sheet, called Sample, containing a single button with a default icon.

Image dia-sheet-sample-min

You can now create a new canvas and add this shape to your canvas. Note that dia takes care of the resizing of the shape and the other characteristics.

The XML describing the shape begins with the usual xml meta element followed the actual shape element, identifying the appropriate XML namespaces (xmlns). The shape has a unique name used to identify the shape by dia. Next we have the actual SVG description of the shape which is 10 by 10 in size

Image dia-sheet-sample-min-canvas

(actually these are ignored by dia but are required by the SVG format), and consisting of a single polygon. The shape is a simple triangle (a polygon with three points) pointing downwards. The polygon is drawn from the top left corner (0,0) to the top right (10,0) then to the bottom middle (5,10) and then back to the top left to finish off the polygon.

The XML for the sheet then identifies this shape as belonging to the Sample sheet, which contains just one object, the Sample - Minimal Shape shape. The description for the object is used as the tooltip for the resulting button.

Copyright © 1995-2006 [email protected]
Contribue and access the PDF Version