MutApp.cpp
gehe zur Dokumentation dieser Datei
00001 
00175 // ---------------------------------------------------------------------------
00176 // headers
00177 // ---------------------------------------------------------------------------
00178 
00179 // For compilers that support precompilation, includes "wx/wx.h".
00180 #include "Defs.h"
00181 #include "wx/wxprec.h"
00182 #include "wx/xrc/xmlres.h"
00183 #include "wx/xrc/xh_all.h"
00184 #include "wx/fs_zip.h"
00185 #include "wx/cshelp.h"
00186 #include "wx/aboutdlg.h"
00187 #include "wx/generic/aboutdlgg.h"
00188 #include "wx/cmdline.h"
00189 #include "wx/file.h"
00190 #include "wx/event.h"
00191 
00192 
00193 #ifdef __BORLANDC__
00194 #pragma hdrstop
00195 #endif
00196 
00197 #ifndef WX_PRECOMP
00198 #include "wx/wx.h"
00199 //    #include "wx/mdi.h"
00200 #include "wx/stdpaths.h"
00201 #include "wx/filename.h"
00202 #include "wx/imagpng.h"
00203 #endif
00204 
00205 //#include "wx/toolbar.h"
00206 
00207 #if !defined(__WXMSW__)
00208 #include "Icon/Mutabor.xpm"
00209 #endif
00210 
00211 //#include "Mutabor.rh"
00212 #include "MutApp.h"
00213 #include "MutFrame.h"
00214 #include "MutDocument.h"
00215 #include "MutView.h"
00216 #include "DevMidi.h"
00217 #include "MutConfDlg.h"
00218 #include "resourceload.h"
00219 #include "Action.h"
00220 #include "stclanguage.h"
00221 
00222 #ifdef __WXMAC__
00223 #include <ApplicationServices/ApplicationServices.h>
00224 #endif
00225 
00226 using namespace mutaborGUI;
00227 
00228 wxHtmlHelpController * HelpController = (wxHtmlHelpController *) NULL;
00229 #if wxUSE_PRINTING_ARCHITECTURE
00230 
00232 wxPrintData *g_printData = (wxPrintData*) NULL;
00233 wxPageSetupData *g_pageSetupData = (wxPageSetupData*) NULL;
00234 
00235 #endif // wxUSE_PRINTING_ARCHITECTURE
00236 
00237 IMPLEMENT_APP(MutApp)
00238 
00239 // ===========================================================================
00240 // implementation
00241 // ===========================================================================
00242 
00243 // ---------------------------------------------------------------------------
00244 // MutApp
00245 // ---------------------------------------------------------------------------
00246 
00247 
00248 #define OPENMENU                                \
00249         { wxMenu * menu = new wxMenu;
00250 
00251 #define CLOSEMENU(name)                         \
00252         menuBar->Append(menu, name); }
00253 
00254 #define MENUITEM(name, id, help)                \
00255         menu->Append(id, name, help)
00256 
00257 #define MENUCHECKITEM(name, id, help)           \
00258         menu->AppendCheckItem(id, name, help)
00259 
00260 #define MENUITEM_ADD(name, id, help, add)       \
00261         menu->Append(id, name, help, add)
00262 
00263 #define MENUITEM_SEPARATOR                      \
00264         menu->AppendSeparator()
00265 
00266 // Initialise this in OnInit, not statically
00267 bool MutApp::OnInit()
00268 {
00269         /* Short form for
00270            for (int i = MUT_FIRST; i < MUT_LAST; i++) 
00271            wxRegisterId(i);
00272         */
00273         wxRegisterId(MUT_LAST);
00274 
00275         SetAppName(_T(PACKAGE));
00276         SetClassName(_T(PACKAGE_NAME));
00277         
00278         wxStandardPaths& sp = (wxStandardPaths &) wxStandardPaths::Get();
00279 
00280 #ifdef __LINUX__
00281         sp.SetInstallPrefix(_T(PREFIX));
00282 #endif
00283 
00284         quitting = false;
00285 
00286         // initialize the languages
00287         m_locale.Init(wxLANGUAGE_DEFAULT);
00288 
00289         // TODO: Check this!
00290         // normally this wouldn't be necessary as the catalog files would be found
00291         // in the default locations, but under Windows then the program is not
00292         // installed the catalogs are in the parent directory (because the binary
00293         // is in a subdirectory of samples/internat) where we wouldn't find them by
00294         // default
00295         wxLocale::AddCatalogLookupPathPrefix(_T("."));
00296         wxLocale::AddCatalogLookupPathPrefix(wxT(".."));
00297 
00298         // Initialize the catalogs we'll be using
00299         m_locale.AddCatalog(wxT("mutabor"));
00300         m_locale.AddCatalog(wxT("wxstd"));
00301 #ifdef __LINUX__
00302         {
00303                 wxLogNull noLog;
00304                 m_locale.AddCatalog(_T("fileutils"));
00305         }
00306 #endif
00307 
00308 
00309 #ifdef DEBUG
00310         std::cout << (muT(__FUNCTION__).ToUTF8()) << std::endl;
00311         std::cout << (muT(typeid(m_locale).name()).ToUTF8()) << std::endl;
00312         std::cout << "ConfigDir:        "
00313 
00314                   << (const char *)(sp.GetConfigDir().ToUTF8()) << std::endl
00315                   << "DataDir:          "
00316                   << (const char *)(sp.GetDataDir().ToUTF8()) << std::endl
00317                   << "DocumentsDir:     "
00318                   << (const char *)(sp.GetDocumentsDir().ToUTF8()) << std::endl
00319                   << "ExecutablePath:   "
00320                   << (const char *)(sp.GetExecutablePath().ToUTF8()) << std::endl
00321 
00322 #if defined(__UNIX__) && !defined(__WXMAC__)
00323                   << "InstallPrefix:    " << (const char *)(sp.GetInstallPrefix().ToUTF8())
00324                   << std::endl
00325 #endif
00326                   << "LocalDataDir:     " << (const char *)(sp.GetLocalDataDir().ToUTF8())
00327                   << std::endl
00328                   << "PluginsDir:       " << (const char *)(sp.GetPluginsDir().ToUTF8())
00329                   << std::endl
00330                   << "ResourcesDir:     " << (const char *)(sp.GetResourcesDir().ToUTF8())
00331                   << std::endl
00332                   << "TempDir:          " << (const char *)(sp.GetTempDir().ToUTF8())
00333                   << std::endl
00334                   << "UserConfigDir:    " << (const char *)(sp.GetUserConfigDir().ToUTF8())
00335                   << std::endl
00336                   << "UserDataDir:      " << (const char *)(sp.GetUserDataDir().ToUTF8())
00337                   << std::endl
00338                   << "UserLocalDataDir: " << (const char *)(sp.GetUserLocalDataDir().ToUTF8())
00339                   << std::endl;
00340 
00341         std::cout
00342                 << "LocalizedResourcesDir(Can): "
00343                 << (const char *)(sp.GetLocalizedResourcesDir(m_locale.GetCanonicalName(),
00344                                                               sp.ResourceCat_None).ToUTF8())
00345                 << std::endl
00346                 << "LocalizedResourcesDir(Can,Messages): "
00347                 << (const char *)(sp.GetLocalizedResourcesDir(m_locale.GetCanonicalName(),
00348                                                               sp.ResourceCat_Messages).ToUTF8())
00349                 << std::endl
00350                 << "LocalizedResourcesDir(): "
00351                 << (const char *)(sp.GetLocalizedResourcesDir(m_locale.GetName(),
00352                                                               sp.ResourceCat_None).ToUTF8())
00353                 << std::endl
00354                 << "LocalizedResourcesDir(Messages): "
00355                 << (const char *)(sp.GetLocalizedResourcesDir(m_locale.GetName(),
00356                                                               sp.ResourceCat_Messages).ToUTF8())
00357                 << std::endl;
00358 
00359 #endif
00360 
00361         
00362         // We are using .png files for some extra bitmaps.
00363         wxImageHandler * pnghandler = new wxPNGHandler;
00364         wxImage::AddHandler(pnghandler);
00365         wxImage::AddHandler(new wxGIFHandler);
00366         
00367         wxFileSystem::AddHandler(new wxZipFSHandler);
00368 
00369         wxXmlResource::Get()->InitAllHandlers();
00370         wxString resfilename = GetResourceName(_T("Mutabor.xrc"));
00371         wxXmlResource::Get()->Load(resfilename);
00372 
00373         wxHelpControllerHelpProvider* provider = new wxHelpControllerHelpProvider;
00374         wxHelpProvider::Set(provider);
00375         HelpController = new wxHtmlHelpController();
00376         provider->SetHelpController(HelpController);
00377 
00378         // we want to name the help files according to the lanuage.
00379         if (!HelpController->Initialize(GetResourceName(_("Help.zip"))))
00380                 std::cerr << "Warning: could not initialize Help system: "
00381                           << (const char *)(wxString(_("Help.zip")).ToUTF8()) << std::endl;
00382 
00383 
00384         //  restrict to having <= 1 doc open at any time
00385         document_manager.SetMaxDocsOpen(5);
00386         //  establish a doc template for the doc,view pair
00387         new wxDocTemplate(&document_manager, 
00388                           _("Mutabor logic file"), 
00389                           wxT("*.mut"), 
00390                           wxT("") /*dir*/, 
00391                           wxT("mut"), 
00392                           wxT("mutabor_logic_document"), 
00393                           wxT("mutabor_logic_view"), 
00394                           CLASSINFO(mutaborGUI::MutDocument), 
00395                           CLASSINFO(mutaborGUI::MutView) );
00396 #ifdef __WXMAC__
00397         wxFileName::MacRegisterDefaultTypeAndCreator( wxT("mut") , 'MUTA' , 'MUTA' ) ;
00398 #endif
00399 
00400 #if defined(__WXMAC__)
00401         // || defined(__WXCOCOA__)
00402         // Make a common menubar
00403 
00404         wxApp::SetExitOnFrameDelete(false);
00405         wxApp::s_macAboutMenuItemId = CM_ABOUT;
00406         wxApp::s_macPreferencesMenuItemId = CM_SETUP;
00407         wxApp::s_macExitMenuItemId = CM_EXIT;
00408         wxApp::s_macHelpMenuTitleName = _("&Help");
00409         wxMenuBar *menuBar = new wxMenuBar;
00410         MakeFileMenu(menuBar,ProgramMenu);
00411         MakeViewMenu(menuBar,ProgramMenu);
00412         MakeHelpMenu(menuBar);
00413         wxMenuBar::MacSetCommonMenuBar(menuBar);
00414         
00415 #endif
00416 
00417         // This call parses the command line
00418         if (!wxApp::OnInit()) return false;
00419 
00420         MidiInit();
00421         RestoreState();
00422                 
00423         if (!GetTopWindow()) {
00424                 MutFrame * frame = CreateMainFrame(EditorMenu);
00425                 frame->RestoreState();
00426                 wxCommandEvent event(CM_ROUTES);
00427                 frame->CmRoutes(event);
00428                 frame->Show(true);
00429         }
00430 
00431         return true;
00432 }
00433 
00434 void MutApp::OnInitCmdLine(wxCmdLineParser&  parser) {
00435         const wxCmdLineEntryDesc cmdLineDesc[] = {
00436                 { wxCMD_LINE_PARAM,  NULL, NULL, _("logic file"), 
00437                   wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_MULTIPLE|wxCMD_LINE_PARAM_OPTIONAL },
00438                 { wxCMD_LINE_NONE }
00439         };
00440 
00441         wxApp::OnInitCmdLine(parser);
00442         parser.SetDesc(cmdLineDesc);
00443 
00444 #ifdef DEBUG
00445         debugFlags::InitCommandLine(parser);
00446 #endif
00447 
00448         
00449 }
00450 
00451 bool MutApp::OnCmdLineParsed(wxCmdLineParser&  parser) {
00452         if (!wxApp::OnCmdLineParsed(parser)) return false;
00453 #ifdef DEBUG
00454         debugFlags::ProcessCommandLine(parser);
00455 #endif
00456         wxString str;
00457         int count = parser.GetParamCount();
00458         for (int i = 0; i<count;i++)
00459         {
00460                 // we have a document to open
00461                 str = parser.GetParam(i);
00462                 printf("cmd line param: %ls\n", WXSTRINGCAST(str));
00463                 // this will probably see if the file exists, and has the right extension
00464 
00465 //              MutFrame * frame = CreateMainFrame(EditorMenu);
00466 //              frame->OpenFile(str);
00467 
00468                 document_manager.CreateDocument(str, wxDOC_SILENT);
00469         }
00470 
00471         DEBUGLOG (other, _T("Command line parsed."));
00472         return true;
00473 }
00474 
00475 // Extend event processing to search the view's event table
00476 bool MutApp::ProcessEvent(wxEvent& event)
00477 {
00478         bool retval =  wxApp::ProcessEvent(event);
00479 #ifdef DEBUG
00480         if (!retval)
00481                 DEBUGLOG(eventqueue,_T("Unhandled event: Type %d"), event.GetEventType());
00482 #endif
00483         return retval;
00484 }
00485 
00486 void MutApp::PassEventToDocManagerCMD(wxCommandEvent& event)
00487 {
00488         DEBUGLOG(eventqueue,_T("Command"));
00489         if (!document_manager.ProcessEvent(event)) 
00490                 event.Skip();
00491 }
00492 void MutApp::PassEventToDocManagerUPD(wxUpdateUIEvent& event)
00493 {
00494         DEBUGLOG(eventqueue,_T("UpdateUI"));
00495         if (!document_manager.ProcessEvent(event)) 
00496                 event.Skip();
00497 }
00498 
00499 void MutApp::OnMRUFile(wxCommandEvent& event)
00500 {
00501     int n = event.GetId() - wxID_FILE1;  // the index in MRU list
00502     wxString filename(document_manager.GetHistoryFile(n));
00503     if ( !filename.empty() )
00504     {
00505         // verify that the file exists before doing anything else
00506         if ( wxFile::Exists(filename) )
00507         {
00508             // try to open it
00509             if (!document_manager.CreateDocument(filename, wxDOC_SILENT))
00510             {
00511                 // remove the file from the MRU list. The user should already be notified.
00512                 document_manager.RemoveFileFromHistory(n);
00513 
00514                 wxLogError(_("The file '%s' couldn't be opened.\nIt has been removed from the most recently used files list."),
00515                        filename.c_str());
00516             } else {
00517                     wxView * v = document_manager.GetCurrentView();
00518                     if (v) {
00519                             wxWindow * w = v->GetFrame();
00520                             if (w) {
00521                                     w->Raise();
00522                             }
00523                     }
00524             }
00525         }
00526         else
00527         {
00528             // remove the bogus filename from the MRU list and notify the user
00529             // about it
00530             document_manager.RemoveFileFromHistory(n);
00531 
00532             wxLogError(_("The file '%s' doesn't exist and couldn't be opened.\nIt has been removed from the most recently used files list."),
00533                        filename.c_str());
00534         }
00535     }
00536 }
00537 
00538 
00539 
00540 BEGIN_EVENT_TABLE(MutConfigDialog, ConfigDlg)
00541         EVT_BUTTON(::wxID_HELP, MutConfigDialog::CmHelp)
00542 END_EVENT_TABLE()
00543 
00544 void MutApp::CmSetup (wxCommandEvent& event)
00545 {
00546 
00547         MutConfigDialog * config;
00548         config = new MutConfigDialog((wxFrame *) NULL);
00549 
00550         if (config) {
00551                 int value = config->ShowModal();
00552                 config->Destroy();
00553         }
00554 }
00555 
00556 void MutApp::CmAbout (wxCommandEvent& event)
00557 {
00558 
00559         /*
00560           (void)wxMessageBox(wxString::Format(_("%s\nAuthors: \n%s\nUsage: %s"),
00561                                               mumT(PACKAGE_STRING),
00562                                               _T("Ruediger Krausze <krausze@mail.berlios.de>\n")
00563                                               _T("Tobias Schlemmer <keinstein@mail.berlios.de>\n"),
00564                                               mumT(PACKAGE)),
00565                              wxString::Format(_("About %s"),mumT(PACKAGE_NAME)));
00566         */
00567         /*      AppAbout * about;
00568                 about = new AppAbout((wxFrame *) NULL);
00569                 about->Destroy();
00570 
00571         */
00572         // setup path
00573         wxStandardPathsBase &path = wxStandardPaths::Get();
00574         wxAboutDialogInfo info;
00575         info.SetCopyright(_("(c) 2005-2011 TU Dresden"));
00576         info.SetVersion(_T(PACKAGE_VERSION));
00577         info.SetWebSite(_T("http://www.math.tu-dresden.de/~mutabor/"));
00578         info.SetIcon(wxIcon(wxFileName(path.GetResourcesDir(),
00579                                        _T("about"),
00580                                        _T("png")).GetFullPath(),
00581                             wxBITMAP_TYPE_PNG));
00582         info.SetDescription(_("An application to implement different tuning logics.\n Both fixed, adaptive and mutable tunings are supported."));
00583         info.AddArtist(_("Rudolf Wille (mathematical foundation)"));
00584         info.AddArtist(_("Tobias Schlemmer (new icon/splash)"));
00585         info.AddDeveloper(_("Bernhard Ganter"));
00586         info.AddDeveloper(_("Volker Abel"));
00587         info.AddDeveloper(_("Peter Reiss"));
00588         info.AddDeveloper(_("Ruediger Krausze <krausze@mail.berlios.de>"));
00589         info.AddDeveloper(_("Tobias Schlemmer <keinstein@mail.berlios.de>"));
00590         info.AddDocWriter(_("Volker Abel"));
00591         info.AddDocWriter(_("Peter Reiss"));
00592         info.AddDocWriter(_("Ruediger Krausze <krausze@mail.berlios.de>"));
00593         info.AddDocWriter(_("Tobias Schlemmer <keinstein@mail.berlios.de>"));
00594         info.AddTranslator(_("English: Tobias Schlemmer"));
00595 
00596         wxGenericAboutBox(info);
00597 }
00598 
00599 
00600 AppAbout::AppAbout (wxWindow *parent, long style)
00601                 : wxDialog (parent, -1, wxEmptyString,
00602                             wxDefaultPosition, wxDefaultSize,
00603                             wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
00604 {
00605 
00606         // setup path
00607         wxStandardPathsBase &path = wxStandardPaths::Get();
00608 
00609 
00610         // sets the application icon
00611         SetTitle (_("About ..."));
00612 
00613         // about info
00614         wxGridSizer *aboutinfo = new wxFlexGridSizer (2, 5, 5);
00615         aboutinfo->Add (new wxStaticText(this, -1, _("Version: ")));
00616         aboutinfo->Add (new wxStaticText(this, -1, _T(PACKAGE_VERSION)));
00617         aboutinfo->Add (new wxStaticText(this, -1, _("Written by: ")));
00618         aboutinfo->Add (new wxStaticText(this, -1, _("Bernhard Ganter\n"
00619                                          "Volker Abel\n"
00620                                          "Peter Reiss\n"
00621                                          "Ruediger Krausze <krausze@mail.berlios.de>\n"
00622                                          "Tobias Schlemmer <keinstein@mail.berlios.de>")));
00623         aboutinfo->Add (new wxStaticText(this, -1, _("Mathematical\nmodelling:")));
00624         aboutinfo->Add (new wxStaticText(this, -1, _("Rudolf Wille")));
00625         aboutinfo->Add (new wxStaticText(this, -1, _("Licence type: ")));
00626         aboutinfo->Add (new wxStaticText(this, -1, _("GPL")));
00627         aboutinfo->Add (new wxStaticText(this, -1, _("wxWidgets: ")));
00628         aboutinfo->Add (new wxStaticText(this, -1, wxVERSION_STRING));
00629         aboutinfo->Add (new wxStaticText(this, -1, _("Copyright: ")));
00630         aboutinfo->Add (new wxStaticText(this, -1, _("(c) 2007 TU Dresden, Institut fuer Algebra")));
00631 
00632         // about title/info
00633         wxBoxSizer *abouttext = new wxBoxSizer (wxVERTICAL);
00634 //    wxStaticText *appname = new wxStaticText (this, -1, g_appname);
00635         wxStaticText * appname = new wxStaticText (this, -1, mumT(PACKAGE_NAME));
00636         appname->SetFont (wxFont (10, wxDEFAULT, wxNORMAL, wxBOLD));
00637         abouttext->Add (appname, 0, wxALIGN_LEFT);
00638         abouttext->Add (0, 10);
00639         abouttext->Add (aboutinfo, 1, wxEXPAND);
00640 
00641         // about icontitle//info
00642         wxBoxSizer *aboutpane = new wxBoxSizer (wxHORIZONTAL);
00643 //    wxBitmap bitmap = wxBitmap(wxICON (mutabor));
00644         wxBitmap bitmap = wxBitmap(wxFileName(path.GetResourcesDir(),_T("about"),_T("png")).GetFullPath(),
00645                                    wxBITMAP_TYPE_PNG);
00646         aboutpane->Add (new wxStaticBitmap (this, -1, bitmap),
00647                         0, wxALIGN_LEFT);
00648         aboutpane->Add (10, 0);
00649         aboutpane->Add (abouttext, 1, wxEXPAND);
00650 
00651         // about complete
00652         wxBoxSizer *totalpane = new wxBoxSizer (wxVERTICAL);
00653         totalpane->Add (aboutpane, 0, wxEXPAND | wxALL, 10);
00654         totalpane->Add (new wxStaticText(this, -1, _("Mutabor tuning")),
00655                         0, wxALIGN_CENTER | wxLEFT | wxRIGHT, 10);
00656         totalpane->Add (0, 6);
00657 //    myHyperLink *website = new myHyperLink (this, -1, APP_WEBSITE);
00658 //    wxString url = APP_WEBSITE;
00659 //    url.Append ("/indexedit.html");
00660 //    website->SetURL (url);
00661 //    totalpane->Add (website, 0, wxALIGN_CENTER);
00662 //      totalpane->Add (new wxStaticLine(this, -1), 0, wxEXPAND | wxALL, 10);
00663         wxButton *okButton = new wxButton (this, wxID_OK, _("OK"));
00664         okButton->SetDefault();
00665         totalpane->Add (okButton, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT | wxBOTTOM, 10);
00666 
00667         SetSizerAndFit (totalpane);
00668 
00669         ShowModal();
00670 }
00671 
00672 
00673 BEGIN_EVENT_TABLE(MutApp, wxApp)
00674         EVT_MENU(CM_SETUP, MutApp::CmSetup)
00675 EVT_MENU(wxID_OPEN, MutApp::PassEventToDocManagerCMD)
00676 EVT_MENU(wxID_CLOSE, MutApp::PassEventToDocManagerCMD)
00677 EVT_MENU(wxID_CLOSE_ALL, MutApp::PassEventToDocManagerCMD)
00678 EVT_MENU(wxID_REVERT, MutApp::PassEventToDocManagerCMD)
00679 EVT_MENU(wxID_NEW, MutApp::PassEventToDocManagerCMD)
00680 EVT_MENU(wxID_SAVE, MutApp::PassEventToDocManagerCMD)
00681 EVT_MENU(wxID_SAVEAS, MutApp::PassEventToDocManagerCMD)
00682 EVT_MENU(wxID_UNDO, MutApp::PassEventToDocManagerCMD)
00683 EVT_MENU(wxID_REDO, MutApp::PassEventToDocManagerCMD)
00684 
00685 EVT_UPDATE_UI(wxID_OPEN, MutApp::PassEventToDocManagerUPD)
00686 EVT_UPDATE_UI(wxID_CLOSE, MutApp::PassEventToDocManagerUPD)
00687 EVT_UPDATE_UI(wxID_CLOSE_ALL, MutApp::PassEventToDocManagerUPD)
00688 EVT_UPDATE_UI(wxID_REVERT, MutApp::PassEventToDocManagerUPD)
00689 EVT_UPDATE_UI(wxID_NEW, MutApp::PassEventToDocManagerUPD)
00690 EVT_UPDATE_UI(wxID_SAVE, MutApp::PassEventToDocManagerUPD)
00691 EVT_UPDATE_UI(wxID_SAVEAS, MutApp::PassEventToDocManagerUPD)
00692 EVT_UPDATE_UI(wxID_UNDO, MutApp::PassEventToDocManagerUPD)
00693 EVT_UPDATE_UI(wxID_REDO, MutApp::PassEventToDocManagerUPD)
00694 
00695 #if wxUSE_PRINTING_ARCHITECTURE
00696 EVT_MENU(wxID_PRINT, MutApp::PassEventToDocManagerCMD)
00697 EVT_MENU(wxID_PREVIEW, MutApp::PassEventToDocManagerCMD)
00698 
00699 EVT_UPDATE_UI(wxID_PRINT, MutApp::PassEventToDocManagerUPD)
00700 EVT_UPDATE_UI(wxID_PREVIEW, MutApp::PassEventToDocManagerUPD)
00701 #endif
00702 //        EVT_MENU(CM_FILENEW, MutApp::PassEventToDocManager)   
00703 //       EVT_MENU(CM_FILEOPEN, MutApp::PassEventToDocManager)   
00704 //      EVT_MENU(CM_FILENEW, MutApp::CmFileNew)
00705 //      EVT_MENU(CM_FILEOPEN, MutApp::CmFileOpen)
00706         EVT_MENU(CM_EXECUTE, MutApp::CmFileOpen)
00707         /*    EVT_MENU(CM_FILESAVE, MutFrame::EventPassOn)
00708             EVT_MENU(CM_DOACTIVATE, MutFrame::CmDoActivate)
00709             EVT_MENU(CM_STOP, MutFrame::CmStop)
00710                 EVT_UPDATE_UI(CM_ACTIVATE, MutFrame::CeActivate)
00711                 EVT_UPDATE_UI(CM_STOP, MutFrame::CeStop)
00712 
00713         */
00714         EVT_MENU_RANGE(wxID_FILE1, wxID_FILE9, MutApp::OnMRUFile)       
00715         EVT_MENU(CM_ROUTES, MutApp::CmRoutes)
00716         EVT_MENU(CM_ROUTELOAD, MutApp::CmRouteLoad)
00717         EVT_MENU(CM_ROUTESAVE, MutApp::CmRouteSave)
00718         EVT_MENU(CM_ROUTESAVEAS, MutApp::CmRouteSaveAs)
00719         /*
00720                 EVT_MENU(CM_TOGGLEKEY, MutFrame::CmToggleKey)
00721                 EVT_MENU(CM_TOGGLETS, MutFrame::CmToggleTS)
00722                 EVT_MENU(CM_TOGGLEACT, MutFrame::CmToggleAct)
00723                 EVT_MENU(CM_OWM, MutFrame::CmToggleOWM)
00724                 EVT_MENU(CM_CAW, MutFrame::CmToggleCAW)
00725                 EVT_UPDATE_UI(CM_TOGGLEKEY, MutFrame::CeToggleKey)
00726                 EVT_UPDATE_UI(CM_TOGGLETS, MutFrame::CeToggleTS)
00727                 EVT_UPDATE_UI(CM_TOGGLEACT, MutFrame::CeToggleAct)
00728                 EVT_UPDATE_UI(CM_OWM, MutFrame::CeToggleOWM)
00729                 EVT_UPDATE_UI(CM_CAW, MutFrame::CeToggleCAW)
00730 
00731                 EVT_MENU(CM_INDEVSTOP, MutFrame::CmInDevStop)
00732                 EVT_MENU(CM_INDEVPLAY, MutFrame::CmInDevPlay)
00733                 EVT_MENU(CM_INDEVPAUSE, MutFrame::CmInDevPause)
00734                 EVT_UPDATE_UI(CM_INDEVSTOP, MutFrame::CeInDevStop)
00735                 EVT_UPDATE_UI(CM_INDEVPLAY, MutFrame::CeInDevPlay)
00736                 EVT_UPDATE_UI(CM_INDEVPAUSE, MutFrame::CeInDevPause)
00737 
00738         */
00739 
00740         EVT_MENU(CM_HELP, MutApp::CmHelp)
00741         EVT_MENU(CM_HELPHANDBOOK, MutApp::CmHelp)
00742         EVT_MENU(CM_HELPREFERENCE, MutApp::CmHelp)
00743         EVT_MENU(CM_HELPINDEX, MutApp::CmHelp)
00744         EVT_MENU(CM_HELPSEARCH, MutApp::CmHelp)
00745         EVT_MENU(CM_HELPONHELP, MutApp::CmHelp)
00746         EVT_MENU(CM_ABOUT, MutApp::CmAbout)
00747         //    EVT_MENU(MDI_NEW_WINDOW, MutFrame::OnNewWindow)
00748         EVT_MENU(CM_EXIT, MutApp::CmQuit)
00749 #ifdef DEBUG
00750         EVT_MENU(cmCallExitId, MutApp::CmCallExit)
00751 #endif
00752 
00753 
00754         /*    EVT_CLOSE(MutFrame::OnClose)
00755             EVT_MENU(CM_UPDATEUI, MutFrame::UpdateUI)
00756                 EVT_IDLE(MutFrame::OnIdle)
00757         */
00758         //    EVT_SIZE(MutFrame::OnSize)
00759 END_EVENT_TABLE()
00760 
00761 MutFrame* MutApp::CreateMainFrame(MenuType type, wxWindowID id)
00762 {
00763         MutFrame* frame = new MutFrame((wxFrame *)NULL, wxID_ANY, _T("Mutabor"),
00764                                        wxDefaultPosition, wxDefaultSize, //wxSize(500, 400),
00765                                        wxDEFAULT_FRAME_STYLE | wxHSCROLL | wxVSCROLL);
00766         return InitMainFrame(type,frame);
00767 }
00768 
00769 
00770         // Give it an icon
00771 MutFrame* MutApp::InitMainFrame(MenuType type, MutFrame * frame) 
00772 {
00773 #ifdef __WXMSW__
00774         frame->SetIcon(wxIcon(_T("mutabor_icn")));
00775 #else
00776         frame->SetIcon(wxIcon( mutabor_xpm ));
00777 #endif
00778 
00779         // Make a menubar
00780 
00781         wxMenuBar *menuBar = new wxMenuBar;
00782         frame->SetFileMenu(MakeFileMenu(menuBar, type));
00783         MakeEditMenu(menuBar, type);
00784         MakeLogicMenu(menuBar);
00785         MakeRoutesMenu(menuBar);
00786         MakeViewMenu(menuBar, type);
00787         MakeSequencerMenu(menuBar);
00788         MakeHelpMenu(menuBar);
00789 
00790         // Associate the menu bar with the frame
00791         frame->SetMenuBar(menuBar);
00792 
00793 #if wxUSE_STATUSBAR
00794         frame->CreateStatusBar();
00795 #endif // wxUSE_STATUSBAR
00796 
00797         return frame;
00798 }
00799 
00800 void MutApp::CmFileNew (wxCommandEvent& event)
00801 {
00802 #ifdef DEBUG
00803         printf("MutApp::CmFileNew\n");
00804 #endif
00805         MutFrame * frame = dynamic_cast<MutFrame*>(GetTopWindow());
00806 
00807         if (MustOpenFrame(frame))
00808                 frame = CreateMainFrame(EditorMenu);
00809 
00810 #ifdef DEBUG
00811         printf("MutApp::CmFileNew: created main frame\n");
00812 
00813 #endif
00814         frame->CmFileNew(event);
00815         frame->Show();
00816 
00817 #ifdef DEBUG
00818         printf("MutApp::CmFileNew: file new: done.\n");
00819 
00820 #endif
00821         event.Skip(false);
00822 }
00823 
00824 
00825 void MutApp::CmFileOpen (wxCommandEvent& event)
00826 {
00827         wxWindow * topwindow=GetTopWindow();
00828 
00829         event.Skip(false);
00830 
00831         wxString path = FileNameDialog(topwindow);
00832 
00833         MutFrame * frame = dynamic_cast<MutFrame*>(topwindow);
00834 
00835         if ( !path )
00836                 return;
00837 
00838         if (MustOpenFrame(frame)) 
00839                 frame = CreateMainFrame(EditorMenu);
00840 
00841         frame->OpenFile(path);
00842 
00843 #ifdef DEBUG
00844         std::cerr << "MutApp:CmFileOpen " << CM_EXECUTE << " == "
00845         << event.GetId() << "?" << std::endl;
00846 
00847 #endif
00848 
00849         switch (event.GetId()) {
00850 
00851         case CM_EXECUTE:
00852                 wxCommandEvent e(wxEVT_COMMAND_MENU_SELECTED,CM_ACTIVATE);
00853 
00854                 wxPostEvent(frame,e);
00855 
00856                 break;
00857         }
00858         frame->Show();
00859 
00860 }
00861 
00862 void MutApp::CmRoutes (wxCommandEvent& event)
00863 {
00864 
00865         wxWindow * topwindow=GetTopWindow();
00866 
00867 #ifdef DEBUG
00868         std::cerr << "MutApp::CmRoutes: window "
00869         << wxWindow::FindWindowById(WK_ROUTE)
00870         << " casted "
00871         << dynamic_cast <MutFrame *>(wxWindow::FindWindowById(WK_ROUTE))
00872         << std::endl;
00873 #endif
00874 
00875         MutFrame * frame = dynamic_cast<MutFrame*>(wxWindow::FindWindowById(WK_ROUTE));
00876 
00877         if (!frame) {
00878                 frame = dynamic_cast<MutFrame*>(GetTopWindow());
00879 
00880                 if (MustOpenFrame(frame))
00881                         frame = CreateMainFrame(RouteMenu);
00882         }
00883 
00884         frame->CmRoutes(event);
00885 
00886         frame->Show(true);
00887         event.Skip(false);
00888 }
00889 
00890 void MutApp::CmHelp (wxCommandEvent& event)
00891 {
00892         ShowHelp(event.GetId());
00893         event.Skip();
00894 }
00895 
00896 void MutApp::ShowHelp(int commandId)
00897 {
00898         switch (commandId) {
00899 
00900         case CM_HELPINDEX:
00901                 HelpController->DisplayContents();
00902 
00903                 break;
00904 
00905         case CM_HELP:
00906                 HelpController->Display(_("help.html"));
00907 
00908                 break;
00909 
00910         case CM_SETUP:
00911                 HelpController->Display(_("The setup dialog"));
00912 
00913                 break;
00914 
00915         case CM_HELPHANDBOOK:
00916                 HelpController->Display(_("manual.html"));
00917 
00918                 break;
00919 
00920         case CM_HELPREFERENCE:
00921                 HelpController->Display(_("reference.html"));
00922 
00923                 break;
00924 
00925         case CM_HELPONHELP:
00926                 HelpController->Display(_("Help window"));
00927 
00928                 break;
00929 
00930         case CM_HELPCOMMON:
00931                 HelpController->DisplayContents();
00932 
00933                 break;
00934 
00935         case CM_HELPSEARCH: {
00936                 wxString key = wxGetTextFromUser(_("Search for?"),
00937                                                  _("Search help for keyword"),
00938                                                  wxEmptyString,
00939                                                  GetTopWindow());
00940 
00941                 if (! key.IsEmpty())
00942                         HelpController->KeywordSearch(key);
00943         }
00944 
00945         break;
00946         }
00947 }
00948 
00949 void MutApp::CmQuit (wxCommandEvent& event)
00950 {
00951         DEBUGLOG (other, _T(""));
00952 
00953         SetExitOnFrameDelete(true);
00954         //              Exit();
00955 
00956         if (quitting) return;
00957 
00958         quitting = true;
00959 
00960         event.Skip(false);
00961 
00962 
00963         wxWindow * window;
00964 
00965         SetTopWindow(NULL);
00966 
00967         //      if (frames.empty()) {
00968         if ((window = GetTopWindow()) == NULL) {
00969                 DEBUGLOG (other, _T("No Frames."));
00970                 quitting = false;
00971                 ExitMainLoop();
00972                 return;
00973         }
00974 
00975         // first check whether docmanager allows quitting
00976         if (!document_manager.Clear(false))
00977         {
00978                 quitting = false;
00979                 return;
00980         }
00981 
00982 
00983         DEBUGLOG (other, _T("Starting Loop"));
00984 
00985         while (Pending())
00986                 Dispatch();
00987 
00988         DEBUGLOG (other, _T("Dispatched all events"));
00989 
00990         wxIdleMode imode = wxIdleEvent::GetMode();
00991         wxIdleEvent::SetMode(wxIDLE_PROCESS_ALL);
00992 
00993         while ((window = GetTopWindow())) {
00994                 DEBUGLOG (other, _("Closing window of class %s"), 
00995                           muT(typeid(*(window)).name()).c_str());
00996 
00997                 if (!window->Close()) {
00998                         wxIdleEvent::SetMode(imode);
00999                         quitting = false;
01000                         return;
01001                 }
01002 
01003                 DEBUGLOG (other, _T("Closed window"));
01004 
01005                 // empty queue and process idle event to delete the frame
01006 
01007                 while (Pending())
01008                         Dispatch();
01009 
01010                 //   wxIdleEvent idle;
01011                 //ProcessEvent(idle);
01012                 //while(Pending())
01013                 //  Dispatch();
01014                 DeletePendingObjects();
01015 
01016                 DEBUGLOG (other, _T("Dispatched all events"));
01017         }
01018 
01019 
01020         DEBUGLOG (other, _T("finished loop"));
01021 }
01022 
01023 
01024 
01025 wxString MutApp::GetResourceName(const wxString & file)
01026 {
01027         const wxLocale * m_locale = wxGetLocale();
01028         wxStandardPathsBase & sp = wxStandardPaths::Get();
01029         wxString localename = m_locale->GetCanonicalName();
01030         wxFileName rcname(sp.GetLocalizedResourcesDir(localename),file);
01031         DEBUGLOGTYPE(other,MutApp,_T("Trying do load resources...\n%s\n%s"),rcname.GetFullPath().c_str(),sp.GetResourcesDir().c_str());
01032         if (!rcname.IsFileReadable()) {
01033                 rcname.SetPath(sp.GetLocalizedResourcesDir(localename.BeforeFirst(_T('_'))));
01034                 DEBUGLOGTYPE(other,MutApp,_T("Trying %s"),rcname.GetFullPath().c_str());
01035                 if (!rcname.IsFileReadable()) {
01036                         rcname.SetPath(sp.GetResourcesDir());
01037                         DEBUGLOGTYPE(other,MutApp,_T("Trying %s"),rcname.GetFullPath().c_str());
01038                 }
01039         }
01040         localename = rcname.GetFullPath();
01041         return localename;
01042 }
01043 
01044 wxMenu * MutApp::MakeFileMenu(wxMenuBar * menuBar, MenuType type)
01045 {
01046         wxMenu * retval;
01047         OPENMENU;
01048         retval = menu;
01049         MENUITEM(_("&New\tCtrl+N"), CM_FILENEW,
01050                  _("Create a new logic file."));
01051         MENUITEM(_("&Open...\tCtrl+O"), CM_FILEOPEN,
01052                  _("Open a logic file in editor window"));
01053 
01054         if (type == EditorMenu || type == RouteMenu) {
01055                 MENUITEM(_("&Save\tCtrl+S"), CM_FILESAVE,
01056                          _("Save the current file."));
01057                 MENUITEM(_("Save &As...\tShift+Ctrl+S"), CM_FILESAVEAS,
01058                          _("Save the current file with a new file name"));
01059                 menu->Append (wxID_CLOSE, 
01060                                   _("&Close\tCtrl+W"),
01061                                   _("Closes the currently active window"));
01062                 menu->AppendSeparator();
01063         }
01064 
01065         MENUITEM_SEPARATOR;
01066 
01067         MENUITEM(_("&Execute\tCtrl+F9"), CM_EXECUTE,
01068                  _("Load a logic file an immediately activate it"));
01069 
01070 #if (defined(__WXMAC__) || defined(__WXCOCOA__))
01071         if (type == EditorMenu)
01072 #endif
01073         MENUITEM_SEPARATOR;
01074 
01075         if (type == EditorMenu) {
01076                 menu->Append (CM_PROPERTIES,
01077                               _("Proper&ties ..\tCtrl+I"),
01078                               _("Get some information about the currently edited file"));
01079         } 
01080         MENUITEM(_("&Preferences"), CM_SETUP, _("Edit program settings"));
01081 
01082 
01083         if (type == EditorMenu) {
01084                 menu->AppendSeparator();
01085                 menu->Append (wxID_PRINT_SETUP,
01086                               _("Print Set&up ..."),
01087                               _("Configure the printer settings"));
01088                 menu->Append (wxID_PREVIEW, 
01089                               _("Print Pre&view\tCtrl+Shift+P"),
01090                               _("Show document as it would be printed"));
01091                 menu->Append (wxID_PRINT,
01092                               _("&Print ..\tCtrl+P"),
01093                               _("Print current document on a printer"));
01094         }
01095 
01096 
01097 
01098 #if !(defined(__WXMAC__) || defined(__WXCOCOA__))
01099         MENUITEM_SEPARATOR;
01100 #endif
01101         MENUITEM(_("E&xit"), CM_EXIT, _("Quit Mutabor"));
01102         DEBUGLOG(docview,_T("Adding file history menu"));
01103         document_manager.FileHistoryUseMenu(menu);
01104         document_manager.GetFileHistory()->AddFilesToMenu(menu);
01105 
01106 #if !(defined(__WXMAC__) || defined(__WXCOCOA__))
01107         CLOSEMENU(_("&File"));
01108 #else
01109         CLOSEMENU(getContextLocal(_("@MAC|&File")));
01110 #endif
01111         return retval;
01112 
01113 }
01114 
01115 void MutApp::MakeEditMenu(wxMenuBar * menuBar, MenuType type)
01116 {
01117         if (type != EditorMenu) return;
01118 
01119         OPENMENU;
01120         menu->Append (wxID_UNDO, _("&Undo\tCtrl+Z"));
01121         menu->Append (wxID_REDO, _("&Redo\tCtrl+Shift+Z"));
01122         menu->AppendSeparator();
01123         menu->Append (wxID_CUT, _("Cu&t\tCtrl+X"));
01124         menu->Append (wxID_COPY, _("&Copy\tCtrl+C"));
01125         menu->Append (wxID_PASTE, _("&Paste\tCtrl+V"));
01126         menu->Append (wxID_CLEAR, _("&Delete\tDel"));
01127         menu->AppendSeparator();
01128         menu->Append (wxID_SELECTALL, _("&Select all\tCtrl+A"));
01129         menu->Append (CM_SELECTLINE, _("Select &line\tCtrl+L"));
01130         menu->AppendSeparator();
01131         menu->Append (wxID_FIND, _("&Find\tCtrl+F"));
01132         menu->Enable (wxID_FIND, false);
01133         menu->Append (CM_FINDNEXT, _("Find &next\tF3"));
01134         menu->Enable (CM_FINDNEXT, false);
01135         menu->Append (CM_REPLACE, _("&Replace\tCtrl+H"));
01136         menu->Enable (CM_REPLACE, false);
01137         menu->Append (CM_REPLACENEXT, _("Replace &again\tShift+F4"));
01138         menu->Enable (CM_REPLACENEXT, false);
01139         menu->AppendSeparator();
01140         menu->Append (CM_BRACEMATCH, _("&Match brace\tCtrl+M"));
01141         menu->Append (CM_GOTO, _("&Goto\tCtrl+G"));
01142         menu->Enable (CM_GOTO, false);
01143         menu->AppendSeparator();
01144         menu->Append (CM_INDENTINC, _("&Indent increase\tTab"));
01145         menu->Append (CM_INDENTRED, _("I&ndent reduce\tBksp"));
01146 
01147         // change case submenu
01148         wxMenu *menuChangeCase = new wxMenu;
01149         menuChangeCase->Append (CM_CHANGEUPPER, _("&Upper case"));
01150         menuChangeCase->Append (CM_CHANGELOWER, _("&Lower case"));
01151 
01152         // convert EOL submenu
01153         wxMenu *menuConvertEOL = new wxMenu;
01154         menuConvertEOL->Append (CM_CONVERTCR, _("CR (&Linux)"));
01155         menuConvertEOL->Append (CM_CONVERTCRLF, _("CR+LF (&Windows)"));
01156         menuConvertEOL->Append (CM_CONVERTLF, _("LF (&Macintosh)"));
01157 
01158         menu->AppendCheckItem (CM_READONLY, _("&Readonly mode"));
01159         menu->Append (CM_CHANGECASE, _("Change &case to ..."), menuChangeCase);
01160         menu->Append (CM_CONVERTEOL, _("Convert line &endings to ..."), 
01161                       menuConvertEOL);
01162 
01163         CLOSEMENU(_("&Edit"));
01164 }
01165 
01166         
01167 void MutApp::MakeLogicMenu(wxMenuBar * menuBar)
01168 {
01169         OPENMENU;
01170         MENUITEM(_("&Compile\tAlt+F9"), CM_COMPILE, _("Load the actual file into the Mutabor Kernel."));
01171         MENUITEM(_("&Activate\tF9"), CM_ACTIVATE, _("Activate the Mutabor Kernel."));
01172         MENUITEM(_("&Stop\tF8"), CM_STOP, _("Stop the Mutabor Kernel."));
01173         MENUITEM_SEPARATOR;
01174         MENUITEM(_("&Panic\tF12"), CM_PANIC, _("Send \"all notes off\" signal to on all MIDI Channels."));
01175         CLOSEMENU(_("&Logic"));
01176 }
01177 
01178 void MutApp::MakeRoutesMenu(wxMenuBar * menuBar)
01179 {
01180         OPENMENU;
01181         MENUITEM(_("&Load routes"), CM_ROUTELOAD,
01182                  _("Load the current route configuration from a file"));
01183         MENUITEM(_("&Save routes"), CM_ROUTESAVE,
01184                  _("Save current route configuration to a file."));
01185         MENUITEM(_("Save routes &as"), CM_ROUTESAVEAS,
01186                  _("Save current route configuration to a file with a new name."));
01187         CLOSEMENU(_("&Routes"));
01188 }
01189 
01190 void MutApp::MakeViewMenu(wxMenuBar * menuBar, MenuType type)
01191 {
01192         
01193 
01194         OPENMENU;
01195         if (type == EditorMenu) {
01196                 // hilight submenu
01197                 wxMenu *menuHilight = new wxMenu;
01198                 int Nr;
01199                 for (Nr = 0; Nr < g_LanguagePrefsSize; Nr++) {
01200                         menuHilight->Append (CM_HILIGHTFIRST + Nr,
01201                                              g_LanguagePrefs [Nr].name);
01202                 }
01203 
01204                 // charset submenu
01205                 wxMenu *menuCharset = new wxMenu;
01206                 menuCharset->Append (CM_CHARSETANSI, _("&ANSI (Windows)"));
01207                 menuCharset->Append (CM_CHARSETMAC, _("&MAC (Macintosh)"));
01208 
01209                 menu->Append (CM_HILIGHTLANG, _("&Hilight language .."), menuHilight);
01210                 menu->AppendSeparator();
01211                 menu->AppendCheckItem (CM_FOLDTOGGLE, _("&Toggle current fold\tCtrl+T"));
01212                 menu->AppendCheckItem (CM_OVERTYPE, _("&Overwrite mode\tIns"));
01213                 menu->AppendCheckItem (CM_WRAPMODEON, _("&Wrap mode\tCtrl+U"));
01214                 menu->AppendSeparator();
01215                 menu->AppendCheckItem (CM_DISPLAYEOL, _("Show line &endings"));
01216                 menu->AppendCheckItem (CM_INDENTGUIDE, _("Show &indent guides"));
01217                 menu->AppendCheckItem (CM_LINENUMBER, _("Show line &numbers"));
01218                 menu->AppendCheckItem (CM_LONGLINEON, _("Show &long line marker"));
01219                 menu->AppendCheckItem (CM_WHITESPACE, _("Show white&space"));
01220                 menu->AppendSeparator();
01221                 menu->Append (CM_USECHARSET, _("Use &code page of .."), menuCharset);
01222                 menu->AppendSeparator();
01223         }
01224         
01225         /*      MENUCHECKITEM(_("&Status bar"), IDW_STATUSBAR,
01226            _("Toggle status bar on/off"));
01227         MENUCHECKITEM(_("&Toolbar"), IDW_TOOLBAR,
01228            _("Toggle tool bar on/off"));
01229         MENUITEM_SEPARATOR;
01230         */
01231         MENUCHECKITEM(_("&Routes\tF11"), CM_ROUTES,
01232                       _("Open route configuration window"));
01233 
01234         if (type != ProgramMenu) {
01235                 MENUITEM_SEPARATOR;
01236                 MENUCHECKITEM(_("Current ke&ys\tF5"), CM_TOGGLEKEY,
01237                               _("Show current keys window"));
01238                 MENUCHECKITEM(_("&Tone system\tF6"), CM_TOGGLETS,
01239                               _("Show tone system window"));
01240                 MENUCHECKITEM(_("&Actions\tF7"), CM_TOGGLEACT,
01241                               _("Show current actions window"));
01242                 /*        MENUITEM_SEPARATOR;
01243                 MENUCHECKITEM(_("&One window mode"), CM_OWM,
01244                 _("Toggle logic satus window: one each or one common"));
01245                 MENUCHECKITEM(_("One &common action window"), CM_CAW,
01246                 _("Toggle action window mode: one each or one common"));
01247                 */
01248                 MENUITEM_SEPARATOR;
01249                 menu->Append(CM_SELECTBOX,_("Select &Box"), new wxMenu(),
01250                              _("Select current Box"));
01251         }
01252 
01253         CLOSEMENU(_("&View"));
01254 }
01255 
01256 void MutApp::MakeSequencerMenu(wxMenuBar * menuBar)
01257 {
01258         OPENMENU;
01259         MENUITEM(_("&Play"), CM_INDEVPLAY,
01260                  _("Start playing the music from input file devices"));
01261         MENUITEM(_("St&op"), CM_INDEVSTOP,
01262                  _("Stop playing the music from input file devices"));
01263         MENUITEM(_("P&ause"), CM_INDEVPAUSE,
01264                  _("Pause plaing the music from input file devices"));
01265         CLOSEMENU(_("&Sequencer"));
01266 }
01267 
01268 
01269 void MutApp::MakeHelpMenu(wxMenuBar * menuBar)
01270 
01271 {
01272         OPENMENU;
01273         MENUITEM(_("Online &Help\tF1"), CM_HELP,
01274                  _("Open the help Window"));
01275         MENUITEM(_("&Manual"), CM_HELPHANDBOOK,
01276                  _("Open the manual"));
01277         MENUITEM(_("Language &reference"), CM_HELPREFERENCE,
01278                  _("Open the Mutabor language reference"));
01279         MENUITEM_SEPARATOR;
01280         MENUITEM(_("&Index"), CM_HELPINDEX,
01281                  _("Open the help index"));
01282         MENUITEM(_("&Search"), CM_HELPSEARCH,
01283                  _("Search the help system for a specific keyword"));
01284         MENUITEM_SEPARATOR;
01285         MENUITEM(_("Help &on help"), CM_HELPONHELP,
01286                  _("Show Help about the help system"));
01287 
01288 #if !(defined(__WXMAC__) || defined(__WXCOCOA__))
01289         MENUITEM_SEPARATOR;
01290 #endif
01291 
01292         MENUITEM(_("&About"), CM_ABOUT,
01293                  _("Show information about the program"));
01294 #ifdef DEBUG
01295         MENUITEM_SEPARATOR;
01296         MENUITEM(_("Stop"), cmCallExitId,
01297                  _("Stop the current program"));
01298 #endif
01299         CLOSEMENU(_("&Help"));
01300 }
01301 
01302 int MutApp::OnExit()
01303 {
01304         SaveState();
01305         AktionTraceReset();
01306         MidiUninit();
01307 #if defined(__WXMAC__)
01308         wxMenuBar::MacSetCommonMenuBar(NULL);
01309 #endif
01310         delete HelpController;
01311         wxXmlResource::Get()->ClearHandlers();
01312         return wxApp::OnExit();
01313 }
01314 
01315 #ifdef __WXMAC__
01316 
01317 void MutApp::MacOpenFile(const wxString &fileName)
01318 {
01319         //  wxApp::MacOpenFile(fileName);
01320 
01321         DEBUGLOG (other, _T("Filename: %s"),fileName.c_str());
01322 
01323         MutFrame * frame = dynamic_cast<MutFrame*>(GetTopWindow());
01324 
01325         if ( !fileName )
01326                 return;
01327 
01328         if (MustOpenFrame(frame))
01329                 frame = CreateMainFrame(EditorMenu);
01330 
01331         frame->OpenFile(fileName);
01332         frame->Show();
01333 }
01334 
01335 #endif
01336 
01337 void MutApp::SaveState()
01338 {
01339         /* \todo save Parameters of all open windows */
01340         wxConfigBase *config = wxConfig::Get();
01341         if (!config) {
01342                 wxLogError(_("Could not get configuration storage"));
01343                 return;
01344         }
01345 
01346         wxString oldpath = config->GetPath();
01347 
01348         config->SetPath(_T("/Settings"));
01349         config->Write(_T("Tone system"), asTS);
01350         config->Write(_T("Save editor"), SaveEditor);
01351         config->Write(_T("Color bars"), UseColorBars);
01352 
01353         config->SetPath(_T("Box settings"));
01354 
01355         for (size_t box = 0 ; box < MAX_BOX ; box++) {
01356                 config->SetPath(wxString::Format(_T("%d"),box));
01357                 config->Write(_T("KeyWindow"), TextBoxWanted[box][WK_KEY]);
01358                 config->Write(_T("ToneSystemWindow"), TextBoxWanted[box][WK_TS]);
01359                 config->Write(_T("ActionsWindow"), TextBoxWanted[box][WK_ACT]);
01360                 config->SetPath(_T(".."));
01361         }
01362 
01363         config->SetPath(_T(".."));
01364 
01365         config->SetPath(_T("DocManager"));
01366         document_manager.FileHistorySave(*config);
01367         config->SetPath(_T(".."));
01368 
01369         SaveRoutes(config);
01370         config->SetPath(oldpath);
01371 }
01372 
01373 void MutApp::RestoreState()
01374 
01375 {
01376         /* \todo restore Windows of last session. */
01377         wxConfigBase *config = wxConfig::Get();
01378         if (!config) {
01379                 wxLogError(_("Could not get configuration storage"));
01380                 return;
01381         }
01382 
01383         wxString oldpath = config->GetPath();
01384 
01385         config->SetPath(_T("/Settings"));
01386         config->Read(_T("ToneSystem"), &asTS, true);
01387         config->Read(_T("SaveEditor"), &SaveEditor, true);
01388         config->Read(_T("ColorBars"), &UseColorBars, true);
01389 
01390         config->SetPath(_T("Box settings"));
01391 
01392         for (size_t box = 0 ; box < MAX_BOX ; box++) {
01393                 config->SetPath(wxString::Format(_T("%d"),box));
01394                 config->Read(_T("KeyWindow"), &TextBoxWanted[box][WK_KEY], false);
01395                 config->Read(_T("ToneSystemWindow"), &TextBoxWanted[box][WK_TS], false);
01396                 config->Read(_T("ActionsWindow"), &TextBoxWanted[box][WK_ACT], false);
01397                 config->SetPath(_T(".."));
01398         }
01399 
01400         config->SetPath(_T(".."));
01401 
01402         config->SetPath(_T("DocManager"));
01403         document_manager.FileHistoryLoad(*config);
01404         config->SetPath(_T(".."));
01405 
01406         LoadRoutes(config);
01407         config->SetPath(oldpath);
01408 }
01409 

Erzeugt am Sun Aug 21 2011 10:51:54 für Mutabor von doxygen 1.7.4