summaryrefslogtreecommitdiff
path: root/support/dktools/WxpqdicApp.cpt
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /support/dktools/WxpqdicApp.cpt
Initial commit
Diffstat (limited to 'support/dktools/WxpqdicApp.cpt')
-rw-r--r--support/dktools/WxpqdicApp.cpt569
1 files changed, 569 insertions, 0 deletions
diff --git a/support/dktools/WxpqdicApp.cpt b/support/dktools/WxpqdicApp.cpt
new file mode 100644
index 0000000000..bef55e979e
--- /dev/null
+++ b/support/dktools/WxpqdicApp.cpt
@@ -0,0 +1,569 @@
+%% options
+
+copyright owner = Dirk Krause
+
+copyright year = 2016-xxxx
+
+license = bsd
+
+
+
+%% header
+
+/** @file WxpqdicApp.h The WxpqdicApp class.
+*/
+
+
+
+/** Application class, derived from wxApp, one instance per program.
+*/
+class WxpqdicApp : public wxApp
+{
+ protected:
+
+ /** Helper object.
+ */
+ Dk4WxApplicationHelper *pAh;
+
+ /** Controller fr online help.
+ */
+ Dk4WxHelpController *pHc;
+
+ /* __CHANGE__ 009: Add further members here.
+ */
+
+ /** Error report if the initialization of socket subsystem fails.
+ */
+ dk4_er_t sockerr;
+
+ /** Flag: Socket subsystem initialized successfully.
+ */
+ bool bSocketsInitialized;
+
+ protected:
+
+ /** Show error message if there is not enough memory.
+ */
+ void
+ ShowMemoryErrorMessage(void);
+
+ public:
+
+ /** Application initialization.
+ @return true on success, false on error.
+ */
+ virtual
+ bool
+ OnInit();
+
+ /** Application shutdown.
+ @return 0 on success, any other value indicates an error.
+ */
+ virtual
+ int
+ OnExit();
+};
+
+
+
+/** Declaration as the wxApp object.
+*/
+DECLARE_APP(WxpqdicApp)
+
+
+
+%% module
+
+#include "wxpqdic.h"
+
+
+
+$!trace-include
+
+
+
+/** Localized wxChar texts.
+*/
+static wxChar const * wxpqdic_texts[] = {
+$!string-table macro=wxT
+#
+# 0: Menu "File"
+#
+File
+#
+# 1: Menu item "File/Quit"
+#
+Quit
+#
+# 2: Tool tip text for menu item "File/Exit"
+#
+Exit the application
+#
+# 3: Menu "Help"
+#
+Help
+#
+# 4: Menu item "Help/About"
+#
+About
+#
+# 5: Tooltip text for menu item "Help/About"
+#
+Show version information
+#
+# 6: Menu item "Help/Contents"
+#
+Contents
+#
+# 7: Tooltip text for menu item "Help/Contents"
+#
+Open table of contents
+#
+# 8: Initial status text
+#
+Ready
+#
+# 9: Copyright notice.
+#
+Copyright (c)
+#
+# 10: Dialog box title "About ..."
+#
+About
+#
+# 11: This program uses the following libraries
+#
+This program uses the following libraries:
+#
+# 12: See
+#
+See:
+#
+# 13: Label text "Limit:"
+#
+Limit:
+#
+# 14: Limit value "unlimited"
+#
+unlimited
+#
+# 15: Label text "Used:"
+#
+Used:
+#
+# 16: Dummy label text to initialize number of used pages
+#
+00000000
+#
+# 17: Label text "Personal print account:"
+#
+Personal print account:
+#
+# 18: Label text "Printing allowed:"
+#
+Printing allowed:
+#
+# 19 20: Result text values
+#
+YES
+NO
+#
+# 21: Label text "Waiting for response from server."
+#
+Waiting for response from server.
+#
+# 22: Menu "View"
+#
+View
+#
+# 23: Menu item: View -> Update
+#
+Update
+#
+# 24: Tool tip text for menu item: View -> Update
+#
+Update information in Window
+#
+# 25: Toolbar button text "Update"
+#
+Update
+#
+# 26: Toolbar button text "Exit"
+#
+Exit
+#
+# 27: Information: unknown
+#
+unknown
+#
+# 28: Error: Failed to send request
+#
+Failed to send request!
+#
+# 29: Error: No response from server!
+#
+No response from server!
+#
+# 30 31
+#
+Command line
+Failed to parse command line, illegal options used!
+#
+# 32 33
+#
+Insufficient memory
+A memory allocation failed due to insufficient memory!
+#
+# 34 35
+#
+Illegal host name
+Failed to convert host name to portable string!
+#
+# 36 37
+#
+Missing host name
+No host name specified! Please use\n-h host\nto specify the remote host.
+#
+# 38 39
+#
+Illegal queue name
+Failed to convert queue name to 8 bit character string!
+#
+# 40 41
+#
+Missing queue name
+No queue name specified! Please use\n-q queue\n to specify the queue name.
+#
+# 42 43 44
+#
+Illegal remote port
+Remote port number out of 16 bit range!
+Remote port number 0 can not be used!
+#
+# 45 46
+#
+Illegal user name
+Failed to convert user name to 8 bit character string!
+#
+# 47 48
+#
+No user name
+User name not found!
+#
+# 49 50 51
+#
+Illegal local port
+Local port number out of 16 bit range!
+Local port number 0 can not be used!
+#
+# 52 53
+#
+Bug
+Failed to construct request string!
+#
+# 54 55
+#
+Numeric overflow
+A numeric overflow occured in size calculation!
+#
+# 56 57
+#
+Network error
+Failed to create communication socket!
+#
+# 58 59
+#
+Error
+An unknown error occured during setup!
+$!end
+};
+
+
+
+/** Non-localized wxChar texts.
+*/
+static wxChar const * wxpqdic_nl_wx[] = {
+$!string-table macro=wxT
+#
+# 0: Program name.
+#
+wxpqdic
+#
+# 1: Program version.
+#
+4.3.0
+#
+# 2: Copyright owner name.
+#
+Dirk Krause
+#
+# 3: Software vendor name.
+# if necessary. Must be one
+# string without spaces.
+#
+DKrause
+#
+# 4: Resource name of Windows icon
+#
+aaaaa
+#
+# 5: UNUSED (previously Windows chm help file name)
+#
+
+#
+# 6: UNUSED (previously non-Windows htb help file name)
+#
+
+#
+# 7: Space
+#
+
+#
+# 8: Newline
+#
+\n
+#
+# 9 10 11 12 13 14 15: List of libraries used.
+#
+DK tools, wxWidgets, libpng, libjpeg, libtiff, zlib.
+http://dktools.sourceforge.net
+http://www.wxwidgets.org
+http://www.libpng.org/pub/png/libpng.html
+http://www.ijg.org
+http://www.remotesensing.org/libtiff
+http://www.zlib.net
+#
+# 16 17
+#
+UTF-8
+utf8
+#
+# 18 19
+#
+Error
+Not enough memory (RAM)!
+$!end
+};
+
+
+
+/** Non-localized dkChar texts.
+*/
+static dkChar const * wxpqdic_nl_dk[] = {
+$!string-table macro=dkT
+#
+# 0: Program group name.
+#
+dktools
+#
+# 1: String table name.
+#
+wxpqdc.str
+#
+# 2: CHM help file name
+#
+wxpqdic.chm
+#
+# 3: HTB help file name
+#
+wxpqdic.htb
+$!end
+};
+
+
+
+/** Implementation of the wxApp functionality.
+*/
+IMPLEMENT_APP(WxpqdicApp)
+
+
+bool
+WxpqdicApp::OnInit()
+{
+ WxpqdicFrame *frame = NULL;
+ wxChar const * const *localizedTexts = NULL;
+ wxPNGHandler *phPng = NULL;
+ wxXPMHandler *phXpm = NULL;
+ wxICOHandler *phIco = NULL;
+ wxArchiveFSHandler *phArchiveFS = NULL;
+ bool back = false;
+
+ $!trace-init c:\\temp\\wxpqdic.deb
+ $? "+ OnInit"
+
+ /* Initialize members.
+ */
+ pAh = NULL;
+ pHc = NULL;
+
+ /* __CHANGE__ 009: Initialize further members here.
+ */
+ bSocketsInitialized = false;
+
+ /* Set up application helper object.
+ */
+ pAh = new Dk4WxApplicationHelper();
+ if (NULL == pAh) {
+ ShowMemoryErrorMessage();
+ goto finished;
+ }
+ if (!(pAh->Initialize(argv[0], wxpqdic_nl_wx[3], wxpqdic_nl_dk[0])))
+ { $? "! pAh failed"
+ 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, wxpqdic_nl_dk[2], wxpqdic_nl_dk[3])))
+ { $? "! pHc failed"
+ goto finished;
+ }
+
+ /* Attempt to get localized texts in the users preferred language.
+ */
+ localizedTexts = pAh->GetStringTable(wxpqdic_nl_dk[1], wxpqdic_texts);
+ if(!(localizedTexts)) { localizedTexts = wxpqdic_texts; }
+
+ /* Initialize socket sub system.
+ */
+ dk4error_init(&sockerr);
+ if (DK4_SOCKET_RESULT_SUCCESS == dk4socket_up(&sockerr)) {
+ bSocketsInitialized = true;
+ }
+
+ /* Create and show frame.
+ */
+ frame = new WxpqdicFrame(
+ WxpqdicFrame_MainWindow,
+ pAh,
+ pHc,
+ argc,
+ argv,
+ localizedTexts,
+ wxpqdic_nl_wx,
+ wxpqdic_nl_dk,
+ bSocketsInitialized,
+ &sockerr
+ );
+ if(!(frame)) {
+ ShowMemoryErrorMessage();
+ goto finished;
+ }
+
+ /* Show frame and indicate success.
+ */
+ frame->Show();
+ frame->RestorePosition();
+ 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;
+ }
+ }
+ $? "- OnInit %d", ((back) ? 1 : 0)
+#if 0
+ if(!(back)) {
+ $!trace-end
+ }
+#endif
+ return back;
+}
+
+
+
+int
+WxpqdicApp::OnExit()
+{
+ int back = 0;
+ $? "+ OnExit"
+ /* __CHANGE__ 009: Release resources allocated by further members.
+ */
+ if (bSocketsInitialized) {
+ dk4socket_down(NULL);
+ }
+
+ /* Release resources. */
+ if (NULL != pHc) {
+ pHc->Cleanup();
+ delete(pHc);
+ pHc = NULL;
+ }
+ if (NULL != pAh) {
+ pAh->Cleanup();
+ delete(pAh);
+ pAh = NULL;
+ }
+ $? "- OnExit %d", back
+ $!trace-end
+ return back;
+}
+
+
+
+void
+WxpqdicApp::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 = wxpqdic_nl_wx[18];
+ }
+ if (NULL == s_text) {
+ s_text = wxpqdic_nl_wx[19];
+ }
+ wxMessageBox(s_text, s_title, (wxOK | wxCENTRE | wxICON_ERROR));
+}
+
+