wxMaxima
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>
48 class CellPointers;
49 class EditorCell;
50 class GroupCell;
51 class TextCell;
52 class Worksheet;
53 class wxXmlNode;
54 
55 // Forward declarations
56 template <typename C, typename std::enable_if<std::is_base_of<Cell, C>::value, bool>::type = true>
57 inline auto OnInner(const C *cell);
58 template <typename C, typename std::enable_if<std::is_base_of<Cell, C>::value, bool>::type = true>
59 inline auto OnInner(C *cell);
60 
63 enum CellType : int8_t
64 {
65  MC_TYPE_DEFAULT,
83 };
85 std::ostream& operator<<(std::ostream& out, const CellType celltype);
86 
87 #if wxUSE_ACCESSIBILITY
88 class CellAccessible;
89 #endif
90 
93 {
94 public:
100  virtual const wxString &GetName() const = 0;
101 };
102 
140 // 120 bytes
141 class Cell: public Observed
142 {
143 #if wxUSE_ACCESSIBILITY
144  friend class CellAccessible;
145 #endif
146  friend class CellList;
147 
148  // This class can be derived from wxAccessible which has no copy constructor
149  void operator=(const Cell&) = delete;
151  Cell(GroupCell *group, const Cell&) = delete;
152 
153  template <typename C, typename std::enable_if<std::is_base_of<Cell, C>::value, bool>::type>
154  friend inline auto OnInner(const C *cell);
155  template <typename C, typename std::enable_if<std::is_base_of<Cell, C>::value, bool>::type>
156  friend inline auto OnInner(C *cell);
157 
158 public:
159 // Cell(GroupCell *group, Configuration *config);
160  Cell(GroupCell *group, Configuration *config);
161 
167  virtual std::unique_ptr<Cell> Copy(GroupCell *group) const = 0;
168 
170  virtual const CellTypeInfo &GetInfo() = 0;
171 
176  wxCoord Scale_Px(double px) const {return m_configuration->Scale_Px(px);}
181  AFontSize Scale_Px(AFontSize size) const { return m_configuration->Scale_Px(size); }
182 
183 #if wxUSE_ACCESSIBILITY
184  // The methods whose implementation within Cell should be sufficient are
185  // not virtual. Should that prove not to be the case eventually, they can be
186  // made virtual with due caution.
188  wxAccStatus GetParent (Cell ** parent) const;
190  wxAccStatus GetChild(int childId, Cell **child) const;
192  wxAccStatus HitTest (const wxPoint &pt, int *childId, Cell **child);
193 
195  virtual wxAccStatus GetDescription(int childId, wxString *description) const;
197  virtual wxAccStatus GetFocus (int *childId, Cell **child) const;
199  virtual wxAccStatus GetDefaultAction(int childId, wxString *actionName) const;
201  virtual wxAccStatus GetLocation (wxRect &rect, int elementId);
203  virtual wxAccStatus GetValue (int childId, wxString *strValue) const;
204  virtual wxAccStatus GetRole (int childId, wxAccRole *role) const;
205 #endif
206 
207 
215  virtual const wxString GetToolTip(wxPoint point) const;
216 
218  virtual ~Cell();
219 
221  unsigned long CellsInListRecursive() const;
222 
224  wxRect CropToUpdateRegion(wxRect rect) const;
225 
227  bool InUpdateRegion() const;
228 
230  void SoftLineBreak(bool breakLine = true) { m_breakLine = breakLine; }
231 
236  bool BreakUpCells();
237 
239  bool UnBreakUpCells();
240 
241  /* Break lines in this list of cells
242  */
243  void BreakLines_List();
244 
246  int GetLineIndent() const;
247 
249  bool BreakLineHere() const { return m_breakLine || m_forceBreakLine; }
250 
252  bool HasHardLineBreak() const { return m_forceBreakLine; }
253 
258  virtual bool BreakUp();
259 
260 protected:
266  void BreakUpAndMark();
267 
268 protected:
270  wxBitmap BitmapFromSVG(wxString svgData, wxSize size);
271 public:
279  bool ContainsRect(const wxRect &sm, bool all = true) const;
280 
285  bool ContainsPoint(wxPoint point) const { return GetRect().Contains(point); }
286 
292  virtual void ClearCache()
293  {}
294 
299  void ClearCacheList();
301  void SetConfigurationList(Configuration *config);
303  virtual void SetConfiguration(Configuration *config);
306 
307 
317  virtual void Draw(wxPoint point, wxDC *dc, wxDC *antialiassingDC);
318 
323  void DrawList(wxPoint point, wxDC *dc, wxDC *adc);
324  void DrawList(wxDC *dc, wxDC *adc){DrawList(m_currentPoint, dc, adc);}
325 
333  virtual void DrawBoundingBox(wxDC &WXUNUSED(dc), bool all = false);
334 
339  bool DrawThisCell(wxPoint point);
343 
350  void ForceBreakLine(bool force = true) { m_forceBreakLine = m_breakLine = force; }
351 
360  wxCoord GetHeight() const
361  { return m_height; }
362 
371  int GetWidth() const
372  { return m_width; }
373 
383  wxCoord GetCenter() const
384  { return m_center; }
385 
387  bool HasValidSize() const;
389  bool HasStaleSize() const;
391  bool HasValidPosition() const;
392 
406  wxCoord GetDrop() const
407  { return m_height - m_center; }
408 
413  { return m_type; }
414 
421  wxCoord GetMaxDrop() const;
422 
429  wxCoord GetCenterList() const;
430 
435  wxCoord GetHeightList() const;
436 
438  wxCoord GetFullWidth() const;
439 
445  wxCoord GetLineWidth() const;
446 
451  wxCoord GetCurrentX() const
452  { return m_currentPoint.x; }
453 
458  wxCoord GetCurrentY() const
459  { return m_currentPoint.y; }
460 
467  virtual wxRect GetRect(bool wholeList = false) const;
468 
470  virtual bool NeedsRecalculation(AFontSize fontSize) const;
471 
473  bool ConfigChanged() const {return m_configuration->CellCfgCnt() != m_cellCfgCnt_last;}
480  virtual wxString GetDiffPart() const;
481 
489  virtual void Recalculate(AFontSize fontsize);
490 
495  void RecalculateList(AFontSize fontsize);
496 
498  void FontsChangedList();
499 
501  void ResetSize_Recursively();
502 
505 
507  void ResetSize();
508 
510  void ResetSizeList();
511 
513  void SetBigSkip(bool skip) { m_bigSkip = skip; }
515  bool HasBigSkip() const { return m_bigSkip; }
516 
518  virtual void SetType(CellType type);
519 
521  const TextStyle &GetTextStyle() const
522  { return m_textStyle; }
523 
525  // cppcheck-suppress functionStatic
526  // cppcheck-suppress functionConst
527  void SetPen(wxDC *dc, double lineWidth = 1.0) const;
529  void SetBrush(wxDC *dc) const;
530  wxColour GetForegroundColor() const;
531 
533  void SetHighlight(bool highlight) { m_highlight = highlight; }
535  bool GetHighlight() const { return m_highlight; }
536 
541  virtual void SetIsExponent();
542 
547  virtual void SetIsExponentList();
548 
553  virtual void SetValue(const wxString &WXUNUSED(text)) {}
555  virtual const wxString &GetValue() const;
556 
558  Cell *first() const;
559 
561  Cell *last() const;
562 
564  struct Range {
565  Cell *first, *last;
566  };
567 
571  Range GetCellsInRect(const wxRect &rect) const;
572 
576  Range GetListCellsInRect(const wxRect &rect) const;
577 
579  virtual Range GetInnerCellsInRect(const wxRect &rect) const;
580 
582  virtual bool IsOperator() const { return false; }
583 
585  bool IsCompound() const;
586 
588  virtual bool IsShortNum() const { return false; }
589 
591  GroupCell *GetGroup() const;
592 
595  {
596  public:
597  double x, y;
598  };
599 
601  virtual wxString ListToString() const;
602 
607  wxString VariablesAndFunctionsList() const;
609  virtual wxString ListToMatlab() const;
611  virtual wxString ListToTeX() const;
613  virtual wxString ListToXML() const;
614 
616  virtual wxString ListToMathML(bool startofline = false) const;
617 
619  virtual wxString ListToOMML(bool startofline = false) const;
620 
622  virtual wxString ListToRTF(bool startofline = false) const;
623 
625  virtual wxString ToString() const;
626 
632  virtual wxString ToRTF() const
633  { return wxEmptyString; }
634 
636  static wxString OMML2RTF(wxXmlNode *node);
637 
639  static wxString OMML2RTF(wxString ommltext);
640 
650  virtual wxString ToOMML() const;
652  virtual wxString ToMatlab() const;
654  virtual wxString ToTeX() const;
656  virtual wxString ToXML() const;
658  virtual wxString ToMathML() const;
659 
661  static wxString RTFescape(wxString, bool MarkDown = false);
662 
664  static wxString XMLescape(wxString);
665 
666  // cppcheck-suppress functionStatic
667  // cppcheck-suppress functionConst
668 
676  virtual void Unbreak();
677 
685  virtual void UnbreakList();
686 
688  Cell *GetPrevious() const { return m_previous; }
689 
691  Cell *GetNext() const { return m_next.get(); }
698  Cell *GetNextToDraw() const { return m_nextToDraw; }
699 
707  virtual void SetNextToDraw(Cell *next) { m_nextToDraw = next; }
708  template <typename T, typename Del,
709  typename std::enable_if<std::is_base_of<Cell, T>::value, bool>::type = true>
717  void SetNextToDraw(const std::unique_ptr<T, Del> &ptr) { SetNextToDraw(ptr.get()); }
718 
723  bool IsComment() const
724  {
725  return m_type == MC_TYPE_TEXT || m_type == MC_TYPE_SECTION ||
726  m_type == MC_TYPE_SUBSECTION || m_type == MC_TYPE_SUBSUBSECTION ||
727  m_type == MC_TYPE_HEADING5 || m_type == MC_TYPE_HEADING6 || m_type == MC_TYPE_TITLE;
728  }
729 
739  bool IsHidden() const { return m_isHidden; }
740 
742  virtual bool FirstLineOnlyEditor();
743 
745  virtual void Hide(bool hide = true) { m_isHidden = hide; }
746 
751  bool IsEditable(bool input = false) const
752  {
753  return (m_type == MC_TYPE_INPUT &&
754  m_previous && m_previous->m_type == MC_TYPE_MAIN_PROMPT)
755  || (!input && IsComment());
756  }
757 
759  virtual bool CanPopOut() const { return false; }
760 
765  virtual wxString GnuplotSource() const {return wxEmptyString;}
766 
768  virtual void ProcessEvent(wxKeyEvent &WXUNUSED(event))
769  {}
770 
775  virtual bool AddEnding()
776  { return false; }
777 
779  virtual void SelectPointText(wxPoint point);
780 
782  virtual void SelectRectText(wxPoint one, wxPoint two);
783 
790  virtual void PasteFromClipboard(bool primary = false);
791 
795  virtual bool CopyToClipboard() const
796  { return false; }
797 
801  virtual bool CutToClipboard()
802  { return false; }
803 
805  virtual void SelectAll()
806  {}
807 
809  virtual bool CanCopy() const
810  { return false; }
811 
813  virtual wxPoint PositionToPoint(size_t WXUNUSED(pos))
814  { return wxPoint(-1, -1); }
815 
817  virtual wxPoint PositionToPoint()
818  { return wxPoint(-1, -1); }
819 
821  virtual bool IsDirty() const
822  { return false; }
823 
824  virtual void SwitchCaretDisplay()
825  {}
826 
828  virtual void SetFocus(bool WXUNUSED(focus))
829  {}
830 
832  void SetTextColor(wxDC *dc);
833 
835  virtual bool IsActive() const
836  { return false; }
837 
839  virtual void SetStyle(TextStyle style)
840  {
842  m_textStyle = style;
843  }
845  bool IsMath() const;
846 
848  virtual int GetImageBorderWidth() const { return 0; }
849 
851  void CopyCommonData(const Cell & cell);
852 
854  std::unique_ptr<Cell> CopyList(GroupCell *group) const;
855 
857  static std::unique_ptr<Cell> CopyList(GroupCell *group, const Cell *cell);
858 
860  void ClearToolTip();
862  void SetToolTip(const wxString &tooltip);
866  void SetToolTip(const wxString *toolTip);
868  void AddToolTip(const wxString &tip);
870  virtual void SetCurrentPoint(wxPoint point) { m_currentPoint = point; }
872  void SetCurrentPoint(int x, int y) { SetCurrentPoint({x, y}); }
874  wxPoint GetCurrentPoint() const {return m_currentPoint;}
875 
882  bool IsBrokenIntoLines() const { return m_isBrokenIntoLines; }
883 
892  bool GetSuppressMultiplicationDot() const { return m_suppressMultiplicationDot; }
893  void SetSuppressMultiplicationDot(bool val) { m_suppressMultiplicationDot = val; }
895  bool GetHidableMultSign() const { return m_isHidableMultSign; }
896  void SetHidableMultSign(bool val) { m_isHidableMultSign = val; }
897 
908  virtual void SetAltCopyText(const wxString &text);
910  virtual const wxString &GetAltCopyText() const { return wxm::emptyString; }
911 
912 #if wxUSE_ACCESSIBILITY
913  CellAccessible *GetAccessible();
914 #endif
915 #if CELL_TEST
916  void MockBreakUp() { m_isBrokenIntoLines = 1; }
917 #endif
918 
919  static wxString wxColor2HtmlString(wxColor col);
920 protected:
921  std::unique_ptr<Cell> MakeVisiblyInvalidCell() const;
922 public:
923  static std::unique_ptr<Cell> MakeVisiblyInvalidCell(GroupCell *group, Configuration *config);
924 
925 protected:
926 //** Bases and internal members (16 bytes)
927 //**
928 // VTable *__vtable;
929 // Observed __observed;
930 
931 //** 8-byte objects (8 bytes)
932 //**
946  wxPoint m_currentPoint{-1, -1};
947 
948 protected:
949 //** 8/4-byte objects (40 + 8* bytes)
950 //**
951 
952 private:
954  std::int_fast32_t m_cellCfgCnt_last = -1;
956  std::unique_ptr<Cell> m_next;
957 
959  Cell *m_previous = {};
960 
961 #if wxUSE_ACCESSIBILITY
962  std::unique_ptr<CellAccessible> m_accessible;
963 #endif
964 
965 public:
966  const wxString &GetLocalToolTip() const;
967 protected:
973 
976 
979  const wxString *m_toolTip /* initialized in the constructor */;
980 
981 //** 4-byte objects (28 bytes)
982 //**
983 protected:
990  wxCoord m_height = -1;
994  wxCoord m_width = -1;
1001  wxCoord m_center = -1;
1002 protected:
1003 //** 2-byte objects (2 bytes)
1004 //**
1007 
1008 //** 1-byte objects (2 bytes)
1009 //**
1010  // The celltype of this object
1011  CellType m_type = MC_TYPE_DEFAULT;
1012  // The text style of this object
1013  TextStyle m_textStyle = TS_MATH;
1014 
1015 private:
1016 //** Bitfield objects (2 bytes)
1017 //**
1018  void InitBitFields_Cell()
1019  { // Keep the initialization order below same as the order
1020  // of bit fields in this class!
1021  m_ownsToolTip = false;
1022  m_bigSkip = false;
1023  m_isBrokenIntoLines = false;
1024  m_isHidden = false;
1025  m_isHidableMultSign = false;
1026  m_suppressMultiplicationDot = false;
1027  m_breakLine = false;
1028  m_forceBreakLine = false;
1029  m_highlight = false;
1030  }
1031 
1032  // In the boolean bit fields below, InitBitFields_Cell is an indication that
1033  // the InitBitFields_Cell() method initializes a given field. It should be
1034  // only added once such initialization is in place. It makes it easier
1035  // to verify that all bit fields are initialized.
1036 
1038  bool m_ownsToolTip : 1 /* InitBitFields_Cell */;
1039  bool m_bigSkip : 1 /* InitBitFields_Cell */;
1040  bool m_isBrokenIntoLines : 1 /* InitBitFields_Cell */;
1041  bool m_isHidden : 1 /* InitBitFields_Cell */;
1042  bool m_isHidableMultSign : 1 /* InitBitFields_Cell */;
1043  bool m_suppressMultiplicationDot : 1 /* InitBitFields_Cell */;
1045  bool m_breakLine : 1 /* InitBitFields_Cell */;
1046  bool m_forceBreakLine : 1 /* InitBitFields_Cell */;
1047  bool m_highlight : 1 /* InitBitFields_Cell */;
1048 
1049 protected:
1050  friend class InnerCellIterator;
1052  virtual size_t GetInnerCellCount() const;
1055  virtual Cell *GetInnerCell(size_t index) const;
1056 
1057  inline Worksheet *GetWorksheet() const;
1058 
1060  virtual void FontsChanged()
1061  { ResetSize_Recursively(); }
1062 
1063  CellPointers *GetCellPointers() const;
1064 
1065 private:
1066  void RecalcCenterListAndMaxDropCache();
1067 };
1068 
1069 // The static cast here requires Cell to be defined
1070 template <typename T>
1071 template <typename PtrT, typename std::enable_if<std::is_pointer<PtrT>::value, bool>::type>
1072 inline PtrT CellPtr<T>::CastAs() const noexcept { return dynamic_cast<PtrT>(static_cast<Cell*>(base_get())); }
1073 
1074 #if wxUSE_ACCESSIBILITY
1075 class CellAccessible final : public wxAccessible
1076 {
1077 public:
1078  explicit CellAccessible(Cell *const forCell) : m_cell(forCell) {}
1079 
1081  wxAccStatus GetParent (wxAccessible **parent) override;
1083  wxAccStatus GetChildCount (int *childCount) override;
1085  wxAccStatus GetChild (int childId, wxAccessible **child) override;
1087  wxAccStatus HitTest (const wxPoint &pt,
1088  int *childId, wxAccessible **child) override;
1090  wxAccStatus GetDescription(int childId, wxString *description) override;
1092  wxAccStatus GetDefaultAction(int childId, wxString *actionName) override;
1094  wxAccStatus GetFocus (int *childId, wxAccessible **child) override;
1096  wxAccStatus GetLocation (wxRect &rect, int elementId) override;
1098  wxAccStatus GetValue (int childId, wxString *strValue) override;
1099  wxAccStatus GetRole (int childId, wxAccRole *role) override;
1100 private:
1101  Cell *const m_cell;
1102 };
1103 #endif
1104 
1106 template <typename C, typename std::enable_if<std::is_base_of<Cell, C>::value, bool>::type = true>
1107 inline auto OnList(const C *cell) { return CellListAdapter<const C>(cell); }
1108 template <typename C, typename std::enable_if<std::is_base_of<Cell, C>::value, bool>::type = true>
1109 inline auto OnList(C *cell) { return CellListAdapter<C>(cell); }
1110 
1112 template <typename C, typename std::enable_if<std::is_base_of<Cell, C>::value, bool>::type = true>
1113 inline auto OnDrawList(const C *cell) { return CellDrawListAdapter<const C>(cell); }
1114 template <typename C, typename std::enable_if<std::is_base_of<Cell, C>::value, bool>::type = true>
1115 inline auto OnDrawList(C *cell) { return CellDrawListAdapter<C>(cell); }
1116 
1118 template <typename C, typename std::enable_if<std::is_base_of<Cell, C>::value, bool>::type>
1119 inline auto OnInner(const C *cell) { return InnerCellAdapter(const_cast<Cell *>(cell)); }
1120 template <typename C, typename std::enable_if<std::is_base_of<Cell, C>::value, bool>::type>
1121 inline auto OnInner(C *cell) { return InnerCellAdapter(cell); }
1122 
1123 inline size_t InnerCellIterator::GetInnerCellCount(const Cell *cell) { return cell->GetInnerCellCount(); }
1124 inline Cell *InnerCellIterator::GetInnerCell(const Cell *cell, size_t index) { return cell->GetInnerCell(index); }
1125 
1126 #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:1107
std::ostream & operator<<(std::ostream &out, const CellType celltype)
Allow Standard c++ streams to print out our enum values as text.
Definition: Cell.cpp:1438
auto OnDrawList(const C *cell)
Returns an iterable that goes over the cell draw list, starting with given, possibly null,...
Definition: Cell.h:1113
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:1119
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:231
A Type-Safe Fixed-Point Font Size.
Definition: FontAttribs.h:98
Definition: CellIterators.h:120
Definition: CellIterators.h:70
Definition: CellList.h:151
The storage for pointers to cells.
Definition: CellPointers.h:45
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:142
bool UnBreakUpCells()
Convert all maths objects in this call list into their 2D form.
Definition: Cell.cpp:536
bool ConfigChanged() const
Has the configuration changed since the last recalculation of this cell?
Definition: Cell.h:473
virtual wxString ToMatlab() const
Convert this cell to its Matlab representation.
Definition: Cell.cpp:649
virtual const wxString GetToolTip(wxPoint point) const
Returns the ToolTip this cell provides at a given point.
Definition: Cell.cpp:49
bool InUpdateRegion() const
Is this cell inside the region that is currently drawn?
Definition: Cell.cpp:561
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:589
virtual std::unique_ptr< Cell > Copy(GroupCell *group) const =0
Create a copy of this cell.
bool IsBrokenIntoLines() const
Whether this cell is broken into two or more lines.
Definition: Cell.h:882
void SetPen(wxDC *dc, double lineWidth=1.0) const
Sets the drawing pen to the cell's default foreground color.
Definition: Cell.cpp:1106
void CopyCommonData(const Cell &cell)
Copy common data (used when copying a cell)
Definition: Cell.cpp:172
virtual void PasteFromClipboard(bool primary=false)
Paste from the clipboard into this cell.
Definition: Cell.cpp:951
bool IsHidden() const
Whether this cell is not to be drawn.
Definition: Cell.h:739
Range GetCellsInRect(const wxRect &rect) const
Returns the first and last cells within the given rectangle, recursing into the inner cells.
Definition: Cell.cpp:986
virtual size_t GetInnerCellCount() const
The number of inner cells - for use by the iterators.
Definition: Cell.cpp:1429
virtual int GetImageBorderWidth() const
0 for ordinary cells, 1 for slide shows and diagrams displayed with a 1-pixel border
Definition: Cell.h:848
virtual wxString ToOMML() const
Returns the cell's representation as OMML.
Definition: Cell.cpp:864
void SetBigSkip(bool skip)
Tell this cell to cause an additional vertical space.
Definition: Cell.h:513
Cell * GetPrevious() const
Returns a pointer to the previous cell in the current cell list.
Definition: Cell.h:688
bool HasBigSkip() const
Does this cell come with an additional vertical space.
Definition: Cell.h:515
wxRect CropToUpdateRegion(wxRect rect) const
The part of the rectangle rect that is in the region that is currently drawn.
Definition: Cell.cpp:219
CellPtr< GroupCell > m_group
The GroupCell this list of cells belongs to.
Definition: Cell.h:969
virtual wxString ListToMatlab() const
Convert this list to its LaTeX representation.
Definition: Cell.cpp:651
virtual wxString ListToOMML(bool startofline=false) const
Convert this list to an OMML representation.
Definition: Cell.cpp:866
GroupCell * GetGroup() const
Returns the group cell this cell belongs to.
Definition: Cell.cpp:234
const TextStyle & GetTextStyle() const
Get the text style.
Definition: Cell.h:521
virtual bool IsActive() const
Is this editor cell focused?
Definition: Cell.h:835
void ResetSize_RecursivelyList()
Mark all cached size information of this cell list as "to be calculated".
Definition: Cell.cpp:1040
virtual const wxString & GetAltCopyText() const
Get the text set using SetAltCopyText - may be empty.
Definition: Cell.h:910
virtual wxString ListToString() const
Returns this cell list's representation as a string.
Definition: Cell.cpp:619
virtual wxRect GetRect(bool wholeList=false) const
Get the smallest rectangle this cell fits in.
Definition: Cell.cpp:552
wxCoord GetHeightList() const
Returns the total height of this line.
Definition: Cell.cpp:272
virtual bool BreakUp()
Try to split this command into lines to make it fit on the screen.
Definition: Cell.cpp:1067
wxCoord GetCenterList() const
Returns the maximum distance between top and center of this line.
Definition: Cell.cpp:250
virtual void SetCurrentPoint(wxPoint point)
Tells this cell where it is placed on the worksheet.
Definition: Cell.h:870
CellPtr< Cell > m_nextToDraw
The next cell in the draw list. This has been factored into Cell temporarily to reduce the change "no...
Definition: Cell.h:972
void ClearToolTip()
Remove this cell's tooltip.
Definition: Cell.cpp:337
wxCoord GetHeight() const
Get the height of this cell.
Definition: Cell.h:360
virtual void SelectAll()
Select all editable text of this cell.
Definition: Cell.h:805
bool HasValidPosition() const
Is the position valid?
Definition: Cell.cpp:448
int GetLineIndent() const
If this were the beginning of a line: How far do we need to indent it?
Definition: Cell.cpp:463
virtual void SetValue(const wxString &WXUNUSED(text))
Allows to change the text a TextCell contains.
Definition: Cell.h:553
wxCoord Scale_Px(double px) const
Scale font sizes and line widths according to the zoom factor.
Definition: Cell.h:176
bool ContainsPoint(wxPoint point) const
Is a given point inside this cell?
Definition: Cell.h:285
virtual bool IsShortNum() const
True if this cell represents a short number.
Definition: Cell.h:588
CellType GetType() const
Returns the type of this cell.
Definition: Cell.h:412
void SetTextColor(wxDC *dc)
Sets the text color.
Definition: Cell.cpp:1121
void DrawList(wxPoint point, wxDC *dc, wxDC *adc)
Draw this list of cells.
Definition: Cell.cpp:395
virtual bool CanCopy() const
Select Can we copy the editable text of this cell?
Definition: Cell.h:809
virtual wxString ListToMathML(bool startofline=false) const
Convert this list to a MathML representation.
Definition: Cell.cpp:699
virtual wxString ListToTeX() const
Convert this list to its LaTeX representation.
Definition: Cell.cpp:684
void BreakUpAndMark()
Break up the internal cells of this cell, and mark it as broken up.
Definition: Cell.cpp:1069
bool GetHidableMultSign() const
Whether this is a hidable multiplication sign.
Definition: Cell.h:895
bool HasHardLineBreak() const
Does this cell begin with a manual linebreak?
Definition: Cell.h:252
unsigned long CellsInListRecursive() const
How many cells does this cell contain?
Definition: Cell.cpp:207
void ResetSize_Recursively()
Mark all cached size information as "to be calculated".
Definition: Cell.cpp:1033
virtual wxString ToString() const
Returns the cell's representation as a string.
Definition: Cell.cpp:603
void SetConfigurationList(Configuration *config)
Tell this cell list to use the configuration object config.
Definition: Cell.cpp:452
void AddToolTip(const wxString &tip)
Add another tooltip to this cell.
Definition: Cell.cpp:364
Cell * last() const
Get the last cell in this list of cells.
Definition: Cell.cpp:1058
virtual void ClearCache()
Clears memory from cached items automatically regenerated when the cell is drawn.
Definition: Cell.h:292
bool GetSuppressMultiplicationDot() const
Do we want to begin this cell with a center dot if it is part of a product?
Definition: Cell.h:892
void ResetSize()
Mark the cached height and width information as "to be calculated".
Definition: Cell.cpp:1045
virtual wxString ListToRTF(bool startofline=false) const
Convert this list to an RTF representation.
Definition: Cell.cpp:895
virtual void SetIsExponent()
Tell this cell to be an exponent.
Definition: Cell.cpp:389
bool GetHighlight() const
Is this cell highlighted (e.G. inside a maxima box)
Definition: Cell.h:535
static wxString RTFescape(wxString, bool MarkDown=false)
Escape a string for RTF.
Definition: Cell.cpp:830
bool HasStaleSize() const
Is the size valid, whether a recalculation is pending or not?
Definition: Cell.cpp:444
void SetHighlight(bool highlight)
Mark this cell as highlighted (e.G. being in a maxima box)
Definition: Cell.h:533
bool HasValidSize() const
Is the size valid and not pending a recalculation?
Definition: Cell.cpp:440
bool IsEditable(bool input=false) const
Is this cell editable?
Definition: Cell.h:751
wxCoord GetCurrentY() const
Get the y position of the top left of this cell.
Definition: Cell.h:458
virtual void SetIsExponentList()
Tell this list of cells to be an exponent.
Definition: Cell.cpp:383
virtual wxString ListToXML() const
Convert this list to a representation fit for saving in a .wxmx file.
Definition: Cell.cpp:953
virtual void SetNextToDraw(Cell *next)
Tells this cell which one should be the next cell to be drawn.
Definition: Cell.h:707
bool BreakLineHere() const
Are we allowed to break a line here?
Definition: Cell.h:249
virtual const CellTypeInfo & GetInfo()=0
Returns the information about this cell's type.
virtual wxString GetDiffPart() const
Get the part for diff tag support.
Definition: Cell.cpp:978
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:993
wxCoord GetCenter() const
Get the distance between the top and the center of this cell.
Definition: Cell.h:383
wxPoint m_currentPoint
The point in the work sheet at which this cell begins.
Definition: Cell.h:946
virtual void Draw(wxPoint point, wxDC *dc, wxDC *antialiassingDC)
Draw this cell.
Definition: Cell.cpp:302
bool DrawThisCell()
Is this cell currently visible in the window?
Definition: Cell.h:342
void SetToolTip(const wxString &tooltip)
Set the tooltip to a given string.
Definition: Cell.cpp:344
virtual void Recalculate(AFontSize fontsize)
Recalculate the size of the cell and the difference between top and center.
Definition: Cell.cpp:416
void ClearCacheList()
Clears the cache of the whole list of cells starting with this one.
Definition: Cell.cpp:202
virtual void Hide(bool hide=true)
Hide this cell. See IsHidden() for details.
Definition: Cell.h:745
virtual void SelectPointText(wxPoint point)
Select the text at point.
Definition: Cell.cpp:947
void SetCurrentPoint(int x, int y)
Tells this cell where it is placed on the worksheet.
Definition: Cell.h:872
void ForceBreakLine(bool force=true)
Insert (or remove) a forced linebreak at the beginning of this cell.
Definition: Cell.h:350
virtual wxString ToXML() const
Convert this cell to a representation fit for saving in a .wxmx file.
Definition: Cell.cpp:695
virtual void SetAltCopyText(const wxString &text)
What should end up if placing this cell on the clipboard?
Definition: Cell.cpp:376
virtual void SelectRectText(wxPoint one, wxPoint two)
Select the text between the two points.
Definition: Cell.cpp:949
virtual wxString ToMathML() const
Convert this cell to a representation fit for saving in a .wxmx file.
Definition: Cell.cpp:697
bool ContainsRect(const wxRect &sm, bool all=true) const
Is a part of this cell inside a certain rectangle?
Definition: Cell.cpp:1018
bool BreakUpCells()
Cell list: Convert 2d math objects bigger than the screen width into linear form.
Definition: Cell.cpp:519
wxString VariablesAndFunctionsList() const
Returns all variable and function names used inside this list of cells.
Definition: Cell.cpp:607
virtual ~Cell()
Delete this list of cells.
Definition: Cell.cpp:71
AFontSize Scale_Px(AFontSize size) const
Scale font sizes and line widths according to the zoom factor.
Definition: Cell.h:181
virtual bool NeedsRecalculation(AFontSize fontSize) const
True, if something that affects the cell size has changed.
Definition: Cell.cpp:242
virtual void SetStyle(TextStyle style)
Sets the TextStyle of this cell.
Definition: Cell.h:839
wxCoord GetLineWidth() const
How many pixels is the current line of this list of cells wide?
Definition: Cell.cpp:285
wxCoord m_height
The height of this cell.
Definition: Cell.h:990
void SetNextToDraw(const std::unique_ptr< T, Del > &ptr)
Tells this cell which one should be the next cell to be drawn.
Definition: Cell.h:717
virtual wxPoint PositionToPoint()
Locates the cursor in the editable text of this cell.
Definition: Cell.h:817
virtual void SetConfiguration(Configuration *config)
Tell this cell to use the configuration object config.
Definition: Cell.cpp:457
virtual wxString GnuplotSource() const
Retrieve the gnuplot source data for this image.
Definition: Cell.h:765
wxCoord GetMaxDrop() const
Returns the maximum distance between center and bottom of this line.
Definition: Cell.cpp:261
static wxString XMLescape(wxString)
Escape a string for XML.
Definition: Cell.cpp:811
virtual bool FirstLineOnlyEditor()
True, if this GroupCell is folded and its editor shows only its first line.
Definition: Cell.cpp:157
wxCoord m_center
The distance between the top and the insertion point of this cell.
Definition: Cell.h:1001
virtual Cell * GetInnerCell(size_t index) const
Retrieve an inner cell with given index which must be less than GetInnerCellCount.
Definition: Cell.cpp:1431
virtual const wxString & GetValue() const
Gets the text this text cell contains.
Definition: Cell.cpp:1119
Configuration * m_configuration
A pointer to the configuration responsible for this worksheet.
Definition: Cell.h:975
int GetWidth() const
Get the width of this cell.
Definition: Cell.h:371
virtual wxString ToTeX() const
Convert this cell to its LaTeX representation.
Definition: Cell.cpp:682
wxPoint GetCurrentPoint() const
Where is this cell placed on the worksheet?
Definition: Cell.h:874
wxCoord m_width
The width of this cell; is recalculated by RecalculateHeight.
Definition: Cell.h:994
Cell * GetNext() const
Get the next cell in the list.
Definition: Cell.h:691
virtual void SetFocus(bool WXUNUSED(focus))
Focus this editor cell.
Definition: Cell.h:828
void SoftLineBreak(bool breakLine=true)
Do we want this cell to start with a linebreak?
Definition: Cell.h:230
virtual void ProcessEvent(wxKeyEvent &WXUNUSED(event))
Processes a key event.
Definition: Cell.h:768
wxCoord GetCurrentX() const
Get the x position of the top left of this cell.
Definition: Cell.h:451
virtual void UnbreakList()
Unbreak this line.
Definition: Cell.cpp:1090
bool IsComment() const
Determine if this cell contains text that isn't code.
Definition: Cell.h:723
void ResetSizeList()
Mark the cached height information of the whole list of cells as "to be calculated".
Definition: Cell.cpp:407
static wxString OMML2RTF(wxXmlNode *node)
Converts an OMML tag to the corresponding RTF snippet.
Definition: Cell.cpp:760
Configuration * GetConfiguration()
Which configuration object is responsible for this cell?
Definition: Cell.h:305
virtual void SetType(CellType type)
Sets the text style according to the type.
Definition: Cell.cpp:79
AFontSize m_fontSize_Scaled
The font size is smaller in super- and subscripts.
Definition: Cell.h:1006
virtual Range GetInnerCellsInRect(const wxRect &rect) const
Select the cells inside this cell described by the rectangle rect.
Definition: Cell.cpp:1005
bool IsCompound() const
Do we have an operator in this line - draw () in frac...
Definition: Cell.cpp:596
wxBitmap BitmapFromSVG(wxString svgData, wxSize size)
Renders a bitmap from svgData at the requested size.
Definition: Cell.cpp:135
std::unique_ptr< Cell > CopyList(GroupCell *group) const
Return a copy of the list of cells beginning with this one.
Definition: Cell.cpp:191
virtual void FontsChanged()
To be called if the font has changed.
Definition: Cell.h:1060
virtual bool IsDirty() const
Is this cell marked as "from an old maxima run"?
Definition: Cell.h:821
friend auto OnInner(const C *cell)
Returns an iterable that goes over the inner cells of this cell.
Definition: Cell.h:1119
virtual bool CutToClipboard()
Cut this cell's editable contents to the clipboard.
Definition: Cell.h:801
virtual bool IsOperator() const
Is this cell an operator?
Definition: Cell.h:582
bool IsMath() const
Is this cell possibly output of maxima?
Definition: Cell.cpp:1150
Cell * GetNextToDraw() const
Get the next cell that needs to be drawn.
Definition: Cell.h:698
virtual bool CanPopOut() const
Can this cell be popped out interactively in gnuplot?
Definition: Cell.h:759
wxCoord GetDrop() const
Get the distance between the center and the bottom of this cell.
Definition: Cell.h:406
void FontsChangedList()
Tell a whole list of cells that their fonts have changed.
Definition: Cell.cpp:226
virtual bool AddEnding()
Add a semicolon to a code cell, if needed.
Definition: Cell.h:775
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:979
virtual bool CopyToClipboard() const
Copy this cell's editable contents to the clipboard.
Definition: Cell.h:795
void SetBrush(wxDC *dc) const
Sets the fill brush to the cell's default foreground color.
Definition: Cell.cpp:1114
virtual void Unbreak()
Undo breaking this cell into multiple lines.
Definition: Cell.cpp:1079
Cell * first() const
Get the first cell in this list of cells.
Definition: Cell.cpp:1049
wxCoord GetFullWidth() const
How many pixels is this list of cells wide, if we don't break it into lines?
Definition: Cell.cpp:274
void RecalculateList(AFontSize fontsize)
Recalculate both width and height of this list of cells.
Definition: Cell.cpp:402
virtual wxString ToRTF() const
Returns the cell's representation as RTF.
Definition: Cell.h:632
virtual wxPoint PositionToPoint(size_t WXUNUSED(pos))
Locates a char in the editable text of this cell.
Definition: Cell.h:813
The configuration storage for the current worksheet.
Definition: Configuration.h:95
std::int_fast32_t CellCfgCnt() const
A counter that increases every time we need to recalculate all worksheet cells.
Definition: Configuration.h:1077
wxCoord Scale_Px(double px) const
Scales a distance [in pixels] according to the zoom factor.
Definition: Configuration.cpp:1373
This class defines what the user sees as input cell.
Definition: EditorCell.h:59
A cell grouping input (and, if there is one, also the output) cell to a foldable item.
Definition: GroupCell.h:74
Definition: CellIterators.h:210
Iterates the inner cells of a cell.
Definition: CellIterators.h:138
Objects deriving from this class can be observed by the CellPtr.
Definition: CellPtr.h:88
A Text cell.
Definition: TextCell.h:38
The canvas that contains the spreadsheet the whole program is about.
Definition: Worksheet.h:95
A struct that allows to specify a region of a cell list.
Definition: Cell.h:564
For the bitmap export we sometimes want to know how big the result will be...
Definition: Cell.h:595