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
|
/*
Copyright (c) 2003 Bruno T. C. de Oliveira
LICENSE INFORMATION:
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Copyright (c) 2002 Bruno T. C. de Oliveira
INFORMA��ES DE LICEN�A:
Este programa � um software de livre distribui��o; voc� pode
redistribu�-lo e/ou modific�-lo sob os termos da GNU General
Public License, conforme publicado pela Free Software Foundation,
pela vers�o 2 da licen�a ou qualquer vers�o posterior.
Este programa � distribu�do na esperan�a de que ele ser� �til
aos seus usu�rios, por�m, SEM QUAISQUER GARANTIAS; sem sequer
a garantia impl�cita de COMERCIABILIDADE ou DE ADEQUA��O A
QUALQUER FINALIDADE ESPEC�FICA. Consulte a GNU General Public
License para obter mais detalhes (uma c�pia acompanha este
programa, armazenada no arquivo COPYING).
*/
#ifndef _btco_aewan_document_h
#define _btco_aewan_document_h
#include "layer.h"
#include "aeff.h"
struct _Document {
int layer_count; /* how many layers in document */
Layer **layers; /* vector of pointers to layers */
char *metainfo; /* additional textual information. The program will
* invoke an external editor when the user wants
* to edit the contents of this string. */
};
typedef struct _Document Document;
/* Creates a new, empty document. */
Document *document_create(void);
/* Destroys a previously created document */
void document_destroy(Document *doc);
/* Adds a new layer to the given document. After the call, the layer
* will belong to the document and no other references to it should
* be kept. */
void document_add_layer(Document *doc, Layer *layer);
/* Add a new layer to the given document, inserting it just before
* the layer whose index is i. Prerequsite: 0 <= i <= doc->layer_count.
* Notice that document_add_layer(doc, l) is equivalent to
* document_insert_layer(doc, doc->layer_count, l) */
void document_insert_layer(Document *doc, int i, Layer *layer);
/* Deletes layer i from the document. */
void document_del_layer(Document *doc, int i);
/* Convenience function that obtains the "nominal width and height"
* of the document, which are the dimensions of the first layer,
* if the document has any layers, or some sensible defaults if
* the document has none */
void document_get_nom_dim(Document *doc, int *w, int *h);
/* Saves document to file f */
void document_save(Document *doc, AeFile *f);
/* Loads a document from file f. If the loading succeeds, returns
* a dynamically allocated document. If the loading fails, returns NULL.
* This function reads the OLD, binary file format. */
Document *document_load_OLD(FILE *f);
/* Loads a document from file f. If the loading succeeds, returns
* a dynamically allocated document. If the loading fails, returns NULL.
* This function reads the NEW, zipped-text format.
*
* On error, this function returns NULL and aeff_get_error can be
* called in order to obtain an error description.
*/
Document *document_load(AeFile *f);
/* A wrapper that opens the file, detects the format and calls
* either document_load or document_load_OLD.
*
* On error, this function returns NULL and aeff_get_error can
* be called in order to obtain an error description.
*/
Document *document_load_from(const char *filename);
/* Gets the character and attribute at position x, y when viewing
* the image as a composite. That is, go through all layers and see
* which ones are transparent, visible, etc, and thus calculate the
* resulting char/attr of the given cell. */
Cell document_calc_effective_cell(Document *doc, int x, int y);
#endif
|