/* WARNING: This file was generated by dkct. Changes you make here will be lost if dkct is run again! You should modify the original source and run dkct on it. Original source: DkWxHtbApp.cpt */ /* Copyright (C) 2014-2017, Dirk Krause Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above opyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** @file DkWxHtbApp.cpp The DkWxHtbApp module. */ #line 59 "DkWxHtbApp.cpt" #include "wxdkhtb.h" #line 64 "DkWxHtbApp.cpt" /** Localized wxChar texts. */ static wxChar const * wxdkhtb_texts[] = { /* 0 */ wxT("File"), /* 1 */ wxT("Exit"), /* 2 */ wxT("Exit the application"), /* 3 */ wxT("Help"), /* 4 */ wxT("About"), /* 5 */ wxT("Show version information"), /* 6 */ wxT("Contents"), /* 7 */ wxT("Open table of contents"), /* 8 */ wxT("Ready"), /* 9 */ wxT("Copyright (c) "), /* 10 */ wxT("About "), /* 11 */ wxT("This program uses the following libraries:"), /* 12 */ wxT("See:"), /* 13 */ wxT("HTB viewer main window"), /* 14 */ wxT("No help controller was created!"), /* 15 */ wxT("Error"), /* 16 */ wxT("No *.htb file name was specified on the command line!"), /* 17 */ wxT("The specified file does not exist!"), /* 18 */ wxT("Failed to create help controller, resources/memory problem!"), NULL #line 148 "DkWxHtbApp.cpt" }; /** Non-localized wxChar texts. */ static wxChar const * wxdkhtb_nl_wx[] = { /* 0 */ wxT("wxdkhtb"), /* 1 */ wxT("1.0.0"), /* 2 */ wxT("Dirk Krause"), /* 3 */ wxT("DirkKrause"), /* 4 */ wxT("aaaaa"), /* 5 */ wxT("wxdkhtb.chm"), /* 6 */ wxT("wxdkhtb.htb"), /* 7 */ wxT(" "), /* 8 */ wxT("\n"), /* 9 */ wxT("DK tools, wxWidgets, libpng, libjpeg, libtiff, zlib."), /* 10 */ wxT("http://dktools.sourceforge.net"), /* 11 */ wxT("http://www.wxwidgets.org"), /* 12 */ wxT("http://www.libpng.org/pub/png/libpng.html"), /* 13 */ wxT("http://www.ijg.org"), /* 14 */ wxT("http://www.remotesensing.org/libtiff"), /* 15 */ wxT("http://www.zlib.net"), /* 16 */ wxT("Error"), /* 17 */ wxT("Not enough memory (RAM)!"), NULL #line 208 "DkWxHtbApp.cpt" }; /** Non-localized dkChar texts. */ static dkChar const * wxdkhtb_nl_dk[] = { /* 0 */ dkT("dktools"), /* 1 */ dkT("wxdkhtb.str"), NULL #line 225 "DkWxHtbApp.cpt" }; /** Implementation of the wxApp functionality. */ IMPLEMENT_APP(DkWxHtbApp) bool DkWxHtbApp::OnInit() { DkWxHtbFrame *frame = NULL; wxChar const * const *localizedTexts = NULL; wxPNGHandler *phPng = NULL; wxXPMHandler *phXpm = NULL; wxICOHandler *phIco = NULL; wxZipFSHandler *phZipFs = NULL; bool back = false; int iStatus = 0; /* 0 No file name 1 File does not exist 2 Not enough memory to create controller 3 Everything ok */ /* Initialize members. */ pHelper = NULL; helpController = NULL; /* Set up helper object. */ pHelper = new DkWxAppHelper( argv[0], wxdkhtb_nl_wx[3], wxdkhtb_nl_dk[0] ); if(!(pHelper)) { ShowMemoryErrorMessage(); goto finished; } if(!(pHelper->checkSetup())) { goto finished; } /* Add image and file system handlers for online help. */ phPng = new wxPNGHandler(); if (NULL != phPng) { wxImage::AddHandler(phPng); } else { ShowMemoryErrorMessage(); goto finished; } phXpm = new wxXPMHandler(); if (NULL != phXpm) { wxImage::AddHandler(phXpm); } else { ShowMemoryErrorMessage(); goto finished; } phIco = new wxICOHandler(); if (NULL != phIco) { wxImage::AddHandler(phIco); } else { ShowMemoryErrorMessage(); goto finished; } phZipFs = new wxZipFSHandler(); if (NULL != phZipFs) { wxFileSystem::AddHandler(phZipFs); } else { ShowMemoryErrorMessage(); goto finished; } localizedTexts = pHelper->getStringTable(wxdkhtb_texts, wxdkhtb_nl_dk[1]); if(!(localizedTexts)) { localizedTexts = wxdkhtb_texts; } /* Set up online help controller. */ if (1 < argc) { wxString fullPath; wxFileName fn(argv[1]); iStatus = 1; fn.Normalize( wxPATH_NORM_LONG | wxPATH_NORM_DOTS | wxPATH_NORM_TILDE | wxPATH_NORM_ABSOLUTE ); if (fn.FileExists()) { iStatus = 2; fullPath = fn.GetFullPath(); helpController = new wxHtmlHelpController( wxHF_DEFAULT_STYLE | wxHF_MERGE_BOOKS ); if (helpController) { helpController->Initialize(fullPath); iStatus = 3; } } } /* Create and show frame. */ frame = new DkWxHtbFrame( DkWxHtbFrame_MainWindow, pHelper, helpController, argc, argv, localizedTexts, wxdkhtb_nl_wx, wxdkhtb_nl_dk, iStatus ); if(!(frame)) { ShowMemoryErrorMessage(); goto finished; } frame->Show(); frame->restorePosition(); back = true; /* Release resources if initialization failed. */ finished: if(!(back)) { if(helpController) { delete(helpController); helpController = NULL; } if(pHelper) { delete(pHelper); pHelper = NULL; } } return back; } int DkWxHtbApp::OnExit() { int back = 0; /* Release resources. */ if(helpController) { delete(helpController); helpController = NULL; } if(pHelper) { delete(pHelper); pHelper = NULL; } return back; } void DkWxHtbApp::ShowMemoryErrorMessage(void) { const wxChar *s_title = NULL; const wxChar *s_text = NULL; if (NULL != pHelper) { s_title = pHelper->getBasicString(3); s_text = pHelper->getBasicString(9); } if (NULL == s_title) { s_title = wxdkhtb_nl_wx[16]; } if (NULL == s_text) { s_text = wxdkhtb_nl_wx[17]; } wxMessageBox(s_text, s_title, (wxOK | wxCENTRE | wxICON_ERROR)); }