[Gtab-cvs] src gtfile.cpp,NONE,1.1 gtfile.h,NONE,1.1 gtzfile.cpp,NONE,1.1 gtzfile.h,NONE,1.1 frame.c
Status: Alpha
Brought to you by:
m0ta
|
From: m0ta <m0...@us...> - 2006-04-15 22:06:09
|
Update of /cvsroot/gtab/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15346 Modified Files: frame.cpp Added Files: gtfile.cpp gtfile.h gtzfile.cpp gtzfile.h Log Message: * some file stuff --- NEW FILE: gtzfile.h --- /* gtab: A tablature authoring tool for Windows. Copyright (C) 2004, 2005 Matthias Vogelgesang 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 Samvel Avanesov <se...@ya...> Jean-Sebastien Valette <jea...@fr...> Jelmer Vernooij <je...@sa...> Matthias Vogelgesang <you...@gm...> */ /** * @file gtzfile.h * @author Matthias Vogelgesang * @date 04-15-06 */ #ifndef GTAB_GTZFILE_H #define GTAB_GTZFILE_H #include "file.h" class GtabZlibFile : public AbstractFile { public: GtabZlibFile(const wxString& filename); ~GtabZlibFile() {} /** * @brief Load data from gtabFile into the given model. * @param model The place to store the data. */ bool load(Controller *); /** * @brief Save data in gtab format. * @param model Which data to save. */ bool save(Controller *); private: wxString filename_; }; #endif --- NEW FILE: gtzfile.cpp --- /* gtab: A tablature authoring tool for Windows. Copyright (C) 2004, 2005 Matthias Vogelgesang 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 Samvel Avanesov <se...@ya...> Jean-Sebastien Valette <jea...@fr...> Jelmer Vernooij <je...@sa...> Matthias Vogelgesang <you...@gm...> */ /** * @file gtzfile.cpp * @author Matthias Vogelgesang * @date 04-15-06 */ #include "gtzfile.h" #include "gtfile.h" #include <wx/wx.h> #include <wx/wfstream.h> #include <wx/zstream.h> GtabZlibFile::GtabZlibFile(const wxString& filename) : filename_(filename) { } bool GtabZlibFile::load(Controller *ctrl) { return true; } bool GtabZlibFile::save(Controller *ctrl) { // add error handling! GtabFile gf(filename_); if (!gf.save(ctrl)) return false; wxString tmpFileName = filename_ + wxT(".tmp"); wxRenameFile(filename_, tmpFileName); wxFileInputStream inStream(tmpFileName); wxFileOutputStream outStream(filename_); wxZlibOutputStream zStream(outStream, 9); const int bufferSize = 1024; char* buffer = new char[bufferSize]; while (!inStream.Eof()) { inStream.Read(buffer, bufferSize); int size = inStream.LastRead(); if (size > 0) zStream.Write(buffer, size); else break; } delete[] buffer; zStream.Close(); outStream.Close(); wxRemoveFile(tmpFileName); // doesnt yet remove, maybe stream still // associated with file return true; } Index: frame.cpp =================================================================== RCS file: /cvsroot/gtab/src/frame.cpp,v retrieving revision 1.103 retrieving revision 1.104 diff -C2 -d -r1.103 -r1.104 *** frame.cpp 5 Apr 2006 15:01:15 -0000 1.103 --- frame.cpp 15 Apr 2006 22:06:04 -0000 1.104 *************** *** 69,73 **** #include "ptbfile.h" #include "gpfile.h" ! #include "musicxmlfile.h" #ifdef _DEBUG --- 69,74 ---- #include "ptbfile.h" #include "gpfile.h" ! #include "gtfile.h" ! #include "gtzfile.h" #ifdef _DEBUG *************** *** 269,276 **** void Frame::onFileOpen(wxCommandEvent& WXUNUSED(event)) { ! enum FilterIndices { GTAB_FILES, POWER_TAB_FILES, GUITAR_PRO_FILES, MIDI_FILES }; wxFileDialog fileDialog(this, _("Choose a file"), currentDirectory_, wxT(""), ! _("gtab Files (*.gtb)|*.gtb|PowerTab Files (*.ptb)|*.ptb|Guitar Pro Files (*.gp*)|*.gp*|MIDI Files (*.mid)|*.mid"), wxOPEN); --- 270,277 ---- void Frame::onFileOpen(wxCommandEvent& WXUNUSED(event)) { ! enum FilterIndices { GTABZ_FILES, GTAB_FILES, POWER_TAB_FILES, GUITAR_PRO_FILES, MIDI_FILES }; wxFileDialog fileDialog(this, _("Choose a file"), currentDirectory_, wxT(""), ! _("compressed gtabFiles (*.gtz)|*.gtz|gtab Files (*.gt)|*.gt|PowerTab Files (*.ptb)|*.ptb|Guitar Pro Files (*.gp*)|*.gp*|MIDI Files (*.mid)|*.mid"), wxOPEN); *************** *** 278,281 **** --- 279,285 ---- SetTitle(fileDialog.GetFilename() + _(" - gtab")); switch (fileDialog.GetFilterIndex()) { + case GTABZ_FILES: + break; + case GTAB_FILES: break; *************** *** 312,321 **** void Frame::onFileSaveAs(wxCommandEvent& WXUNUSED(event)) { wxFileDialog fileDialog(this, _("Choose a file"), currentDirectory_, wxT(""), ! _("MusicXML Files (*.xml)|*.xml"), wxSAVE); if (fileDialog.ShowModal() == wxID_OK) { ! //MusicXMLFile xf(fileDialog.GetPath().c_str()); ! //controller_->saveFile(xf); } } --- 316,338 ---- void Frame::onFileSaveAs(wxCommandEvent& WXUNUSED(event)) { + enum FilterIndices { GTABZ_FILES, GTAB_FILES, POWER_TAB_FILES }; + wxFileDialog fileDialog(this, _("Choose a file"), currentDirectory_, wxT(""), ! wxT("compressed Gtab Files (*.gtz)|*.gtz|gtab Files (*.gt)|*.gt"), wxSAVE); if (fileDialog.ShowModal() == wxID_OK) { ! switch (fileDialog.GetFilterIndex()) { ! case GTABZ_FILES: { ! GtabZlibFile gtf(fileDialog.GetPath()); ! gtf.save(controller_); ! break; ! } ! ! case GTAB_FILES: { ! GtabFile gtf(fileDialog.GetPath()); ! gtf.save(controller_); ! break; ! } ! } } } --- NEW FILE: gtfile.cpp --- /* gtab: A tablature authoring tool for Windows. Copyright (C) 2004, 2005 Matthias Vogelgesang 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 Samvel Avanesov <se...@ya...> Jean-Sebastien Valette <jea...@fr...> Jelmer Vernooij <je...@sa...> Matthias Vogelgesang <you...@gm...> */ /** * @file gtfile.cpp * @author Matthias Vogelgesang * @date 04-15-06 */ #include "gtfile.h" #include <wx/file.h> GtabFile::GtabFile(const wxString& filename) : filename_(filename) { } bool GtabFile::load(Controller *ctrl) { return true; } bool GtabFile::save(Controller *ctrl) { wxFile file(filename_.c_str(), wxFile::write); file.Write(wxT("test")); file.Close(); return true; } --- NEW FILE: gtfile.h --- /* gtab: A tablature authoring tool for Windows. Copyright (C) 2004, 2005 Matthias Vogelgesang 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 Samvel Avanesov <se...@ya...> Jean-Sebastien Valette <jea...@fr...> Jelmer Vernooij <je...@sa...> Matthias Vogelgesang <you...@gm...> */ /** * @file gtfile.h * @author Matthias Vogelgesang * @date 04-15-06 */ #ifndef GTAB_GTFILE_H #define GTAB_GTFILE_H #include "file.h" class GtabFile : public AbstractFile { public: GtabFile(const wxString& filename); ~GtabFile() {} /** * @brief Load data from gtabFile into the given model. * @param model The place to store the data. */ bool load(Controller *); /** * @brief Save data in gtab format. * @param model Which data to save. */ bool save(Controller *); private: wxString filename_; }; #endif |