wxMaxima
Loading...
Searching...
No Matches
PageSettings.h
Go to the documentation of this file.
1// -*- mode: c++; c-file-style: "linux"; c-basic-offset: 2; indent-tabs-mode: nil -*-
2//
3// Copyright (C) 2026 Gunter Königsmann <wxMaxima@physikbuch.de>
4//
5// This program is free software; you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation; either version 2 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15//
16// You should have received a copy of the GNU General Public License
17// along with this program; if not, write to the Free Software
18// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19//
20// SPDX-License-Identifier: GPL-2.0+
21
26#ifndef PAGESETTINGS_H
27#define PAGESETTINGS_H
28
29#include "precomp.h"
30#include <wx/defs.h>
31#include <wx/gdicmn.h>
32#include <wx/string.h>
33#include <optional>
34
35class wxXmlNode;
36
37namespace wxm {
38
51{
53 wxPaperSize paper = wxPAPER_A4;
55 wxPrintOrientation orientation = wxPORTRAIT;
57 double marginTop = 10;
58 double marginBottom = 10;
59 double marginLeft = 10;
60 double marginRight = 10;
62 double scale = 1.0;
75 static constexpr long DefaultLayoutDpi = 600;
76
77 bool operator==(const PageSettings &) const = default;
78
84 wxRealPoint PaperSizeMm() const;
90 wxRealPoint PrintableSizeMm() const;
91
99 wxRealPoint PrintableSizeAt96Dpi() const;
100
107
113 wxString ToXMLAttributes() const;
119 static std::optional<PageSettings> FromXML(const wxXmlNode *root);
120
122 static wxString PaperName(wxPaperSize paper);
123};
124
125} // namespace wxm
126
127#endif // PAGESETTINGS_H
The paper a worksheet is printed or exported to PDF on.
Definition: PageSettings.h:51
wxRealPoint PaperSizeMm() const
The size of the paper in mm, as it is oriented.
Definition: PageSettings.cpp:72
wxPaperSize paper
The paper size, as wxWidgets' print dialog knows it.
Definition: PageSettings.h:53
double scale
Makes everything on paper bigger (> 1) or smaller (< 1)
Definition: PageSettings.h:62
static constexpr long DefaultLayoutDpi
The layoutDpi a document without one gets: the commonest printer resolution.
Definition: PageSettings.h:75
static std::optional< PageSettings > FromXML(const wxXmlNode *root)
The settings a .wxmx's root element stores, if it stores any.
Definition: PageSettings.cpp:124
wxRealPoint PrintableSizeAt96Dpi() const
The size of the printable area in the worksheet's unzoomed pixels.
Definition: PageSettings.cpp:86
long layoutDpi
The printer resolution text is measured for, in dots per inch.
Definition: PageSettings.h:73
static wxString PaperName(wxPaperSize paper)
The paper's name in the language of the user interface ("A4 sheet, 210 x 297 mm")
Definition: PageSettings.cpp:146
PageSettings & Sanitize()
Makes the values sensible: margins between 0 and 100 mm, a scale between 0.1 and 4,...
Definition: PageSettings.cpp:92
double marginTop
The margins, in mm.
Definition: PageSettings.h:57
wxRealPoint PrintableSizeMm() const
The size of the part of the paper inside the margins, in mm.
Definition: PageSettings.cpp:80
wxString ToXMLAttributes() const
The attributes a .wxmx's root element stores these settings in.
Definition: PageSettings.cpp:109
wxPrintOrientation orientation
Portrait or landscape.
Definition: PageSettings.h:55