/* 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: DkWxProgressDialog.wxc */ /* Copyright (C) 2011-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. */ /** @file DkWxProgressDialog.cpp The DkWxProgressDialog module. */ #line 142 "DkWxProgressDialog.wxc" #include "dkwxtrace.h" #line 146 "DkWxProgressDialog.wxc" BEGIN_EVENT_TABLE(DkWxProgressDialog,wxDialog) EVT_IDLE(DkWxProgressDialog::OnIdle) EVT_BUTTON(wxID_CANCEL, DkWxProgressDialog::OnCancel) END_EVENT_TABLE() /** 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 179 "DkWxProgressDialog.wxc" }; #line 184 "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 203 "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 208 "DkWxProgressDialog.wxc" if(dkctGUILayoutOK) { if(sttWait) { sttWait->SetLabel(dkwx_pd_def_texts[0]); } } #line 214 "DkWxProgressDialog.wxc" } #line 219 "DkWxProgressDialog.wxc" void DkWxProgressDialog::OnIdle(wxIdleEvent & event) { int canContinue = 1; int res; #line 227 "DkWxProgressDialog.wxc" if(pComm) { #line 228 "DkWxProgressDialog.wxc" res = pComm->getUpdates(this, sttFilename, gaugeProgress); #line 230 "DkWxProgressDialog.wxc" if(res & DK_WX_COMMUNICATOR_STATUS_UPDATE) { #line 231 "DkWxProgressDialog.wxc" Refresh(); Update(); } else { #line 234 "DkWxProgressDialog.wxc" } if(res & DK_WX_COMMUNICATOR_STATUS_RUNNING) { #line 236 "DkWxProgressDialog.wxc" canContinue = 1; } else { #line 238 "DkWxProgressDialog.wxc" canContinue = 0; } } else { #line 241 "DkWxProgressDialog.wxc" canContinue = 0; } if(canContinue) { #line 244 "DkWxProgressDialog.wxc" event.RequestMore(); } else { #line 246 "DkWxProgressDialog.wxc" canContinue = 1; if(pComm) { canContinue = pComm->getCanContinue(); if(pLogTextField) { #line 250 "DkWxProgressDialog.wxc" pComm->getText(pLogTextField); if(pParent) { #line 252 "DkWxProgressDialog.wxc" pParent->Refresh(); } else { #line 254 "DkWxProgressDialog.wxc" pLogTextField->Refresh(); } } } if(IsModal()) { #line 259 "DkWxProgressDialog.wxc" EndModal((canContinue) ? wxID_OK : wxID_CANCEL); } else { #line 261 "DkWxProgressDialog.wxc" SetReturnCode((canContinue) ? wxID_OK : wxID_CANCEL); Show(false); } } event.Skip(); #line 266 "DkWxProgressDialog.wxc" } void DkWxProgressDialog::OnCancel(wxCommandEvent & event) { #line 274 "DkWxProgressDialog.wxc" if(pComm) { pComm->setCanContinue(0); } if(sttWait) { sttWait->SetLabel(sWaitPlease); } if(bCancel) { bCancel->Enable(false); bCancel->SetToolTip(sWaitPlease); } Refresh(); Update(); #line 287 "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 303 "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 316 "DkWxProgressDialog.wxc" }