OpenCPN Partial API docs
Loading...
Searching...
No Matches
print_dialog.cpp
Go to the documentation of this file.
1/***************************************************************************
2 * Copyright (C) 2025 by NoCodeHummel *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, see <https://www.gnu.org/licenses/>. *
16 **************************************************************************/
17
24#include "gui_lib.h"
25#include "print_dialog.h"
26
27PrintDialog::PrintDialog() {
28 wxPrintData data;
29 m_initialized = false;
30}
31
33 static PrintDialog instance;
34 return instance;
35}
36
37void PrintDialog::Initialize(wxPrintOrientation orientation) {
38 if (!m_initialized) {
39 wxPrintData data;
40 data.SetOrientation(orientation);
41 m_print_data = wxPrintDialogData(data);
42 m_initialized = true;
43 }
44}
45
47 m_print_data.EnablePageNumbers(enable);
48}
49
50void PrintDialog::Print(wxWindow* parent, wxPrintout* output) {
51 assert(m_initialized);
52 wxPrinter printer(&m_print_data);
53 if (!printer.Print(parent, output, true)) {
54 if (wxPrinter::GetLastError() == wxPRINTER_ERROR) {
55 OCPNMessageBox(
56 NULL,
57 _("There was a problem printing.\nPerhaps your current printer is "
58 "not set correctly?"),
59 _("OpenCPN"), wxOK);
60 }
61
62 } else {
63 wxPrintData data = printer.GetPrintDialogData().GetPrintData();
64 m_print_data.SetPrintData(data);
65 }
66}
Handle the print process and dialog.
void Initialize(wxPrintOrientation orientation)
Initialize the printer with default setup.
void Print(wxWindow *parent, wxPrintout *output)
Start print process and opens the print dialog.
void EnablePageNumbers(bool enable)
Print page numbers.
static PrintDialog & GetInstance()
Get instance to handle the print process,.
General purpose GUI support.
Generic, styled prit dialog.