wxMaxima
Loading...
Searching...
No Matches
Data Structures | Public Types | Public Member Functions | Static Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
Worksheet Class Reference

The canvas that contains the spreadsheet the whole program is about. More...

#include <Worksheet.h>

Inheritance diagram for Worksheet:
[legend]
Collaboration diagram for Worksheet:
[legend]

Public Types

enum  ClickType {
  CLICK_TYPE_NONE , CLICK_TYPE_GROUP_SELECTION , CLICK_TYPE_INPUT_SELECTION , CLICK_TYPE_INPUT_LABEL_SELECTION ,
  CLICK_TYPE_OUTPUT_SELECTION
}
 An enum for all classes of items one can click on.
 
enum  TimerIDs { TIMER_ID , CARET_TIMER_ID , DISPLAY_TIMEOUT_ID }
 An enum of individual IDs for all timers this class handles.
 

Public Member Functions

void GetViewClientSize (int *width, int *height) const override
 The visible client area, in device pixels.
 
int GetViewScrollUnitY () const override
 The current vertical scroll position, in scroll units (not pixels).
 
void SetViewVirtualSize (int width, int height) override
 Set the scrollable (virtual) area, in device pixels.
 
void SetViewScrollRate (int rate) override
 Set the scroll granularity (device pixels per scroll unit) on both axes.
 
void GetViewPosition (int *x, int *y) const override
 The view's position within its parent, in device pixels (wxWindow::GetPosition).
 
RecentDocumentsUnsavedDocuments ()
 The list of unsaved (autosaved) documents offered for recovery.
 
bool UpdateControlsNeeded ()
 Is an update of the worksheet controls needed?
 
void UpdateControlsNeeded (bool updateControlsNeeded)
 
void TreeUndo_ClearRedoActionList ()
 Clear the list of actions for which an undo can be undone.
 
void TreeUndo_ClearUndoActionList ()
 Clear the list of actions for which undo can undo.
 
void TreeUndo_AppendAction ()
 Add another action to this undo action.
 
void TreeUndo_LimitUndoBuffer ()
 Drop actions from the back of the undo list until it is within the undo limit.
 
bool TreeUndo (UndoActions *sourcelist, UndoActions *undoForThisOperation)
 Undo an item from a list of undo actions.
 
bool TreeUndoTextChange (UndoActions *sourcelist, UndoActions *undoForThisOperation)
 Undo a text change.
 
bool TreeUndoCellDeletion (UndoActions *sourcelist, UndoActions *undoForThisOperation)
 Undo a call deletion.
 
bool TreeUndoCellAddition (UndoActions *sourcelist, UndoActions *undoForThisOperation)
 Undo adding cells.
 
bool TreeUndo ()
 Undo a tree operation.
 
bool TreeRedo ()
 Redo an undone tree operation.
 
bool CanTreeUndo () const
 Can we undo a tree operation?
 
bool CanTreeRedo () const
 Can we redo a tree operation?
 
void TreeUndo_CellEntered ()
 The cursor has entered one cell => save the value to see if it has changed.
 
void TreeUndo_CellLeft ()
 The cursor is about to leave the current cell => Store the change if the value has changed.
 
void TreeUndo_MarkCellsAsAdded (GroupCell *start, GroupCell *end, UndoActions *undoBuffer)
 Remember that these cells were just added so this addition can be undone.
 
void TreeUndo_MarkCellsAsAdded (GroupCell *parentOfStart, GroupCell *end)
 Remember that these cells were just added so this addition can be undone.
 
std::unique_ptr< CellCopySelection (bool asData=false) const
 Copy the currently selected cells.
 
std::unique_ptr< CellCopySelection (Cell *start, Cell *end, bool asData=false) const
 Copy the currently given list of cells.
 
void GetMaxPoint (int *width, int *height)
 Get the coordinates of the bottom right point of the worksheet.
 
void OnTimer (wxTimerEvent &event)
 Is executed if a timer associated with Worksheet has expired.
 
void OnMouseExit (wxMouseEvent &event)
 
void OnMouseEnter (wxMouseEvent &event)
 
void OnPaint (wxPaintEvent &event)
 Is called by wxWidgets when it wants to redraw the worksheet or a part of it.
 
void DrawGroupCell (wxDC &dc, wxDC &adc, GroupCell &cell)
 Draws a groupcell on the DC.
 
void DrawGroupCell_UsingBitmap (wxDC *dc, GroupCell *cell)
 Draws a groupcell in a bitmap and then blits it onto the DC.
 
void PrepareDrawGC (wxDC &dc) const
 All that has need to be done before drawing a GroupCell in a DC.
 
void OnSize (wxSizeEvent &event)
 
void OnMouseRightDown (wxMouseEvent &event)
 
void OnSidebarKey (wxCommandEvent &event)
 
void OnMouseLeftUp (wxMouseEvent &event)
 
void OnMouseCaptureLost (wxMouseCaptureLostEvent &event)
 Is called if we loose the mouse connection whilst selecting text/cells.
 
void OnMouseLeftDown (wxMouseEvent &event)
 
void OnMouseLeftInGcCell (wxMouseEvent &event, GroupCell *clickedInGC)
 
void OnMouseLeftInGcLeft (wxMouseEvent &event, GroupCell *clickedInGC)
 
void OnMouseLeftInGc (wxMouseEvent &event, GroupCell *clickedInGC)
 
void OnMouseMotion (wxMouseEvent &event)
 
void OnDoubleClick (wxMouseEvent &event)
 Is called on double click on a cell.
 
void OnCharInActive (wxKeyEvent &event)
 Key pressed inside a cell.
 
