wxMaxima
Loading...
Searching...
No Matches
ExptCell.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// (C) 2014-2016 Gunter Königsmann <wxMaxima@physikbuch.de>
5//
6// This program is free software; you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation; either version 2 of the License, or
9// (at your option) any later version.
10//
11// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15//
16//
17// You should have received a copy of the GNU General Public License
18// along with this program; if not, write to the Free Software
19// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20//
21// SPDX-License-Identifier: GPL-2.0+
22
23#ifndef EXPTCELL_H
24#define EXPTCELL_H
25
26#include "Cell.h"
27#include "TextCell.h"
28#include <memory>
29#include <utility>
30
55class ExptCell final : public Cell
56{
57public:
59 ExptCell(GroupCell *group, Configuration *config, std::unique_ptr<Cell> &&base, std::unique_ptr<Cell> &&expt);
60 ExptCell(GroupCell *group, const ExptCell &cell);
61 std::unique_ptr<Cell> Copy(GroupCell *group) const override;
62 const CellTypeInfo &GetInfo() override;
63
68 size_t GetInnerCellCount() const override { return 7; }
69 Cell *GetInnerCell(size_t index) const override {
70 switch (index) {
71 case 0:
72 return m_baseCell.get();
73 case 1:
74 return m_exp.get();
75 case 2:
76 return m_open.get();
77 case 3:
78 return m_exptCell.get();
79 case 4:
80 return m_close.get();
81 case 5:
82 return m_matrixOpen.get();
83 case 6:
84 return m_matrixClose.get();
85 default:
86 return nullptr;
87 }
88 }
89
91 size_t GetBrokenCellCount() const override { return 5; }
92
94 double PowRise() const {return .3 * m_fontSize_Scaled;}
95
96 void Recalculate(const AFontSize fontsize) const override;
97
99 void SetCurrentPoint(wxPoint point) const override;
100
101 void Draw(wxDC *dc, wxDC *antialiassingDC) override;
102
103 wxString ToMathML() const override;
104 wxString ToMatlab() const override;
105 wxString ToOMML() const override;
106 wxString ToString() const override;
107 wxString ToTeX() const override;
108 wxString ToXML() const override;
109
110 wxString GetDiffPart() const override;
111
117 void IsMatrix(bool isMatrix);
118 bool IsMatrix() const { return m_isMatrix; }
120 static wxString MatrixPowerToolTip();
121
122 bool BreakUp() const override;
123
124 void SetAltCopyText(const wxString &text) override { m_altCopyText = text; }
125 const wxString &GetAltCopyText() const override { return m_altCopyText; }
126
127private:
128 void MakeBreakupCells();
130 wxCoord ExponentWidth() const;
132 wxString ExponentToMathML() const;
133
135 wxString m_altCopyText;
136
137 // The pointers below point to inner cells and must be kept contiguous.
138 // ** This is the draw list order. All pointers must be the same:
139 // ** either Cell * or std::unique_ptr<Cell>. NO OTHER TYPES are allowed.
140 std::unique_ptr<Cell> m_baseCell;
141 std::unique_ptr<Cell> m_exp;
142 std::unique_ptr<Cell> m_open;
143 std::unique_ptr<Cell> m_exptCell;
144 std::unique_ptr<Cell> m_close;
145 std::unique_ptr<Cell> m_matrixOpen;
146 std::unique_ptr<Cell> m_matrixClose;
147 // The pointers above point to inner cells and must be kept contiguous.
148
149 mutable int m_expt_yoffset = 0;
150
151//** Bitfield objects (1 bytes)
152//**
153 bool m_isMatrix : 1 = false;
154};
155
156
157#endif // EXPTCELL_H
The definition of the base class of all cells the worksheet consists of.
int group
Neighbouring sections of the same group aren't separated.
Definition: ToolBarSections.cpp:45
A Type-Safe Fixed-Point Font Size.
Definition: FontAttribs.h:99
A class that carries information about the type of a cell.
Definition: Cell.h:93
The base class all cell types the worksheet can consist of are derived from.
Definition: Cell.h:148
virtual void SetCurrentPoint(wxPoint point) const
Pass 2: Arrangement.
Definition: Cell.cpp:532
AFontSize m_fontSize_Scaled
The font size is smaller in super- and subscripts.
Definition: Cell.h:1289
The configuration storage for the current worksheet.
Definition: Configuration.h:102
This cell represents a exp() or e^x-construct.
Definition: ExptCell.h:56
wxString GetDiffPart() const override
Get the part for diff tag support.
Definition: ExptCell.cpp:234
size_t GetInnerCellCount() const override
ORDER MATTERS: the first five are also this cell's broken/linear draw sequence (see GetBrokenCellCoun...
Definition: ExptCell.h:68
wxString ToMatlab() const override
Convert this cell to its Matlab representation.
Definition: ExptCell.cpp:197
wxString ToTeX() const override
Convert this cell to its LaTeX representation.
Definition: ExptCell.cpp:213
std::unique_ptr< Cell > Copy(GroupCell *group) const override
Create a copy of this cell.
double PowRise() const
By how much do we want to rise the power?
Definition: ExptCell.h:94
Cell * GetInnerCell(size_t index) const override
Retrieve an inner cell with given index which must be less than GetInnerCellCount.
Definition: ExptCell.h:69
static wxString MatrixPowerToolTip()
The tooltip explaining a matrix power; SubSupCell uses it, too.
Definition: ExptCell.cpp:88
const CellTypeInfo & GetInfo() override
Returns the information about this cell's type.
wxString ToXML() const override
Convert this cell to a representation fit for saving in a .wxmx file.
Definition: ExptCell.cpp:260
bool BreakUp() const override
Try to split this command into lines to make it fit on the screen.
Definition: ExptCell.cpp:266
void SetCurrentPoint(wxPoint point) const override
Pass 2 (Arrange): Positions the base and the raised exponent.
Definition: ExptCell.cpp:104
void Recalculate(const AFontSize fontsize) const override
Recalculate the size of the cell and the difference between top and center.
Definition: ExptCell.cpp:140
wxString ToOMML() const override
Returns the cell's representation as OMML.
Definition: ExptCell.cpp:251
void SetAltCopyText(const wxString &text) override
What should end up if placing this cell on the clipboard?
Definition: ExptCell.h:124
size_t GetBrokenCellCount() const override
The linear form never shows the angle brackets of a matrix power.
Definition: ExptCell.h:91
const wxString & GetAltCopyText() const override
Get the text set using SetAltCopyText - may be empty.
Definition: ExptCell.h:125
wxString ToMathML() const override
Convert this cell to a representation fit for saving in a .wxmx file.
Definition: ExptCell.cpp:244
void Draw(wxDC *dc, wxDC *antialiassingDC) override
Pass 3 (Paint): Renders the cell using pre-calculated coordinates.
Definition: ExptCell.cpp:129
wxString ToString() const override
Returns the cell's representation as a string.
Definition: ExptCell.cpp:182
A cell grouping input (and, if there is one, also the output) cell to a foldable item.
Definition: GroupCell.h:88