/* Copyright (C) 2017-2020, Dirk Krause SPDX-License-Identifier: BSD-3-Clause */ /* WARNING: This file was generated by the dkct program (see http://dktools.sourceforge.net/ for details). 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: ScreenSizeApp.cpt */ /** @file ScreenSizeApp.cpp The ScreenSizeApp module. */ #line 72 "ScreenSizeApp.cpt" #include "wxdkscrsz.h" #line 78 "ScreenSizeApp.cpt" /** Localized wxChar texts. */ static wxChar const * wxdkscrsz_texts[] = { /* 0 */ wxT("File"), /* 1 */ wxT("Quit"), /* 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("Screen size change:"), /* 14 */ wxT("Not yet started"), /* 15 */ wxT("Started"), /* 16 */ wxT("OK"), /* 17 */ wxT("Failed"), /* 18 */ wxT("Error"), /* 19 */ wxT("Failed to retrieve current screen settings!"), /* 20 */ wxT("Failed to change screen size!"), /* 21 */ wxT("Only available on Windows platforms!"), /* 22 */ wxT("Not an unsigned integer: \""), /* 23 */ wxT("\"!"), /* 24 */ wxT("Missing command line arguments: width, height."), /* 25 */ wxT("Old screen size"), /* 26 */ wxT("Width:"), /* 27 */ wxT("Height:"), /* 28 */ wxT(""), /* 29 */ wxT("New screen size"), /* 30 */ wxT("Result"), NULL #line 206 "ScreenSizeApp.cpt" }; /** Non-localized wxChar texts. */ static wxChar const * wxdkscrsz_nl_wx[] = { /* 0 */ wxT("wxdkscrsz"), /* 1 */ wxT("1.0.0"), /* 2 */ wxT("Dirk Krause"), /* 3 */ wxT("DKrause"), /* 4 */ wxT("aaaaa"), /* 5 */ wxT(""), /* 6 */ wxT(""), /* 7 */ wxT(" "), /* 8 */ wxT("\n"), /* 9 */ wxT("DK tools, wxWidgets, libpng, libjpeg, libtiff, zlib."), /* 10 */ wxT("http://sourceforge.net/p/dktools/wiki/Home/"), /* 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 266 "ScreenSizeApp.cpt" }; /** Non-localized dkChar texts. */ static dkChar const * wxdkscrsz_nl_dk[] = { /* 0 */ dkT("dktools"), /* 1 */ dkT("wxdkscrsz.str"), /* 2 */ dkT("wxdkscrsz.chm"), /* 3 */ dkT("wxdkscrsz.htb"), NULL #line 291 "ScreenSizeApp.cpt" }; /** Implementation of the wxApp functionality. */ #if wxCHECK_VERSION(3,0,0) wxIMPLEMENT_APP(ScreenSizeApp); #else IMPLEMENT_APP(ScreenSizeApp) #endif bool ScreenSizeApp::OnInit() { ScreenSizeFrame *frame = NULL; wxChar const * const *localizedTexts = NULL; wxPNGHandler *phPng = NULL; wxXPMHandler *phXpm = NULL; wxICOHandler *phIco = NULL; wxArchiveFSHandler *phArchiveFS = NULL; bool back = false; /* Initialize members. */ pAh = NULL; pHc = NULL; /* __CHANGE__ 009: Initialize further members here. */ /* Set up helper object. */ pAh = new Dk4WxApplicationHelper(); if (NULL == pAh) { ShowMemoryErrorMessage(); goto finished; } if (!(pAh->Initialize(argv[0], wxdkscrsz_nl_wx[3], wxdkscrsz_nl_dk[0]))) { 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; } phArchiveFS = new wxArchiveFSHandler(); if (NULL != phArchiveFS) { wxFileSystem::AddHandler(phArchiveFS); } else { ShowMemoryErrorMessage(); goto finished; } /* Set up help controller. */ pHc = new Dk4WxHelpController(); if (NULL == pHc) { ShowMemoryErrorMessage(); goto finished; } if (!(pHc->Initialize(pAh, wxdkscrsz_nl_dk[2], wxdkscrsz_nl_dk[3]))) { goto finished; } /* Attempt to obtain localized texts in users preferred language. */ localizedTexts = pAh->GetStringTable(wxdkscrsz_nl_dk[1], wxdkscrsz_texts); if(!(localizedTexts)) { localizedTexts = wxdkscrsz_texts; } /* Create and show frame. */ frame = new ScreenSizeFrame( ScreenSizeFrame_MainWindow, pAh, pHc, argc, argv, localizedTexts, wxdkscrsz_nl_wx, wxdkscrsz_nl_dk ); if(!(frame)) { ShowMemoryErrorMessage(); goto finished; } /* Show frame, restore position and indicate success. */ frame->RestorePosition(); frame->Show(); back = true; /* Release resources if initialization failed. */ finished: if(!(back)) { if (NULL != pHc) { pHc->Cleanup(); delete(pHc); pHc = NULL; } if (NULL != pAh) { pAh->Cleanup(); delete(pAh); pAh = NULL; } } return back; } int ScreenSizeApp::OnExit() { int back = 0; /* __CHANGE__ 009: Release resources allocated by further members. */ /* Release resources. */ if (NULL != pHc) { pHc->Cleanup(); delete(pHc); pHc = NULL; } if (NULL != pAh) { pAh->Cleanup(); delete(pAh); pAh = NULL; } /* Set exit status code. */ return back; } void ScreenSizeApp::ShowMemoryErrorMessage(void) { const wxChar *s_title = NULL; const wxChar *s_text = NULL; if (NULL != pAh) { s_title = pAh->GetBasicString(6); s_text = pAh->GetBasicString(7); } if (NULL == s_title) { s_title = wxdkscrsz_nl_wx[16]; } if (NULL == s_text) { s_text = wxdkscrsz_nl_wx[17]; } wxMessageBox(s_text, s_title, (wxOK | wxCENTRE | wxICON_ERROR)); } /* vim: set ai sw=4 ts=4 : */