void OnCharNoActive (wxKeyEvent &event)
 Key pressed and no cell was active.
 
void SelectEditable (EditorCell *editor, bool up)
 Is called when a hCursor is active and we have a WXK_UP/WXK_DOWN event.
 
void SelectWithChar (int ccode)
 Handle selecting text using the keyboard Is called when the all of the following is true:
 
void ClickNDrag (wxPoint down, wxPoint up)
 Select the rectangle surrounded by down and up.
 
void SelectGroupCells (wxPoint down, wxPoint up)
 
void AdjustSize ()
 Adjust the virtual size and scrollbars; see WorksheetLayout::AdjustSize().
 
void OnEraseBackground (wxEraseEvent &WXUNUSED(event))
 Cannot be static as it is called using a function pointer to an object.
 
void CheckUnixCopy ()
 
void OnMouseMiddleUp (wxMouseEvent &event)
 
GroupCellEndOfSectioningUnit (GroupCell *start)
 Finds the end of the current chapter/section/...
 
void OnComplete (wxCommandEvent &event)
 Is called if an action from the autocomplete menu is selected.
 
void EraseBackground (wxEraseEvent &event)
 Is called if wxWidgets wants to erase the worksheet's background.
 
GroupCellGetLastCellInWorksheet () const
 Returns a pointer to the last cell of this worksheet.
 
bool IsEmpty () const
 Is this worksheet empty?
 
void CloseAutoCompletePopup ()
 Close the autocompletion pop-up if it is currently open.
 
void OnChar (wxKeyEvent &event)
 Key for a printable character pressed.
 
void OnKeyDown (wxKeyEvent &event)
 A special key has been pressed.
 
void SetCellStyle (GroupCell *group, GroupType style)
 Change the style of a cell.
 
void NumberSections () const
 Renumber all sections.
 
bool SectioningMoveIn (GroupCell *parent)
 Make this chapter/section/... a section/subsection/... changing its subheadings, too.
 
bool SectioningMoveOut (GroupCell *parent)
 Make this section/subsection/... a chapter/section/... changing its subheadings, too.
 
std::optional< Notification > & GetNotification ()
 The error notification message, if any.
 
void WindowActive (bool active)
 Is this window active?
 
void ClearNotification ()
 Clears the notification message from SetNotification.
 
void SetNotification (const wxString &message, int flags=wxICON_INFORMATION)
 Inform the user that something happened in a non-active window.
 
void OnActivate (wxActivateEvent &event)
 Is called if this element looses or gets the focus.
 
void FocusFindDialogue ()
 
AutoCompleteGetAutocomplete ()
 The storage for the autocompletion feature.
 
ConfigurationGetConfig () const
 
EditorCellGetActiveCell () const
 Get the currently active EditorCell.
 
EditorCellKeyboardSelectionStart () const
 Tells us which cell the keyboard selection has started in.
 
EditorCellMouseSelectionStart () const
 
EditorCellSearchStart () const
 
int IndexSearchStartedAt () const
 
CellPointersGetCellPointers ()
 
CellPointers::ErrorListGetErrorList ()
 
TextCellGetCurrentTextCell () const
 
void SetCurrentTextCell (TextCell *cell)
 
void SetWorkingGroup (GroupCell *group)
 
void UpdateTableOfContents ()
 Update the table of contents.
 
void QuestionPending (bool pending)
 Does maxima currently wait for the answer of a question?
 
void SetMaximaDocDir (const wxString &dir)
 
const wxString & GetMaximaDocDir () const
 
bool GCContainsCurrentQuestion (const GroupCell *cell)
 Does the GroupCell cell points to contain the question currently asked by maxima?
 
bool OpenQuestionCaret (const wxString &txt={})
 Move the cursor to the question maxima currently asks and if needed add a cell for user input.
 
void UpdateScrollPos ()
 Execute all collected scroll events in one go.
 
GroupCellGetWorkingGroup (bool resortToLast=false) const
 Returns the cell maxima currently works on.
 
void LoadHelpFileAnchors (const wxString &docdir, const wxString &maximaVersion)
 Tries to parse maxima's manual in order to find out which anchors it contains.
 
wxString GetHelpfileAnchorName (const wxString &keyword)
 
wxString GetHelpfileURL (const wxString &keyword)
 
MaximaManualGetMaximaManual ()
 

Static Public Member Functions

static bool IsLesserGCType (int type, int comparedTo)
 
static GroupCellStartOfSectioningUnit (GroupCell *start)
 Finds the start of the current chapter/section/...
 

Data Fields

std::vector< wxString > m_replacementsForCurrentWord
 Suggestions for how the word that was right-clicked on could continue.
 
MaximaManual m_maximaManual
 

Protected Member Functions

void FocusTextControl ()
 
virtual wxSize DoGetBestClientSize () const override
 

Protected Attributes

wxString m_lastQuestion
 
wxBitmap m_memory
 A memory we can manually buffer the contents of the area that is to be redrawn in.
 
int m_pointer_x = -1
 The x position of the mouse pointer.
 
int m_pointer_y = -1
 The y position of the mouse pointer.
 
bool m_mouseMotionWas = false
 Was there a mouse motion we didn't react to until now?
 
bool m_inPopupMenu = false
 Is there an active popup menu?
 
FindReplaceDialogm_findDialog = NULL
 The find-and-replace-dialog.
 
ToolBarm_mainToolBar = NULL
 The toolbar of the main window: We need to access it and therefore have it defined here.
 
void MarkRefreshAsDone ()
 Handle redrawing the worksheet or of parts of it.
 
bool RedrawIfRequested ()
 Redraw the worksheet if RequestRedraw() has been called.
 
