File: embedding.html

package info (click to toggle)
siag 3.1.22-5
  • links: PTS
  • area: main
  • in suites: potato
  • size: 7,024 kB
  • ctags: 8,635
  • sloc: ansic: 66,498; lisp: 4,499; sh: 568; makefile: 550
file content (139 lines) | stat: -rw-r--r-- 4,663 bytes parent folder | download
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
<html>
<head>
<title>Embedding</title>
</head>

<body>
<h1>Embedding</h1>

Documents from one program can be "embedded" in a document by
another program using a simple mechanism called IOA, Independent
Object Architecture.

<h2>Definition of Independent Object</h2>

An Independent Object is a file in X11 Bitmap format, which illustrates
the state of an IOA server at some point. Typically this will be a
screenshot of a document.
<p>
The file may also contain a comment which describes how the server
program can be invoked in a way which brings back its state at the
time of the object creation. The format of the comment is:
<pre>
/*
EmBeDcommand string
*/
</pre>
The command string will, when handed over to the shell, start the server
with whatever parameters are appropriate. For example, if an object is
created from Siag with the document heaven.siag loaded, the command
string will be:
<pre>
siag heaven.siag
</pre>

<h2>Definition of IOA Server</h2>
An IOA server is a program which is capable of creating Independent
Objects. It should also add the description comment to the file
as described above.

<h2>Definition of IOA Client</h2>
An IOA client is a program which is capable of reading and displaying
Independent Objects. It should also be able to extract the description
comment and invoke the server that created the object.
<p>
Fully conforming servers and/or clients must implement the "should"
capabilities. It is possible for a program to be a server, a client
or both.

<h2>Reference Implementation</h2>
There is a reference implementation of this specification which makes
adding IOA to an application very easy. This was inspired by the DND
library, which adds Drag and Drop with almost no extra coding. The
implementation consists of two C source files, embed.c and embed.h.
These are in the common subdirectory of the Siag source tree.

<h3>Return Values</h3>
<pre>
#define EMBED_OK 0
#define EMBED_ERR 1
</pre>

Conditions that may give the return EMBED_ERR include out of memory,
specified object file does not exist, tag does not refer to a loaded
object.

<h3>Functions</h3>
<pre>
int embed_init(Widget toplevel)
</pre>
Called before any other functions.
<pre>
char *embed_load(char *filename)
</pre>
Loads an object. Returns the file name if successful, otherwise NULL.
This is used as a tag to the object in subsequent calls to
embedding functions.
<pre>
int embed_unload(char *tag)
</pre>
Unloads a previously loaded object.
<pre>
int embed_open(char *tag)
</pre>
Starts the creating server program according to the description
comment. If there is no description comment, as is the case with
X11 Bitmap files created by nonconforming applications, the file
is loaded into the application <b>bitmap</b>.
<pre>
int embed_save(char *filename, char *command, Pixmap bitmap)
</pre>
A new object file is created, using filename as file name, command
as the description (without the "EmBeD") and bitmap as the bitmap
of depth 1 which should be displayed by a client.
<pre>
int embed_print(FILE *fp, char *tag, int x, int y)
</pre>
Creates Postscript code to print the object at offset x,y on a page.
This is not yet implemented, only the outline rectangle is drawn.
<pre>
int embed_size(char *tag, unsigned int width, unsigned int height)
</pre>
Returns the width and height of the object.
<pre>
int embed_draw(Drawable d, int x, int y, char *tag)
</pre>
Draws the object on the specified drawable.

<h3>Conforming Applications</h3>
Siag and Pathetic Writer use the reference implementation to
create and use objects. Egon Animator will do so when it is ready.
<p>
Many applications created before the IOA specification are capable
of creating and/or displaying X11 Bitmaps, including XPaint, Netscape,
Chimera and XV.

<h2>Discussion about File Formats</h2>
The most basic use for this feature is for plain images, with no regard
to the "objectisms". However, the XBM format is not very good for this
purpose. It is black-and-white and uses a lot of disk space even for
small pictures. There are a few other candidates for the job, but none
that have all these three properties:
<ul>
<li>No patented algorithm
<li>Lossless
<li>Can be displayed by popular applications like Netscape
</ul>
The format which comes closest is XPM, which is almost an X standard.
Would be almost perfect, were it not for the fact that
Netscape can't display XPM. Chimera can, however.
<p>
XPM shares with XBM the property that the file format is plain C
which can trivially be #included in a C program. This makes it
monumentally simple to create a basic object server.

<hr>
<address>Ulric Eriksson - July 1997 - ulric@siag.nu</address>
</body>
</html>