summaryrefslogtreecommitdiff
path: root/support/dktools/DkWxProgressDialog.wxc
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2020-10-12 03:04:00 +0000
committerNorbert Preining <norbert@preining.info>2020-10-12 03:04:00 +0000
commit0ce40abb18ec02ec6fd6bcc5f21612c88daa7578 (patch)
tree416289fe1448873fd8ca33051f50ad85bffa8aaa /support/dktools/DkWxProgressDialog.wxc
parentfdb18507cd80dc17f5a5256153d34668b4f4e61c (diff)
CTAN sync 202010120303
Diffstat (limited to 'support/dktools/DkWxProgressDialog.wxc')
-rw-r--r--support/dktools/DkWxProgressDialog.wxc330
1 files changed, 0 insertions, 330 deletions
diff --git a/support/dktools/DkWxProgressDialog.wxc b/support/dktools/DkWxProgressDialog.wxc
deleted file mode 100644
index 6bc57abadf..0000000000
--- a/support/dktools/DkWxProgressDialog.wxc
+++ /dev/null
@@ -1,330 +0,0 @@
-%% options
-
-copyright owner = Dirk Krause
-copyright year = 2011-xxxx
-SPDX-License-Identifier: BSD-3-Clause
-
-
-%% wx-gui
-
-type = dialog
-contents = sDialog
-# status bar = 1 dkwx_pd_def_texts[0]
-# title = ((title) ? title : dkwx_pd_def_texts[1])
-
-[wxBoxSizer sDialog]
-direction = horizontal
-contents = $space(10)
-contents = verticalSizer
-contents = $space(10)
-
-[wxBoxSizer verticalSizer]
-direction = vertical
-grow = yes
-proportion = 1
-contents = $space(10)
-contents = sttFilename left
-contents = $space(10)
-contents = gaugeProgress centered-x
-contents = $space(10)
-contents = sttWait left
-contents = $space(10)
-contents = bCancel centered-x
-contents = $space(10)
-
-[wxStaticText sttFilename]
-text = ((firstFileName) ? firstFileName : dkwx_pd_def_texts[0])
-text style = centered
-grow = yes
-proportion = 1
-
-[wxGauge gaugeProgress]
-range = 1000
-value = 0
-grow = yes
-
-[wxButton bCancel]
-text = ((buttonText) ? buttonText : dkwx_pd_def_texts[2])
-tip = ((buttonTip) ? buttonTip : dkwx_pd_def_texts[3])
-id = wxID_CANCEL
-
-[wxStaticText sttWait]
-text = ((waitText) ? waitText : dkwx_pd_def_texts[4])
-text style = left no-auto-resize
-
-
-
-%% header start
-
-#include <DkWxCommunicator.h>
-
-
-
-%% class start
-
-/** Progress dialog showing currently process file, progress bar
- and a button to abort operation.
-*/
-class DkWxProgressDialog : public wxDialog
-{
- private:
- /** Event table.
- */
-#if wxCHECK_VERSION(3,0,0)
- wxDECLARE_EVENT_TABLE();
-#else
- DECLARE_EVENT_TABLE()
-#endif
-
- protected:
-
- /** Communicator object delivering the file name and progress bar
- value.
- */
- DkWxCommunicator *pComm;
-
- /** String: Cancel operation scheduled. Please wait.
- */
- wxChar const *sWaitPlease;
-
- /** Parent frame.
- */
- DkWxFrame *pParent;
-
- /** Log text field to receive the messages.
- */
- wxTextCtrl *pLogTextField;
-
-%% class end
- public:
-
- /** Constructor.
- @param parent Parent window.
- @param comm Communicator object.
- @param tc Text control to show messages.
- @param title Title text.
- @param firstFileName First file name to show.
- @param buttonText Text for "Cancel" button.
- @param buttonTip Tooltip text for button.
- @param waitText Button to show while waiting for thread exit.
- */
- DkWxProgressDialog(
- DkWxFrame *parent,
- DkWxCommunicator *comm,
- wxTextCtrl *tc,
- wxChar const *title,
- wxChar const *firstFileName,
- wxChar const *buttonText,
- wxChar const *buttonTip,
- wxChar const *waitText
- );
-
- /** Handler for idle events.
- We request the current file name and progress bar from
- the communicator object and update the information shown
- in the dialog.
- */
- void
- OnIdle(wxIdleEvent & event);
-
- /** Handler for cancel button.
- */
- void
- OnCancel(wxCommandEvent & event);
-
- /** Choose a modal position centered on the parent.
- */
- void chooseModalPosition();
-
-};
-
-
-
-%% header end
-
-%% module start
-
-#include "dkwxtrace.h"
-
-$!trace-include
-
-#if wxCHECK_VERSION(3,0,0)
-wxBEGIN_EVENT_TABLE(DkWxProgressDialog,wxDialog)
-#else
-BEGIN_EVENT_TABLE(DkWxProgressDialog,wxDialog)
-#endif
- EVT_IDLE(DkWxProgressDialog::OnIdle)
- EVT_BUTTON(wxID_CANCEL, DkWxProgressDialog::OnCancel)
-#if wxCHECK_VERSION(3,0,0)
-wxEND_EVENT_TABLE()
-#else
-END_EVENT_TABLE()
-#endif
-
-
-
-/** Default texts to use if the constructor has NULL pointer arguments.
-*/
-wxChar const * const dkwx_pd_def_texts[] = {
-$!string-table macro=wxT
-#
-# 0: Empty string
-#
-
-#
-# 1: Default title.
-#
-Progress
-#
-# 2: Button text.
-#
-Cancel
-#
-# 3: Button tool tip.
-#
-Push button to interrupt processing.
-#
-# 4: Notification, user should wait.
-#
-Cancel command scheduled... Wait, please!
-$!end
-};
-
-
-
-%% constructor start
-DkWxProgressDialog::DkWxProgressDialog(
- DkWxFrame *parent,
- DkWxCommunicator *comm,
- wxTextCtrl *tc,
- wxChar const *title,
- wxChar const *firstFileName,
- wxChar const *buttonText,
- wxChar const *buttonTip,
- wxChar const *waitText
-) : wxDialog(
- parent,
- wxID_ANY,
- ((title) ? title : dkwx_pd_def_texts[1]),
- wxDefaultPosition,
- wxDefaultSize,
- wxDEFAULT_DIALOG_STYLE
-)
-{
- $? "+ DkWxProgressDialog::DkWxProgressDialog"
- pParent = parent;
- pLogTextField = tc;
- pComm = comm;
- sWaitPlease = ((waitText) ? waitText : dkwx_pd_def_texts[4]);
-%% constructor end
- if(dkctGUILayoutOK) {
- if(sttWait) {
- sttWait->SetLabel(dkwx_pd_def_texts[0]);
- }
- }
- $? "- DkWxProgressDialog::DkWxProgressDialog"
-}
-
-
-
-%% module end
-
-
-void
-DkWxProgressDialog::OnIdle(wxIdleEvent & event)
-{
- int canContinue = 1;
- int res;
- $? "+ DkWxProgressDialog::OnIdle"
- if(pComm) { $? ". pComm ok"
- res = pComm->getUpdates(this, sttFilename, gaugeProgress);
- $? ". res = %d", res
- if(res & DK_WX_COMMUNICATOR_STATUS_UPDATE) { $? ". must update"
- Refresh();
- Update();
- } else { $? ". no update"
- }
- if(res & DK_WX_COMMUNICATOR_STATUS_RUNNING) { $? ". can continue"
- canContinue = 1;
- } else { $? ". finished, end indicated"
- canContinue = 0;
- }
- } else { $? "! no pComm"
- canContinue = 0;
- }
- if(canContinue) { $? ". can continue"
- event.RequestMore();
- } else { $? ". finished"
- canContinue = 1;
- if(pComm) {
- canContinue = pComm->getCanContinue();
- if(pLogTextField) { $? ". transfer text"
- pComm->getText(pLogTextField);
- if(pParent) { $? ". refresh win"
- pParent->Refresh();
- } else { $? ". refresh text"
- pLogTextField->Refresh();
- }
- }
- }
- if(IsModal()) { $? ". end modal"
- EndModal((canContinue) ? wxID_OK : wxID_CANCEL);
- } else { $? ". show false"
- SetReturnCode((canContinue) ? wxID_OK : wxID_CANCEL);
- Show(false);
- }
- }
- event.Skip(); $? "- DkWxProgressDialog::OnIdle"
-}
-
-
-
-void
-DkWxProgressDialog::OnCancel(wxCommandEvent & WXUNUSED(event))
-{
- $? "+ DkWxProgressDialog::OnCancel"
- if(pComm) {
- pComm->setCanContinue(0);
- }
- if(sttWait) {
- sttWait->SetLabel(sWaitPlease);
- }
- if(bCancel) {
- bCancel->Enable(false);
- bCancel->SetToolTip(sWaitPlease);
- }
- Refresh();
- Update();
- $? "- DkWxProgressDialog::OnCancel"
-}
-
-
-
-void
-DkWxProgressDialog::chooseModalPosition()
-{
- int px = 0; /* Parent x position. */
- int py = 0; /* Parent y position. */
- int pw = 0; /* Parent width. */
- int ph = 0; /* Parent height. */
- int x = 0; /* X position. */
- int y = 0; /* Y position. */
- int w = 0; /* Width. */
- int h = 0; /* Height. */
- $? "+ DkWxProgressDialog::chooseModalPosition"
- /* Sceen size */
- wxSize scsz = wxGetDisplaySize();
- pParent->GetPosition(&px, &py);
- pParent->GetSize(&pw, &ph);
- GetSize(&w, &h);
- x = px + (pw - w) / 2;
- y = py + (ph - h) / 2;
- if((x + w) > scsz.x) { x = scsz.x - w; }
- if((y + h) > scsz.y) { y = scsz.y - h; }
- if(x < 0) { x = 0; }
- if(y < 0) { y = 0; }
- SetSize(x, y, w, h);
- $? "- DkWxProgressDialog::chooseModalPosition"
-}
-
-