void RequestRedraw (GroupCell *start=NULL)
 Request the worksheet to be redrawn.
 
void RequestRedraw (wxRect rect)
 Request a part of the worksheet to be redrawn.
 
void ForceRedraw ()
 Redraw the window now and mark any pending redraw request as "handled".
 
void CodeCellVisibilityChanged ()
 To be called after enabling or disabling the visibility of code cells.
 
void UpdateConfig ()
 Re-read the configuration.
 
const wxString & GetCurrentFile () const
 The name of the currently-opened file.
 
void SetCurrentFile (const wxString &file)
 Set the name of the currently-opened file.
 
const wxString UnicodeToMaxima (wxString s)
 Make a few unicode characters interpretable by maxima.
 
void ScrollToStart ()
 Scroll to the start of the worksheet.
 
void ScrollToError ()
 Unfold the cell that produced the error, if necessary and, if requested, scroll to it.
 
bool HCaretActive () const
 Is the vertically-drawn cursor active?
 
bool CanMergeSelection () const
 Can we merge the selected cells into one?
 
bool CanUndo () const
 
bool CanRedo () const
 
void Undo ()
 
void Redo ()
 
void TreeUndo_ClearBuffers ()
 
 Worksheet (wxWindow *parent, int id, Configuration *config, wxPoint pos=wxDefaultPosition, wxSize size=wxDefaultSize, bool reactToEvents=true)
 The constructor.
 
virtual ~Worksheet ()
 The destructor.
 
wxTimer & KeyboardInactiveTimer ()
 The timer that tells us when the keyboard is inactive so an autosave isn't disrupting.
 
void DestroyTree ()
 Clear the whole worksheet.
 
std::unique_ptr< GroupCellCopyTree () const
 Copies the worksheet's entire contents.
 
GroupCellInsertGroupCells (std::unique_ptr< GroupCell > &&cells, GroupCell *where, UndoActions *undoBuffer)
 Insert group cells into the worksheet.
 
GroupCellInsertGroupCells (std::unique_ptr< GroupCell > &&cells, GroupCell *where=NULL)
 Insert group cells into the worksheet.
 
void InsertLine (std::unique_ptr< Cell > &&newCell, bool forceNewLine=false)
 Add a new line to the output cell of the working group.
 
GroupCellGetInsertGroup () const
 The group that the line's cells will belong to - used by InsertLine.
 
bool RecalculateIfNeeded (bool timeout=false, long timeSliceMs=50)
 Actually recalculate the worksheet.
 
void RequestRecalculation (Cell *start)
 Schedule a recalculation of the worksheet starting with the cell start.
 
void RequestRecalculation ()
 Schedule a recalculation of the whole worksheet. See RequestRecalculation(Cell*).
 
void ClearDocument ()
 Empties the current document.
 
void ResetInputPrompts ()
 
bool CanCopy () const
 
bool CanPaste () const
 
bool CanCut () const
 
void SelectAll ()
 Select the whole document.
 
bool HasCellsSelected () const
 Is at least one entire cell selected?
 
void DeleteRegion (GroupCell *start, GroupCell *end, UndoActions *undoBuffer)
 
void DeleteRegion (GroupCell *start, GroupCell *end)
 
void DeleteSelection ()
 
void TOCdnd (GroupCell *dndStart, GroupCell *dndEnd)
 
bool CanDeleteRegion (GroupCell *start, const GroupCell *end) const
 Is it possible to delete the cells between start and end?
 
bool CanDeleteSelection () const
 Is it possible to delete the currently selected cells?
 
void DeleteCurrentCell ()
 Delete the currently active cell - or the cell above this one.
 
AnimationCellGetSelectedAnimation () const
 Returns the selected cell - or NULL, if the selection isn't an animation.
 
ImgCellGetSelectedImgCell () const
 Returns the selected cell - or NULL, if the selection isn't an image.
 
ImgCellBaseGetSelectedImgCellBase () const
 Returns the selected cell - or NULL, if the selection isn't image nor animation.
 
TextCellGetSelectedTextCell () const
 Returns the selected cell - or NULL, if the selection isn't a text cell.
 
bool CanAnimate () const
 Does it make sense to enable the "Play" button and the slider now?
 
void Animate (bool run=true) const
 Animate the current slide show.
 
void DivideCell ()
 
void MergeCells ()
 
void SetLastQuestion (const wxString &lastQuestion)
 
wxString GetLastQuestion () const
 
bool CutToClipboard ()
 Add the currently selected cells to the clipboard and delete them.
 
void PasteFromClipboard ()
 
bool Copy (bool astext=false) const
 Copy the current selection to the clipboard.
 
bool CopyCells () const
 Copy the selection to the clipboard as it would appear in a .wxm file.
 
bool CopyMatlab () const
 Copy a Matlab representation of the current selection to the clipboard.
 
bool CopyText () const
 Copy a textual representation of the current selection to the clipboard.
 
bool CopyTeX () const
 Copy the TeX representation of the current selection to the clipboard.
 
wxString ConvertSelectionToMathML () const
 Convert the current selection to MathML.
 
wxBitmap ConvertSelectionToBitmap () const
 Convert the current selection to a bitmap.
 
bool CopyMathML () const
 Copy the MathML representation of the current selection to the clipboard.
 
bool CopyBitmap () const
 Copy a bitmap of the current selection to the clipboard.
 
bool CopyAnimation () const
 Copy the current animation to the clipboard.
 
bool CopySVG () const
 Copy a svg of the current selection to the clipboard.
 
bool CopyRTF () const
 Copy a rtf version of the current selection to the clipboard.
 
