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
70 explicit OutCommon(const Configuration * const *configuration, const wxString &filename,
71 int fullWidth, double scale);
72 explicit OutCommon(const Configuration * const *configuration, int fullWidth, double scale);
73 ~OutCommon();
74
75 OutCommon(const OutCommon&) = delete;
76 void operator=(const OutCommon&) = delete;
77
78 int Scale_Px(double px) const { return m_thisconfig.Scale_Px(px); }
79 double GetScale() const { return m_scale; }
80 const wxString &GetFilename() const { return m_filename; }
81 const wxString &GetTempFilename() const { return m_tempFilename; }
83 Configuration *GetConfiguration() { return &m_thisconfig; }
85 const Configuration &GetScreenConfig() const { return *(*m_configuration); }
86 wxSize getPPI() const { return m_ppi; }
87
89 void SetRecalculationContext(wxDC *context) { m_recalculationDc = context; }
90
92 bool PrepareLayout(Cell *tree);
93
95 wxSize GetSize() const { return m_size; }
97 void SetSize(wxSize size) { m_size = size; }
98
100 wxSize GetScaledSize() const;
102 wxSize GetInvScaledSize() const;
103
106 bool ToClipboard(const wxDataFormat &format);
107
109 void Draw(Cell *tree);
110
111private:
112 void GetMaxPoint(Cell *tree, int *width, int *height) const;
113 void Recalculate(Cell *tree) const;
114
115 void BreakLines(Cell *tree) const;
116 void BreakUpCells(Cell *tree) const;
117
119 wxString m_tempFilename;
121 wxDC *m_recalculationDc = {};
122
123 wxString m_filename;
124 const Configuration * const *m_configuration;
125 const Configuration *m_oldconfig = *m_configuration;
126 Configuration m_thisconfig{ {}, Configuration::temporary };
128 double m_scale = 1.0;
130 wxSize m_size = wxDefaultSize;
132 int m_fullWidth;
134 wxSize m_ppi;
135};
136
137#endif // OUTCOMMON_H
The base class all cell types the worksheet can consist of are derived from.
Definition: Cell.h:142
The configuration storage for the current worksheet.
Definition: Configuration.h:85
wxCoord Scale_Px(double px) const
Scales a distance [in pixels] according to the zoom factor.
Definition: Configuration.cpp:1398
@ temporary
This configuration is temporary and shouldn't redetect Maxima etc.
Definition: Configuration.h:120
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:245
bool ToClipboard(const wxDataFormat &format)
Copies the representation of the list of cells that was passed to SetData() to the clipboard.
Definition: OutCommon.cpp:232
wxSize GetSize() const
Returns the size of the prepared output layout.
Definition: OutCommon.h:95
void SetRecalculationContext(wxDC *context)
Sets the context for the configuration used in recalculating the cell dimensions.
Definition: OutCommon.h:89
wxSize GetScaledSize() const
Returns the size of the prepared output layout multiplied by the scale factor.
Definition: OutCommon.cpp:75
bool PrepareLayout(Cell *tree)
Prepares to render the tree to the output DC, and computes the size of the output.
Definition: OutCommon.cpp:87
wxSize GetInvScaledSize() const
Returns the size of the prepared output layout divided by the scale factor.
Definition: OutCommon.cpp:81
void Draw(Cell *tree)
Recursively draws the cells.
Definition: OutCommon.cpp:182
void SetSize(wxSize size)
Sets the "default" size of the prepared layout.
Definition: OutCommon.h:97
Configuration * GetConfiguration()
Get the configuration for the file/bitmap/... output.
Definition: OutCommon.h:83
const Configuration & GetScreenConfig() const
Get the configuration for the screen output.
Definition: OutCommon.h:85