wxMaxima
Loading...
Searching...
No Matches
SumCell.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-2018 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
31#ifndef SUMCELL_H
32#define SUMCELL_H
33
34#include "precomp.h"
35#include "Cell.h"
36#include "ParenCell.h"
37
38class TextCell;
39
40//cppcheck-suppress ctuOneDefinitionRuleViolation
41class SumCell : public Cell
42{
43public:
44 SumCell(GroupCell *group, Configuration *config,
45 std::unique_ptr<Cell> &&under, std::unique_ptr<Cell> &&over,
46 std::unique_ptr<Cell> &&base);
47 SumCell(GroupCell *group, const SumCell &cell);
48 std::unique_ptr<Cell> Copy(GroupCell *group) const override;
49 const CellTypeInfo &GetInfo() override;
50
51 size_t GetInnerCellCount() const override { return 10; }
52 // cppcheck-suppress objectIndex
53 Cell *GetInnerCell(size_t index) const override { return (&m_open)[index].get(); }
54
55 void Recalculate(AFontSize fontsize) override;
56
57 void Draw(wxPoint point, wxDC *dc, wxDC *antialiassingDC) override;
58
59 wxString ToMathML() const override;
60 wxString ToMatlab() const override;
61 wxString ToOMML() const override;
62 wxString ToString() const override;
63 wxString ToTeX() const override;
64 wxString ToXML() const override;
65
66 void SetAltCopyText(const wxString &text) override { m_altCopyText = text; }
67 const wxString &GetAltCopyText() const override { return m_altCopyText; }
68
69 bool BreakUp() override;
70 void SetNextToDraw(Cell *next) override;
71 void Unbreak() override final;
72
73protected:
75 virtual const wxString GetMaximaCommandName() const;
77 virtual const wxString GetMatlabCommandName() const;
79 virtual const wxString GetLaTeXCommandName() const;
81 virtual const wxString GetUnicodeSymbol() const;
83 virtual const wxString GetSvgSymbolData() const;
85 virtual const wxString GetXMLType() const;
87 virtual const wxSize GetSymbolSize() const;
89 Cell *Base() const;
90 Cell *Over() const {return m_over.get();}
91 Cell *Under() const {return m_under.get();}
92
93private:
94 std::unique_ptr<Cell> MakeStart(Cell *under) const;
95 void MakeBreakUpCells();
96 const static wxString m_svgSumSign;
97
98 ParenCell *Paren() const;
100 Cell *DisplayedBase() const;
101
103 wxString m_altCopyText;
104 // The pointers below point to inner cells and must be kept contiguous.
105 // ** This is the partial draw list order. All pointers must be the same:
106 // ** either Cell * or std::unique_ptr<Cell>. NO OTHER TYPES are allowed.
107 std::unique_ptr<Cell> m_open;
108 std::unique_ptr<Cell> m_paren;
109 std::unique_ptr<Cell> m_comma1;
110 std::unique_ptr<Cell> m_var;
111 std::unique_ptr<Cell> m_comma2;
112 std::unique_ptr<Cell> m_start;
113 std::unique_ptr<Cell> m_comma3;
114 std::unique_ptr<Cell> m_close;
115 std::unique_ptr<Cell> m_over;
116 std::unique_ptr<Cell> m_under;
117 // The pointers above point to inner cells and must be kept contiguous.
118
119 wxSize m_signSize;
120
121//** Bitfield objects (1 bytes)
122//**
123 void InitBitFields_SumCell()
124 { // Keep the initialization order below same as the order
125 // of bit fields in this class!
126 m_displayParen = true;
127 }
128
130 bool m_displayParen : 1 /* InitBitFields_SumCell */;
131};
132
133#endif // SUMCELL_H
The definition of the base class of all cells the worksheet consists of.
This file declares the class ParenCell.
A Type-Safe Fixed-Point Font Size.
Definition: FontAttribs.h:98
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:142
The configuration storage for the current worksheet.
Definition: Configuration.h:85
A cell grouping input (and, if there is one, also the output) cell to a foldable item.
Definition: GroupCell.h:74
The class that represents parenthesis that are wrapped around text.
Definition: ParenCell.h:50
Definition: SumCell.h:42
size_t GetInnerCellCount() const override
The number of inner cells - for use by the iterators.
Definition: SumCell.h:51
wxString ToMathML() const override
Convert this cell to a representation fit for saving in a .wxmx file.
Definition: SumCell.cpp:309
wxString ToMatlab() const override
Convert this cell to its Matlab representation.
Definition: SumCell.cpp:243
bool BreakUp() override
Try to split this command into lines to make it fit on the screen.
Definition: SumCell.cpp:340
virtual const wxString GetMaximaCommandName() const
What maxima command name corresponds to this cell?
Definition: SumCell.cpp:116
const CellTypeInfo & GetInfo() override
Returns the information about this cell's type.
virtual const wxString GetXMLType() const
Returns the type our cell has when saving it to .wxmx.
Definition: SumCell.cpp:145
std::unique_ptr< Cell > Copy(GroupCell *group) const override
Create a copy of this cell.
void Recalculate(AFontSize fontsize) override
Recalculate the size of the cell and the difference between top and center.
Definition: SumCell.cpp:153
void Draw(wxPoint point, wxDC *dc, wxDC *antialiassingDC) override
Draw this cell.
Definition: SumCell.cpp:188
void SetNextToDraw(Cell *next) override
Tells this cell which one should be the next cell to be drawn.
Definition: SumCell.cpp:366
void Unbreak() override final
Undo breaking this cell into multiple lines.
Definition: SumCell.cpp:335
virtual const wxString GetMatlabCommandName() const
What matlab command name corresponds to this cell?
Definition: SumCell.cpp:130
wxString ToString() const override
Returns the cell's representation as a string.
Definition: SumCell.cpp:217
virtual const wxSize GetSymbolSize() const
How big do we want our svg symbol to be?
Definition: SumCell.cpp:106
const wxString & GetAltCopyText() const override
Get the text set using SetAltCopyText - may be empty.
Definition: SumCell.h:67
virtual const wxString GetLaTeXCommandName() const
What LaTeX command name corresponds to this cell?
Definition: SumCell.cpp:135
wxString ToTeX() const override
Convert this cell to its LaTeX representation.
Definition: SumCell.cpp:265
void SetAltCopyText(const wxString &text) override
What should end up if placing this cell on the clipboard?
Definition: SumCell.h:66
wxString ToXML() const override
Convert this cell to a representation fit for saving in a .wxmx file.
Definition: SumCell.cpp:298
Cell * GetInnerCell(size_t index) const override
Retrieve an inner cell with given index which must be less than GetInnerCellCount.
Definition: SumCell.h:53
virtual const wxString GetUnicodeSymbol() const
What unicode symbol name corresponds to this cell?
Definition: SumCell.cpp:140
virtual const wxString GetSvgSymbolData() const
Returns the data that creates our SVG symbol.
Definition: SumCell.cpp:124
Cell * Base() const
The base cell owned by the paren (it's without the paren)
Definition: SumCell.cpp:76
wxString ToOMML() const override
Returns the cell's representation as OMML.
Definition: SumCell.cpp:278
A Text cell.
Definition: TextCell.h:38