2 * This file is part of ShapeFusion (Copyright 2000 Tito Dal Canton)
4 * ShapeFusion is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * ShapeFusion is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with ShapeFusion; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 // Shapes class representing what's inside a Marathon shapes file.
22 // Note that, for keeping things simple and providing compatibility,
23 // the class doesn't store everything using the original on-disk format.
24 // For example, flags are expanded to bool fields and fixed point values
25 // are converted to doubles. Every bitmap is converted to a simple block
26 // of width*height pixels, regardless of its compression and pixel order.
27 // Conversions take place only when actually loading and writing files.
30 #ifndef SHAPESDOCUMENT_H
31 #define SHAPESDOCUMENT_H
33 #include "wx/docview.h"
34 #include "ShapesElements.h"
36 // class representing the contents of a Marathon shapes file
37 class ShapesDocument: public wxDocument, public ShapesElement
39 DECLARE_DYNAMIC_CLASS(ShapesDocument)
42 vector<ShapesCollection*> mCollections;
45 unsigned int CollectionCount(void) const;
46 // collection data access
47 int CollectionStatus(unsigned int id);
48 unsigned int CollectionFlags(unsigned int id) const;
49 bool CollectionDefined(unsigned int id, unsigned int chunk) const;
50 int CollectionVersion(unsigned int id, unsigned int chunk) const;
51 int CollectionType(unsigned int id, unsigned int chunk) const;
52 unsigned int CollectionFlags(unsigned int id, unsigned int chunk) const;
53 int CollectionScaleFactor(unsigned int id, unsigned int chunk) const;
54 unsigned int CollectionBitmapCount(unsigned int id, unsigned int chunk) const;
55 unsigned int CollectionColorTableCount(unsigned int id, unsigned int chunk) const;
56 unsigned int CollectionFrameCount(unsigned int id, unsigned int chunk) const;
57 unsigned int CollectionSequenceCount(unsigned int id, unsigned int chunk) const;
58 ShapesColorTable *GetColorTable(unsigned int coll, unsigned int chunk, unsigned int ct) const;
59 ShapesBitmap *GetBitmap(unsigned int coll, unsigned int chunk, unsigned int bitmap) const;
60 ShapesFrame *GetFrame(unsigned int coll, unsigned int chunk, unsigned int frame) const;
61 ShapesSequence *GetSequence(unsigned int coll, unsigned int chunk, unsigned int seq) const;
62 ShapesChunk* GetChunk(unsigned int coll, unsigned int chunk) const;
63 // collection alteration
64 void InsertColorTable(ShapesColorTable *ct, unsigned int coll, unsigned int chunk);
65 void DeleteColorTable(unsigned int coll, unsigned int chunk, unsigned int ct);
66 void InsertBitmap(ShapesBitmap *b, unsigned int coll, unsigned int chunk);
67 void DeleteBitmap(unsigned int coll, unsigned int chunk, unsigned int b);
68 void InsertFrame(ShapesFrame *f, unsigned int coll, unsigned int chunk);
69 void DeleteFrame(unsigned int coll, unsigned int chunk, unsigned int f);
70 void InsertSequence(ShapesSequence *s, unsigned int coll, unsigned int chunk);
71 void DeleteSequence(unsigned int coll, unsigned int chunk, unsigned int s);
73 bool DoOpenDocument(const wxString& file);
75 #if wxUSE_STD_IOSTREAM
76 wxSTD ostream& SaveObject(wxSTD ostream& stream);
77 wxSTD istream& LoadObject(wxSTD istream& stream);
78 wxSTD ostream& SavePatch(wxSTD ostream& stream, const ShapesDocument& other);
79 bool LoadPatch(wxSTD istream& stream);
81 wxOutputStream& SaveObject(wxOutputStream& stream);
82 wxInputStream& LoadObject(wxInputStream& stream);
83 wxOutputStream& SavePatch(wxOutputStream& stream, const ShapesDocument& other);
84 bool LoadPatch(wxInputStream& stream);
88 ~ShapesDocument(void);