/* Copyright (C) 2011-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: DkWxProgressDialog.wxc */ /** @file DkWxProgressDialog.cpp The DkWxProgressDialog module. */ #line 146 "DkWxProgressDialog.wxc" #include "dkwxtrace.h" #line 150 "DkWxProgressDialog.wxc" #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[] = { /* 0 */ wxT(""), /* 1 */ wxT("Progress"), /* 2 */ wxT("Cancel"), /* 3 */ wxT("Push button to interrupt processing."), /* 4 */ wxT("Cancel command scheduled... Wait, please!"), NULL #line 191 "DkWxProgressDialog.wxc" }; #line 196 "DkWxProgressDialog.wxc" 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 ) { #line 215 "DkWxProgressDialog.wxc" pParent = parent; pLogTextField = tc; pComm = comm; sWaitPlease = ((waitText) ? waitText : dkwx_pd_def_texts[4]); dkctGUILayoutOK = false; sDialog = NULL; verticalSizer = NULL; sttFilename = NULL; gaugeProgress = NULL; sttWait = NULL; bCancel = NULL; sDialog = new wxBoxSizer( wxHORIZONTAL ); if(!(sDialog)) { goto dkctGUILayoutFinished; } sDialog->Add(10, 10, 0); verticalSizer = new wxBoxSizer( wxVERTICAL ); if(!(verticalSizer)) { goto dkctGUILayoutFinished; } verticalSizer->Add(10, 10, 0); sttFilename = new wxStaticText( this, wxID_ANY, ((firstFileName) ? firstFileName : dkwx_pd_def_texts[0]), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE ); if(!(sttFilename)) { goto dkctGUILayoutFinished; } verticalSizer->Add( sttFilename, 1, wxALIGN_LEFT|wxGROW ); verticalSizer->Add(10, 10, 0); gaugeProgress = new wxGauge( this, wxID_ANY, 1000 ); if(!(gaugeProgress)) { goto dkctGUILayoutFinished; } verticalSizer->Add( gaugeProgress, 0, wxALIGN_CENTER_HORIZONTAL|wxGROW ); verticalSizer->Add(10, 10, 0); sttWait = new wxStaticText( this, wxID_ANY, ((waitText) ? waitText : dkwx_pd_def_texts[4]), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT ); if(!(sttWait)) { goto dkctGUILayoutFinished; } verticalSizer->Add( sttWait, 0, wxALIGN_LEFT ); verticalSizer->Add(10, 10, 0); bCancel = new wxButton( this, wxID_CANCEL, ((buttonText) ? buttonText : dkwx_pd_def_texts[2]) ); if(!(bCancel)) { goto dkctGUILayoutFinished; } bCancel->SetToolTip(((buttonTip) ? buttonTip : dkwx_pd_def_texts[3])); verticalSizer->Add( bCancel, 0, wxALIGN_CENTER_HORIZONTAL ); verticalSizer->Add(10, 10, 0); sDialog->Add( verticalSizer, 1, wxGROW ); sDialog->Add(10, 10, 0); SetSizer(sDialog); dkctGUILayoutOK = true; dkctGUILayoutFinished: if(dkctGUILayoutOK) { sDialog->Fit(this); sDialog->SetSizeHints(this); } #line 220 "DkWxProgressDialog.wxc" if(dkctGUILayoutOK) { if(sttWait) { sttWait->SetLabel(dkwx_pd_def_texts[0]); } } #line 226 "DkWxProgressDialog.wxc" } #line 231 "DkWxProgressDialog.wxc" void DkWxProgressDialog::OnIdle(wxIdleEvent & event) { int canContinue = 1; int res; #line 239 "DkWxProgressDialog.wxc" if(pComm) { #line 240 "DkWxProgressDialog.wxc" res = pComm->getUpdates(this, sttFilename, gaugeProgress); #line 242 "DkWxProgressDialog.wxc" if(res & DK_WX_COMMUNICATOR_STATUS_UPDATE) { #line 243 "DkWxProgressDialog.wxc" Refresh(); Update(); } else { #line 246 "DkWxProgressDialog.wxc" } if(res & DK_WX_COMMUNICATOR_STATUS_RUNNING) { #line 248 "DkWxProgressDialog.wxc" canContinue = 1; } else { #line 250 "DkWxProgressDialog.wxc" canContinue = 0; } } else { #line 253 "DkWxProgressDialog.wxc" canContinue = 0; } if(canContinue) { #line 256 "DkWxProgressDialog.wxc" event.RequestMore(); } else { #line 258 "DkWxProgressDialog.wxc" canContinue = 1; if(pComm) { canContinue = pComm->getCanContinue(); if(pLogTextField) { #line 262 "DkWxProgressDialog.wxc" pComm->getText(pLogTextField); if(pParent) { #line 264 "DkWxProgressDialog.wxc" pParent->Refresh(); } else { #line 266 "DkWxProgressDialog.wxc" pLogTextField->Refresh(); } } } if(IsModal()) { #line 271 "DkWxProgressDialog.wxc" EndModal((canContinue) ? wxID_OK : wxID_CANCEL); } else { #line 273 "DkWxProgressDialog.wxc" SetReturnCode((canContinue) ? wxID_OK : wxID_CANCEL); Show(false); } } event.Skip(); #line 278 "DkWxProgressDialog.wxc" } void DkWxProgressDialog::OnCancel(wxCommandEvent & WXUNUSED(event)) { #line 286 "DkWxProgressDialog.wxc" if(pComm) { pComm->setCanContinue(0); } if(sttWait) { sttWait->SetLabel(sWaitPlease); } if(bCancel) { bCancel->Enable(false); bCancel->SetToolTip(sWaitPlease); } Refresh(); Update(); #line 299 "DkWxProgressDialog.wxc" } 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. */ #line 315 "DkWxProgressDialog.wxc" /* 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); #line 328 "DkWxProgressDialog.wxc" }