wxSize CopyToFile (const wxString &file) const
 
wxSize CopyToFile (const wxString &file, Cell *start, Cell *end, bool asData=false, double scale=1) const
 
bool ExportToHTML (const wxString &file)
 Export the file to an html document.
 
bool ExportToMAC (const wxString &file)
 Export the file to a text file maxima's load command can read.
 
wxString RTFStart () const
 The start of a RTF document.
 
wxString RTFEnd () const
 The end of a RTF document.
 
bool ExportToTeX (const wxString &file)
 export to a LaTeX file
 
wxString GetString (bool lb=false) const
 Convert the current selection to a string.
 
GroupCellGetTree () const
 
std::unique_ptr< GroupCell > * GetTreeAddress ()
 
CellGetSelectionStart () const
 Return the first of the currently selected cells.
 
CellGetSelectionEnd () const
 Return the last of the currently selected cells.
 
void ClearSelection ()
 Clear the selection - make it empty, i.e. no selection.
 
void SetSelection (Cell *sel)
 Select the cell sel.
 
void SetSelection (Cell *start, Cell *end)
 Select the cell range start-end.
 
CellFindCellByUUID (const wxString &uuid)
 Find a cell by its UUID.
 
void UpdateConfigurationClientSize ()
 Inform the configuration about the current client size.
 
bool CanEdit ()
 We can edit the input if the we have the whole input in selection!
 
bool ActivatePrevInput ()
 
bool ActivateNextInput ()
 
wxString GetStatusText () const
 
bool StatusTextChangedHas ()
 
bool StatusTextHas () const
 
void ScrollToCaret ()
 Request to scroll to the cursor as soon as wxMaxima is idle.
 
bool ScrollToCaretIfNeeded ()
 Scrolls to the cursor, if requested.
 
void ScrollToCellIfNeeded ()
 Scrolls to the cell given by ScheduleScrollToCell; Is called once we have time to do so.
 
void ScheduleScrollToCell (Cell *cell, bool scrollToTop=true)
 Schedules scrolling to a given cell.
 
bool PointVisibleIs (wxPoint point)
 Is the point currently visible on the worksheet?
 
bool CaretVisibleIs ()
 Is the caret (hcaret or vcaret) currently visible on the worksheet?
 
GroupCellFirstVisibleGC ()
 The first groupCell that is currently visible.
 
void ShowPoint (wxPoint point)
 Scrolls to a point on the worksheet.
 
void OnSetFocus (wxFocusEvent &event)
 What to do if the worksheet is in the input focus.
 
void OnKillFocus (wxFocusEvent &event)
 What to do if the worksheet looses the input focus.
 
bool IsSelected (CellType type)
 Does the selection start with a cell of the type "type".
 
void StepAnimation (int change=1)
 Set the slide of the currently selected animation or advance it by one step.
 
bool IsActiveInLast () const
 Is the editor active in the last cell of the worksheet?
 
GroupCellGetLastCell ()
 Returns the last cell of the worksheet.
 
bool IsSelectionInWorkingGroup ()
 Is the selection in the current working group?
 
void SetActiveCell (EditorCell *cell)
 Mark an editor cell as the active one.
 
void SetDefaultHCaret ()
 Set the HCaret to its default location, at the end of the document.
 
void SetHCaret (GroupCell *where)
 Set the HCaret at the location of the given Cell.
 
GroupCellGetHCaret ()
 The cell the horizontal cursor is above. NULL means at the start of the document.
 
void OpenHCaret (const wxString &txt={})
 Place the cursor into a new cell where the horizontal cursor is.
 
void OpenHCaret (const wxString &txt, GroupType type)
 Place the cursor into a new cell where the horizontal cursor is.
 
void ShowHCaret ()
 Activates the horizontal cursor.
 
bool CanUndoInsideCell () const
 Is it possible to issue an undo in the currently selected cell?
 
void UndoInsideCell ()
 
bool CanRedoInsideCell () const
 Is it possible to issue an undo in the currently selected cell?
 
void RedoInsideCell ()
 
void FollowEvaluation (bool followEvaluation)
 Do we want to follow the evaluation process?
 
bool FollowEvaluation () const
 Query if we want to automatically scroll to the cell that is currently evaluated.
 
void ScrolledAwayFromEvaluation (bool ScrolledAway)
 Set or get the "Scrolled away from evaluation" status.
 
bool ScrolledAwayFromEvaluation () const
 
void SaveValue ()
 
bool IsSaved () const
 
void SetSaved (bool saved)
 
void OutputChanged ()
 
void RemoveAllOutput ()
 
void RemoveAllOutput (GroupCell *cell)
 
void Evaluate ()
 Trigger the evaluation of the current cell(s)
 
void AddToEvaluationQueue (GroupCell *cell)
 Adds a group cell to the evaluation queue marking its contents as "outdated".
 
void AddDocumentToEvaluationQueue ()
 
void AddEntireDocumentToEvaluationQueue ()
 Schedule all cells in the document for evaluation.
 
void AddDocumentTillHereToEvaluationQueue ()
 Schedule all cells stopping with the one the caret is in for evaluation.
 
void AddRestToEvaluationQueue ()
 Add all cells below the cursor to the evaluation queue.
 
void AddSectionToEvaluationQueue (GroupCell *start)
 Adds a chapter, a section or a subsection to the evaluation queue.
 
void AddSelectionToEvaluationQueue ()
 Schedule all cells in the selection to be evaluated.
 
void AddSelectionToEvaluationQueue (GroupCell *start, GroupCell *end)
 Schedule all cells in a region to be evaluated.
 
