summaryrefslogtreecommitdiff
path: root/support/dktools/Dk4WxFrame.cpp
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2020-09-20 03:03:26 +0000
committerNorbert Preining <norbert@preining.info>2020-09-20 03:03:26 +0000
commit1f457376b478257b88d4a857f5ec1b6155442dd7 (patch)
tree2a06a60551dea362cf8cb0cb0ba66c78608717c4 /support/dktools/Dk4WxFrame.cpp
parentac690ca29ad5bf8a5203a65fd6252f7b564f4727 (diff)
CTAN sync 202009200303
Diffstat (limited to 'support/dktools/Dk4WxFrame.cpp')
-rw-r--r--support/dktools/Dk4WxFrame.cpp488
1 files changed, 435 insertions, 53 deletions
diff --git a/support/dktools/Dk4WxFrame.cpp b/support/dktools/Dk4WxFrame.cpp
index ead3817166..4d684ace05 100644
--- a/support/dktools/Dk4WxFrame.cpp
+++ b/support/dktools/Dk4WxFrame.cpp
@@ -1,52 +1,59 @@
/*
- 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: Dk4WxFrame.cpt
+Copyright (C) 2015-2020, Dirk Krause
+SPDX-License-Identifier: BSD-3-Clause
*/
/*
-Copyright (C) 2015-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.
+ 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: Dk4WxFrame.cpt
*/
/** @file Dk4WxFrame.cpp The Dk4WxFrame module.
*/
-#line 136 "Dk4WxFrame.cpt"
+#line 166 "Dk4WxFrame.cpt"
+
+#ifndef DK4CONF_H_INCLUDED
+#include "dk4conf.h"
+#endif
+#ifndef DK4WXFRAME_H_INCLUDED
#include "Dk4WxFrame.h"
+#endif
+#ifndef DK4MPL_H_INCLUDED
+#include "dk4mpl.h"
+#endif
+#ifndef DK4MEM_H_INCLUDED
+#include "dk4mem.h"
+#endif
+#ifndef DK4STRD_H_INCLUDED
+#include "dk4strd.h"
+#endif
+
+#ifndef DK4PATHD_H_INCLUDED
+#include "dk4pathd.h"
+#endif
+
+#ifndef DK4STRX_H_INCLUDED
+#include "dk4strx.h"
+#endif
+
+#ifndef DK4RECWX_H_INCLUDED
+#include "dk4recwx.h"
+#endif
-#line 143 "Dk4WxFrame.cpt"
+
+
+#line 202 "Dk4WxFrame.cpt"
@@ -87,7 +94,7 @@ wxT("window.iconized"),
NULL
-#line 170 "Dk4WxFrame.cpt"
+#line 229 "Dk4WxFrame.cpt"
};
@@ -107,7 +114,38 @@ wxT("window.restore-size"),
NULL
-#line 182 "Dk4WxFrame.cpt"
+#line 241 "Dk4WxFrame.cpt"
+};
+
+
+
+/** File name suffixes indicating to open file in web browser.
+*/
+static const wxChar * const dk4wxframe_suffix_web[] = {
+/* 0 */
+wxT(".html"),
+
+/* 1 */
+wxT(".htm"),
+
+NULL
+
+
+#line 252 "Dk4WxFrame.cpt"
+};
+
+
+
+/** Static text fragments, not localized.
+*/
+static const wxChar * const dk4wxframe_kwnl_wx[] = {
+/* 0 */
+wxT("file://"),
+
+NULL
+
+
+#line 265 "Dk4WxFrame.cpt"
};
@@ -167,7 +205,7 @@ Dk4WxFrame::OnClose(wxCloseEvent & event)
bool
-Dk4WxFrame::CanClose(bool isFinal)
+Dk4WxFrame::CanClose(bool WXUNUSED(isFinal))
{
return true;
}
@@ -177,6 +215,9 @@ void
Dk4WxFrame::SavePosition(void)
{
int iv[6];
+
+
+#line 335 "Dk4WxFrame.cpt"
if (NULL != pAppHelp) {
iv[4] = iv[5] = 0;
if (IsIconized()) {
@@ -191,21 +232,24 @@ Dk4WxFrame::SavePosition(void)
GetSize(&(iv[2]), &(iv[3]));
-#line 264 "Dk4WxFrame.cpt"
+#line 348 "Dk4WxFrame.cpt"
-#line 265 "Dk4WxFrame.cpt"
+#line 349 "Dk4WxFrame.cpt"
-#line 266 "Dk4WxFrame.cpt"
+#line 350 "Dk4WxFrame.cpt"
-#line 267 "Dk4WxFrame.cpt"
+#line 351 "Dk4WxFrame.cpt"
-#line 268 "Dk4WxFrame.cpt"
+#line 352 "Dk4WxFrame.cpt"
pAppHelp->SetMultiple(dk4wxframe_kw_size, iv, 6);
}
+
+
+#line 355 "Dk4WxFrame.cpt"
}
@@ -214,7 +258,7 @@ void
Dk4WxFrame::RestorePosition(void)
{
int iv[6]; /* Values stored in config */
- bool bv[3]; /* Feature restore */
+ bool bv[3]; /* Feature restore: maximized, iconized, position */
int x; /* X position */
int y; /* Y position */
int w; /* Width */
@@ -222,13 +266,11 @@ Dk4WxFrame::RestorePosition(void)
-#line 285 "Dk4WxFrame.cpt"
+#line 370 "Dk4WxFrame.cpt"
-#if wxCHECK_VERSION(3,0,0)
- bv[2] = false;
-#else
+ /* Restore position by default.
+ */
bv[2] = true;
-#endif
/* Initialize variables.
*/
@@ -240,7 +282,34 @@ Dk4WxFrame::RestorePosition(void)
*/
if (NULL != pAppHelp) {
pAppHelp->GetMultiple(dk4wxframe_kw_size, iv, 6);
+
+
+#line 386 "Dk4WxFrame.cpt"
+
+
+#line 387 "Dk4WxFrame.cpt"
+
+
+#line 388 "Dk4WxFrame.cpt"
+
+
+#line 389 "Dk4WxFrame.cpt"
+
+
+#line 390 "Dk4WxFrame.cpt"
+
+
+#line 391 "Dk4WxFrame.cpt"
pAppHelp->GetMultiple(dk4wxframe_kw_restore, bv, 3);
+
+
+#line 393 "Dk4WxFrame.cpt"
+
+
+#line 394 "Dk4WxFrame.cpt"
+
+
+#line 395 "Dk4WxFrame.cpt"
}
/* Find size if not stored.
@@ -248,27 +317,92 @@ Dk4WxFrame::RestorePosition(void)
GetSize(&w, &h);
x = iv[0];
y = iv[1];
+
+
+#line 403 "Dk4WxFrame.cpt"
+
+
+#line 404 "Dk4WxFrame.cpt"
+
+
+#line 405 "Dk4WxFrame.cpt"
+
+
+#line 406 "Dk4WxFrame.cpt"
/* Correct size if size restoration wanted, increase if necessary.
*/
if (bv[2]) {
-#line 314 "Dk4WxFrame.cpt"
- if (iv[2] > w) { w = iv[2]; }
- if (iv[3] > h) { h = iv[3]; }
+#line 410 "Dk4WxFrame.cpt"
+ if (iv[2] > w) {
+ w = iv[2];
+
+#line 412 "Dk4WxFrame.cpt"
+ }
+ if (iv[3] > h) {
+ h = iv[3];
+
+#line 415 "Dk4WxFrame.cpt"
+ }
}
/* Correct values, no parts of window should be outside screen.
*/
Dk4WxApplicationHelper::CorrectPosition(x, y, w, h);
+
+
+#line 422 "Dk4WxFrame.cpt"
+
+
+#line 423 "Dk4WxFrame.cpt"
+
+
+#line 424 "Dk4WxFrame.cpt"
+
+
+#line 425 "Dk4WxFrame.cpt"
/* Set position and optionally size.
*/
if (bv[2]) {
-#line 325 "Dk4WxFrame.cpt"
+#line 429 "Dk4WxFrame.cpt"
SetSize(x, y, w, h);
- } else {
+#if wxCHECK_VERSION(3,0,0)
+ {
+ int t1 = 0;
+ int t2 = 0;
+ GetSize(&t1, &t2);
+ if ((t1 > w) || (t2 > h)) {
+
+#line 436 "Dk4WxFrame.cpt"
+ if (t1 > w) {
+ w = w - (t1 - w);
+
+#line 438 "Dk4WxFrame.cpt"
+ }
+ if (t2 > h) {
+ h = h - (t2 - h);
+
+#line 441 "Dk4WxFrame.cpt"
+ }
+
+#line 442 "Dk4WxFrame.cpt"
+ SetSize(x, y, w, h);
+ GetSize(&t1, &t2);
+
+
+#line 445 "Dk4WxFrame.cpt"
+
+
+#line 446 "Dk4WxFrame.cpt"
+ }
+ }
+#endif
+ } else {
+
+#line 450 "Dk4WxFrame.cpt"
SetPosition( wxPoint(x,y) );
}
@@ -276,18 +410,30 @@ Dk4WxFrame::RestorePosition(void)
*/
if (bv[0]) {
-#line 333 "Dk4WxFrame.cpt"
+#line 456 "Dk4WxFrame.cpt"
Maximize(0 != iv[4]);
}
+#if TRACE_DEBUG
+ else {
+
+#line 460 "Dk4WxFrame.cpt"
+ }
+#endif
if (bv[1]) {
-#line 336 "Dk4WxFrame.cpt"
+#line 463 "Dk4WxFrame.cpt"
Iconize(0 != iv[5]);
}
+#if TRACE_DEBUG
+ else {
+
+#line 467 "Dk4WxFrame.cpt"
+ }
+#endif
-#line 340 "Dk4WxFrame.cpt"
+#line 471 "Dk4WxFrame.cpt"
}
@@ -321,3 +467,239 @@ Dk4WxFrame::DisplaySection(int number)
}
+
+bool
+Dk4WxFrame::FindFileAndLaunch(dkChar const *fn, bool bIsHelp, bool bVerbose)
+{
+ wxChar bw[2 * DK4_MAX_PATH]; /* Full path in wxChar */
+ wxChar b2[2 * DK4_MAX_PATH];
+ dkChar b1[DK4_MAX_PATH]; /* Search result (full path) */
+ wxChar const *psuffix; /* File name suffix */
+ wxChar *pmod;
+ size_t szb1 = DK4_SIZEOF(b1,dkChar); /* Size of b1 (num of dkChar) */
+ size_t szb2 = DK4_SIZEOF(b2,wxChar); /* Size of b2 (num of wxChar) */
+ size_t szbw = DK4_SIZEOF(bw,wxChar); /* Size of bw (num of wxChar) */
+ int res; /* Operation result */
+ int de; /* Destination encoding */
+ int se; /* Source encoding */
+ bool isweb; /* Use web browser */
+ bool done; /* Successfully done */
+ bool back; /* Result */
+
+
+#line 523 "Dk4WxFrame.cpt"
+ back = false;
+ if ((NULL != fn) && (NULL != pAppHelp)) {
+ done = false;
+ /*
+ Check for absolute path.
+ Use absolute path unchanged.
+ For a relative path do file search.
+ */
+ if (0 != dk4path_is_absolute(fn)) {
+
+#line 532 "Dk4WxFrame.cpt"
+ if (0 != dk4str_cpy_s(b1, szb1, fn, NULL)) {
+
+#line 533 "Dk4WxFrame.cpt"
+ done = true;
+ }
+#if TRACE_DEBUG
+ else {
+
+#line 537 "Dk4WxFrame.cpt"
+ }
+#endif
+ }
+ else {
+
+#line 541 "Dk4WxFrame.cpt"
+ if (bIsHelp) {
+ if (pAppHelp->FindHelpFile(b1, szb1, fn)) {
+
+#line 543 "Dk4WxFrame.cpt"
+ done = true;
+
+#line 544 "Dk4WxFrame.cpt"
+ }
+#if TRACE_DEBUG
+ else {
+
+#line 547 "Dk4WxFrame.cpt"
+ }
+#endif
+ }
+ else {
+ if (pAppHelp->FindDataFile(b1, szb1, fn)) {
+
+#line 552 "Dk4WxFrame.cpt"
+ done = true;
+
+#line 553 "Dk4WxFrame.cpt"
+ }
+#if TRACE_DEBUG
+ else {
+
+#line 556 "Dk4WxFrame.cpt"
+ }
+#endif
+ }
+ }
+ if (done) {
+ done = false;
+ de = pAppHelp->GetWxEncoding();
+ se = pAppHelp->GetDkEncoding();
+ res = dk4recwx_dkchar_to_wxchar(bw, szbw, de, b1, se, NULL);
+ if (0 != res) {
+
+#line 566 "Dk4WxFrame.cpt"
+ isweb = false;
+
+#line 567 "Dk4WxFrame.cpt"
+ psuffix = dk4strx_get_path_suffix(bw, NULL);
+ if (NULL != psuffix) {
+
+#line 569 "Dk4WxFrame.cpt"
+ if (0 <= dk4strx_array_index(dk4wxframe_suffix_web, psuffix, 0)) {
+ isweb = true;
+
+#line 571 "Dk4WxFrame.cpt"
+ }
+ }
+ if (isweb) {
+
+#line 574 "Dk4WxFrame.cpt"
+ if (::wxLaunchDefaultBrowser(bw)) {
+ done = true;
+
+#line 576 "Dk4WxFrame.cpt"
+ back = true;
+ }
+ else {
+
+#line 579 "Dk4WxFrame.cpt"
+ if (0 != dk4strx_cpy_s(b2, szb2, dk4wxframe_kwnl_wx[0], NULL)) {
+
+
+#line 581 "Dk4WxFrame.cpt"
+ if (0 != dk4strx_cat_s(b2, szb2, bw, NULL)) {
+
+#line 582 "Dk4WxFrame.cpt"
+
+
+#line 583 "Dk4WxFrame.cpt"
+ if (::wxLaunchDefaultBrowser(bw)) {
+
+#line 584 "Dk4WxFrame.cpt"
+ done = true;
+ back = true;
+ }
+ else {
+
+#line 588 "Dk4WxFrame.cpt"
+ pmod = &(b2[dk4strx_len(dk4wxframe_kwnl_wx[0])]);
+ while (wxT('\0') != *pmod) {
+ if (wxT('\\') == *pmod) { *pmod = wxT('/'); }
+ pmod++;
+ }
+
+#line 593 "Dk4WxFrame.cpt"
+
+
+#line 594 "Dk4WxFrame.cpt"
+ if (::wxLaunchDefaultBrowser(bw)) {
+ done = true;
+
+#line 596 "Dk4WxFrame.cpt"
+ back = true;
+ }
+#if TRACE_DEBUG
+ else {
+
+#line 600 "Dk4WxFrame.cpt"
+ }
+#endif
+ }
+ }
+ else {
+
+#line 605 "Dk4WxFrame.cpt"
+ /* ##### ERROR: BUG */
+ }
+ }
+ else {
+
+#line 609 "Dk4WxFrame.cpt"
+ /* ##### ERROR: BUG */
+ }
+ }
+ }
+ if (!(done)) {
+
+#line 614 "Dk4WxFrame.cpt"
+#if wxCHECK_VERSION(3,0,0)
+ if (::wxLaunchDefaultApplication(bw)) {
+
+#line 616 "Dk4WxFrame.cpt"
+ done = true;
+ back = true;
+ }
+#if TRACE_DEBUG
+ else {
+
+#line 621 "Dk4WxFrame.cpt"
+ }
+#endif
+#endif
+ }
+ if (!(done)) {
+ /* ERROR: Failed to start application */
+ if (bVerbose) {
+ wxString t;
+ t.Append(pAppHelp->GetBasicString(12));
+ t.Append(bw);
+ t.Append(pAppHelp->GetBasicString(13));
+ ::wxMessageBox(
+ t, pAppHelp->GetBasicString(11), (wxOK | wxCENTRE | wxICON_ERROR)
+ );
+ }
+ }
+ }
+ else {
+
+#line 639 "Dk4WxFrame.cpt"
+ /* ERROR: Recoding failed */
+ if (bVerbose) {
+ ::wxMessageBox(
+ pAppHelp->GetBasicString(10), pAppHelp->GetBasicString(9),
+ (wxOK | wxCENTRE | wxICON_ERROR)
+ );
+ }
+ }
+ }
+ else {
+
+#line 649 "Dk4WxFrame.cpt"
+ /* ERROR: File not found */
+ if (bVerbose) {
+ ::wxMessageBox(
+ pAppHelp->GetBasicString(10), pAppHelp->GetBasicString(9),
+ (wxOK | wxCENTRE | wxICON_ERROR)
+ );
+ }
+ }
+ }
+#if TRACE_DEBUG
+ else {
+
+#line 660 "Dk4WxFrame.cpt"
+ }
+#endif
+
+
+#line 663 "Dk4WxFrame.cpt"
+ return back;
+}
+
+
+