wxMaxima
Loading...
Searching...
No Matches
OutCommon.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) 2004-2015 Andrej Vodopivec <andrej.vodopivec@gmail.com>
4// Copyright (C) 2015 Gunter Königsmann <wxMaxima@physikbuch.de>
5// Copyright (C) 2020 Kuba Ober <kuba@bertec.com>
6//
7// This program is free software; you can redistribute it and/or modify
8// it under the terms of the GNU General Public License as published by
9// the Free Software Foundation; either version 2 of the License, or
10// (at your option) any later version.
11//
12// This program is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17//
18// You should have received a copy of the GNU General Public License
19// along with this program; if not, write to the Free Software
20// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21//
22// SPDX-License-Identifier: GPL-2.0+
23
24#ifndef OUTCOMMON_H
25#define OUTCOMMON_H
26
27#include "Configuration.h"
28#include "precomp.h"
29#include <wx/dataobj.h>
30#include <memory>
31
37class Cell;
38class wxDC;
39
43{
44public:
46 class DataObject final : public wxCustomDataObject
47 {
48 wxMemoryBuffer m_databuf;
49
50 public:
51 explicit DataObject(const wxDataFormat &format, const wxMemoryBuffer &data);
52 bool GetDataHere(void *buf) const override;
53 size_t GetDataSize() const override;
54 void Free() override;
55 };
56
59 std::unique_ptr<DataObject> GetDataObject(const wxDataFormat &format);
60
82 static wxString AccessibleText(const Cell *tree);
83
93 explicit OutCommon(const Configuration * const *configuration, const wxString &filename,
94 int fullWidth, double scale);
95 explicit OutCommon(const Configuration * const *configuration, int fullWidth, double scale);
96 ~OutCommon();
97
98 OutCommon(const OutCommon&) = delete;
99 void operator=(const OutCommon&) = delete;
100
101 int Scale_Px(double px) const { return m_thisconfig.Scale_Px(px); }
102 double GetScale() const { return m_scale; }
103 const wxString &GetFilename() const { return m_filename; }
104 const wxString &GetTempFilename() const { return m_tempFilename; }
106 Configuration *GetConfiguration() { return &m_thisconfig; }
108 const Configuration &GetScreenConfig() const { return *(*m_configuration); }
109 wxSize getPPI() const { return m_ppi; }
110
112 void SetRecalculationContext(wxDC *context) { m_recalculationDc = context; }
113
115 bool PrepareLayout(Cell *tree);
116
118 wxSize GetSize() const { return m_size; }
120 void SetSize(wxSize size) { m_size = size; }
121
123 wxSize GetScaledSize() const;
125 wxSize GetInvScaledSize() const;
126
129 bool ToClipboard(const wxDataFormat &format);
130
132 void Draw(Cell *tree);
133
134private:
135 void GetMaxPoint(Cell *tree, int *width, int *height) const;
136 void Recalculate(Cell *tree) const;
137
138 void BreakLines(Cell *tree) const;
139 void BreakUpCells(Cell *tree) const;
140
142 wxString m_tempFilename;
144 wxDC *m_recalculationDc = {};
145
146 wxString m_filename;
147 const Configuration * const *m_configuration;
148 const Configuration *m_oldconfig = *m_configuration;
149 Configuration m_thisconfig{ {}, Configuration::temporary };
151 double m_scale = 1.0;
153 wxSize m_size = wxDefaultSize;
155 int m_fullWidth;
157 wxSize m_ppi;
158};
159
160#endif // OUTCOMMON_H
The base class all cell types the worksheet can consist of are derived from.
Definition: Cell.h:148
The configuration storage for the current worksheet.
Definition: Configuration.h:98
wxCoord Scale_Px(double px) const
Scales a distance [in pixels] according to the zoom factor.
Definition: Configuration.cpp:1151
@ temporary
This configuration is temporary and shouldn't redetect Maxima etc.
Definition: Configuration.h:179
An object that can be filled with output data in given format for the clipboard.
Definition: OutCommon.h:47
A collection of common code used in rendering the cells to a non-default output, e....
Definition: OutCommon.h:43
std::unique_ptr< DataObject > GetDataObject(const wxDataFormat &format)
Returns the representation that can be placed on the clipboard. Removes the file the data was saved i...
Definition: OutCommon.cpp:296
bool ToClipboard(const wxDataFormat &format)
Copies the representation of the list of cells that was passed to SetData() to the clipboard.
Definition: OutCommon.cpp:283
wxSize GetSize() const
Returns the size of the prepared output layout.
Definition: OutCommon.h:118
void SetRecalculationContext(wxDC *context)
Sets the context for the configuration used in recalculating the cell dimensions.
Definition: OutCommon.h:112
wxSize GetScaledSize() const
Returns the size of the prepared output layout multiplied by the scale factor.
Definition: OutCommon.cpp:125
bool PrepareLayout(Cell *tree)
Prepares to render the tree to the output DC, and computes the size of the output.
Definition: OutCommon.cpp:137
wxSize GetInvScaledSize() const
Returns the size of the prepared output layout divided by the scale factor.
Definition: OutCommon.cpp:131
void Draw(Cell *tree)
Recursively draws the cells.
Definition: OutCommon.cpp:232
void SetSize(wxSize size)
Sets the "default" size of the prepared layout.
Definition: OutCommon.h:120
Configuration * GetConfiguration()
Get the configuration for the file/bitmap/... output.
Definition: OutCommon.h:106
const Configuration & GetScreenConfig() const
Get the configuration for the screen output.
Definition: OutCommon.h:108
static wxString AccessibleText(const Cell *tree)
The plain-text form of a cell list, for use as an accessible label.
Definition: OutCommon.cpp:68