COOPY » Guide
version 0.6.5
|
00001 // -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*- 00002 00003 /* 00004 * Copyright (C) 2010 Paul Fitzpatrick 00005 * CopyPolicy: Released under the terms of the GNU GPL v2.0. 00006 * 00007 */ 00008 00009 #ifndef COOPY_MERGEFRAME 00010 #define COOPY_MERGEFRAME 00011 00012 #include <coopy/CsvFile.h> 00013 #include <coopy/BookCompare.h> 00014 //#include <coopy/MergeOutputAccum.h> 00015 #include <coopy/Options.h> 00016 #include <coopy/Diff.h> 00017 #include <coopy/PolyBook.h> 00018 00019 using namespace coopy::store; 00020 using namespace coopy::cmp; 00021 using namespace coopy::app; 00022 00023 // wxwidgets library version issue 00024 #ifdef __APPLE__ 00025 #ifdef NDEBUG 00026 #undef NDEBUG 00027 #endif 00028 #endif 00029 00030 #include <wx/wx.h> 00031 #include <wx/wxprec.h> 00032 #include <wx/dcbuffer.h> 00033 #include <wx/image.h> 00034 #include <wx/cmdline.h> 00035 #include <wx/dirdlg.h> 00036 #include <wx/textdlg.h> 00037 #include <wx/filefn.h> 00038 #include <wx/filename.h> 00039 #include <wx/textctrl.h> 00040 #include <wx/url.h> 00041 #include <wx/filepicker.h> 00042 #include <wx/process.h> 00043 #include <wx/stdpaths.h> 00044 #include <wx/txtstrm.h> 00045 #include <wx/arrstr.h> 00046 #include <wx/dir.h> 00047 #include <wx/config.h> 00048 #include <wx/log.h> 00049 00050 #include <string> 00051 #include <list> 00052 #include <iostream> 00053 00054 00055 /* 00056 class MergeApp: public wxApp { 00057 private: 00058 bool silent; 00059 public: 00060 MergeApp() { 00061 silent = false; 00062 } 00063 00064 virtual bool OnInit(); 00065 00066 virtual void OnInitCmdLine(wxCmdLineParser& parser); 00067 virtual bool OnCmdLineParsed(wxCmdLineParser& parser); 00068 }; 00069 00070 static const wxCmdLineEntryDesc g_cmdLineDesc [] = { 00071 { wxCMD_LINE_SWITCH, wxT("h"), wxT("help"), wxT("displays help on the command line parameters"), 00072 wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP }, 00073 { wxCMD_LINE_SWITCH, wxT("s"), wxT("silent"), wxT("disables the GUI") }, 00074 { wxCMD_LINE_OPTION, wxT("r"), wxT("res"), wxT("set resource location"), 00075 wxCMD_LINE_VAL_STRING, 0 }, 00076 //{ wxCMD_LINE_PARAM, NULL, NULL, wxT("input file"), wxCMD_LINE_VAL_STRING, 00077 //wxCMD_LINE_PARAM_OPTIONAL }, 00078 { wxCMD_LINE_NONE }, 00079 }; 00080 00081 00082 void MergeApp::OnInitCmdLine(wxCmdLineParser& parser) { 00083 parser.SetDesc (g_cmdLineDesc); 00084 // must refuse '/' as parameter starter or cannot use "/path" style paths 00085 parser.SetSwitchChars (wxT("--")); 00086 } 00087 00088 bool MergeApp::OnCmdLineParsed(wxCmdLineParser& parser) { 00089 silent = parser.Found(wxT("s")); 00090 00091 wxString location; 00092 if (parser.Found(wxT("r"),&location)) { 00093 string loc = conv(location); 00094 printf("*** should set location to [%s]\n", loc.c_str()); 00095 } 00096 00097 // to get at your unnamed parameters use 00098 wxArrayString files; 00099 for (size_t i = 0; i < parser.GetParamCount(); i++) { 00100 files.Add(parser.GetParam(i)); 00101 } 00102 00103 // and other command line parameters 00104 00105 // then do what you need with them. 00106 00107 return true; 00108 } 00109 00110 #ifdef WIN32 00111 IMPLEMENT_APP_NO_MAIN(MergeApp); 00112 #else 00113 IMPLEMENT_APP(MergeApp); 00114 #endif 00115 00116 */ 00117 00118 class MergeFrame: public wxFrame 00119 { 00120 DECLARE_CLASS(MergeFrame) 00121 DECLARE_EVENT_TABLE() 00122 00123 private: 00124 wxBoxSizer *topsizer; 00125 wxFilePickerCtrl *files[5]; 00126 00127 wxString config_tags[5]; 00128 00129 std::string mode; 00130 00131 wxButton *action_button; 00132 wxBoxSizer *boxes[5]; 00133 00134 public: 00135 00136 MergeFrame(wxWindow *parent, const wxString& title, const wxPoint& pos, const wxSize& size); 00137 00138 virtual bool OnInit(); 00139 00140 void OnQuit(wxCommandEvent& event); 00141 void OnAbout(wxCommandEvent& event); 00142 00143 void OnSaveJob(wxCommandEvent& event); 00144 void OnLoadJob(wxCommandEvent& event); 00145 00146 void SetMode(const char *mode); 00147 00148 void OnExit(wxCloseEvent& event) { 00149 //Destroy(); 00150 //printf("Exiting ssmerge\n"); 00151 Show(FALSE); 00152 } 00153 00154 void OnMerge(wxCommandEvent& event); 00155 00156 enum 00157 { 00158 TEXT_Main = wxID_HIGHEST + 101, 00159 TEXT_Parent, 00160 TEXT_Local, 00161 TEXT_Remote, 00162 TEXT_Output, 00163 TEXT_MORE1, 00164 TEXT_MORE2, 00165 TEXT_MORE3, 00166 ID_Quit, 00167 ID_Merge, 00168 ID_About, 00169 ID_SaveJob, 00170 ID_LoadJob, 00171 }; 00172 }; 00173 00174 00175 #endif