void AddCellToEvaluationQueue (GroupCell *gc)
 Schedule this cell for evaluation.
 
EvaluationQueueGetEvaluationQueue ()
 The list of cells that have to be evaluated.
 
void FoldOccurred ()
 Call when a fold action was detected, to update the state in response to a fold occurring.
 
GroupCellToggleFold (GroupCell *which)
 Fold or unfold a cell.
 
GroupCellToggleFoldAll (GroupCell *which)
 Toggles the status of the fold for the given GroupCell and its children.
 
void FoldAll ()
 Recursively folds the whole document.
 
void UnfoldAll ()
 Recursively unfolds the whole document.
 
void SetZoomFactor (double newzoom)
 
void CommentSelection ()
 
void OnScrollChanged (wxScrollEvent &ev)
 Called if the user is using the scrollbar for scrolling through the document.
 
void OnScrollEvent (wxScrollWinEvent &ev)
 
void CheckIfActiveCellScrolledOut ()
 
void OnMouseWheel (wxMouseEvent &event)
 Called if the mouse wheel sents events.
 
bool FindIncremental (const wxString &str, bool down, bool ignoreCase, bool searchInInput=true, bool searchInOutput=true)
 Do an incremental search from the cursor or the point the last search started at.
 
bool FindIncremental_RegEx (const wxString &str, bool down, bool searchInInput=true, bool searchInOutput=true)
 
bool FindNext (const wxString &str, bool down, bool ignoreCase, bool searchInInput=true, bool searchInOutput=true, bool warn=true)
 Find the next occurrence of a string.
 
bool FindNext_Regex (const wxString &str, const bool &down, bool searchInInput=true, bool searchInOutput=true, bool warn=true)
 
void Replace (const wxString &oldString, const wxString &newString, bool ignoreCase)
 Replace the current occurrence of a string.
 
void Replace_RegEx (const wxString &oldString, const wxString &newString)
 
int ReplaceAll (const wxString &oldString, const wxString &newString, bool ignoreCase, bool searchInInput=true, bool searchInOutput=true)
 Replace all occurrences of a string.
 
int ReplaceAll_RegEx (const wxString &oldString, const wxString &newString, bool searchInInput=true, bool searchInOutput=true)
 
wxString GetInputAboveCaret ()
 
wxString GetOutputAboveCaret ()
 
void LoadSymbols ()
 Compile a list of known autocompletion symbols.
 
bool Autocomplete (AutoComplete::autoCompletionType type=AutoComplete::command)
 
void AddSymbol (const wxString &fun, AutoComplete::autoCompletionType type=AutoComplete::command)
 Add a symbol to the autocompletion list.
 
void AddSymbols (const wxString &xml)
 Add a xml-encoded list of symbols to the autocompletion list.
 
void AddSymbols (wxXmlDocument xml)
 Add a xml-encoded list of symbols to the autocompletion list.
 
void SetActiveCellText (const wxString &text)
 
bool InsertText (const wxString &text)
 
void OpenNextOrCreateCell ()
 
void OnFollow ()
 Called when the "Scroll to currently evaluated" button is pressed.
 
void SelectGroupCell (GroupCell *cell)
 Set this cell as the currently selected one.
 
void SetAnswer (const wxString &answer)
 Handling questions from and answers for maxima.
 
void QuestionAnswered ()
 Mark the current question from maxima as "answered"..
 
bool QuestionPending () const
 Does maxima wait for the answer of a question?
 

Detailed Description

The canvas that contains the spreadsheet the whole program is about.

This canvas contains all the math-, title-, image- input- ("editor-")- etc.- cells of the current session.

