iohandler.h

00001 /***************************************************************************
00002  *   Copyright (C) 2007 by Mike Polan                                      *
00003  *   kanadakid@gmail.com                                                   *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 // iohandler.h: I/O functionality
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; // magic number
00051         int version; // file version
00052         
00053         // byte offsets in data (relative to start of file)
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 }; // namespace IO
00188 
00189 #endif

Generated on Fri Feb 22 22:34:17 2008 for Phoenix Wright Case Editor API by  doxygen 1.5.3