Re: [Re-posting] Adding object-specific properties to custom objects
- From: "Marco Contenti" <m contenti libero it>
- To: <dia-list gnome org>
- Subject: Re: [Re-posting] Adding object-specific properties to custom objects
- Date: Sun, 9 Nov 2003 17:47:00 +0100
----- Original Message -----
From: "Marco Contenti" <m contenti libero it>
To: <dia-list gnome org>
Sent: Friday, November 07, 2003 11:45 PM
Subject: [Re-posting] Adding object-specific properties to custom objects
So, I'm going to implement this right away, but I'd like to:
1. share what I'm doing with the community and, if possible, make it a
part
of the Dia project;
2. do it the most standard way possible;
3. know if someone has already thought or made something, not to waste
effort.
My ideas are:
- use standard properties (of course);
- use the existing dia:attribute tag in .dia files;
- create a new tag in .shape files to describe attributes, supporting all
standard types including composite;
- modify the custom object plug-in adding code that interprets additional
shape info and compiles PropDescription and PropOffset accordingly, plus
code to load and save the additional info.
If I understood well the Dia architecture, all this should be enough, and
can be accomplished in a matter of days.
Getting more into detail, here is a s summary of changes in file formats
required to implement custom object properties. The changes proposed consist
in additions only and preserve backward compatibility with the present
format.
Again, Please let me know your comments and suggestions.
Regards.
Marco Contenti
(m dot contenti at libero dot it)
----------------------------------------------------------------------------
-------
Proposed change to shape files (in .dtd notation)
A new child type "properties" is added to the "shape" element:
<!ELEMENT shape (name, description*, icon?, connections?,
aspectratio?, properties?, svg:svg) >
the new element contains all custom properties under a single tag:
<!ELEMENT properties (attribute*) >
<!ELEMENT attribute (attribute*) >
<!ATTLIST attribute
name CDATA #REQUIRED
type CDATA #REQUIRED >
where "type" may be one of the standard property types: composite, int,
enum, real, boolean, color, point, rectangle, string, font.
The attribute element should be empty except for type composite.
The code loading shape info should automatically enclose all custom
properties in a single composite attribute (say: "custom_properties") to
avoid namespace conflicts with existing dia:attribute tags.
Thus, for example, if a shape file contains:
<shape ... >
<name>Widget</name>
...
<properties>
<attribute name="part_no" type="string"/>
</properties>
...
</shape>
then the saved .dia file will contain an attribute like this:
<dia:object type="Widget" version="0" id="O1">
...
<dia:composite type="custom_properties">
<dia:attribute name="custom_properties">
<dia:attribute name="part_no">
<dia:string>1234-ABCD-0001</dia:string>
</dia:attribute>
</dia:attribute>
</dia:composite>
...
</dia:object>
Note: this is not really a change in .dia format, since the present syntax
already allows this construct and such a file should be loaded by the
present Dia without problems (ignoring the custom attributes). Also changed
.shape files shouldn't cause problems.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]