wxMaxima
Loading...
Searching...
No Matches
Cell.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) 2014-2018 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
29#ifndef CELL_H
30#define CELL_H
31
32#include "../precomp.h"
33#include "CellPtr.h"
34#include "CellIterators.h"
35#include "Configuration.h"
36#include "StringUtils.h"
37#include "TextStyle.h"
38#include "CachedValue.h"
39#include <wx/defs.h>
40#if wxUSE_ACCESSIBILITY
41#include <wx/access.h>
42#endif // wxUSE_ACCESSIBILITY
43#include <algorithm>
44#include <map>
45#include <memory>
46#include <vector>
47#include <type_traits>
50class EditorCell;
51class GroupCell;
52class TextCell;
53class wxXmlNode;
54
55// Forward declarations
56template <typename C, typename std::enable_if<std::is_base_of<Cell, C>::value, bool>::type = true>
57inline auto OnInner(const C *cell);
58template <typename C, typename std::enable_if<std::is_base_of<Cell, C>::value, bool>::type = true>
59inline auto OnInner(C *cell);
60
63enum CellType : int8_t
64{
65 MC_TYPE_DEFAULT,
83};
85std::ostream& operator<<(std::ostream& out, const CellType celltype);
86
87#if wxUSE_ACCESSIBILITY
88class CellAccessible;
89#endif
90
93{
94public:
100 virtual const wxString &GetName() const = 0;
101};
102
146// 120 bytes
147class Cell: public Observed
148{
149#if wxUSE_ACCESSIBILITY
150 friend class CellAccessible;
151#endif
152 friend class CellList;
153
154 // This class can be derived from wxAccessible which has no copy constructor
155 void operator=(const Cell&) = delete;
157 Cell(GroupCell *group, const Cell&) = delete;
158
159 template <typename C, typename std::enable_if<std::is_base_of<Cell, C>::value, bool>::type>
160 friend inline auto OnInner(const C *cell);
161 template <typename C, typename std::enable_if<std::is_base_of<Cell, C>::value, bool>::type>
162 friend inline auto OnInner(C *cell);
163
164public:
165// Cell(GroupCell *group, Configuration *config);
166 Cell(GroupCell *group, Configuration *config);
167
173 virtual std::unique_ptr<Cell> Copy(GroupCell *group) const = 0;
174
176 virtual const CellTypeInfo &GetInfo() = 0;
177
182 wxCoord Scale_Px(double px) const {return m_configuration->Scale_Px(px);}
187 AFontSize Scale_Px(AFontSize size) const { return m_configuration->Scale_Px(size); }
188
189#if wxUSE_ACCESSIBILITY
190 // The methods whose implementation within Cell should be sufficient are
191 // not virtual. Should that prove not to be the case eventually, they can be
192 // made virtual with due caution.
194 wxAccStatus GetParent (Cell ** parent) const;
196 wxAccStatus GetChild(int childId, Cell **child) const;
198 wxAccStatus HitTest (const wxPoint &pt, int *childId, Cell **child);
199
201 virtual wxAccStatus GetName (int childId, wxString *name) const;
203 virtual wxAccStatus GetDescription(int childId, wxString *description) const;
205 virtual wxAccStatus GetFocus (int *childId, Cell **child) const;
207 virtual wxAccStatus GetDefaultAction(int childId, wxString *actionName) const;
209 virtual wxAccStatus GetLocation (wxRect &rect, int elementId);
211 virtual wxAccStatus GetValue (int childId, wxString *strValue) const;
212 virtual wxAccStatus GetRole (int childId, wxAccRole *role) const;
214 virtual wxAccStatus GetState (int childId, long *state) const;
215#endif
216
217
225 virtual const wxString GetToolTip(wxPoint point) const;
226
228 virtual ~Cell();
229
231 unsigned long CellsInListRecursive() const;
232
234 wxRect CropToUpdateRegion(wxRect rect) const;
235
237 bool InUpdateRegion() const;
238
240 void SoftLineBreak(bool breakLine = true) const
241 {
242 bool newBreak = breakLine || m_forceBreakLine;
243 if (m_breakLine != newBreak)
244 {
245 m_breakLine = newBreak;
246 InvalidateListCache();
247 }
248 }
249
254 bool BreakUpCells() const;
255
261 void CollectWideCells(std::vector<const Cell *> &wideCells,
262 int clientWidth) const;
263
265 bool UnBreakUpCells() const;
266
289 void BreakLines_List() const;
290
292 int GetLineIndent() const;
293
295 bool BreakLineHere() const { return m_breakLine || m_forceBreakLine; }
296
298 bool HasHardLineBreak() const { return m_forceBreakLine; }
299
304 virtual bool BreakUp() const;
305
306protected:
312 void BreakUpAndMark() const;
313
314protected:
316 wxBitmap BitmapFromSVG(wxString svgData, wxSize size);
317public:
325 bool ContainsRect(const wxRect &sm, bool all = true) const;
326
331 bool ContainsPoint(wxPoint point) const { return GetRect().Contains(point); }
332
338 virtual void ClearCache()
339 {}
340
345 void ClearCacheList();
346
355 virtual void TallyImageLoadFailures(int &WXUNUSED(dataUnavailable),
356 int &WXUNUSED(decodeFailed)) const
357 {}
358
368 void TallyImageLoadFailures_Recursively(int &dataUnavailable,
369 int &decodeFailed) const;
370
374 void TallyImageLoadFailures_RecursivelyList(int &dataUnavailable,
375 int &decodeFailed) const;
379 virtual void SetConfiguration(Configuration *config);
382
383
389 virtual void Draw(wxDC *dc, wxDC *antialiassingDC);
390
396 void DrawList(wxDC *dc, wxDC *adc);
397
405 virtual void DrawBoundingBox(wxDC &WXUNUSED(dc), bool all = false);
406
412 bool DrawThisCell();
413
420 void ForceBreakLine(bool force = true) const
421 {
422 if (m_forceBreakLine != force || m_breakLine != force)
423 {
424 m_forceBreakLine = m_breakLine = force;
425 InvalidateListCache();
426 }
427 }
428
430 wxString GetUUID() const { return m_uuid; }
432 void SetUUID(const wxString &uuid) { m_uuid = uuid; }
434 void GenerateUUID();
436 wxString GetExtraXMLAttributes() const;
438 void AddExtraAttribute(const wxString &name, const wxString &value);
439
446 wxCoord GetHeight() const;
447
454 int GetWidth() const;
455
463 wxCoord GetCenter() const;
464
466 bool HasValidSize() const;
468 bool HasStaleSize() const;
470 bool HasValidPosition() const;
471
483 wxCoord GetDrop() const
484 { return GetHeight() - GetCenter(); }
485
490 { return m_type; }
491
498 virtual wxCoord GetMaxDrop() const;
499
506 virtual wxCoord GetCenterList() const;
507
512 virtual wxCoord GetHeightList() const;
513
515 wxCoord SumOfWidths() const;
516
522 wxCoord GetLineWidth() const;
523
528 wxCoord GetCurrentX() const
529 { return m_currentPoint.x; }
530
535 wxCoord GetCurrentY() const
536 { return m_currentPoint.y; }
537
544 virtual wxRect GetRect(bool wholeList = false) const;
545
547 virtual bool NeedsRecalculation(AFontSize fontSize) const;
550
552 void ScheduleRecalculation() const {m_cellCfgCnt_last = m_configuration->CellCfgCnt() - 1 ;}
554 bool ConfigChanged() const {return m_configuration->CellCfgCnt() != m_cellCfgCnt_last;}
561 virtual wxString GetDiffPart() const;
562
570 virtual void Recalculate(AFontSize fontsize) const;
571
582 bool RecalculateList(AFontSize fontsize) const;
583
594 bool RecalculateTracked(AFontSize fontsize) const;
595
605 bool FontSizeMatchesExpectation() const;
606
608 void FontsChangedList();
609
611 void ResetSize_Recursively() const;
612
614 void ResetSize_RecursivelyList() const;
615
617 void ResetSize() const;
618
620 void ResetSizeList() const;
621
623 void SetBigSkip(bool skip) { m_bigSkip = skip; }
625 bool HasBigSkip() const { return m_bigSkip; }
626
628 virtual void SetType(CellType type);
629
631 const TextStyle &GetTextStyle() const
632 { return m_textStyle; }
633
635 // cppcheck-suppress functionStatic
636 // cppcheck-suppress functionConst
637 void SetPen(wxDC *dc, double lineWidth = 1.0) const;
639 void SetBrush(wxDC *dc) const;
640 wxColour GetForegroundColor() const;
641
643 void SetHighlight(bool highlight) { m_highlight = highlight; }
645 bool GetHighlight() const { return m_highlight; }
646
651 virtual void SetIsExponent();
652
657 virtual void SetIsExponentList();
658
663 virtual void SetValue(const wxString &WXUNUSED(text)) {}
665 virtual const wxString &GetValue() const;
666 virtual const wxString GetDisplayedString() const {return GetValue();}
667
669 Cell *first() const;
670
672 Cell *last() const;
673
675 struct Range {
676 Cell *first, *last;
677 };
678
682 Range GetCellsInRect(const wxRect &rect) const;
683
687 Range GetListCellsInRect(const wxRect &rect) const;
688
690 virtual Range GetInnerCellsInRect(const wxRect &rect) const;
691
693 virtual bool IsOperator() const { return false; }
694
696 bool IsCompound() const;
697
699 virtual bool IsShortNum() const { return false; }
700
702 GroupCell *GetGroup() const;
703
706 {
707 public:
708 double x, y;
709 };
710
712 virtual wxString ListToString() const;
713
718 wxString VariablesAndFunctionsList() const;
720 virtual wxString ListToMatlab() const;
722 virtual wxString ListToTeX() const;
724 virtual wxString ListToXML() const;
725
727 virtual wxString ListToMathML(bool startofline = false) const;
728
730 virtual wxString ListToOMML(bool startofline = false) const;
731
733 virtual wxString ListToRTF(bool startofline = false) const;
734
736 virtual wxString ToString() const;
737
743 virtual wxString ToRTF() const
744 { return wxEmptyString; }
745
747 static wxString OMML2RTF(wxXmlNode *node);
748
750 static wxString OMML2RTF(wxString ommltext);
751
761 virtual wxString ToOMML() const;
763 virtual wxString ToMatlab() const;
765 virtual wxString ToTeX() const;
767 virtual wxString ToXML() const;
768 virtual wxString GetXMLFlags() const;
770 virtual wxString ToMathML() const;
771
773 static wxString RTFescape(wxString, bool MarkDown = false);
774
776 static wxString XMLescape(wxString);
777
778 // cppcheck-suppress functionStatic
779 // cppcheck-suppress functionConst
780
788 virtual void Unbreak() const;
789
797 virtual void UnbreakList() const;
798
800 Cell *GetPrevious() const { return m_previous; }
801
803 Cell *GetNext() const { return m_next.get(); }
804
827 virtual size_t GetBrokenCellCount() const { return GetInnerCellCount(); }
829 virtual Cell *GetBrokenCell(size_t index) const { return GetInnerCell(index); }
830
835 bool IsComment() const
836 {
837 return m_type == MC_TYPE_TEXT || m_type == MC_TYPE_SECTION ||
838 m_type == MC_TYPE_SUBSECTION || m_type == MC_TYPE_SUBSUBSECTION ||
839 m_type == MC_TYPE_HEADING5 || m_type == MC_TYPE_HEADING6 || m_type == MC_TYPE_TITLE;
840 }
841
851 bool IsHidden() const { return m_isHidden; }
852
854 virtual bool FirstLineOnlyEditor() const;
855
857 virtual void Hide(bool hide = true) { m_isHidden = hide; }
858
863 bool IsEditable(bool input = false) const
864 {
865 return (m_type == MC_TYPE_INPUT &&
866 m_previous && m_previous->m_type == MC_TYPE_MAIN_PROMPT)
867 || (!input && IsComment());
868 }
869
871 virtual bool CanPopOut() const { return false; }
872
877 virtual wxString GnuplotSource() const {return wxEmptyString;}
878
880 virtual void ProcessEvent(wxKeyEvent &WXUNUSED(event))
881 {}
882
887 virtual bool AddEnding()
888 { return false; }
889
891 virtual void SelectPointText(wxPoint point);
892
894 virtual void SelectRectText(wxPoint one, wxPoint two);
895
902 virtual void PasteFromClipboard(bool primary = false);
903
907 virtual bool CopyToClipboard() const
908 { return false; }
909
913 virtual bool CutToClipboard()
914 { return false; }
915
917 virtual void SelectAll()
918 {}
919
921 virtual bool CanCopy() const
922 { return false; }
923
925 virtual wxPoint PositionToPoint(size_t WXUNUSED(pos))
926 { return wxDefaultPosition; }
927
929 virtual wxPoint PositionToPoint()
930 { return wxDefaultPosition; }
931
933 virtual bool IsDirty() const
934 { return false; }
935
936 virtual void SwitchCaretDisplay()
937 {}
938
940 virtual void SetFocus(bool WXUNUSED(focus))
941 {}
942
944 void SetTextColor(wxDC *dc);
945
947 virtual bool IsActive() const
948 { return false; }
949
951 virtual void SetStyle(TextStyle style)
952 {
954 m_textStyle = style;
955 }
957 bool IsMath() const;
958
960 virtual int GetImageBorderWidth() const { return 0; }
961
963 void CopyCommonData(const Cell & cell);
964
966 std::unique_ptr<Cell> CopyList(GroupCell *group) const;
967
969 static std::unique_ptr<Cell> CopyList(GroupCell *group, const Cell *cell);
970
972 void ClearToolTip();
974 void SetToolTip(const wxString &tooltip) const ;
978 void SetToolTip(const wxString *toolTip) const;
980 void AddToolTip(const wxString &tip);
981
994
1003 virtual void SetCurrentPoint(wxPoint point) const;
1004
1008 void SetCurrentPoint(int x, int y) const { SetCurrentPoint({x, y}); }
1009
1016 void SetCurrentPointList(wxPoint point);
1017
1024 void SetCurrentPointDrawList(wxPoint point);
1025
1029 wxPoint GetCurrentPoint() const {return m_currentPoint;}
1031
1038 bool IsBrokenIntoLines() const { return m_isBrokenIntoLines; }
1039
1048 bool GetSuppressMultiplicationDot() const { return m_suppressMultiplicationDot; }
1049 void SetSuppressMultiplicationDot(bool val) { m_suppressMultiplicationDot = val; }
1051 bool GetHidableMultSign() const { return m_isHidableMultSign; }
1052 void SetHidableMultSign(bool val) { m_isHidableMultSign = val; }
1053
1064 virtual void SetAltCopyText(const wxString &text);
1066 virtual const wxString &GetAltCopyText() const { return wxm::emptyString; }
1067
1068#if wxUSE_ACCESSIBILITY
1069 CellAccessible *GetAccessible();
1070#endif
1071#if CELL_TEST
1072 void MockBreakUp() { m_isBrokenIntoLines = 1; }
1073#endif
1074
1075 static wxString wxColor2HtmlString(wxColor col);
1076protected:
1077 std::unique_ptr<Cell> MakeVisiblyInvalidCell() const;
1078public:
1079 static std::unique_ptr<Cell> MakeVisiblyInvalidCell(GroupCell *group, Configuration *config);
1080
1081protected:
1082//** Bases and internal members (16 bytes)
1083//**
1084// VTable *__vtable;
1085// Observed __observed;
1086
1087//** 8-byte objects (8 bytes)
1088//**
1102 mutable wxPoint m_currentPoint{-1, -1};
1103
1104protected:
1105//** 8/4-byte objects (40 + 8* bytes)
1106//**
1107
1108private:
1110 mutable std::atomic<std::int_fast32_t> m_cellCfgCnt_last = { -1 };
1120 mutable std::atomic<std::int_fast32_t> m_listCacheCfgCnt = { -1 };
1122 std::unique_ptr<Cell> m_next;
1123
1125 Cell *m_previous = {};
1126
1127#if wxUSE_ACCESSIBILITY
1128 std::unique_ptr<CellAccessible> m_accessible;
1129#endif
1130
1131public:
1132 const wxString &GetLocalToolTip() const;
1133protected:
1136
1139
1142 mutable const wxString *m_toolTip /* initialized in the constructor */;
1143
1144//** 4-byte objects (28 bytes)
1145//**
1146protected:
1177protected:
1178//** 2-byte objects (2 bytes)
1179//**
1183 mutable AFontSize m_fontSize = {};
1191
1192//** 1-byte objects (2 bytes)
1193//**
1194 // The celltype of this object
1195 CellType m_type = MC_TYPE_DEFAULT;
1196 // The text style of this object
1197 TextStyle m_textStyle = TS_MATH;
1198
1199private:
1200//** Bitfield objects (2 bytes)
1201//**
1208 void UpdateListCaches() const;
1209
1211 mutable bool m_ownsToolTip : 1 = false;
1212 bool m_bigSkip : 1 = false;
1213 mutable bool m_isBrokenIntoLines : 1 = false;
1214 bool m_isHidden : 1 = false;
1215 bool m_isHidableMultSign : 1 = false;
1216 bool m_suppressMultiplicationDot : 1 = false;
1218 mutable bool m_breakLine : 1 = false;
1219protected:
1221 wxString m_uuid;
1223 std::map<wxString, wxString> m_extraAttributes;
1224
1225 mutable bool m_forceBreakLine : 1 = false;
1226 bool m_highlight : 1 = false;
1227
1228protected:
1229 friend class InnerCellIterator;
1231 virtual size_t GetInnerCellCount() const;
1234 virtual Cell *GetInnerCell(size_t index) const;
1235
1237 virtual void FontsChanged() const
1239
1244
1245 void InvalidateListCache() const;
1246};
1247
1248// The static cast here requires Cell to be defined
1249template <typename T>
1250template <typename PtrT, typename std::enable_if<std::is_pointer<PtrT>::value, bool>::type>
1251inline PtrT CellPtr<T>::CastAs() const noexcept { return dynamic_cast<PtrT>(static_cast<Cell*>(base_get())); }
1252
1253#if wxUSE_ACCESSIBILITY
1254class CellAccessible final : public wxAccessible
1255{
1256public:
1257 explicit CellAccessible(Cell *const forCell) : m_cell(forCell) {}
1258
1260 wxAccStatus GetName (int childId, wxString *name) override;
1262 wxAccStatus GetParent (wxAccessible **parent) override;
1264 wxAccStatus GetChildCount (int *childCount) override;
1266 wxAccStatus GetChild (int childId, wxAccessible **child) override;
1268 wxAccStatus HitTest (const wxPoint &pt,
1269 int *childId, wxAccessible **child) override;
1271 wxAccStatus GetDescription(int childId, wxString *description) override;
1273 wxAccStatus GetDefaultAction(int childId, wxString *actionName) override;
1275 wxAccStatus GetFocus (int *childId, wxAccessible **child) override;
1277 wxAccStatus GetLocation (wxRect &rect, int elementId) override;
1279 wxAccStatus GetValue (int childId, wxString *strValue) override;
1280 wxAccStatus GetRole (int childId, wxAccRole *role) override;
1282 wxAccStatus GetState (int childId, long *state) override;
1283private:
1284 Cell *const m_cell;
1285};
1286#endif
1287
1289template <typename C, typename std::enable_if<std::is_base_of<Cell, C>::value, bool>::type = true>
1290inline auto OnList(const C *cell) { return CellListAdapter<const C>(cell); }
1291template <typename C, typename std::enable_if<std::is_base_of<Cell, C>::value, bool>::type = true>
1292inline auto OnList(C *cell) { return CellListAdapter<C>(cell); }
1293
1295template <typename C, typename std::enable_if<std::is_base_of<Cell, C>::value, bool>::type = true>
1296inline auto OnDrawList(const C *cell) { return CellDrawListAdapter<const C>(cell); }
1297template <typename C, typename std::enable_if<std::is_base_of<Cell, C>::value, bool>::type = true>
1298inline auto OnDrawList(C *cell) { return CellDrawListAdapter<C>(cell); }
1299
1301template <typename C, typename std::enable_if<std::is_base_of<Cell, C>::value, bool>::type>
1302inline auto OnInner(const C *cell) { return InnerCellAdapter(const_cast<Cell *>(cell)); }
1303template <typename C, typename std::enable_if<std::is_base_of<Cell, C>::value, bool>::type>
1304inline auto OnInner(C *cell) { return InnerCellAdapter(cell); }
1305
1306inline size_t InnerCellIterator::GetInnerCellCount(const Cell *cell) { return cell->GetInnerCellCount(); }
1307inline Cell *InnerCellIterator::GetInnerCell(const Cell *cell, size_t index) { return cell->GetInnerCell(index); }
1308
1309#endif // CELL_H
Declares "mostly read-only" wrappers around values that are expensive to compute and are thus cached.
Declares the various iterators useful with the Cell class.
Implementation of an observing weak Cell pointer.
auto OnList(const C *cell)
Returns an iterable the goes over the cell list, starting with given, possibly null,...
Definition: Cell.h:1290
std::ostream & operator<<(std::ostream &out, const CellType celltype)
Allow Standard c++ streams to print out our enum values as text.
Definition: Cell.cpp:1828
auto OnDrawList(const C *cell)
Returns an iterable that goes over the cell draw list, starting with given, possibly null,...
Definition: Cell.h:1296
CellType
The supported types of math cells.
Definition: Cell.h:64
@ MC_TYPE_WARNING
A warning output by maxima.
Definition: Cell.h:70
@ MC_TYPE_PROMPT
Maxima questions or lisp prompts.
Definition: Cell.h:67
@ MC_TYPE_SECTION
A section name.
Definition: Cell.h:78
@ MC_TYPE_ASCIIMATHS
Equations displayed in 2D.
Definition: Cell.h:73
@ MC_TYPE_LABEL
An output label generated by maxima.
Definition: Cell.h:68
@ MC_TYPE_GROUP
A group cells that bundles several individual cells together.
Definition: Cell.h:82
@ MC_TYPE_MAIN_PROMPT
Input labels.
Definition: Cell.h:66
@ MC_TYPE_SUBSECTION
A subsection name.
Definition: Cell.h:74
@ MC_TYPE_INPUT
A cell containing code.
Definition: Cell.h:69
@ MC_TYPE_HEADING5
A subsubsection name.
Definition: Cell.h:76
@ MC_TYPE_TITLE
The title of the document.
Definition: Cell.h:79
@ MC_TYPE_SLIDE
An animation created by the with_slider_* maxima commands.
Definition: Cell.h:81
@ MC_TYPE_SUBSUBSECTION
A subsubsection name.
Definition: Cell.h:75
@ MC_TYPE_HEADING6
A subsubsection name.
Definition: Cell.h:77
@ MC_TYPE_TEXT
Text that isn't passed to maxima.
Definition: Cell.h:72
@ MC_TYPE_IMAGE
An image.
Definition: Cell.h:80
@ MC_TYPE_ERROR
An error output by maxima.
Definition: Cell.h:71
auto OnInner(const C *cell)
Returns an iterable that goes over the inner cells of this cell.
Definition: Cell.h:1302
This file declares everything needed for the text style system used to style all the elements on the ...
TextStyle
All text styles known to wxMaxima.
Definition: TextStyle.h:235
A Type-Safe Fixed-Point Font Size.
Definition: FontAttribs.h:99
Definition: diagrams_c.h:5
A cached integer value.
Definition: CachedValue.h:45
Definition: CellIterators.h:179
Definition: CellIterators.h:78
Definition: CellList.h:151
A weak non-owning pointer that becomes null whenever the observed object is destroyed.
Definition: CellPtr.h:539
A class that carries information about the type of a cell.
Definition: Cell.h:93
virtual const wxString & GetName() const =0
The name of the cell type, e.g.
The base class all cell types the worksheet can consist of are derived from.
Definition: Cell.h:148
bool ConfigChanged() const
Has the configuration changed since the last recalculation of this cell?
Definition: Cell.h:554
bool FontSizeMatchesExpectation() const
Does this cell's font size match what its owner last dictated?
Definition: Cell.cpp:566
virtual wxString ToMatlab() const
Convert this cell to its Matlab representation.
Definition: Cell.cpp:896
virtual const wxString GetToolTip(wxPoint point) const
Returns the ToolTip this cell provides at a given point.
Definition: Cell.cpp:79
bool InUpdateRegion() const
Is this cell inside the region that is currently drawn?
Definition: Cell.cpp:808
virtual void DrawBoundingBox(wxDC &WXUNUSED(dc), bool all=false)
Draw a rectangle that marks this cell or this list of cells as selected.
Definition: Cell.cpp:836
std::map< wxString, wxString > m_extraAttributes
Extra XML attributes we don't know yet.
Definition: Cell.h:1223
bool IsBrokenIntoLines() const
Whether this cell is broken into two or more lines.
Definition: Cell.h:1038
void SetPen(wxDC *dc, double lineWidth=1.0) const
Sets the drawing pen to the cell's default foreground color.
Definition: Cell.cpp:1424
void CopyCommonData(const Cell &cell)
Copy common data (used when copying a cell)
Definition: Cell.cpp:209
virtual void PasteFromClipboard(bool primary=false)
Paste from the clipboard into this cell.
Definition: Cell.cpp:1231
bool IsHidden() const
Whether this cell is not to be drawn.
Definition: Cell.h:851
Range GetCellsInRect(const wxRect &rect) const
Returns the first and last cells within the given rectangle, recursing into the inner cells.
Definition: Cell.cpp:1266
virtual size_t GetInnerCellCount() const
The number of inner cells - for use by the iterators.
Definition: Cell.cpp:1819
void ResetSize_RecursivelyList() const
Mark all cached size information of this cell list as "to be calculated".
Definition: Cell.cpp:1321
virtual int GetImageBorderWidth() const
0 for ordinary cells, 1 for slide shows and diagrams displayed with a 1-pixel border
Definition: Cell.h:960
virtual wxString ToOMML() const
Returns the cell's representation as OMML.
Definition: Cell.cpp:1144
void SetBigSkip(bool skip)
Tell this cell to cause an additional vertical space.
Definition: Cell.h:623
void TallyImageLoadFailures_Recursively(int &dataUnavailable, int &decodeFailed) const
Recursively visits this cell and everything nested inside it (including an image produced by the very...
Definition: Cell.cpp:1326
bool HasBigSkip() const
Does this cell come with an additional vertical space.
Definition: Cell.h:625
virtual void UnbreakList() const
Unbreak this line.
Definition: Cell.cpp:1408
wxRect CropToUpdateRegion(wxRect rect) const
The part of the rectangle rect that is in the region that is currently drawn.
Definition: Cell.cpp:270
void SoftLineBreak(bool breakLine=true) const
Do we want this cell to start with a linebreak?
Definition: Cell.h:240
CellPtr< GroupCell > m_group
The GroupCell this list of cells belongs to.
Definition: Cell.h:1135
virtual wxString ListToMatlab() const
Convert this list to its LaTeX representation.
Definition: Cell.cpp:898
virtual wxString ListToOMML(bool startofline=false) const
Convert this list to an OMML representation.
Definition: Cell.cpp:1146
GroupCell * GetGroup() const
Returns the group cell this cell belongs to.
Definition: Cell.cpp:285
virtual bool IsActive() const
Is this editor cell focused?
Definition: Cell.h:947
Configuration * GetConfiguration()
Which configuration object is responsible for this cell?
Definition: Cell.h:381
virtual wxString ListToString() const
Returns this cell list's representation as a string.
Definition: Cell.cpp:866
void BreakUpAndMark() const
Break up the internal cells of this cell, and mark it as broken up.
Definition: Cell.cpp:1387
void ForceBreakLine(bool force=true) const
Insert (or remove) a forced linebreak at the beginning of this cell.
Definition: Cell.h:420
virtual wxRect GetRect(bool wholeList=false) const
Get the smallest rectangle this cell fits in.
Definition: Cell.cpp:799
void AddExtraAttribute(const wxString &name, const wxString &value)
Adds an extra XML attribute to this cell.
Definition: Cell.cpp:1875
virtual wxCoord GetHeightList() const
Returns the total height of this line.
Definition: Cell.cpp:399
virtual void FontsChanged() const
To be called if the font has changed.
Definition: Cell.h:1237
void CollectWideCells(std::vector< const Cell * > &wideCells, int clientWidth) const
Recursively collect all cells that are too wide to fit the line.
Definition: Cell.cpp:761
virtual wxCoord GetCenterList() const
Returns the maximum distance between top and center of this line.
Definition: Cell.cpp:389
AFontSize m_fontSize_expected
The font size this cell's owner last dictated (via RecalculateTracked()).
Definition: Cell.h:1190
void ClearToolTip()
Remove this cell's tooltip.
Definition: Cell.cpp:456
wxString GetUUID() const
Returns the UUID of this cell.
Definition: Cell.h:430
wxCoord GetHeight() const
Get the height of this cell.
Definition: Cell.cpp:293
Cell * GetNext() const
Get the next cell in the list.
Definition: Cell.h:803
virtual void SelectAll()
Select all editable text of this cell.
Definition: Cell.h:917
virtual Cell * GetBrokenCell(size_t index) const
Retrieve a piece of this cell's broken (linear/1D) display; see GetBrokenCellCount().
Definition: Cell.h:829
bool HasValidPosition() const
Is the position valid?
Definition: Cell.cpp:630
virtual void Unbreak() const
Undo breaking this cell into multiple lines.
Definition: Cell.cpp:1397
int GetLineIndent() const
If this were the beginning of a line: How far do we need to indent it?
Definition: Cell.cpp:645
void SetCurrentPointList(wxPoint point)
Helper to position a horizontal list of cells.
Definition: Cell.cpp:518
virtual void SetValue(const wxString &WXUNUSED(text))
Allows to change the text a TextCell contains.
Definition: Cell.h:663
wxCoord Scale_Px(double px) const
Scale font sizes and line widths according to the zoom factor.
Definition: Cell.h:182
CachedInteger< wxCoord > m_cachedLineWidth
Cache for GetLineWidth(): the width of only the first display line of the list starting at this cell ...
Definition: Cell.h:1176
virtual void TallyImageLoadFailures(int &WXUNUSED(dataUnavailable), int &WXUNUSED(decodeFailed)) const
Blocks until this cell's own image (if any) has finished loading, then adds 1 to dataUnavailable or d...
Definition: Cell.h:355
bool ContainsPoint(wxPoint point) const
Is a given point inside this cell?
Definition: Cell.h:331
virtual bool IsShortNum() const
True if this cell represents a short number.
Definition: Cell.h:699
CellType GetType() const
Returns the type of this cell.
Definition: Cell.h:489
void SetTextColor(wxDC *dc)
Sets the text color.
Definition: Cell.cpp:1439
virtual bool CanCopy() const
Select Can we copy the editable text of this cell?
Definition: Cell.h:921
virtual wxString ListToMathML(bool startofline=false) const
Convert this list to a MathML representation.
Definition: Cell.cpp:961
virtual wxString ListToTeX() const
Convert this list to its LaTeX representation.
Definition: Cell.cpp:931
Cell * GetPrevious() const
Returns a pointer to the previous cell in the current cell list.
Definition: Cell.h:800
virtual const wxString & GetAltCopyText() const
Get the text set using SetAltCopyText - may be empty.
Definition: Cell.h:1066
bool GetHidableMultSign() const
Whether this is a hidable multiplication sign.
Definition: Cell.h:1051
bool HasHardLineBreak() const
Does this cell begin with a manual linebreak?
Definition: Cell.h:298
unsigned long CellsInListRecursive() const
How many cells does this cell contain?
Definition: Cell.cpp:258
virtual bool FirstLineOnlyEditor() const
True, if this GroupCell is folded and its editor shows only its first line.
Definition: Cell.cpp:191
virtual wxString ToString() const
Returns the cell's representation as a string.
Definition: Cell.cpp:850
void SetConfigurationList(Configuration *config)
Tell this cell list to use the configuration object config.
Definition: Cell.cpp:634
void AddToolTip(const wxString &tip)
Add another tooltip to this cell.
Definition: Cell.cpp:483
Cell * last() const
Get the last cell in this list of cells.
Definition: Cell.cpp:1376
virtual void ClearCache()
Clears memory from cached items automatically regenerated when the cell is drawn.
Definition: Cell.h:338
bool GetSuppressMultiplicationDot() const
Do we want to begin this cell with a center dot if it is part of a product?
Definition: Cell.h:1048
virtual wxString ListToRTF(bool startofline=false) const
Convert this list to an RTF representation.
Definition: Cell.cpp:1175
virtual void SetIsExponent()
Tell this cell to be an exponent.
Definition: Cell.cpp:508
bool GetHighlight() const
Is this cell highlighted (e.G. inside a maxima box)
Definition: Cell.h:645
static wxString RTFescape(wxString, bool MarkDown=false)
Escape a string for RTF.
Definition: Cell.cpp:1098
bool HasStaleSize() const
Is the size valid, whether a recalculation is pending or not?
Definition: Cell.cpp:626
void SetHighlight(bool highlight)
Mark this cell as highlighted (e.G. being in a maxima box)
Definition: Cell.h:643
bool HasValidSize() const
Is the size valid and not pending a recalculation?
Definition: Cell.cpp:622
virtual size_t GetBrokenCellCount() const
The number of pieces this cell is displayed as once it IsBrokenIntoLines(), and in what order – see G...
Definition: Cell.h:827
bool IsEditable(bool input=false) const
Is this cell editable?
Definition: Cell.h:863
wxCoord GetCurrentY() const
Get the y position of the top left of this cell.
Definition: Cell.h:535
virtual void SetIsExponentList()
Tell this list of cells to be an exponent.
Definition: Cell.cpp:502
virtual wxString ListToXML() const
Convert this list to a representation fit for saving in a .wxmx file.
Definition: Cell.cpp:1233
bool BreakLineHere() const
Are we allowed to break a line here?
Definition: Cell.h:295
void ResetSizeList() const
Mark the cached height information of the whole list of cells as "to be calculated".
Definition: Cell.cpp:581
virtual wxString GetDiffPart() const
Get the part for diff tag support.
Definition: Cell.cpp:1258
Range GetListCellsInRect(const wxRect &rect) const
Returns the first and last cells within the given rectangle, without recursing into the inner cells.
Definition: Cell.cpp:1273
wxCoord GetCenter() const
Get the distance between the top and the center of this cell.
Definition: Cell.cpp:313
CachedInteger< wxCoord > m_cachedMaxDrop
Cache for GetMaxDrop(): the largest drop (height below the center) of the cells on the first display ...
Definition: Cell.h:1167
void SetCurrentPoint(int x, int y) const
Sets the position for the cell and convenience overload.
Definition: Cell.h:1008
void BreakLines_List() const
Break lines in this list of cells.
Definition: Cell.cpp:655
wxPoint m_currentPoint
The point in the work sheet at which this cell begins.
Definition: Cell.h:1102
AFontSize m_fontSize
The unscaled font size.
Definition: Cell.h:1183
bool DrawThisCell()
Is this cell currently visible in the window?
Definition: Cell.cpp:608
void ClearCacheList()
Clears the cache of the whole list of cells starting with this one.
Definition: Cell.cpp:253
virtual void Hide(bool hide=true)
Hide this cell. See IsHidden() for details.
Definition: Cell.h:857
virtual void SelectPointText(wxPoint point)
Select the text at point.
Definition: Cell.cpp:1227
void DrawList(wxDC *dc, wxDC *adc)
Helper to draw a list of cells.
Definition: Cell.cpp:532
virtual wxString ToXML() const
Convert this cell to a representation fit for saving in a .wxmx file.
Definition: Cell.cpp:942
CachedInteger< wxCoord > m_cachedSumOfWidths
Cache for SumOfWidths(): the summed width of all cells of the draw list starting at this cell (the wh...
Definition: Cell.h:1173
void SetUUID(const wxString &uuid)
Sets the UUID of this cell.
Definition: Cell.h:432
virtual void SetAltCopyText(const wxString &text)
What should end up if placing this cell on the clipboard?
Definition: Cell.cpp:495
virtual void SelectRectText(wxPoint one, wxPoint two)
Select the text between the two points.
Definition: Cell.cpp:1229
virtual wxString ToMathML() const
Convert this cell to a representation fit for saving in a .wxmx file.
Definition: Cell.cpp:959
CachedInteger< wxCoord > m_height
The height of this cell.
Definition: Cell.h:1151
bool ContainsRect(const wxRect &sm, bool all=true) const
Is a part of this cell inside a certain rectangle?
Definition: Cell.cpp:1298
wxCoord SumOfWidths() const
How many pixels is this list of cells wide, if we don't break it into lines?
Definition: Cell.cpp:401
wxString VariablesAndFunctionsList() const
Returns all variable and function names used inside this list of cells.
Definition: Cell.cpp:854
virtual ~Cell()
Delete this list of cells.
Definition: Cell.cpp:109
AFontSize Scale_Px(AFontSize size) const
Scale font sizes and line widths according to the zoom factor.
Definition: Cell.h:187
virtual void SetStyle(TextStyle style)
Sets the TextStyle of this cell.
Definition: Cell.h:951
virtual const CellTypeInfo & GetInfo()=0
Returns the information about this cell's type.
virtual std::unique_ptr< Cell > Copy(GroupCell *group) const =0
Create a copy of this cell.
void ScheduleRecalculation() const
Cause this cell to be recalculated the next time.
Definition: Cell.h:552
wxCoord GetLineWidth() const
How many pixels is the current line of this list of cells wide?
Definition: Cell.cpp:406
virtual wxPoint PositionToPoint()
Locates the cursor in the editable text of this cell.
Definition: Cell.h:929
void SetToolTip(const wxString &tooltip) const
Set the tooltip to a given string.
Definition: Cell.cpp:463
virtual void SetConfiguration(Configuration *config)
Tell this cell to use the configuration object config.
Definition: Cell.cpp:639
virtual wxString GnuplotSource() const
Retrieve the gnuplot source data for this image.
Definition: Cell.h:877
virtual wxCoord GetMaxDrop() const
Returns the maximum distance between center and bottom of this line.
Definition: Cell.cpp:394
static wxString XMLescape(wxString)
Escape a string for XML.
Definition: Cell.cpp:1079
virtual void Draw(wxDC *dc, wxDC *antialiassingDC)
Pass 3 (Paint): Renders the cell using pre-calculated coordinates.
Definition: Cell.cpp:422
virtual Cell * GetInnerCell(size_t index) const
Retrieve an inner cell with given index which must be less than GetInnerCellCount.
Definition: Cell.cpp:1821
virtual const wxString & GetValue() const
Gets the text this text cell contains.
Definition: Cell.cpp:1437
Configuration * m_configuration
A pointer to the configuration responsible for this worksheet.
Definition: Cell.h:1138
int GetWidth() const
Get the width of this cell.
Definition: Cell.cpp:303
virtual wxString ToTeX() const
Convert this cell to its LaTeX representation.
Definition: Cell.cpp:929
void ResetSize() const
Mark the cached height and width information as "to be calculated".
Definition: Cell.cpp:1340
void GenerateUUID()
Generates a new UUID for this cell.
Definition: Cell.cpp:1854
wxPoint GetCurrentPoint() const
Returns the pre-calculated worksheet position of the cell.
Definition: Cell.h:1029
virtual void SetFocus(bool WXUNUSED(focus))
Focus this editor cell.
Definition: Cell.h:940
wxString GetExtraXMLAttributes() const
Returns a string containing all extra XML attributes.
Definition: Cell.cpp:1864
DocumentCellPointers * GetDocumentCellPointers() const
The document-model half of the cell-pointer registry this cell uses.
Definition: Cell.cpp:71
virtual void ProcessEvent(wxKeyEvent &WXUNUSED(event))
Processes a key event.
Definition: Cell.h:880
void SetCurrentPointDrawList(wxPoint point)
Helper to position a list of cells using the draw-list logic.
Definition: Cell.cpp:525
virtual void SetCurrentPoint(wxPoint point) const
Pass 2: Arrangement.
Definition: Cell.cpp:514
void TallyImageLoadFailures_RecursivelyList(int &dataUnavailable, int &decodeFailed) const
Same as TallyImageLoadFailures_Recursively(), but for the whole list of cells starting with this one.
Definition: Cell.cpp:1334
wxCoord GetCurrentX() const
Get the x position of the top left of this cell.
Definition: Cell.h:528
bool IsComment() const
Determine if this cell contains text that isn't code.
Definition: Cell.h:835
bool BreakUpCells() const
Cell list: Convert 2d math objects bigger than the screen width into linear form.
Definition: Cell.cpp:705
static wxString OMML2RTF(wxXmlNode *node)
Converts an OMML tag to the corresponding RTF snippet.
Definition: Cell.cpp:1028
bool UnBreakUpCells() const
Convert all maths objects in this call list into their 2D form.
Definition: Cell.cpp:786
virtual void SetType(CellType type)
Sets the text style according to the type.
Definition: Cell.cpp:117
AFontSize m_fontSize_Scaled
The font size is smaller in super- and subscripts.
Definition: Cell.h:1181
virtual Range GetInnerCellsInRect(const wxRect &rect) const
Select the cells inside this cell described by the rectangle rect.
Definition: Cell.cpp:1285
CachedInteger< wxCoord > m_width
The width of this cell; is recalculated by RecalculateHeight.
Definition: Cell.h:1155
ViewCellPointers * GetViewCellPointers() const
The transient view-state half of the cell-pointer registry this cell uses.
Definition: Cell.cpp:75
virtual bool BreakUp() const
Try to split this command into lines to make it fit on the screen.
Definition: Cell.cpp:1385
bool IsCompound() const
Do we have an operator in this line - draw () in frac...
Definition: Cell.cpp:843
wxBitmap BitmapFromSVG(wxString svgData, wxSize size)
Renders a bitmap from svgData at the requested size.
Definition: Cell.cpp:173
void ResetSize_Recursively() const
Mark all cached size information as "to be calculated".
Definition: Cell.cpp:1313
CachedInteger< wxCoord > m_cachedCenterList
Cache for GetCenterList(): the largest center (height above the center) of the cells on the first dis...
Definition: Cell.h:1170
std::unique_ptr< Cell > CopyList(GroupCell *group) const
Return a copy of the list of cells beginning with this one.
Definition: Cell.cpp:233
virtual bool IsDirty() const
Is this cell marked as "from an old maxima run"?
Definition: Cell.h:933
friend auto OnInner(const C *cell)
Returns an iterable that goes over the inner cells of this cell.
Definition: Cell.h:1302
virtual bool CutToClipboard()
Cut this cell's editable contents to the clipboard.
Definition: Cell.h:913
virtual bool IsOperator() const
Is this cell an operator?
Definition: Cell.h:693
bool IsMath() const
Is this cell possibly output of maxima?
Definition: Cell.cpp:1468
wxString m_uuid
The UUID of this cell.
Definition: Cell.h:1221
virtual bool CanPopOut() const
Can this cell be popped out interactively in gnuplot?
Definition: Cell.h:871
wxCoord GetDrop() const
Get the distance between the center and the bottom of this cell.
Definition: Cell.h:483
CachedInteger< wxCoord > m_center
The distance between the top and the insertion point of this cell.
Definition: Cell.h:1161
virtual void Recalculate(AFontSize fontsize) const
Recalculate the size of the cell and the difference between top and center.
Definition: Cell.cpp:590
void FontsChangedList()
Tell a whole list of cells that their fonts have changed.
Definition: Cell.cpp:277
bool NeedsRecalculation() const
True, if something that affects the cell size has changed.
Definition: Cell.h:549
virtual bool AddEnding()
Add a semicolon to a code cell, if needed.
Definition: Cell.h:887
const wxString * m_toolTip
This tooltip is owned by us when m_ownsToolTip is true. Otherwise, it points to a "static" string.
Definition: Cell.h:1142
virtual bool CopyToClipboard() const
Copy this cell's editable contents to the clipboard.
Definition: Cell.h:907
void SetBrush(wxDC *dc) const
Sets the fill brush to the cell's default foreground color.
Definition: Cell.cpp:1432
bool RecalculateTracked(AFontSize fontsize) const
Recalculate this cell at the font size its owner dictates.
Definition: Cell.cpp:548
bool RecalculateList(AFontSize fontsize) const
Recalculate both width and height of this list of cells.
Definition: Cell.cpp:538
const TextStyle & GetTextStyle() const
Get the text style.
Definition: Cell.h:631
Cell * first() const
Get the first cell in this list of cells.
Definition: Cell.cpp:1367
virtual wxString ToRTF() const
Returns the cell's representation as RTF.
Definition: Cell.h:743
virtual wxPoint PositionToPoint(size_t WXUNUSED(pos))
Locates a char in the editable text of this cell.
Definition: Cell.h:925
The configuration storage for the current worksheet.
Definition: Configuration.h:98
std::int_fast32_t CellCfgCnt() const
A counter that increases every time we need to recalculate all worksheet cells.
Definition: Configuration.h:1316
wxCoord Scale_Px(double px) const
Scales a distance [in pixels] according to the zoom factor.
Definition: Configuration.cpp:1151
The document-model half of the cell-pointer registry.
Definition: CellPointers.h:50
This class defines what the user sees as input cell.
Definition: EditorCell.h:62
A cell grouping input (and, if there is one, also the output) cell to a foldable item.
Definition: GroupCell.h:88
Definition: CellIterators.h:275
Iterates the inner cells of a cell.
Definition: CellIterators.h:197
Objects deriving from this class can be observed by the CellPtr.
Definition: CellPtr.h:97
A Text cell.
Definition: TextCell.h:38
The view/interaction half of the cell-pointer registry.
Definition: CellPointers.h:187
A struct that allows to specify a region of a cell list.
Definition: Cell.h:675
For the bitmap export we sometimes want to know how big the result will be...
Definition: Cell.h:706