summaryrefslogtreecommitdiff
path: root/support/dktools/WinprintChooserDialog.cpp
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /support/dktools/WinprintChooserDialog.cpp
Initial commit
Diffstat (limited to 'support/dktools/WinprintChooserDialog.cpp')
-rw-r--r--support/dktools/WinprintChooserDialog.cpp259
1 files changed, 259 insertions, 0 deletions
diff --git a/support/dktools/WinprintChooserDialog.cpp b/support/dktools/WinprintChooserDialog.cpp
new file mode 100644
index 0000000000..49ebcd19b8
--- /dev/null
+++ b/support/dktools/WinprintChooserDialog.cpp
@@ -0,0 +1,259 @@
+/*
+ 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: WinprintChooserDialog.wxc
+*/
+
+/*
+Copyright (C) 2013-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 WinprintChooserDialog.cpp The WinprintChooserDialog module.
+*/
+
+
+#line 134 "WinprintChooserDialog.wxc"
+
+#include "winprint.h"
+
+
+
+
+
+#line 140 "WinprintChooserDialog.wxc"
+
+
+/** Event table.
+*/
+BEGIN_EVENT_TABLE(WinprintChooserDialog, wxDialog)
+ EVT_BUTTON(wxID_OK, WinprintChooserDialog::OnOK)
+ EVT_BUTTON(wxID_CANCEL, WinprintChooserDialog::OnCancel)
+END_EVENT_TABLE()
+
+
+
+#line 151 "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 171 "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 195 "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);
+ }
+}
+
+