00001 /* 00002 * * 00003 * This program is free software; you can redistribute it and/or modify * 00004 * it under the terms of the GNU General Public License as published by * 00005 * the Free Software Foundation; either version 2 of the License, or * 00006 * (at your option) any later version. * 00007 * * 00008 * This program is distributed in the hope that it will be useful, * 00009 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00011 * GNU General Public License for more details. * 00012 * * 00013 * You should have received a copy of the GNU General Public License * 00014 * along with this program; if not, write to the * 00015 * Free Software Foundation, Inc., * 00016 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00017 */ 00018 00030 #ifndef RULEMANAGER_HPP_ 00031 #define RULEMANAGER_HPP_ 00032 00033 #include "rule.hpp" 00034 #include "ruleView.hpp" 00035 #include "fileManagerView.hpp" 00036 #include "ruleDiskManager.hpp" 00037 #include "mainController.hpp" 00038 #include <map> 00039 00040 using namespace std; 00041 00042 class RuleView; 00043 class RuleDiskManager; 00044 class MainController; 00045 00046 class RuleManager 00047 { 00048 public: 00049 RuleManager(MainController *controller); 00050 virtual ~RuleManager(); 00051 void setView(RuleView *view); 00052 void newRule(int width, int height); 00053 void newRule(Rule *rule); 00054 void ruleSelected(unsigned int ruleId); 00055 void cellChanged(GridType grid, int x, int y); 00056 void removeRule(); 00057 void copyGrids(); 00058 bool saveFile(); 00059 bool saveFileAs(); 00060 void openFile(); 00061 bool openPFile(wxString file); 00062 bool saveFilename(wxString file); 00063 wxArrayString getRuleList(); 00064 bool isModified(); 00065 wxString getFileName(); 00066 void clean(); 00067 bool checkRules(); 00068 Rule *getRule(unsigned int id); 00069 00070 private: 00072 RuleView *view; 00074 FileManagerView fileView; 00076 RuleDiskManager *diskManager; 00078 MainController *controller; 00080 map<unsigned int, Rule*> ruleList; 00082 unsigned int nextId; 00084 unsigned int currentRule; 00086 bool modified; 00088 bool needNewFile; 00090 wxString fileName; 00091 void updateGrids(bool changed); 00092 void updateList(); 00093 void deleteRules(); 00094 bool appendRules(bool mustDeleteRules, bool newFile); 00095 }; 00096 00097 #endif /*RULEMANAGER_HPP_*/