00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef IOHANDLER_H
00023 #define IOHANDLER_H
00024
00025 #include <cstdio>
00026 #include <gdkmm/pixbuf.h>
00027 #include <glibmm/ustring.h>
00028 #include <gtkmm/textbuffer.h>
00029 #include <map>
00030
00031 #include "case.h"
00032 #include "iconmanager.h"
00033 #include "sprite.h"
00034
00036 namespace IO {
00037
00039 enum Code { CODE_OK= 1,
00040 CODE_OPEN_FAILED= 0,
00041 CODE_WRONG_MAGIC_NUM= -1,
00042 CODE_WRONG_VERSION= -2,
00043 CODE_VALIDATE_FAILED= -3
00044 };
00045
00049 struct _PWTHeader {
00050 int ident;
00051 int version;
00052
00053
00054 int overviewOffset;
00055 int overridesOffset;
00056 int charOffset;
00057 int imgOffset;
00058 int bgOffset;
00059 int evidenceOffset;
00060 int locationOffset;
00061 int audioOffset;
00062 int testimonyOffset;
00063 int blockOffset;
00064 };
00065 typedef struct _PWTHeader PWTHeader;
00066
00068 const int FILE_MAGIC_NUM=(('T' << 16) + ('W' << 8) + 'P');
00069
00071 const int FILE_VERSION=10;
00072
00074 const Glib::ustring SPR_MAGIC_NUM="SPR";
00075
00077 const int SPR_VERSION=10;
00078
00080 const long RESOURCE_FILE_SIZE=192434;
00081
00089 IO::Code save_case_to_file(const Glib::ustring &path, const Case::Case &pcase,
00090 const BufferMap &buffers,
00091 std::map<Glib::ustring, Glib::ustring> &bufferDescriptions);
00092
00099 IO::Code export_case_to_file(const Glib::ustring &path, const Case::Case &pcase, const BufferMap &buffers);
00100
00108 IO::Code load_case_from_file(const Glib::ustring &path, Case::Case &pcase,
00109 BufferMap &buffers,
00110 std::map<Glib::ustring, Glib::ustring> &bufferDescriptions);
00111
00117 IO::Code save_sprite_to_file(const Glib::ustring &path, const Sprite &spr);
00118
00124 IO::Code export_sprite_to_file(const Glib::ustring &path, const Sprite &spr);
00125
00131 IO::Code load_sprite_from_file(const Glib::ustring &path, Sprite &spr);
00132
00137 void write_string(FILE *f, const Glib::ustring &str);
00138
00143 Glib::ustring read_string(FILE *f);
00144
00149 void write_export_image(FILE *f, const Glib::RefPtr<Gdk::Pixbuf> &pixbuf);
00150
00155 void write_pixbuf(FILE *f, const Glib::RefPtr<Gdk::Pixbuf> &pixbuf);
00156
00161 Glib::RefPtr<Gdk::Pixbuf> read_pixbuf(FILE *f);
00162
00167 void add_recent_file(const Glib::ustring &uri, const Glib::ustring &display);
00168
00173 IO::Code read_recent_files(std::vector<StringPair> &vec);
00174
00179 IO::Code unpack_resource_file(const Glib::ustring &file);
00180
00185 IO::Code read_icons_from_file(IconMap &icons);
00186
00187 };
00188
00189 #endif