Most of the logic that handles that this canvas might be larger than the screen (and could even be larger than the computer's RAM would it have been handled as a big bitmap) is provided by wxWidgets:

The worksheet isn't immediately redrawn on a key press, a mouse click or on maxima outputting new data. Instead all such events are processed in order until wxMaxima has caught up with all the events (which causes wxWidgets to send a Idle event to the wxMaxima object) or until we reach a timeout. If the user manages to type faster than wxMaxima redraws the screen this allows us to skip a few redraws in order to process the keypresses as fast as the user types. Also this keeps us responsive even if maxima outputs data faster than wxMaxima can display it.

The worksheet layout is structured around several key geometric parameters defined in the Configuration:

Constructor & Destructor Documentation

◆ Worksheet()

Worksheet::Worksheet ( wxWindow *  parent,
int  id,
Configuration config,
wxPoint  pos = wxDefaultPosition,
wxSize  size = wxDefaultSize,
bool  reactToEvents = true 
)

The constructor.

This class represents the worksheet shown in the middle of the wxMaxima window.

Parameters
parentThe parent window
idThe window ID. Often wxID_ANY
Theworksheet's initial location
Theworksheet's initial size
reactToEventsCan be set to false for creating an example panel, for example for the config dialogue.

Member Function Documentation

◆ AddEntireDocumentToEvaluationQueue()

void Worksheet::AddEntireDocumentToEvaluationQueue ( )

Schedule all cells in the document for evaluation.

Add the entire document, including hidden cells, to the evaluation queue.

◆ Animate()

void Worksheet::Animate ( bool  run = true) const

Animate the current slide show.

Starts playing the animation of a cell generated with the with_slider_* commands.

Parameters
run
  • false: Stop the animation
  • true: Run the animation

◆ Autocomplete()

bool Worksheet::Autocomplete ( AutoComplete::autoCompletionType  type = AutoComplete::command)

No completions - clear the selection and return false

If there is only one completion, use it

If there are more than one completions, popup a menu

◆ CanMergeSelection()

bool Worksheet::CanMergeSelection ( ) const

Can we merge the selected cells into one?

Todo:
Does it make sense to make to allow the text of sections and image cells with math cells?

◆ CanRedoInsideCell()

bool Worksheet::CanRedoInsideCell ( ) const

Is it possible to issue an undo in the currently selected cell?

Returns
false if no cell is selected or no redo can be executed.

◆ CanUndoInsideCell()

bool Worksheet::CanUndoInsideCell ( ) const

Is it possible to issue an undo in the currently selected cell?

Returns
false if no cell is selected or there is no further undo information

◆ ClearDocument()

void Worksheet::ClearDocument ( )

Empties the current document.

Used before opening a new file or when the "new" button is pressed.

◆ ClickNDrag()

void Worksheet::ClickNDrag ( wxPoint  down,
wxPoint  up 
)

Select the rectangle surrounded by down and up.

Called from OnMouseMotion.

The method decides what to do, based on the value of m_clickType which was set previously in OnMouseLeftDown. This enables different selection behaviours depending on where we first clicked. If m_clickType equals CLICK_TYPE_NONE - click-dragging does not result in a selection (we clicked in hideRect for instance) CLICK_TYPE_GROUP_SELECTION - we are selecting full groupcells only. Only y-coordinate matters. CLICK_TYPE_INPUT_SELECTION - we clicked in an editor (GroupCell::GetEditable()) and dragging results in selecting text in EditorCell CLICK_TYPE_OUTPUT_SELECTION - we clicked in an output, we want selection to be confined to that GroupCell's output. GC we first clicked in was stored in OnMouseMotion method into m_clickInGC pointer.

◆ Copy()

bool Worksheet::Copy ( bool  astext = false) const

Copy the current selection to the clipboard.

Parameters
astext
  • true: Copy the current selection as text
  • false: Copy the current selection as they would appear in a .wxm file

◆ CopySelection()

std::unique_ptr< Cell > Worksheet::CopySelection ( Cell start,
Cell end,
bool  asData = false 
) const

Copy the currently given list of cells.

Parameters
startThe cell to start copying at
endThe cell the copy has to end with
asData
  • true: The cells are copied in the cell list order.
  • false: The cells are copied in the draw list order

◆ DeleteCurrentCell()

void Worksheet::DeleteCurrentCell ( )

Delete the currently active cell - or the cell above this one.

Used for the "delete current cell" shortcut.

◆ DeleteRegion()

void Worksheet::DeleteRegion ( GroupCell start,
GroupCell end,
UndoActions undoBuffer 
)

Set the cursor to a sane place

◆ DrawGroupCell_UsingBitmap()

void Worksheet::DrawGroupCell_UsingBitmap ( wxDC *  dc,
GroupCell cell 
)

Draws a groupcell in a bitmap and then blits it onto the DC.

Drawing to a DC is only allowed to one thread at once. But doing the lengthy stuff with bitmaps is possible to do in multiple threads at the same time so as long as there is a mutex watching that we do the blit when no-one else accesses the DC should be fine.

◆ EraseBackground()

void Worksheet::EraseBackground ( wxEraseEvent &  event)

Is called if wxWidgets wants to erase the worksheet's background.

We don't want to erase the worksheet's background.

◆ Evaluate()

void Worksheet::Evaluate ( )

Trigger the evaluation of the current cell(s)

Internally this function simulates a click on the "Cell/Evaluate Cell(s)" button.

◆ ExportToHTML()

bool Worksheet::ExportToHTML ( const wxString &  file)

Export the file to an html document.

Todo:
Worksheet and text cell background work fine, but their names might be interchanged.

◆ ExportToTeX()

bool Worksheet::ExportToTeX ( const wxString &  file)

export to a LaTeX file

Export the file as TeX code.

◆ FindIncremental()

bool Worksheet::FindIncremental ( const wxString &  str,
bool  down,
bool  ignoreCase,
bool  searchInInput = true,
bool  searchInOutput = true 
)

Do an incremental search from the cursor or the point the last search started at.

Used by the find dialog.

Todo:
Keep a list of positions the last few letters were found at?

◆ FindNext()

bool Worksheet::FindNext ( const wxString &  str,
bool  down,
bool  ignoreCase,
bool  searchInInput = true,
bool  searchInOutput = true,
bool  warn = true 
)

Find the next occurrence of a string.

Used by the find dialog. The group-cell iteration lives in WorksheetSearch::FindNextTarget; this method derives the start position, handles searching for a cell by its UUID and shows the match.

◆ FollowEvaluation()

void Worksheet::FollowEvaluation ( bool  followEvaluation)

Do we want to follow the evaluation process?

Maxima can automagically scroll to the cell that is currently evaluated. If it does do so can be queried by FollowEvaluation(). Changing the behavior (for example because the user has scrolled away from the cell being evaluated and now clearly wants the cursor to stay where it is) can be achieved by FollowEvaluation(true) or FollowEvaluation(false).

◆ GetSelectionEnd()

Cell * Worksheet::GetSelectionEnd ( ) const
inline

Return the last of the currently selected cells.

NULL means: No cell is selected.

◆ GetSelectionStart()

Cell * Worksheet::GetSelectionStart ( ) const
inline

Return the first of the currently selected cells.

NULL means: No cell is selected.

◆ GetString()

wxString Worksheet::GetString ( bool  lb = false) const

Convert the current selection to a string.

Parameters
lb
  • true: Include linebreaks
  • false: Remove linebreaks from the converted string

◆ GetViewClientSize()

void Worksheet::GetViewClientSize ( int *  width,
int *  height 
) const
inlineoverridevirtual

The visible client area, in device pixels.

Implements WorksheetView.

◆ GetViewPosition()

void Worksheet::GetViewPosition ( int *  x,
int *  y 
) const
inlineoverridevirtual

The view's position within its parent, in device pixels (wxWindow::GetPosition).

Implements WorksheetView.

◆ GetViewScrollUnitY()

int Worksheet::GetViewScrollUnitY ( ) const
inlineoverridevirtual

The current vertical scroll position, in scroll units (not pixels).

Implements WorksheetView.

◆ GetWorkingGroup()

GroupCell * Worksheet::GetWorkingGroup ( bool  resortToLast = false) const

Returns the cell maxima currently works on.

NULL if there isn't such a cell.

Parameters
resortToLasttrue = if we already have set the cell maxima works on to NULL use the last cell maxima was known to work on.

◆ InsertGroupCells() [1/2]

GroupCell * Worksheet::InsertGroupCells ( std::unique_ptr< GroupCell > &&  cells,
GroupCell where,
UndoActions undoBuffer 
)

Insert group cells into the worksheet.

Parameters
cellsThe list of cells that has to be inserted
whereThe cell the cells have to be inserted after. NULL means: Insert the cells at the beginning of the worksheet.
undoBufferThe buffer the undo information for this action has to be kept in. Might be
  • m_treeUndo.UndoStack() for normal deletes,
  • m_treeUndo.RedoStack() for deletions while executing an undo or
  • NULL for: Don't keep any copy of the cells.

◆ InsertGroupCells() [2/2]

GroupCell * Worksheet::InsertGroupCells ( std::unique_ptr< GroupCell > &&  cells,
GroupCell where = NULL 
)

Insert group cells into the worksheet.

Parameters
cellsThe list of cells that has to be inserted
whereThe cell the cells have to be inserted after

◆ InsertLine()

void Worksheet::InsertLine ( std::unique_ptr< Cell > &&  newCell,
bool  forceNewLine = false 
)

Add a new line to the output cell of the working group.

If maxima isn't currently evaluating and therefore there is no working group the line is appended to m_last, instead.

◆ IsSelected()

bool Worksheet::IsSelected ( CellType  type)

Does the selection start with a cell of the type "type".

Is this cell selected?

◆ MarkRefreshAsDone()

void Worksheet::MarkRefreshAsDone ( )
inline

Handle redrawing the worksheet or of parts of it.

This functionality is important for scrolling, if we have changed anything that needs updating or if part of the screen memory containing a window was overwritten by a window that was in front of it and now needs to be redrawn for this reason.

We don't redraw the window immediately if this seems necessary but wait for the idle loop instead - which is called when all selected gui events have been processed. This allows us to handle events as fast as the user can type and (if the user types faster than we can display the text) enables us to update the display as often as the typing speed allows, but not more often. Request the worksheet to be redrawn

◆ OnChar()

void Worksheet::OnChar ( wxKeyEvent &  event)

Key for a printable character pressed.

Can call OnCharInActive or OnCharNoActive, if appropriate. See OnKeyDown for non-printable characters like "up" or "right".

◆ OnCharInActive()

void Worksheet::OnCharInActive ( wxKeyEvent &  event)

Key pressed inside a cell.

send event to active cell

If we need to recalculate then refresh the window

Otherwise refresh only the active cell

◆ OnKeyDown()

void Worksheet::OnKeyDown ( wxKeyEvent &  event)

A special key has been pressed.

Printable characters are handled by OnChar instead.

◆ OnMouseWheel()

void Worksheet::OnMouseWheel ( wxMouseEvent &  event)

Called if the mouse wheel sents events.

The virtual mouse wheel touchpads provide are handled by OnThumbtrack instead.

◆ OnPaint()

void Worksheet::OnPaint ( wxPaintEvent &  event)

Is called by wxWidgets when it wants to redraw the worksheet or a part of it.

The canonical way to schedule triggering this function is calling the Refresh() or RequestRedraw() function of this class.

Using multiple threads in order to speed up this process is kind of hard: Using more than one wxPaintDC at the same time isn't supported by most (if not all) operating systems. Drawing in a wxMemoryDC and then blitting the result in the central wxPaintDC works, but each wxMemoryDC needs to draw into a separate bitmap for that to work.

◆ OnScrollChanged()

void Worksheet::OnScrollChanged ( wxScrollEvent &  ev)

Called if the user is using the scrollbar for scrolling through the document.

See also OnThumbtrack and OnMouseWheel

◆ QuestionPending() [1/2]

bool Worksheet::QuestionPending ( ) const
inline

Does maxima wait for the answer of a question?

Return values
true= maxima waits for the answer of a question.

◆ QuestionPending() [2/2]

void Worksheet::QuestionPending ( bool  pending)
inline

Does maxima currently wait for the answer of a question?

◆ RecalculateIfNeeded()

bool Worksheet::RecalculateIfNeeded ( bool  timeout = false,
long  timeSliceMs = 50 
)
inline

Actually recalculate the worksheet.

Parameters
timeoutIf true the walk is time-sliced: after timeSliceMs it yields (returning true so the idle handler asks for another tick) and resumes from where it left off next time. If false the whole scheduled range is laid out in one call.
timeSliceMsHow long (ms) a time-sliced pass may run before yielding. Only used when timeout is true; exposed mainly so tests can force a yield after every cell (a value < 0 does that).
Returns
Whether there may be more work to do (the caller should call again).

See WorksheetLayout::RecalculateIfNeeded(), which does the actual work.

◆ RedrawIfRequested()

bool Worksheet::RedrawIfRequested ( )

Redraw the worksheet if RequestRedraw() has been called.

Also handles setting tooltips and redrawing the brackets on mouse movements.

◆ Replace()

void Worksheet::Replace ( const wxString &  oldString,
const wxString &  newString,
bool  ignoreCase 
)

Replace the current occurrence of a string.

Used by the find dialog.

◆ ReplaceAll()

int Worksheet::ReplaceAll ( const wxString &  oldString,
const wxString &  newString,
bool  ignoreCase,
bool  searchInInput = true,
bool  searchInOutput = true 
)

Replace all occurrences of a string.

Used by the find dialog.

◆ RequestRecalculation()

void Worksheet::RequestRecalculation ( Cell start)
inline

Schedule a recalculation of the worksheet starting with the cell start.

This only records where the next layout pass has to start (it marks the group dirty and moves the engine's resume point); it does not size or position any cell. The actual work - and, crucially, AdjustSize() once the cell positions are correct - happens in RecalculateIfNeeded(). Calling AdjustSize() (or otherwise reading cell geometry) right after this, without a RecalculateIfNeeded() in between, reads stale positions. Was named Recalculate(), which wrongly implied it does the layout itself.

◆ RequestRedraw() [1/2]

void Worksheet::RequestRedraw ( GroupCell start = NULL)

Request the worksheet to be redrawn.

Parameters
startWhich cell do we need to start the redraw in? Subsequent calls to this function with different cells start the redraw at the upmost of the cells that were passed to it.

The actual redraw is done in the idle loop which means that as many redraw actions are merged as is necessary to allow wxMaxima to process things in real time.

Returns
true, if we did redraw a workscreet portion.

◆ RequestRedraw() [2/2]

void Worksheet::RequestRedraw ( wxRect  rect)

Request a part of the worksheet to be redrawn.

Parameters
rectThe rectangle that is to be requested to be redrawn. If this function is called multiple times the rectangles are automatically merged.

The actual redraw is done in the idle loop which means that as many redraw actions are merged as is necessary to allow wxMaxima to process things in real time.

◆ ScrolledAwayFromEvaluation()

void Worksheet::ScrolledAwayFromEvaluation ( bool  ScrolledAway)

Set or get the "Scrolled away from evaluation" status.

Sets FollowEvaluation() to false and enables the toolbar button to follow the evaluation process again.

◆ SelectWithChar()

void Worksheet::SelectWithChar ( int  ccode)

Handle selecting text using the keyboard Is called when the all of the following is true:

  • We have a wxKeyEvent with no active editor,
  • shift is down and
  • keycode (ccode) is WXK_UP/WXK_DOWN

◆ SetActiveCell()

void Worksheet::SetActiveCell ( EditorCell cell)

Mark an editor cell as the active one.

◆ SetAnswer()

void Worksheet::SetAnswer ( const wxString &  answer)

Handling questions from and answers for maxima.

Remember the answer to the LastQuestion().

◆ SetHCaret()

void Worksheet::SetHCaret ( GroupCell where)

Set the HCaret at the location of the given Cell.

Parameters
whereThe cell to place the cursor before.

◆ SetNotification()

void Worksheet::SetNotification ( const wxString &  message,
int  flags = wxICON_INFORMATION 
)

Inform the user that something happened in a non-active window.

This command will be ignored if the wxMaxima window is currently active

◆ SetViewScrollRate()

void Worksheet::SetViewScrollRate ( int  rate)
inlineoverridevirtual

Set the scroll granularity (device pixels per scroll unit) on both axes.

Implements WorksheetView.

◆ SetViewVirtualSize()

void Worksheet::SetViewVirtualSize ( int  width,
int  height 
)
inlineoverridevirtual

Set the scrollable (virtual) area, in device pixels.

Implements WorksheetView.

◆ ShowPoint()

void Worksheet::ShowPoint ( wxPoint  point)

Scrolls to a point on the worksheet.

Todo:
I have deactivated this assert for the release as it scares the users in a case we don't seem to have a problem. But we perhaps should try to find out why it is triggered.

Test case:

  • Create a code cell
  • Press the "hide all code cells" button.
  • click between 2 worksheet cells which makes the cursor appear as a horizontal line
  • press any letter.

◆ StepAnimation()

void Worksheet::StepAnimation ( int  change = 1)

Set the slide of the currently selected animation or advance it by one step.

Parameters
change
  • >=0: The slide the animation has to be set to
  • <0: Advance the animation by one step.

◆ ToggleFold()

GroupCell * Worksheet::ToggleFold ( GroupCell which)

Fold or unfold a cell.

Toggles the status of the fold for the given GroupCell.

If the cell is folded, it will be unfolded; otherwise it will be folded.

Parameters
whichThe GroupCell to fold or unfold.
Returns
A pointer to a GroupCell if the action succeeded; NULL otherwise.

◆ ToggleFoldAll()

GroupCell * Worksheet::ToggleFoldAll ( GroupCell which)

Toggles the status of the fold for the given GroupCell and its children.

If the cell is folded, it will be recursively unfolded; otherwise it will be recursively folded.

Parameters
whichThe GroupCell to recursively fold or unfold.
Returns
A pointer to a GroupCell if the action succeeded; NULL otherwise.

◆ UnicodeToMaxima()

const wxString Worksheet::UnicodeToMaxima ( wxString  s)

Make a few unicode characters interpretable by maxima.

Does convert the not equal sign to a '#' and similar.

◆ UpdateTableOfContents()

void Worksheet::UpdateTableOfContents ( )

Update the table of contents.

This function actually only schedules the update of the table-of-contents-tab. The actual update is done when wxMaxima is idle.


The documentation for this class was generated from the following files: