 |
wxMaxima
|
Go to the documentation of this file.
32 #include "../precomp.h"
35 #include "Configuration.h"
36 #include "StringUtils.h"
40 #if wxUSE_ACCESSIBILITY
41 #include <wx/access.h>
42 #endif // wxUSE_ACCESSIBILITY
47 #include <type_traits>
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>
85 #if wxUSE_ACCESSIBILITY
98 virtual const wxString &
GetName()
const = 0;
141 #if wxUSE_ACCESSIBILITY
142 friend class CellAccessible;
147 void operator=(
const Cell&) =
delete;
150 template <typename C, typename std::enable_if<std::is_base_of<Cell, C>::value,
bool>::type>
151 friend inline auto OnInner(
const C *cell);
152 template <typename C, typename std::enable_if<std::is_base_of<Cell, C>::value,
bool>::type>
153 friend inline auto OnInner(C *cell);
164 virtual std::unique_ptr<Cell>
Copy(
GroupCell *group)
const = 0;
173 int Scale_Px(
double px)
const {
return (*m_configuration)->Scale_Px(px);}
176 #if wxUSE_ACCESSIBILITY
181 wxAccStatus GetParent (
Cell ** parent)
const;
183 wxAccStatus GetChild(
int childId,
Cell **child)
const;
185 wxAccStatus HitTest (
const wxPoint &pt,
int *childId,
Cell **child);
188 virtual wxAccStatus GetDescription(
int childId, wxString *description)
const;
190 virtual wxAccStatus GetFocus (
int *childId,
Cell **child)
const;
192 virtual wxAccStatus GetDefaultAction(
int childId, wxString *actionName)
const;
194 virtual wxAccStatus GetLocation (wxRect &rect,
int elementId);
196 virtual wxAccStatus GetValue (
int childId, wxString *strValue)
const;
197 virtual wxAccStatus GetRole (
int childId, wxAccRole *role)
const;
208 virtual const wxString &
GetToolTip(wxPoint point)
const;
225 bool result = (m_breakLine == breakLine);
226 m_breakLine = breakLine;
254 bool ContainsRect(
const wxRect &sm,
bool all =
true)
const;
289 virtual void Draw(wxPoint point);
318 void ForceBreakLine(
bool force =
true) { m_forceBreakLine = m_breakLine = force; }
419 virtual wxRect
GetRect(
bool all =
false)
const;
424 virtual wxString GetDiffPart()
const;
444 void ClearNeedsToRecalculateWidths() { m_recalculateWidths =
false; }
449 void ResetDataList();
465 void SetBigSkip(
bool skip) { m_bigSkip = skip; }
466 bool HasBigSkip()
const {
return m_bigSkip; }
472 {
return m_textStyle; }
477 void SetPen(
double lineWidth = 1.0)
const;
480 wxColour GetForegroundColor()
const;
487 virtual void SetExponentFlag()
490 virtual void SetValue(
const wxString &WXUNUSED(text)) {}
491 virtual const wxString &GetValue()
const;
522 virtual bool IsShortNum()
const {
return false; }
550 virtual wxString
ListToMathML(
bool startofline =
false)
const;
553 virtual wxString
ListToOMML(
bool startofline =
false)
const;
556 virtual wxString
ListToRTF(
bool startofline =
false)
const;
567 {
return wxEmptyString; }
570 static wxString
OMML2RTF(wxXmlNode *node);
573 static wxString
OMML2RTF(wxString ommltext);
584 virtual wxString
ToOMML()
const;
588 virtual wxString
ToTeX()
const;
590 virtual wxString
ToXML()
const;
595 static wxString
RTFescape(wxString,
bool MarkDown =
false);
621 Cell *GetPrevious()
const {
return m_previous; }
641 template <
typename T,
typename Del,
642 typename std::enable_if<std::is_base_of<Cell, T>::value,
bool>::type =
true>
665 virtual void Hide(
bool hide =
true) { m_isHidden = hide; }
667 bool IsEditable(
bool input =
false)
const
694 virtual void SelectPointText(wxPoint point);
696 virtual void SelectRectText(wxPoint one, wxPoint two);
698 virtual void PasteFromClipboard(
bool primary =
false);
700 virtual bool CopyToClipboard()
const
703 virtual bool CutToClipboard()
706 virtual void SelectAll()
709 virtual bool CanCopy()
const
712 virtual wxPoint PositionToPoint(
int WXUNUSED(pos) = -1)
713 {
return wxPoint(-1, -1); }
715 virtual bool IsDirty()
const
718 virtual void SwitchCaretDisplay()
721 virtual void SetFocus(
bool WXUNUSED(focus))
727 virtual bool IsActive()
const
785 void SetSuppressMultiplicationDot(
bool val) { m_suppressMultiplicationDot = val; }
788 void SetHidableMultSign(
bool val) { m_isHidableMultSign = val; }
804 #if wxUSE_ACCESSIBILITY
805 CellAccessible *GetAccessible();
808 void MockBreakUp() { m_isBrokenIntoLines = 1; }
812 std::unique_ptr<Cell> MakeVisiblyInvalidCell()
const;
843 std::unique_ptr<Cell> m_next;
846 Cell *m_previous = {};
848 #if wxUSE_ACCESSIBILITY
849 std::unique_ptr<CellAccessible> m_accessible;
853 const wxString &GetLocalToolTip()
const;
900 m_ownsToolTip =
false;
902 m_isBrokenIntoLines =
false;
904 m_isHidableMultSign =
false;
905 m_suppressMultiplicationDot =
false;
906 m_recalculateWidths =
true;
908 m_forceBreakLine =
false;
918 bool m_ownsToolTip : 1 ;
920 bool m_isBrokenIntoLines : 1 ;
921 bool m_isHidden : 1 ;
922 bool m_isHidableMultSign : 1 ;
923 bool m_suppressMultiplicationDot : 1 ;
925 bool m_recalculateWidths : 1 ;
927 bool m_breakLine : 1 ;
928 bool m_forceBreakLine : 1 ;
929 bool m_highlight : 1 ;
950 void InvalidateMaxDrop() { m_maxDrop.Invalidate(); }
953 void RecalcCenterListAndMaxDropCache();
957 template <
typename T>
958 template <typename PtrT, typename std::enable_if<std::is_pointer<PtrT>::value,
bool>::type>
959 inline PtrT
CellPtr<T>::CastAs() const noexcept {
return dynamic_cast<PtrT
>(
static_cast<Cell*
>(base_get())); }
961 #if wxUSE_ACCESSIBILITY
962 class CellAccessible final :
public wxAccessible
965 explicit CellAccessible(
Cell *
const forCell) : m_cell(forCell) {}
968 wxAccStatus GetParent (wxAccessible **parent)
override;
970 wxAccStatus GetChildCount (
int *childCount)
override;
972 wxAccStatus GetChild (
int childId, wxAccessible **child)
override;
974 wxAccStatus HitTest (
const wxPoint &pt,
975 int *childId, wxAccessible **childObject)
override;
977 wxAccStatus GetDescription(
int childId, wxString *description)
override;
979 wxAccStatus GetDefaultAction(
int childId, wxString *actionName)
override;
981 wxAccStatus GetFocus (
int *childId, wxAccessible **child)
override;
983 wxAccStatus GetLocation (wxRect &rect,
int elementId)
override;
985 wxAccStatus GetValue (
int childId, wxString *strValue)
override;
986 wxAccStatus GetRole (
int childId, wxAccRole *role)
override;
993 template <typename C, typename std::enable_if<std::is_base_of<Cell, C>::value,
bool>::type =
true>
995 template <typename C, typename std::enable_if<std::is_base_of<Cell, C>::value,
bool>::type =
true>
999 template <typename C, typename std::enable_if<std::is_base_of<Cell, C>::value,
bool>::type =
true>
1001 template <typename C, typename std::enable_if<std::is_base_of<Cell, C>::value,
bool>::type =
true>
1005 template <typename C, typename std::enable_if<std::is_base_of<Cell, C>::value,
bool>::type>
1007 template <typename C, typename std::enable_if<std::is_base_of<Cell, C>::value,
bool>::type>
1010 inline int InnerCellIterator::GetInnerCellCount(
const Cell *cell) {
return cell->
GetInnerCellCount(); }
1011 inline Cell *InnerCellIterator::GetInnerCell(
const Cell *cell,
int index) {
return cell->
GetInnerCell(index); }
1013 #endif // MATHCELL_H
int GetCurrentX() const
Definition: Cell.h:403
virtual wxString GnuplotSource() const
Definition: Cell.h:681
virtual void SetStyle(TextStyle style)
Sets the TextStyle of this cell.
Definition: Cell.h:731
int GetHeight() const
Definition: Cell.h:324
virtual bool NeedsRecalculation(AFontSize fontSize) const
True, if something that affects the cell size has changed.
Definition: Cell.cpp:219
bool GetSuppressMultiplicationDot() const
Definition: Cell.h:784
@ MC_TYPE_ERROR
An error output by maxima.
Definition: Cell.h:71
void AddToolTip(const wxString &tip)
Add another tooltip to this cell.
Definition: Cell.cpp:366
bool ContainsPoint(wxPoint point) const
Definition: Cell.h:260
void SetCurrentPoint(int x, int y)
Tells this cell where it is placed on the worksheet.
Definition: Cell.h:764
int GetCurrentY() const
Definition: Cell.h:410
int CellsInListRecursive() const
How many cells does this cell contain?
Definition: Cell.cpp:180
virtual wxString ListToXML() const
Convert this list to a representation fit for saving in a .wxmx file.
Definition: Cell.cpp:914
virtual void SetAltCopyText(const wxString &text)
Definition: Cell.cpp:381
static wxString RTFescape(wxString, bool MarkDown=false)
Escape a string for RTF.
Definition: Cell.cpp:769
@ MC_TYPE_GROUP
A group cells that bundles several individual cells together.
Definition: Cell.h:82
Definition: TextCell.h:36
bool GetHidableMultSign() const
Whether this is a hidable multiplication sign.
Definition: Cell.h:787
friend auto OnInner(const C *cell)
Returns an iterable that goes over the inner cells of this cell.
Definition: Cell.h:1006
bool HasHardLineBreak() const
Does this cell begin with a manual linebreak?
Definition: Cell.h:234
virtual void ProcessEvent(wxKeyEvent &WXUNUSED(event))
Processes a key event.
Definition: Cell.h:684
TextStyle
Definition: TextStyle.h:307
@ MC_TYPE_INPUT
A cell containing code.
Definition: Cell.h:69
virtual const wxString & GetName() const =0
@ MC_TYPE_LABEL
An output label generated by maxima.
Definition: Cell.h:68
virtual Cell * GetInnerCell(int index) const
Definition: Cell.cpp:1450
void ClearCacheList()
Definition: Cell.cpp:174
@ MC_TYPE_TITLE
The title of the document.
Definition: Cell.h:79
For the bitmap export we sometimes want to know how big the result will be...
Definition: Cell.h:528
void ResetData()
Mark all cached size information as "to be calculated".
Definition: Cell.cpp:1010
void DrawList(wxPoint point)
Definition: Cell.cpp:387
wxString VariablesAndFunctionsList() const
Definition: Cell.cpp:524
virtual wxString ListToRTF(bool startofline=false) const
Convert this list to an RTF representation.
Definition: Cell.cpp:846
bool HasValidSize() const
Is the size valid and not pending a recalculation?
Definition: Cell.cpp:437
virtual ~Cell()
Delete this list of cells.
Definition: Cell.cpp:72
Iterates the inner cells of a cell.
Definition: CellIterators.h:137
void CopyCommonData(const Cell &cell)
Copy common data (used when copying a cell)
Definition: Cell.cpp:140
virtual wxString ToXML() const
Convert this cell to a representation fit for saving in a .wxmx file.
Definition: Cell.cpp:631
int GetLineWidth() const
Definition: Cell.cpp:282
virtual wxString ListToString() const
Returns the list's representation as a string.
Definition: Cell.cpp:542
virtual const wxString & GetAltCopyText() const
Get the text set using SetAltCopyText - may be empty.
Definition: Cell.h:802
@ MC_TYPE_WARNING
A warning output by maxima.
Definition: Cell.h:70
virtual int GetInnerCellCount() const
The number of inner cells - for use by the iterators.
Definition: Cell.cpp:1448
void ResetCellListSizes()
Mark the line and cell list widths and heights as "to be calculated".
Definition: Cell.cpp:1043
virtual void Unbreak()
Definition: Cell.cpp:1092
Definition: CellIterators.h:70
const wxString * m_toolTip
Definition: Cell.h:865
virtual wxString ToMatlab() const
Convert this cell to its Matlab representation.
Definition: Cell.cpp:575
AFontSize m_fontSize_Scaled
The font size is smaller in super- and subscripts.
Definition: Cell.h:887
virtual void SetType(CellType type)
Sets the text style according to the type.
Definition: Cell.cpp:81
bool ContainsRect(const wxRect &sm, bool all=true) const
Definition: Cell.cpp:993
bool BreakLineHere() const
Are we allowed to break a line here?
Definition: Cell.h:231
void SetPen(double lineWidth=1.0) const
Sets the drawing pen to the cell's default foreground color.
Definition: Cell.cpp:1134
virtual void DrawBoundingBox(wxDC &WXUNUSED(dc), bool all=false)
Definition: Cell.cpp:500
virtual wxString ToOMML() const
Definition: Cell.cpp:814
void ForceBreakLine(bool force=true)
Definition: Cell.h:318
virtual std::unique_ptr< Cell > Copy(GroupCell *group) const =0
virtual const wxString & GetToolTip(wxPoint point) const
Definition: Cell.cpp:45
virtual bool CanPopOut() const
Can this cell be popped out interactively in gnuplot?
Definition: Cell.h:675
virtual wxString ListToTeX() const
Convert this list to its LaTeX representation.
Definition: Cell.cpp:618
Definition: CellList.h:142
bool IsMath() const
Is this cell possibly output of maxima?
Definition: Cell.cpp:1203
bool IsBrokenIntoLines() const
Definition: Cell.h:774
bool GetHighlight() const
Is this cell highlighted (e.G. inside a maxima box)
Definition: Cell.h:485
virtual void ClearCache()
Definition: Cell.h:267
int GetCenter() const
Definition: Cell.h:339
void ResetSizeList()
Mark the cached height information of the whole list of cells as "to be calculated".
Definition: Cell.cpp:402
virtual wxString ListToOMML(bool startofline=false) const
Convert this list to an OMML representation.
Definition: Cell.cpp:816
@ MC_TYPE_MAIN_PROMPT
Input labels.
Definition: Cell.h:66
@ MC_TYPE_SLIDE
An animation created by the with_slider_* maxima commands.
Definition: Cell.h:81
bool HasStaleSize() const
Is the size valid, whether a recalculation is pending or not?
Definition: Cell.cpp:443
@ MC_TYPE_ASCIIMATHS
Equations displayed in 2D.
Definition: Cell.h:73
bool HasValidPosition() const
Is the position valid?
Definition: Cell.cpp:448
void RecalculateList(AFontSize fontsize)
Definition: Cell.cpp:396
bool InUpdateRegion() const
Is this cell inside the region that is currently drawn?
Definition: Cell.cpp:476
virtual bool IsOperator() const
Is this cell an operator?
Definition: Cell.h:517
int Scale_Px(double px) const
Definition: Cell.h:173
CellType GetType() const
Definition: Cell.h:364
int GetHeightList() const
Definition: Cell.cpp:260
wxRect CropToUpdateRegion(wxRect rect) const
The part of the rectangle rect that is in the region that is currently drawn.
Definition: Cell.cpp:194
virtual Range GetInnerCellsInRect(const wxRect &rect) const
Select the cells inside this cell described by the rectangle rect.
Definition: Cell.cpp:978
bool IsComment() const
Definition: Cell.h:649
bool DrawThisCell(wxPoint point)
Definition: Cell.cpp:417
@ MC_TYPE_TEXT
Text that isn't passed to maxima.
Definition: Cell.h:72
void BreakUpAndMark()
Break up the internal cells of this cell, and mark it as broken up.
Definition: Cell.cpp:1083
Cell * GetNextToDraw() const
Definition: Cell.h:631
@ MC_TYPE_HEADING5
A subsubsection name.
Definition: Cell.h:76
Cell * first() const
Get the first cell in this list of cells.
Definition: Cell.cpp:1058
int GetDrop() const
Definition: Cell.h:358
Definition: EditorCell.h:57
void SetForeground()
Sets the foreground color.
Definition: Cell.cpp:1166
CellPtr< Cell > m_nextToDraw
Definition: Cell.h:859
Cell * GetNext() const
Get the next cell in the list.
Definition: Cell.h:624
virtual const CellTypeInfo & GetInfo()=0
Returns the information about this cell's type.
CellPtr< GroupCell > m_group
Definition: Cell.h:856
Definition: CellPointers.h:44
GroupCell * GetGroup() const
Returns the group cell this cell belongs to.
Definition: Cell.cpp:212
virtual void Draw(wxPoint point)
Definition: Cell.cpp:305
virtual int GetImageBorderWidth() const
0 for ordinary cells, 1 for slide shows and diagrams displayed with a 1-pixel border
Definition: Cell.h:740
@ MC_TYPE_SUBSECTION
A subsection name.
Definition: Cell.h:74
Definition: CellIterators.h:210
void SetToolTip(wxString &&toolTip)
Set the tooltip to a given temporary string - the cell will move from it.
Definition: Cell.cpp:342
Definition: FontAttribs.h:97
int GetWidth() const
Definition: Cell.h:331
@ MC_TYPE_PROMPT
Maxima questions or lisp prompts.
Definition: Cell.h:67
virtual void SetNextToDraw(Cell *next)
Definition: Cell.h:640
CellType
Definition: Cell.h:63
bool SoftLineBreak(bool breakLine=true)
Do we want this cell to start with a linebreak?
Definition: Cell.h:223
int m_height
The height of this cell.
Definition: Cell.h:871
std::unique_ptr< Cell > CopyList(GroupCell *group) const
Return a copy of the list of cells beginning with this one.
Definition: Cell.cpp:161
auto OnDrawList(const C *cell)
Returns an iterable that goes over the cell draw list, starting with given, possibly null,...
Definition: Cell.h:1000
bool IsHidden() const
Definition: Cell.h:663
virtual wxString ToTeX() const
Convert this cell to its LaTeX representation.
Definition: Cell.cpp:613
static wxString OMML2RTF(wxXmlNode *node)
Converts an OMML tag to the corresponding RTF snippet.
Definition: Cell.cpp:700
int m_width
The width of this cell; is recalculated by RecalculateHeight.
Definition: Cell.h:873
int GetCenterList() const
Definition: Cell.cpp:226
wxPoint m_currentPoint
Definition: Cell.h:837
Definition: Configuration.h:83
virtual wxString ListToMathML(bool startofline=false) const
Convert this list to a MathML representation.
Definition: Cell.cpp:641
void FontsChangedList()
Tell a whole list of cells that their fonts have changed.
Definition: Cell.cpp:202
void ResetCellListSizesList()
Mark the line and cell list widths and heights as "to be calculated".
Definition: Cell.cpp:1024
void ClearToolTip()
Remove this cell's tooltip.
Definition: Cell.cpp:334
virtual bool AddEnding()
Definition: Cell.h:691
Definition: CellIterators.h:119
auto OnList(const C *cell)
Returns an iterable the goes over the cell list, starting with given, possibly null,...
Definition: Cell.h:994
virtual void SetCurrentPoint(wxPoint point)
Tells this cell where it is placed on the worksheet.
Definition: Cell.h:762
Cell * last() const
Get the last cell in this list of cells.
Definition: Cell.cpp:1068
@ MC_TYPE_IMAGE
An image.
Definition: Cell.h:80
virtual void UnbreakList()
Definition: Cell.cpp:1109
void SetHighlight(bool highlight)
Mark this cell as highlighted (e.G. being in a maxima box)
Definition: Cell.h:483
Definition: Worksheet.h:86
int GetFullWidth() const
How many pixels is this list of cells wide, if we don't break it into lines?
Definition: Cell.cpp:265
void ResetSize()
Mark the cached height and width information as "to be calculated".
Definition: Cell.cpp:1034
virtual wxString ToMathML() const
Convert this cell to a representation fit for saving in a .wxmx file.
Definition: Cell.cpp:636
virtual wxString ListToMatlab() const
Convert this list to its LaTeX representation.
Definition: Cell.cpp:580
Range GetCellsInRect(const wxRect &rect) const
Definition: Cell.cpp:956
virtual wxRect GetRect(bool all=false) const
Definition: Cell.cpp:466
virtual wxString ToRTF() const
Definition: Cell.h:566
Definition: GroupCell.h:68
bool IsCompound() const
Do we have an operator in this line - draw () in frac...
Definition: Cell.cpp:509
int GetMaxDrop() const
Definition: Cell.cpp:243
void SetBrush() const
Sets the fill brush to the cell's default foreground color.
Definition: Cell.cpp:1149
virtual void FontsChanged()
To be called if the font has changed.
Definition: Cell.h:942
A class that carries information about the type of a cell.
Definition: Cell.h:90
virtual wxString ToString() const
Returns the cell's representation as a string.
Definition: Cell.cpp:517
@ MC_TYPE_SUBSUBSECTION
A subsubsection name.
Definition: Cell.h:75
auto OnInner(const C *cell)
Returns an iterable that goes over the inner cells of this cell.
Definition: Cell.h:1006
@ MC_TYPE_SECTION
A section name.
Definition: Cell.h:78
virtual void Recalculate(AFontSize fontsize)
Definition: Cell.cpp:408
static wxString XMLescape(wxString)
Escape a string for XML.
Definition: Cell.cpp:759
virtual bool BreakUp()
Definition: Cell.cpp:1078
wxPoint GetCurrentPoint() const
Where is this cell placed on the worksheet?
Definition: Cell.h:766
Range GetListCellsInRect(const wxRect &rect) const
Definition: Cell.cpp:964
@ MC_TYPE_HEADING6
A subsubsection name.
Definition: Cell.h:77