/* Copyright (C) 2013-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: WinprintChooserDialog.wxc */ /** @file WinprintChooserDialog.cpp The WinprintChooserDialog module. */ #line 138 "WinprintChooserDialog.wxc" #include "dk3conf.h" #include "winprint.h" #line 146 "WinprintChooserDialog.wxc" /** Event table. */ #if wxCHECK_VERSION(3,0,0) wxBEGIN_EVENT_TABLE(WinprintChooserDialog,wxDialog) #else BEGIN_EVENT_TABLE(WinprintChooserDialog,wxDialog) #endif EVT_BUTTON(wxID_OK, WinprintChooserDialog::OnOK) EVT_BUTTON(wxID_CANCEL, WinprintChooserDialog::OnCancel) #if wxCHECK_VERSION(3,0,0) wxEND_EVENT_TABLE() #else END_EVENT_TABLE() #endif #line 166 "WinprintChooserDialog.wxc" WinprintChooserDialog::WinprintChooserDialog( DkWxFrame *parent, wxChar const *title, wxChar const * const *messageTexts, wxString const *printerNames, size_t numberOfPrinters ) : wxDialog( parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE ) { sTexts = messageTexts; cbChoosePrinter = NULL; pNames = printerNames; nNames = numberOfPrinters; dkctGUILayoutOK = false; sDialog = NULL; verticalSizer = NULL; sContents = NULL; sButtons = NULL; lChoosePrinter = NULL; bOK = NULL; bCancel = NULL; sDialog = new wxBoxSizer( wxHORIZONTAL ); if(!(sDialog)) { goto dkctGUILayoutFinished; } sDialog->Add(10, 10, 1); verticalSizer = new wxBoxSizer( wxVERTICAL ); if(!(verticalSizer)) { goto dkctGUILayoutFinished; } verticalSizer->Add(10, 10, 1); sContents = new wxGridBagSizer( 5, 5 ); if(!(sContents)) { goto dkctGUILayoutFinished; } lChoosePrinter = new wxStaticText( this, wxID_ANY, sTexts[31] ); if(!(lChoosePrinter)) { goto dkctGUILayoutFinished; } sContents->Add( lChoosePrinter, wxGBPosition(0, 0), wxGBSpan(1, 1) ); verticalSizer->Add( sContents ); verticalSizer->Add(10, 10, 1); sButtons = new wxStdDialogButtonSizer( ); if(!(sButtons)) { goto dkctGUILayoutFinished; } bOK = new wxButton( this, wxID_OK, sTexts[32] ); if(!(bOK)) { goto dkctGUILayoutFinished; } bOK->SetToolTip(sTexts[33]); sButtons->AddButton( bOK ); bCancel = new wxButton( this, wxID_CANCEL, sTexts[34] ); if(!(bCancel)) { goto dkctGUILayoutFinished; } bCancel->SetToolTip(sTexts[35]); sButtons->AddButton( bCancel ); sButtons->Realize(); verticalSizer->Add( sButtons, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL ); verticalSizer->Add(10, 10, 1); sDialog->Add( verticalSizer, 0, wxGROW ); sDialog->Add(10, 10, 1); SetSizer(sDialog); dkctGUILayoutOK = true; dkctGUILayoutFinished: if(dkctGUILayoutOK) { sDialog->Fit(this); sDialog->SetSizeHints(this); } #line 186 "WinprintChooserDialog.wxc" if(dkctGUILayoutOK) { if((pNames) && (nNames > 0)) { #if VERSION_BEFORE_20140929 cbChoosePrinter = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, nNames, pNames ); #else if ((dk3_um_t)DK3_I_MAX >= (dk3_um_t)nNames) { cbChoosePrinter = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, (int)nNames, pNames ); } #endif if(cbChoosePrinter) { cbChoosePrinter->SetToolTip(sTexts[36]); sContents->Add( cbChoosePrinter, wxGBPosition(0, 1), wxGBSpan(2, 1)); sDialog->Fit(this); sDialog->SetSizeHints(this); } } } } #line 210 "WinprintChooserDialog.wxc" void WinprintChooserDialog::setCurrentPrinter(int i) { unsigned count; /* Number of printers in chooser. */ int val; /* Corrected index. */ if(cbChoosePrinter) { count = cbChoosePrinter->GetCount(); val = i; if(i > ((int)count - 1)) { val = (int)count - 1; } if(val < 0) { val = 0; } cbChoosePrinter->SetSelection(val); } } int WinprintChooserDialog::getCurrentPrinter(void) { int back = wxNOT_FOUND; if(cbChoosePrinter) { back = cbChoosePrinter->GetSelection(); } return back; } void WinprintChooserDialog::OnOK(wxCommandEvent & event) { if(IsModal()) { EndModal(wxID_OK); } else { SetReturnCode(wxID_OK); Show(false); } } void WinprintChooserDialog::OnCancel(wxCommandEvent & event) { if(IsModal()) { EndModal(wxID_CANCEL); } else { SetReturnCode(wxID_CANCEL); Show(false); } }