wxMaxima
Loading...
Searching...
No Matches
Worksheet.h
Go to the documentation of this file.
1// -*- mode: c++; c-file-style: "linux"; c-basic-offset: 2; indent-tabs-mode: nil -*-
2//
3// Copyright (C) 2004-2015 Andrej Vodopivec <andrej.vodopivec@gmail.com>
4// (C) 2012-2013 Doug Ilijev <doug.ilijev@gmail.com>
5// (C) 2015 Gunter Königsmann <wxMaxima@physikbuch.de>
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
30#ifndef WORKSHEET_H
31#define WORKSHEET_H
32
33#include <optional>
34#include "precomp.h"
35#include "MaximaManual.h"
36#include "EventIDs.h"
37#include "RecentDocuments.h"
38#include <wx/wx.h>
39#include <wx/xml/xml.h>
40#include <wx/aui/aui.h>
41#include <wx/textfile.h>
42#include <wx/fdrepdlg.h>
43#include <wx/dc.h>
44#include <vector>
45#include <utility>
46#include <memory>
47#include <list>
48#include "CellPointers.h"
50#include "Notification.h"
51#include "cells/Cell.h"
52#include "cells/EditorCell.h"
53#include "cells/ImgCell.h"
54#include "cells/ImgCellBase.h"
55#include "cells/AnimationCell.h"
56#include "cells/GroupCell.h"
57#include "TreeUndoManager.h"
58#include "WorksheetCursor.h"
59#include "WorksheetDocument.h"
61#include "WorksheetSearch.h"
62#include "WorksheetLayout.h"
63#include "cells/TextCell.h"
64#include "EvaluationQueue.h"
66#include "Autocomplete.h"
67#include "AutocompletePopup.h"
69#include "ToolBar.h"
70#include <thread>
71
114class Worksheet : public wxScrolled<wxWindow>, public WorksheetView,
116{
117public:
118 // WorksheetView: the narrow window surface the layout pipeline
119 // (WorksheetLayout) drives; each forwards to the wxScrolled base.
120 void GetViewClientSize(int *width, int *height) const override
121 { GetClientSize(width, height); }
122 int GetViewScrollUnitY() const override
123 { int x, y; GetViewStart(&x, &y); return y; }
124 void SetViewVirtualSize(int width, int height) override
125 { SetVirtualSize(width, height); }
126 void SetViewScrollRate(int rate) override { SetScrollRate(rate, rate); }
127 void GetViewPosition(int *x, int *y) const override
128 { const wxPoint p = GetPosition(); *x = p.x; *y = p.y; }
129
130 // WorksheetDocumentView: how m_document tells this window that a structural
131 // edit happened; each forwards to the real layout/redraw/save machinery.
132 void NotifyRecalculation(GroupCell *start) override
133 { RequestRecalculation(start); }
134 void NotifyRedraw(GroupCell *start) override { RequestRedraw(start); }
135 void NotifyAdjustSizeNeeded() override { m_layout.RequestAdjustSize(); }
136 void NotifySavedStateChanged() override { m_updateControls = true; }
137
139 RecentDocuments &UnsavedDocuments() { return m_unsavedDocuments; }
140private:
141 RecentDocuments m_unsavedDocuments;
142public:
144 bool UpdateControlsNeeded(){bool result = m_updateControls; m_updateControls = false; return result;}
145 void UpdateControlsNeeded(bool updateControlsNeeded){m_updateControls = updateControlsNeeded;}
146private:
148 wxString m_maximaDocDir;
150 bool m_updateControls = true;
152 bool m_scrollToCaret = false;
153 // The x position to scroll to
154 int m_newxPosition = -1;
155 // The y position to scroll to
156 int m_newyPosition = -1;
158 double m_zoomAtGestureStart = 1.0;
160 bool m_scrollToTopOfCell = false;
162 bool m_windowActive = true;
164 wxRegion m_regionToRefresh;
169 wxClientDC m_dc;
171 CellPtr<GroupCell> m_redrawStart;
173 bool m_fullRedrawRequested = false;
175
177 static wxDataFormat m_wxmFormat;
179 static wxDataFormat m_mathmlFormat;
181 static wxDataFormat m_mathmlFormat2;
183 static wxDataFormat m_rtfFormat;
185 static wxDataFormat m_rtfFormat2;
186
189 class MathMLDataObject : public wxCustomDataObject
190 {
191 public:
192 explicit MathMLDataObject(const wxString &data);
193
194 MathMLDataObject();
195
196 private:
197 wxCharBuffer m_databuf;
198 };
199
201 class wxmDataObject : public wxCustomDataObject
202 {
203 public:
204 explicit wxmDataObject(const wxString &data);
205
206 wxmDataObject();
207
208 private:
209 wxCharBuffer m_databuf;
210 };
211
212 class MathMLDataObject2 : public wxCustomDataObject
213 {
214 public:
215 explicit MathMLDataObject2(const wxString &data);
216
217 MathMLDataObject2();
218
219 private:
220 wxCharBuffer m_databuf;
221 };
222
225 class RtfDataObject : public wxCustomDataObject
226 {
227 public:
228 explicit RtfDataObject(const wxString &data);
229
230 RtfDataObject();
231
232 private:
233 wxCharBuffer m_databuf;
234 };
235
236 class RtfDataObject2 : public wxCustomDataObject
237 {
238 public:
239 explicit RtfDataObject2(const wxString &data);
240
241 RtfDataObject2();
242
243 private:
244 wxCharBuffer m_databuf;
245 };
246
248 bool m_hasFocus = true;
250 long m_lastTop = 0;
252 long m_lastBottom = 0;
274 // TreeUndoAction/UndoActions live in TreeUndoAction.h and the undo/redo
275 // state (the two stacks + the active-cell snapshot) is owned by the
276 // TreeUndoManager below; only the tree surgery of applying an action
277 // remains a Worksheet responsibility.
278
279private:
281 TreeUndoManager &GetTreeUndo() { return m_document.GetTreeUndo(); }
282 const TreeUndoManager &GetTreeUndo() const { return m_document.GetTreeUndo(); }
283
284public:
287
290
292 void TreeUndo_AppendAction() { GetTreeUndo().AppendAction(); }
293
299 bool TreeUndo(UndoActions *sourcelist, UndoActions *undoForThisOperation);
300
304 bool TreeUndoTextChange(UndoActions *sourcelist, UndoActions *undoForThisOperation);
308 bool TreeUndoCellDeletion(UndoActions *sourcelist, UndoActions *undoForThisOperation);
312 bool TreeUndoCellAddition(UndoActions *sourcelist, UndoActions *undoForThisOperation);
313
315 bool TreeUndo()
316 { return TreeUndo(&GetTreeUndo().UndoStack(), &GetTreeUndo().RedoStack()); }
317
319 bool TreeRedo()
320 { return TreeUndo(&GetTreeUndo().RedoStack(), &GetTreeUndo().UndoStack()); }
321
323 bool CanTreeUndo() const;
324
326 bool CanTreeRedo() const;
327
331
334 void TreeUndo_CellLeft();
335
344 void TreeUndo_MarkCellsAsAdded(GroupCell *start, GroupCell *end, UndoActions *undoBuffer);
345
346
352 void TreeUndo_MarkCellsAsAdded(GroupCell *parentOfStart, GroupCell *end);
354
355private:
356 bool m_scrolledAwayFromEvaluation = false;
357public:
358
361 {
362 CLICK_TYPE_NONE,
363 CLICK_TYPE_GROUP_SELECTION,
364 CLICK_TYPE_INPUT_SELECTION,
365 CLICK_TYPE_INPUT_LABEL_SELECTION,
366 CLICK_TYPE_OUTPUT_SELECTION
367 };
368
371 {
372 TIMER_ID,
373 CARET_TIMER_ID,
374 DISPLAY_TIMEOUT_ID
375 };
376
378 std::unique_ptr<Cell> CopySelection(bool asData = false) const;
379
388 std::unique_ptr<Cell> CopySelection(Cell *start, Cell *end, bool asData = false) const;
389
391 void GetMaxPoint(int *width, int *height) { m_layout.GetMaxPoint(width, height); }
392
394 void OnTimer(wxTimerEvent &event);
395
396#if wxCHECK_VERSION(3, 1, 1)
398 void OnZoom(wxZoomGestureEvent &event);
399#endif
400
401 void OnMouseExit(wxMouseEvent &event);
402
403 void OnMouseEnter(wxMouseEvent &event);
404
417 void OnPaint(wxPaintEvent &event);
419 void DrawGroupCell(wxDC &dc, wxDC &adc, GroupCell &cell);
427 void DrawGroupCell_UsingBitmap(wxDC *dc, GroupCell *cell);
428
430 void PrepareDrawGC(wxDC &dc) const;
431
432 void OnSize(wxSizeEvent &event);
433
434 void OnMouseRightDown(wxMouseEvent &event);
435
436 void OnSidebarKey(wxCommandEvent &event);
437
438 void OnMouseLeftUp(wxMouseEvent &event);
439
441 void OnMouseCaptureLost(wxMouseCaptureLostEvent &event);
442
443 void OnMouseLeftDown(wxMouseEvent &event);
444
445 void OnMouseLeftInGcCell(wxMouseEvent &event, GroupCell *clickedInGC);
446
447 void OnMouseLeftInGcLeft(wxMouseEvent &event, GroupCell *clickedInGC);
448
449 void OnMouseLeftInGc(wxMouseEvent &event, GroupCell *clickedInGC);
450
451 void OnMouseMotion(wxMouseEvent &event);
452
454 void OnDoubleClick(wxMouseEvent &event);
455
457 void OnCharInActive(wxKeyEvent &event);
458
460 void OnCharNoActive(wxKeyEvent &event);
461
463 void SelectEditable(EditorCell *editor, bool up);
464
471 void SelectWithChar(int ccode);
472
487 void ClickNDrag(wxPoint down, wxPoint up);
488
489 // Select all group cells inside the given rectangle;
490 void SelectGroupCells(wxPoint down, wxPoint up);
491
492public:
494 void AdjustSize() { m_layout.AdjustSize(); }
495
497 void OnEraseBackground(wxEraseEvent& WXUNUSED(event))
498 {}
499
500 void CheckUnixCopy();
501
502 void OnMouseMiddleUp(wxMouseEvent &event);
503
504 static bool IsLesserGCType(int type, int comparedTo);
505
508
511
513 void OnComplete(wxCommandEvent &event);
514
519 void EraseBackground(wxEraseEvent &event);
520
521private:
523 wxPoint m_leftDownPosition;
524 wxPoint m_down;
525 wxPoint m_up;
526 wxPoint m_mousePoint;
535 WorksheetCursor &GetHCaretCursor() { return m_document.GetCursor(); }
536 const WorksheetCursor &GetHCaretCursor() const { return m_document.GetCursor(); }
537 bool m_leftDown = false;
539 bool m_followEvaluation = true;
540 bool m_mouseDrag = false;
541 bool m_mouseOutside = false;
542
543public:
546private:
547 int m_clickType = CLICK_TYPE_NONE;
548 CellPtr<GroupCell> m_clickInGC;
550 bool m_blinkDisplayCaret = true;
552 bool m_hCaretBlinkVisible = true;
554 wxTimer m_timer;
556 wxTimer m_caretTimer;
557 std::vector<wxString> m_completions;
558 bool m_autocompleteTemplates = true;
559 AutocompletePopup *m_autocompletePopup;
560
561public:
563 bool IsEmpty() const
564 { return !GetTree() || (!GetTree()->GetNext() && GetTree()->GetEditable()->GetValue().Length() <= 1); }
567 {
568 if(m_autocompletePopup != NULL)
569 m_autocompletePopup->Destroy();
570 }
571
577 void OnChar(wxKeyEvent &event);
578
583 void OnKeyDown(wxKeyEvent &event);
585 void SetCellStyle(GroupCell *group, GroupType style);
586
588 void NumberSections() const;
589
591 bool SectioningMoveIn(GroupCell *parent);
593 bool SectioningMoveOut(GroupCell *parent);
595 std::optional<Notification> &GetNotification() { return m_notificationMessage; }
596private:
598 std::optional<Notification> m_notificationMessage;
599public:
601 void WindowActive(bool active){m_windowActive = active;}
603 void ClearNotification();
608 void SetNotification(const wxString &message, int flags = wxICON_INFORMATION);
609
611 void OnActivate(wxActivateEvent &event);
612private:
615 std::unique_ptr<GroupCell> &TreeOwner() { return m_document.TreeOwner(); }
616 CellPtr<GroupCell> &LastCache() const { return m_document.LastCache(); }
617// std::vector<std::jthread> m_drawThreads;
618 static std::mutex m_drawDCLock;
621 Configuration *m_configuration = NULL;
628 WorksheetLayout m_layout;
629public:
630 void FocusFindDialogue()
631 {
632 if(m_findDialog)
633 m_findDialog->SetFocus();
634 }
636 AutoComplete &GetAutocomplete() { return m_autocomplete; }
637private:
638 AutoComplete m_autocomplete;
639public:
640
641 Configuration *GetConfig() const { return m_configuration; }
642
645
649
650 EditorCell *MouseSelectionStart() const
652
653 EditorCell *SearchStart() const
654 { return GetViewCellPointers().SearchStart(); }
655
656 int IndexSearchStartedAt() const
658
665
667 TextCell *GetCurrentTextCell() const { return GetDocumentCellPointers().GetCurrentTextCell(); }
668 void SetCurrentTextCell(TextCell *cell) { GetDocumentCellPointers().SetCurrentTextCell(cell); }
669 void SetWorkingGroup(GroupCell *group) { GetDocumentCellPointers().SetWorkingGroup(group); }
670
677
695 {
696 m_redrawStart = NULL;
697 m_fullRedrawRequested = false;
698 }
699
704 bool RedrawIfRequested();
705
718 void RequestRedraw(GroupCell *start = NULL);
728 void RequestRedraw(wxRect rect);
729
732 {
735 }
736
739
742 m_configuration->ReadConfig();
745 Refresh();
746 }
747
757
759 const wxString &GetCurrentFile() const { return m_document.GetCurrentFile(); }
761 void SetCurrentFile(const wxString &file) { m_document.SetCurrentFile(file); }
762
767 const wxString UnicodeToMaxima(wxString s);
768
770 void ScrollToStart() { Scroll(0, 0); }
771
773 void ScrollToError();
774
777
779 bool HCaretActive() const { return GetHCaretCursor().IsActive(); }
780
787
788 bool CanUndo() const;
789
790 bool CanRedo() const;
791
792 void Undo();
793
794 void Redo();
795
800 void TreeUndo_ClearBuffers();
801
811 Worksheet(wxWindow *parent, int id, Configuration *config,
812 wxPoint pos = wxDefaultPosition, wxSize size = wxDefaultSize,
813 bool reactToEvents = true);
814
816 virtual ~Worksheet();
817
819 wxTimer &KeyboardInactiveTimer() { return m_keyboardInactiveTimer; }
820private:
821 wxTimer m_keyboardInactiveTimer;
822public:
823
825 void DestroyTree();
826
828 std::unique_ptr<GroupCell> CopyTree() const;
829
841 GroupCell *InsertGroupCells(std::unique_ptr<GroupCell> &&cells, GroupCell *where,
842 UndoActions *undoBuffer);
843
849 GroupCell *InsertGroupCells(std::unique_ptr<GroupCell> &&cells, GroupCell *where = NULL);
850
856 void InsertLine(std::unique_ptr<Cell> &&newCell, bool forceNewLine = false);
857
859 GroupCell *GetInsertGroup() const;
860
876 bool RecalculateIfNeeded(bool timeout = false, long timeSliceMs = 50)
877 { return m_layout.RecalculateIfNeeded(timeout, timeSliceMs); }
878
889 void RequestRecalculation(Cell *start) { m_layout.RequestRecalculation(start); }
890
901
903 int GetLastCellsVisited() const { return m_layout.GetLastCellsVisited(); }
905 int GetLastCellsRecalculated() const { return m_layout.GetLastCellsRecalculated(); }
906
911 void ClearDocument();
912
913 void ResetInputPrompts();
914
915 bool CanCopy() const
916 {
920 }
921
930 bool CanCopyAsMathML() const;
931
932 bool CanPaste() const
933 { return GetDocumentCellPointers().GetActiveCell() || GetHCaretCursor().IsActive(); }
934
935 bool CanCut() const
936 {
939 }
940
942 void SelectAll();
943
946
957 void DeleteRegion(
958 GroupCell *start,
959 GroupCell *end,
960 UndoActions *undoBuffer
961 );
962
969 void DeleteRegion(
970 GroupCell *start,
971 GroupCell *end
972 );
973
979 void DeleteSelection();
980
981 void TOCdnd(GroupCell *dndStart, GroupCell *dndEnd);
982
984 bool CanDeleteRegion(GroupCell *start, const GroupCell *end) const;
985
988
993 void DeleteCurrentCell();
994
997 {
999 return NULL;
1000 return dynamic_cast<AnimationCell *>(GetSelectionStart());
1001 }
1002
1005 {
1007 return NULL;
1008 return dynamic_cast<ImgCell *>(GetSelectionStart());
1009 }
1010
1013 {
1015 return NULL;
1016 return dynamic_cast<ImgCellBase *>(GetSelectionStart());
1017 }
1018
1021 {
1023 return NULL;
1024 return dynamic_cast<TextCell *>(GetSelectionStart());
1025 }
1026
1028 bool CanAnimate() const
1029 {
1031 (dynamic_cast<AnimationCell *>(GetSelectionStart()) != NULL);
1032 }
1033
1040 void Animate(bool run = true) const;
1041
1042 void DivideCell();
1043
1044 void MergeCells();
1045
1046 void SetLastQuestion(const wxString &lastQuestion){m_document.SetLastQuestion(lastQuestion);}
1047 wxString GetLastQuestion() const {return m_document.GetLastQuestion();}
1048
1050 bool CutToClipboard();
1051
1052 void PasteFromClipboard();
1053
1060 bool Copy(bool astext = false) const;
1061
1069 std::unique_ptr<wxDataObject> CreateSelectionDataObject() const;
1070
1072 bool CopyCells() const;
1073
1080 std::unique_ptr<wxDataObject> CreateCellsDataObject() const;
1081
1083 bool CopyMatlab() const;
1084
1086 bool CopyText() const;
1087
1089 bool CopyTeX() const;
1090
1092 wxString ConvertSelectionToMathML() const;
1093
1096
1098 bool CopyMathML() const;
1099
1101 bool CopyBitmap() const;
1102
1104 bool CopyAnimation() const;
1105
1107 bool CopySVG() const;
1108
1109#if wxUSE_ENH_METAFILE
1111 bool CopyEMF() const;
1112#endif
1113
1115 bool CopyRTF() const;
1116
1117 wxSize CopyToFile(const wxString &file) const;
1118
1119 wxSize CopyToFile(const wxString &file, Cell *start, Cell *end, bool asData = false, double scale = 1) const;
1120
1132 int ExportSelectionOutputToDir(const wxString &dir, bool svg);
1133
1138 bool ExportToHTML(const wxString &file);
1139
1141 bool ExportToMAC(const wxString &file);
1142
1144 wxString RTFStart() const;
1145
1147 wxString RTFEnd() const;
1148
1150 bool ExportToTeX(const wxString &file);
1151
1157 wxString GetString(bool lb = false) const;
1158
1159 GroupCell *GetTree() const { return m_document.GetTree(); }
1160 std::unique_ptr<GroupCell> *GetTreeAddress() { return &m_document.TreeOwner(); }
1161
1168
1175
1177 void ClearSelection() { SetSelection(nullptr, nullptr); }
1178
1180 void SetSelection(Cell *sel) { SetSelection(sel, sel); }
1181
1183 void SetSelection(Cell *start, Cell *end);
1184
1186 Cell *FindCellByUUID(const wxString &uuid);
1187
1190
1193 bool CanEdit() const { return m_document.CanEdit(); }
1194
1195 bool ActivatePrevInput() { return ActivateInput(-1); }
1196 bool ActivateNextInput() { return ActivateInput(+1); }
1197 wxString GetStatusText() const {return m_statusText;}
1198 bool StatusTextChangedHas() {
1199 bool retval = (m_statusTextHas != m_statusTextHas_old) ||
1200 (m_statusText != m_statusText_old);
1201 m_statusText_old = m_statusText;
1202 m_statusTextHas_old = m_statusTextHas;
1203 return retval;
1204 }
1205 bool StatusTextHas() const {return m_statusTextHas;}
1206private:
1207 /* ! A timer that tells us to urgently update the display
1208
1209 Normally we prioritize tasks: If there are GUI actions to process we do so.
1210 If not we look if there is data from maxima to process. If not we
1211 If not we recalculate the worksheet element sizes and positions and if
1212 there still is no pressing task we update the display. This way we
1213 respond quickly to the most important inputs.
1214
1215 This timer, if expired, tells us that if we don't update the screen now
1216 maxima feels like not being responsive.
1217 */
1218 wxTimer m_displayTimeoutTimer;
1219
1220 template <class T_SRC, class T_DEST>
1221 inline std::unique_ptr<T_DEST> unique_cast(std::unique_ptr<T_SRC> &&src)
1222 {
1223 if (!src) return std::unique_ptr<T_DEST>();
1224
1225 T_DEST *dest_ptr = &dynamic_cast<T_DEST &>(*src.get());
1226
1227 (void) src.release();
1228 return std::unique_ptr<T_DEST>(dest_ptr);
1229 }
1230 wxString m_statusText;
1231 wxString m_statusText_old;
1232 bool m_statusTextHas = false;
1233 bool m_statusTextHas_old = false;
1234 void StatusText(const wxString &text){m_statusText = text; m_statusTextHas = true;}
1235 void UnsetStatusText(){m_statusTextHas = false;}
1236 bool ActivateInput(int direction);
1237
1238public:
1241 {
1243 m_scrollToCaret = true;
1244 }
1245
1247 bool ScrollToCaretIfNeeded();
1248
1250 void ScrollToCellIfNeeded();
1251
1253 void ScheduleScrollToCell(Cell *cell, bool scrollToTop = true)
1254 {
1255 GetViewCellPointers().ScrollToCell(cell);
1256 m_scrollToTopOfCell = scrollToTop;
1257 m_scrollToCaret = false;
1258
1260 }
1261
1263 bool PointVisibleIs(wxPoint point);
1264
1266 bool CaretVisibleIs();
1267
1270
1284 void ShowPoint(wxPoint point);
1285
1287 void OnSetFocus(wxFocusEvent &event);
1288
1290 void OnKillFocus(wxFocusEvent &event);
1291
1293 bool IsSelected(CellType type) const { return m_document.IsSelected(type); }
1294
1301 void StepAnimation(int change = 1);
1302
1304 bool IsActiveInLast() const
1306
1309 {
1310 return GetLastCellInWorksheet();
1311 }
1312
1315
1316 void SetActiveCell(EditorCell *cell);
1317
1321 void SetDefaultHCaret();
1322
1327 void SetHCaret(GroupCell *where); // call with false, when manually refreshing
1330
1332 void OpenHCaret(const wxString &txt = {})
1333 {
1334 if(m_mainToolBar == NULL)
1335 OpenHCaret(txt, GC_TYPE_CODE);
1336 else
1338 }
1339
1341 void OpenHCaret(const wxString &txt, GroupType type);
1342
1344 void ShowHCaret();
1345
1351
1352 void UndoInsideCell();
1353
1359
1360 void RedoInsideCell();
1361
1371 void FollowEvaluation(bool followEvaluation);
1372
1374 bool FollowEvaluation() const
1375 { return m_followEvaluation; }
1376
1382 void ScrolledAwayFromEvaluation(bool ScrolledAway);
1383
1384 bool ScrolledAwayFromEvaluation() const
1385 { return m_scrolledAwayFromEvaluation; }
1386
1387 void SaveValue();
1388
1389 bool IsSaved() const
1390 { return m_document.IsSaved(); }
1391
1392 void SetSaved(bool saved)
1393 { m_document.SetSaved(saved); }
1394
1395 void OutputChanged()
1397
1399 void RemoveAllOutput();
1400
1408 void RemoveAllOutput(GroupCell *cell);
1409 // methods related to evaluation queue
1410
1416 void Evaluate();
1417
1419 void AddToEvaluationQueue(GroupCell *cell);
1420
1421 void AddDocumentToEvaluationQueue();
1422
1425
1428
1431
1434
1437
1440
1443
1446
1447 void FoldOccurred();
1448
1449 // methods for folding
1452
1453 GroupCell *ToggleFoldAll(GroupCell *which) { return m_document.ToggleFoldAll(which); }
1454
1455 void FoldAll() { m_document.FoldAll(); }
1456
1457 void UnfoldAll() { m_document.UnfoldAll(); }
1458
1459 // methods for zooming the document in and out
1460 void SetZoomFactor(double newzoom);
1461
1462 void CommentSelection();
1463
1468 void OnScrollChanged(wxScrollEvent &ev);
1469 void OnScrollEvent(wxScrollWinEvent &ev);
1470 void CheckIfActiveCellScrolledOut();
1475 void OnMouseWheel(wxMouseEvent &event);
1476
1482 bool FindIncremental(const wxString &str, bool down, bool ignoreCase, bool searchInInput = true, bool searchInOutput = true);
1483 bool FindIncremental_RegEx(const wxString &str, bool down, bool searchInInput = true, bool searchInOutput = true);
1484
1485private:
1489 WorksheetSearch::SearchStart FindStart(bool down);
1495 bool ApplyFindResult(const WorksheetSearch::SearchTarget &target, bool warn);
1496public:
1503 bool FindNext(const wxString &str, bool down, bool ignoreCase, bool searchInInput = true, bool searchInOutput = true, bool warn = true);
1504 bool FindNext_Regex(const wxString &str, const bool &down, bool searchInInput = true, bool searchInOutput = true, bool warn = true);
1505
1510 void Replace(const wxString &oldString, const wxString &newString, bool ignoreCase);
1511 void Replace_RegEx(const wxString &oldString, const wxString &newString);
1512
1517 int ReplaceAll(const wxString &oldString, const wxString &newString, bool ignoreCase, bool searchInInput = true, bool searchInOutput = true);
1518 int ReplaceAll_RegEx(const wxString &oldString, const wxString &newString, bool searchInInput = true, bool searchInOutput = true);
1519
1520 wxString GetInputAboveCaret();
1521
1522 wxString GetOutputAboveCaret();
1523
1525 void LoadSymbols();
1526
1527 bool Autocomplete(AutoComplete::autoCompletionType type = AutoComplete::command);
1528
1530 void AddSymbol(const wxString &fun, AutoComplete::autoCompletionType type = AutoComplete::command)
1531 { m_autocomplete.AddSymbol(fun, type); }
1532
1534 void AddSymbols(const wxString &xml)
1535 { m_autocomplete.AddSymbols(xml); }
1537 void AddSymbols(wxXmlDocument xml)
1538 { m_autocomplete.AddSymbols(xml); }
1539
1540 void SetActiveCellText(const wxString &text);
1541
1542 bool InsertText(const wxString &text);
1543
1544 void OpenNextOrCreateCell();
1545
1547 void OnFollow();
1548
1551
1553 void SelectGroupCell(GroupCell *cell);
1554
1559 void SetAnswer(const wxString &answer);
1561 void QuestionAnswered();
1562
1567 bool QuestionPending() const
1568 { return m_document.QuestionPending(); }
1570
1574 void QuestionPending(bool pending)
1575 { m_document.SetQuestionPending(pending); }
1576
1577 void SetMaximaDocDir(const wxString &dir)
1578 {
1579 m_maximaDocDir = dir;
1580 }
1581 const wxString &GetMaximaDocDir() const { return m_maximaDocDir; }
1582
1584 bool GCContainsCurrentQuestion(const GroupCell *cell);
1585
1588 bool OpenQuestionCaret(const wxString &txt = {});
1589
1598 bool WillAutoAnswer() const;
1599 void UpdateScrollPos();
1600
1606 GroupCell *GetWorkingGroup(bool resortToLast = false) const;
1608 void LoadHelpFileAnchors(const wxString &docdir, const wxString &maximaVersion)
1609 {m_maximaManual.LoadHelpFileAnchors(docdir, maximaVersion);}
1610 wxString GetHelpfileAnchorName(const wxString &keyword)
1611 {return m_maximaManual.GetHelpfileAnchorName(keyword);}
1612 wxString GetHelpfileURL(const wxString &keyword)
1613 {return m_maximaManual.GetHelpfileURL(keyword);}
1614
1616 std::vector<wxString> m_replacementsForCurrentWord;
1617#if wxUSE_ACCESSIBILITY
1618 int GetAccessibilityId(Cell *cell) const;
1619#endif
1620
1621#if wxUSE_ACCESSIBILITY
1622 class AccessibilityInfo: public wxAccessible
1623 {
1624 public:
1625 AccessibilityInfo(wxWindow *parent, Worksheet *worksheet);
1626 wxAccStatus GetName (int childId, wxString *name);
1627 wxAccStatus GetChildCount (int *childCount);
1628 wxAccStatus GetChild (int childId, wxAccessible **child);
1629 wxAccStatus GetDefaultAction(int childId, wxString *actionName);
1630 wxAccStatus GetParent (wxAccessible ** parent);
1631 wxAccStatus GetFocus (int *childId, wxAccessible **child);
1632 wxAccStatus GetLocation (wxRect &rect, int elementId);
1633 wxAccStatus HitTest (const wxPoint &pt,
1634 int *childId, wxAccessible **childObject);
1635 wxAccStatus GetDescription(int childId, wxString *description);
1636 wxAccStatus GetRole(int childId, wxAccRole *role);
1637 wxAccStatus GetState(int childId, long *state);
1638 private:
1639 wxWindow *m_parent = NULL;
1640 Worksheet *m_worksheet = NULL;
1641
1642 class CaretAccessibilityInfo : public wxAccessible {
1643 public:
1644 CaretAccessibilityInfo(AccessibilityInfo* parent, Worksheet* worksheet)
1645 : wxAccessible(worksheet->GetTargetWindow()), m_parent(parent), m_worksheet(worksheet) {}
1646
1647 wxAccStatus GetName(int childId, wxString *name) override;
1648 wxAccStatus GetDescription(int WXUNUSED(childId), wxString *description) override;
1649 wxAccStatus GetParent(wxAccessible **parent) override;
1650 wxAccStatus GetChildCount(int *childCount) override;
1651 wxAccStatus GetChild(int childId, wxAccessible **child) override;
1652 wxAccStatus GetRole(int childId, wxAccRole *role) override;
1653 private:
1654 AccessibilityInfo* m_parent;
1655 Worksheet* m_worksheet;
1656 };
1657 CaretAccessibilityInfo* m_caretAccessible = nullptr;
1658 };
1659#endif
1660 MaximaManual m_maximaManual;
1661 MaximaManual *GetMaximaManual() {return &m_maximaManual;}
1662protected:
1663 void FocusTextControl();
1673 wxBitmap m_memory;
1674 virtual wxSize DoGetBestClientSize() const override;
1675#if wxUSE_ACCESSIBILITY
1676 AccessibilityInfo *m_accessibilityInfo = NULL;
1677#endif
1679 int m_pointer_x = -1;
1681 int m_pointer_y = -1;
1683 bool m_mouseMotionWas = false;
1685 bool m_inPopupMenu = false;
1686};
1687
1688wxDECLARE_EVENT(TOC_UPDATE_NEEDED_EVENT, wxCommandEvent);
1689
1690#endif // WORKSHEET_H
This file declares the class AnimationCell.
The first number that is open for dynamic ID assignment.
This file declares the class AutoComplete.
The definition of the base class of all cells the worksheet consists of.
CellType
The supported types of math cells.
Definition: Cell.h:64
@ MC_TYPE_GROUP
A group cells that bundles several individual cells together.
Definition: Cell.h:82
This file contains the definition of the class EditorCell.
The evaluation queue.
This file declares the class EventIDs that contains unique IDs for many events wxMaxima needs.
This file defines the class FindReplaceDialog.
This file defines the class GroupCell that bundles input and output in the worksheet.
GroupType
All types a GroupCell can be of.
Definition: GroupCell.h:43
This file declares the class MaximaManual.
This file defines the class Notification.
The definition of the class RecentDocuments that provides a recent files mechanism that is extensible...
This file declares the class ToolBar that represents wxMaxima's main tool bar.
std::list< TreeUndoAction > UndoActions
The type of the list of tree actions that can be undone.
Definition: TreeUndoAction.h:120
Declares TreeUndoManager: the owner of the cell-tree undo/redo state.
This file contains the definition of the class Unicodesidebar that allows to select arbitrary unicode...
The file that contains the "variables" sidepane.
The worksheet's "between the cells" cursor (the horizontally drawn caret).
The narrow "something in the document changed" surface a WorksheetDocument needs to poke its view.
The document half of the worksheet: the state and commands that describe the edited document itself,...
The worksheet's layout engine: scheduling, the recalculation walk and the virtual-size update,...
The worksheet's search engine.
Definition: AnimationCell.h:46
Definition: Autocomplete.h:61
autoCompletionType
All types of things we can autocomplete.
Definition: Autocomplete.h:68
void AddSymbols(wxString xml)
Interprets the XML autocompletable symbol list maxima can send us.
Definition: Autocomplete.cpp:135
void AddSymbol(wxString fun, autoCompletionType type=command)
Manually add an autocompletable symbol to our symbols lists.
Definition: Autocomplete.cpp:686
Definition: AutocompletePopup.h:47
A weak non-owning pointer that becomes null whenever the observed object is destroyed.
Definition: CellPtr.h:511
The base class all cell types the worksheet can consist of are derived from.
Definition: Cell.h:142
GroupCell * GetGroup() const
Returns the group cell this cell belongs to.
Definition: Cell.cpp:286
CellType GetType() const
Returns the type of this cell.
Definition: Cell.h:453
The configuration storage for the current worksheet.
Definition: Configuration.h:98
void ReadConfig()
Read the config from the wxConfig object.
Definition: Configuration.cpp:589
A list of editor cells containing error messages.
Definition: CellPointers.h:54
The document-model half of the cell-pointer registry.
Definition: CellPointers.h:50
TextCell * GetCurrentTextCell() const
The text cell the text maxima is currently sending us is being appended to.
Definition: CellPointers.cpp:134
const CellPtr< Cell > & GetSelectionStart() const
The first cell of the currently selected range of cells, or null. Returned by reference so callers ke...
Definition: CellPointers.h:93
const CellPtr< Cell > & GetSelectionEnd() const
The last cell of the currently selected range of cells, or null.
Definition: CellPointers.h:95
void SetCurrentTextCell(TextCell *cell)
Set the text cell maxima's incoming text is being appended to (may be null).
Definition: CellPointers.cpp:138
bool HasCellsSelected() const
Are any whole cells (as opposed to text inside an editor) selected?
Definition: CellPointers.h:88
void SetWorkingGroup(GroupCell *group)
Sets the cell maxima currently works on. NULL if there isn't such a cell.
Definition: CellPointers.cpp:146
ErrorList & GetErrorList()
The list of cells maxima has complained about errors in.
Definition: CellPointers.h:134
EditorCell * GetActiveCell() const
The editor cell the blinking text cursor is in, or null.
Definition: CellPointers.cpp:142
This class defines what the user sees as input cell.
Definition: EditorCell.h:60
const wxString & GetValue() const override
Returns the text contained in this cell.
Definition: EditorCell.h:222
bool CanCopy() const override
Select Can we copy the editable text of this cell?
Definition: EditorCell.h:374
A simple FIFO queue with manual removal of elements.
Definition: EvaluationQueue.h:43
The find+replace dialog.
Definition: FindReplaceDialog.h:42
A cell grouping input (and, if there is one, also the output) cell to a foldable item.
Definition: GroupCell.h:88
GroupCell * GetNext() const
Get the next GroupCell in the list.
Definition: GroupCell.h:280
Definition: ImgCellBase.h:42
Definition: ImgCell.h:35
Definition: MaximaManual.h:59
void LoadHelpFileAnchors(const wxString &docdir, const wxString &maximaVersion)
Search maxima's help file for command and variable names.
Definition: MaximaManual.cpp:538
A class that maintains a list of recent documents.
Definition: RecentDocuments.h:42
A Text cell.
Definition: TextCell.h:38
Definition: ToolBar.h:41
GroupType GetCellType()
Get the cell style for new cells.
Definition: ToolBar.cpp:698
Owns the cell-tree undo/redo stacks and the active-cell snapshot.
Definition: TreeUndoManager.h:51
void ClearUndoActionList()
Clear the list of actions that can be undone.
Definition: TreeUndoManager.h:94
void ClearRedoActionList()
Clear the list of actions that can be redone.
Definition: TreeUndoManager.h:87
static void AppendAction(UndoActions *actionList)
Mark the newest action of the list as part of the following atomic action.
Definition: TreeUndoManager.h:77
The view/interaction half of the cell-pointer registry.
Definition: CellPointers.h:187
const CellPtr< EditorCell > & MouseSelectionStart() const
The EditorCell a mouse selection was started in, or null.
Definition: CellPointers.h:214
int IndexSearchStartedAt() const
The cursor position an incremental search was started at (-1 = none).
Definition: CellPointers.h:202
const CellPtr< EditorCell > & KeyboardSelectionStart() const
The EditorCell a keyboard selection was started in, or null.
Definition: CellPointers.h:223
const CellPtr< EditorCell > & SearchStart() const
The EditorCell an incremental search was started in, or null.
Definition: CellPointers.h:200
void SetScrollToCellScheduled(bool scheduled)
Schedule (or cancel) scrolling to CellToScrollTo().
Definition: CellPointers.h:197
The between-the-cells cursor: active flag, position, selection anchors.
Definition: WorksheetCursor.h:49
bool IsActive() const
Is this (rather than the in-cell text cursor) the active cursor?
Definition: WorksheetCursor.h:52
The view notifications a WorksheetDocument emits when it edits itself.
Definition: WorksheetDocumentView.h:50
The view-independent state and commands of an edited worksheet document.
Definition: WorksheetDocument.h:60
bool CanMergeSelection() const
Can the current selection (of more than one cell) be merged into one?
Definition: WorksheetDocument.cpp:311
CellPtr< GroupCell > & LastCache() const
The cached pointer to the document's last GroupCell (<0 = unknown).
Definition: WorksheetDocument.h:92
bool CanRedoInsideCell() const
Can the active cell's own (intra-cell) redo be invoked right now?
Definition: WorksheetDocument.cpp:340
void SetSaved(bool saved)
Record whether the document is in its saved state.
Definition: WorksheetDocument.cpp:34
void FoldAll()
Recursively folds every foldable cell in the document.
Definition: WorksheetDocument.cpp:271
void UnfoldAll()
Recursively unfolds every folded cell in the document.
Definition: WorksheetDocument.cpp:278
bool QuestionPending() const
Is Maxima currently waiting for an answer to a question?
Definition: WorksheetDocument.h:205
bool CanUndoInsideCell() const
Can the active cell's own (intra-cell) undo be invoked right now?
Definition: WorksheetDocument.cpp:336
bool IsSaved() const
True while the document has no unsaved changes.
Definition: WorksheetDocument.h:216
void SetCurrentFile(const wxString &file)
Record the file this document is associated with.
Definition: WorksheetDocument.h:195
EvaluationQueue & GetEvaluationQueue()
The list of cells scheduled to be sent to Maxima for evaluation.
Definition: WorksheetDocument.h:63
bool IsSelectionInWorkingGroup() const
Is the selection start inside the group Maxima is currently evaluating?
Definition: WorksheetDocument.cpp:331
DocumentCellPointers & GetCellPointers()
The document-model half of the cell-pointer registry (selection, the active/answer/current-text cell,...
Definition: WorksheetDocument.h:211
bool IsSelected(CellType type) const
Is the selection exactly one cell of the given type?
Definition: WorksheetDocument.cpp:324
GroupCell * ToggleFold(GroupCell *which)
Fold or unfold which, whichever it currently isn't; see GroupCell::Fold()/Unfold().
Definition: WorksheetDocument.cpp:246
TreeUndoManager & GetTreeUndo()
The document's undo/redo history of tree-structure edits.
Definition: WorksheetDocument.h:68
const wxString & GetCurrentFile() const
The file this document was last loaded from / saved to (empty if none).
Definition: WorksheetDocument.h:193
std::unique_ptr< GroupCell > & TreeOwner()
Mutable access to the owning pointer of the cell tree.
Definition: WorksheetDocument.h:86
const wxString & GetLastQuestion() const
The text of the Maxima question the user is currently being asked.
Definition: WorksheetDocument.h:198
bool CanDeleteSelection() const
Can the current selection be deleted right now (see CanRemoveCells())?
Definition: WorksheetDocument.cpp:303
bool CanEdit() const
Is exactly one cell selected, and does it directly follow Maxima's own input prompt (as opposed to be...
Definition: WorksheetDocument.cpp:285
void SetQuestionPending(bool pending)
Record whether Maxima is waiting for an answer to a question.
Definition: WorksheetDocument.h:207
WorksheetCursor & GetCursor()
The between-cells cursor (the h-caret) and its group-level selection.
Definition: WorksheetDocument.h:73
GroupCell * GetTree() const
The first GroupCell of the document (null when the document is empty).
Definition: WorksheetDocument.h:78
void SetLastQuestion(const wxString &lastQuestion)
Remember the text of the question Maxima is currently asking.
Definition: WorksheetDocument.h:200
GroupCell * ToggleFoldAll(GroupCell *which)
Like ToggleFold(), but folds/unfolds which's whole subtree.
Definition: WorksheetDocument.cpp:258
void OutputChanged()
Note that a cell's output changed.
Definition: WorksheetDocument.h:231
The layout/recalculation engine of a worksheet.
Definition: WorksheetLayout.h:54
void RequestFullRecalculation()
Schedule a recalculation of the whole worksheet.
Definition: WorksheetLayout.cpp:237
void RequestAdjustSize()
Flag the virtual (scroll) size as needing re-adjustment.
Definition: WorksheetLayout.h:143
void RequestRecalculation(Cell *start)
Schedule a recalculation of the worksheet starting with the cell start.
Definition: WorksheetLayout.cpp:179
void GetMaxPoint(int *width, int *height)
Get the coordinates of the bottom right point of the worksheet.
Definition: WorksheetLayout.cpp:259
void UpdateConfigurationClientSize()
Inform the configuration about the view's current client size.
Definition: WorksheetLayout.cpp:246
int GetLastCellsVisited() const
GroupCells walked by the most recent RecalculateIfNeeded() pass (visited includes cheap reposition-on...
Definition: WorksheetLayout.h:156
void AdjustSize()
Adjust the virtual size and scrollbars to the document's extent.
Definition: WorksheetLayout.cpp:305
bool RecalculateIfNeeded(bool timeout=false, long timeSliceMs=50)
Perform the scheduled recalculation, if one is pending.
Definition: WorksheetLayout.cpp:41
The narrow view surface the worksheet's layout pipeline needs.
Definition: WorksheetSizeMath.h:172
The canvas that contains the spreadsheet the whole program is about.
Definition: Worksheet.h:116
bool IsActiveInLast() const
Is the editor active in the last cell of the worksheet?
Definition: Worksheet.h:1304
GroupCell * ToggleFold(GroupCell *which)
Fold or unfold a cell.
Definition: Worksheet.h:1451
void OnTimer(wxTimerEvent &event)
Is executed if a timer associated with Worksheet has expired.
Definition: Worksheet.cpp:3348
void ClearSelection()
Clear the selection - make it empty, i.e. no selection.
Definition: Worksheet.h:1177
const wxString UnicodeToMaxima(wxString s)
Make a few unicode characters interpretable by maxima.
Definition: Worksheet.cpp:3709
bool CanMergeSelection() const
Can we merge the selected cells into one?
Definition: Worksheet.h:786
bool IsSelectionInWorkingGroup() const
Is the selection in the current working group?
Definition: Worksheet.h:1314
int GetLastCellsRecalculated() const
How many cells the last layout pass truly recalculated. See WorksheetLayout.
Definition: Worksheet.h:905
void SetViewScrollRate(int rate) override
Set the scroll granularity (device pixels per scroll unit) on both axes.
Definition: Worksheet.h:126
ImgCellBase * GetSelectedImgCellBase() const
Returns the selected cell - or NULL, if the selection isn't image nor animation.
Definition: Worksheet.h:1012
wxString RTFStart() const
The start of a RTF document.
Definition: Worksheet.cpp:5882
int m_pointer_x
The x position of the mouse pointer.
Definition: Worksheet.h:1679
void SetDefaultHCaret()
Set the HCaret to its default location, at the end of the document.
Definition: Worksheet.cpp:4847
bool CanDeleteRegion(GroupCell *start, const GroupCell *end) const
Is it possible to delete the cells between start and end?
Definition: Worksheet.cpp:2105
void AddSectionToEvaluationQueue(GroupCell *start)
Adds a chapter, a section or a subsection to the evaluation queue.
Definition: Worksheet.cpp:4001
void AddSymbols(const wxString &xml)
Add a xml-encoded list of symbols to the autocompletion list.
Definition: Worksheet.h:1534
virtual ~Worksheet()
The destructor.
Definition: Worksheet.cpp:527
bool CutToClipboard()
Add the currently selected cells to the clipboard and delete them.
Definition: Worksheet.cpp:4545
void GetViewPosition(int *x, int *y) const override
The view's position within its parent, in device pixels (wxWindow::GetPosition).
Definition: Worksheet.h:127
WorksheetDocument m_document
The view-independent document state (file, current question, ...) that Worksheet's document accessors...
Definition: Worksheet.h:1667
std::unique_ptr< wxDataObject > CreateCellsDataObject() const
Build the multi-format clipboard object for a whole-cell selection.
Definition: Worksheet.cpp:2019
GroupCell * GetInsertGroup() const
The group that the line's cells will belong to - used by InsertLine.
Definition: Worksheet.cpp:941
void OnCharNoActive(wxKeyEvent &event)
Key pressed and no cell was active.
Definition: Worksheet.cpp:2872
bool QuestionPending() const
Does maxima wait for the answer of a question?
Definition: Worksheet.h:1567
void AddEntireDocumentToEvaluationQueue()
Schedule all cells in the document for evaluation.
Definition: Worksheet.cpp:3992
GroupCell * FirstVisibleGC()
The first groupCell that is currently visible.
Definition: Worksheet.cpp:1472
void UpdateConfigurationClientSize()
Inform the configuration about the current client size.
Definition: Worksheet.h:1189
int ReplaceAll(const wxString &oldString, const wxString &newString, bool ignoreCase, bool searchInInput=true, bool searchInOutput=true)
Replace all occurrences of a string.
Definition: Worksheet.cpp:5313
void AddSymbols(wxXmlDocument xml)
Add a xml-encoded list of symbols to the autocompletion list.
Definition: Worksheet.h:1537
void LoadHelpFileAnchors(const wxString &docdir, const wxString &maximaVersion)
Tries to parse maxima's manual in order to find out which anchors it contains.
Definition: Worksheet.h:1608
bool ExportToHTML(const wxString &file)
Export the file to an html document.
Definition: Worksheet.cpp:3679
void OpenHCaret(const wxString &txt={})
Place the cursor into a new cell where the horizontal cursor is.
Definition: Worksheet.h:1332
void NotifyAdjustSizeNeeded() override
The scrollable size will need re-adjusting once cell positions settle.
Definition: Worksheet.h:135
void ApplyOverlayScrollbarsSetting()
Apply the configuration's OverlayScrollbars() choice to this window.
Definition: Worksheet.cpp:502
TextCell * GetSelectedTextCell() const
Returns the selected cell - or NULL, if the selection isn't a text cell.
Definition: Worksheet.h:1020
void ScrollToError()
Unfold the cell that produced the error, if necessary and, if requested, scroll to it.
Definition: Worksheet.cpp:891
bool HCaretActive() const
Is the vertically-drawn cursor active?
Definition: Worksheet.h:779
void OnEraseBackground(wxEraseEvent &WXUNUSED(event))
Cannot be static as it is called using a function pointer to an object.
Definition: Worksheet.h:497
void ClearDocument()
Empties the current document.
Definition: Worksheet.cpp:1070
wxString RTFEnd() const
The end of a RTF document.
Definition: Worksheet.cpp:5886
ViewCellPointers m_viewCellPointers
The transient view-state half of the cell-pointer registry (hover, selection anchors,...
Definition: Worksheet.h:1671
void UpdateTableOfContents()
Update the table of contents.
Definition: Worksheet.cpp:6211
void RemoveAllOutput()
Remove all output cells from the whole worksheet.
Definition: Worksheet.cpp:4920
Cell * GetSelectionEnd() const
Return the last of the currently selected cells.
Definition: Worksheet.h:1173
void QuestionPending(bool pending)
Does maxima currently wait for the answer of a question?
Definition: Worksheet.h:1574
void ClickNDrag(wxPoint down, wxPoint up)
Select the rectangle surrounded by down and up.
Definition: Worksheet.cpp:1624
DocumentCellPointers & GetDocumentCellPointers()
The document-model half of the cell-pointer registry (owned by m_document).
Definition: Worksheet.h:660
const wxString & GetCurrentFile() const
The name of the currently-opened file.
Definition: Worksheet.h:759
void SetCurrentFile(const wxString &file)
Set the name of the currently-opened file.
Definition: Worksheet.h:761
RecentDocuments & UnsavedDocuments()
The list of unsaved (autosaved) documents offered for recovery.
Definition: Worksheet.h:139
void DeleteCurrentCell()
Delete the currently active cell - or the cell above this one.
Definition: Worksheet.cpp:2090
AutoComplete & GetAutocomplete()
The storage for the autocompletion feature.
Definition: Worksheet.h:636
AnimationCell * GetSelectedAnimation() const
Returns the selected cell - or NULL, if the selection isn't an animation.
Definition: Worksheet.h:996
void Replace(const wxString &oldString, const wxString &newString, bool ignoreCase)
Replace the current occurrence of a string.
Definition: Worksheet.cpp:5279
bool CopyMatlab() const
Copy a Matlab representation of the current selection to the clipboard.
Definition: Worksheet.cpp:1911
bool CopyText() const
Copy a textual representation of the current selection to the clipboard.
Definition: Worksheet.cpp:1974
bool m_inPopupMenu
Is there an active popup menu?
Definition: Worksheet.h:1685
EvaluationQueue & GetEvaluationQueue()
The list of cells that have to be evaluated.
Definition: Worksheet.h:1445
void Animate(bool run=true) const
Animate the current slide show.
Definition: Worksheet.cpp:4824
static GroupCell * StartOfSectioningUnit(GroupCell *start)
Finds the start of the current chapter/section/...
Definition: Worksheet.cpp:2487
bool CopyRTF() const
Copy a rtf version of the current selection to the clipboard.
Definition: Worksheet.cpp:3494
void UpdateConfig()
Re-read the configuration.
Definition: Worksheet.h:741
int m_pointer_y
The y position of the mouse pointer.
Definition: Worksheet.h:1681
bool Copy(bool astext=false) const
Copy the current selection to the clipboard.
Definition: Worksheet.cpp:1731
bool CopyAnimation() const
Copy the current animation to the clipboard.
Definition: Worksheet.cpp:3472
void StepAnimation(int change=1)
Set the slide of the currently selected animation or advance it by one step.
Definition: Worksheet.cpp:3322
void SelectEditable(EditorCell *editor, bool up)
Is called when a hCursor is active and we have a WXK_UP/WXK_DOWN event.
Definition: Worksheet.cpp:2841
void SetAnswer(const wxString &answer)
Handling questions from and answers for maxima.
Definition: Worksheet.cpp:2214
ViewCellPointers & GetViewCellPointers()
The transient view-state half of the cell-pointer registry (owned here).
Definition: Worksheet.h:663
void OnChar(wxKeyEvent &event)
Key for a printable character pressed.
Definition: Worksheet.cpp:3206
void SelectWithChar(int ccode)
Handle selecting text using the keyboard Is called when the all of the following is true:
Definition: Worksheet.cpp:2756
void AddSelectionToEvaluationQueue()
Schedule all cells in the selection to be evaluated.
Definition: Worksheet.cpp:4030
bool HasCellsSelected() const
Is at least one entire cell selected?
Definition: Worksheet.h:945
std::optional< Notification > & GetNotification()
The error notification message, if any.
Definition: Worksheet.h:595
void OnSetFocus(wxFocusEvent &event)
What to do if the worksheet is in the input focus.
Definition: Worksheet.cpp:4784
void SetNotification(const wxString &message, int flags=wxICON_INFORMATION)
Inform the user that something happened in a non-active window.
Definition: Worksheet.cpp:3184
bool IsSelected(CellType type) const
Does the selection start with a cell of the type "type".
Definition: Worksheet.h:1293
void ScheduleScrollToCell(Cell *cell, bool scrollToTop=true)
Schedules scrolling to a given cell.
Definition: Worksheet.h:1253
int GetViewScrollUnitY() const override
The current vertical scroll position, in scroll units (not pixels).
Definition: Worksheet.h:122
GroupCell * InsertGroupCells(std::unique_ptr< GroupCell > &&cells, GroupCell *where, UndoActions *undoBuffer)
Insert group cells into the worksheet.
Definition: Worksheet.cpp:871
void AddDocumentTillHereToEvaluationQueue()
Schedule all cells stopping with the one the caret is in for evaluation.
Definition: Worksheet.cpp:4046
void OnComplete(wxCommandEvent &event)
Is called if an action from the autocomplete menu is selected.
Definition: Worksheet.cpp:5632
bool CanAnimate() const
Does it make sense to enable the "Play" button and the slider now?
Definition: Worksheet.h:1028
bool RecalculateIfNeeded(bool timeout=false, long timeSliceMs=50)
Actually recalculate the worksheet.
Definition: Worksheet.h:876
bool m_mouseMotionWas
Was there a mouse motion we didn't react to until now?
Definition: Worksheet.h:1683
void SelectAll()
Select the whole document.
Definition: Worksheet.cpp:4707
void OnKillFocus(wxFocusEvent &event)
What to do if the worksheet looses the input focus.
Definition: Worksheet.cpp:4796
void InsertLine(std::unique_ptr< Cell > &&newCell, bool forceNewLine=false)
Add a new line to the output cell of the working group.
Definition: Worksheet.cpp:950
void ClearNotification()
Clears the notification message from SetNotification.
Definition: Worksheet.cpp:3182
void OnPaint(wxPaintEvent &event)
Is called by wxWidgets when it wants to redraw the worksheet or a part of it.
Definition: Worksheet.cpp:570
void OnFollow()
Called when the "Scroll to currently evaluated" button is pressed.
Definition: Worksheet.cpp:5816
void PrepareDrawGC(wxDC &dc) const
All that has need to be done before drawing a GroupCell in a DC.
Definition: Worksheet.cpp:747
void OnCharInActive(wxKeyEvent &event)
Key pressed inside a cell.
Definition: Worksheet.cpp:2531
Cell * GetSelectionStart() const
Return the first of the currently selected cells.
Definition: Worksheet.h:1166
void FoldOccurred()
Call when a fold action was detected, to update the state in response to a fold occurring.
Definition: Worksheet.cpp:1159
void OnMouseCaptureLost(wxMouseCaptureLostEvent &event)
Is called if we loose the mouse connection whilst selecting text/cells.
Definition: Worksheet.cpp:5890
wxTimer & KeyboardInactiveTimer()
The timer that tells us when the keyboard is inactive so an autosave isn't disrupting.
Definition: Worksheet.h:819
ClickType
An enum for all classes of items one can click on.
Definition: Worksheet.h:361
ImgCell * GetSelectedImgCell() const
Returns the selected cell - or NULL, if the selection isn't an image.
Definition: Worksheet.h:1004
Cell * FindCellByUUID(const wxString &uuid)
Find a cell by its UUID.
Definition: Worksheet.cpp:4094
void EraseBackground(wxEraseEvent &event)
Is called if wxWidgets wants to erase the worksheet's background.
Definition: Worksheet.cpp:305
bool CanDeleteSelection() const
Is it possible to delete the currently selected cells?
Definition: Worksheet.h:987
ToolBar * m_mainToolBar
The toolbar of the main window: We need to access it and therefore have it defined here.
Definition: Worksheet.h:1550
bool CaretVisibleIs()
Is the caret (hcaret or vcaret) currently visible on the worksheet?
Definition: Worksheet.cpp:5215
EditorCell * GetActiveCell() const
Get the currently active EditorCell.
Definition: Worksheet.h:644
bool UpdateControlsNeeded()
Is an update of the worksheet controls needed?
Definition: Worksheet.h:144
bool CopyCells() const
Copy the selection to the clipboard as it would appear in a .wxm file.
Definition: Worksheet.cpp:2003
bool OpenQuestionCaret(const wxString &txt={})
Move the cursor to the question maxima currently asks and if needed add a cell for user input.
Definition: Worksheet.cpp:2229
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.
Definition: Worksheet.cpp:5062
GroupCell * GetLastCell()
Returns the last cell of the worksheet.
Definition: Worksheet.h:1308
GroupCell * GetHCaret()
The cell the horizontal cursor is above. NULL means at the start of the document.
Definition: Worksheet.cpp:4830
wxString ConvertSelectionToMathML() const
Convert the current selection to MathML.
Definition: Worksheet.cpp:1816
bool CanUndoInsideCell() const
Is it possible to issue an undo in the currently selected cell?
Definition: Worksheet.h:1350
void SetHCaret(GroupCell *where)
Set the HCaret at the location of the given Cell.
Definition: Worksheet.cpp:4857
bool CanRedoInsideCell() const
Is it possible to issue an undo in the currently selected cell?
Definition: Worksheet.h:1358
bool GCContainsCurrentQuestion(const GroupCell *cell)
Does the GroupCell cell points to contain the question currently asked by maxima?
Definition: Worksheet.cpp:2459
bool WillAutoAnswer() const
Execute all collected scroll events in one go.
Definition: Worksheet.cpp:2222
bool IsEmpty() const
Is this worksheet empty?
Definition: Worksheet.h:563
void NumberSections() const
Renumber all sections.
Definition: Worksheet.cpp:1103
void SetViewVirtualSize(int width, int height) override
Set the scrollable (virtual) area, in device pixels.
Definition: Worksheet.h:124
void OnKeyDown(wxKeyEvent &event)
A special key has been pressed.
Definition: Worksheet.cpp:2354
EditorCell * KeyboardSelectionStart() const
Tells us which cell the keyboard selection has started in.
Definition: Worksheet.h:647
void SetSelection(Cell *sel)
Select the cell sel.
Definition: Worksheet.h:1180
void AddCellToEvaluationQueue(GroupCell *gc)
Schedule this cell for evaluation.
Definition: Worksheet.cpp:4064
void SetCellStyle(GroupCell *group, GroupType style)
Change the style of a cell.
Definition: Worksheet.cpp:2147
bool Autocomplete(AutoComplete::autoCompletionType type=AutoComplete::command)
Definition: Worksheet.cpp:5377
wxBitmap m_memory
A memory we can manually buffer the contents of the area that is to be redrawn in.
Definition: Worksheet.h:1673
void LoadSymbols()
Compile a list of known autocompletion symbols.
Definition: Worksheet.cpp:3707
void SelectGroupCell(GroupCell *cell)
Set this cell as the currently selected one.
Definition: Worksheet.cpp:5802
void ShowPoint(wxPoint point)
Scrolls to a point on the worksheet.
Definition: Worksheet.cpp:4496
void WindowActive(bool active)
Is this window active?
Definition: Worksheet.h:601
bool ExportToTeX(const wxString &file)
export to a LaTeX file
Definition: Worksheet.cpp:3701
void AdjustSize()
Adjust the virtual size and scrollbars; see WorksheetLayout::AdjustSize().
Definition: Worksheet.h:494
void ShowHCaret()
Activates the horizontal cursor.
Definition: Worksheet.cpp:4889
TimerIDs
An enum of individual IDs for all timers this class handles.
Definition: Worksheet.h:371
void CodeCellVisibilityChanged()
To be called after enabling or disabling the visibility of code cells.
Definition: Worksheet.cpp:3689
void ScrollToCaret()
Request to scroll to the cursor as soon as wxMaxima is idle.
Definition: Worksheet.h:1240
void MarkRefreshAsDone()
Handle redrawing the worksheet or of parts of it.
Definition: Worksheet.h:694
bool CopyMathML() const
Copy the MathML representation of the current selection to the clipboard.
Definition: Worksheet.cpp:1884
bool CopyBitmap() const
Copy a bitmap of the current selection to the clipboard.
Definition: Worksheet.cpp:3465
bool CanCopyAsMathML() const
Would "Copy as MathML" of the current selection produce actual math?
Definition: Worksheet.cpp:1865
void GetViewClientSize(int *width, int *height) const override
The visible client area, in device pixels.
Definition: Worksheet.h:120
bool PointVisibleIs(wxPoint point)
Is the point currently visible on the worksheet?
Definition: Worksheet.cpp:4475
std::unique_ptr< Cell > CopySelection(bool asData=false) const
Copy the currently selected cells.
Definition: Worksheet.cpp:3614
GroupCell * GetLastCellInWorksheet() const
Returns a pointer to the last cell of this worksheet.
Definition: Worksheet.cpp:1619
void ScrollToStart()
Scroll to the start of the worksheet.
Definition: Worksheet.h:770
void NotifyRecalculation(GroupCell *start) override
Schedule a re-layout of the document starting at start (null = all).
Definition: Worksheet.h:132
void AddSymbol(const wxString &fun, AutoComplete::autoCompletionType type=AutoComplete::command)
Add a symbol to the autocompletion list.
Definition: Worksheet.h:1530
bool CanEdit() const
We can edit the input if the we have the whole input in selection!
Definition: Worksheet.h:1193
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.
Definition: Worksheet.cpp:5149
bool SectioningMoveIn(GroupCell *parent)
Make this chapter/section/... a section/subsection/... changing its subheadings, too.
Definition: Worksheet.cpp:5669
wxBitmap ConvertSelectionToBitmap() const
Convert the current selection to a bitmap.
void RequestRedraw(GroupCell *start=NULL)
Request the worksheet to be redrawn.
Definition: Worksheet.cpp:474
bool RedrawIfRequested()
Redraw the worksheet if RequestRedraw() has been called.
Definition: Worksheet.cpp:317
bool ExportToMAC(const wxString &file)
Export the file to a text file maxima's load command can read.
Definition: Worksheet.cpp:3833
void SetActiveCell(EditorCell *cell)
Mark an editor cell as the active one.
Definition: Worksheet.cpp:4391
FindReplaceDialog * m_findDialog
The find-and-replace-dialog.
Definition: Worksheet.h:776
void DrawGroupCell(wxDC &dc, wxDC &adc, GroupCell &cell)
Draws a groupcell on the DC.
Definition: Worksheet.cpp:813
void QuestionAnswered()
Mark the current question from maxima as "answered"..
Definition: Worksheet.cpp:2463
void DeleteRegion(GroupCell *start, GroupCell *end, UndoActions *undoBuffer)
Definition: Worksheet.cpp:2178
bool ScrollToCaretIfNeeded()
Scrolls to the cursor, if requested.
Definition: Worksheet.cpp:5249
void NotifyRedraw(GroupCell *start) override
Schedule a redraw of the document starting at start (null = all).
Definition: Worksheet.h:134
std::unique_ptr< GroupCell > CopyTree() const
Copies the worksheet's entire contents.
Definition: Worksheet.cpp:3461
GroupCell * EndOfSectioningUnit(GroupCell *start)
Finds the end of the current chapter/section/...
Definition: Worksheet.cpp:2504
std::vector< wxString > m_replacementsForCurrentWord
Suggestions for how the word that was right-clicked on could continue.
Definition: Worksheet.h:1616
int ExportSelectionOutputToDir(const wxString &dir, bool svg)
Write each selected group cell's output to an image file in a folder.
Definition: Worksheet.cpp:3559
void ForceRedraw()
Redraw the window now and mark any pending redraw request as "handled".
Definition: Worksheet.h:731
bool CopyTeX() const
Copy the TeX representation of the current selection to the clipboard.
Definition: Worksheet.cpp:1939
void AddRestToEvaluationQueue()
Add all cells below the cursor to the evaluation queue.
Definition: Worksheet.cpp:4010
void ScrollToCellIfNeeded()
Scrolls to the cell given by ScheduleScrollToCell; Is called once we have time to do so.
Definition: Worksheet.cpp:4116
void DrawGroupCell_UsingBitmap(wxDC *dc, GroupCell *cell)
Draws a groupcell in a bitmap and then blits it onto the DC.
Definition: Worksheet.cpp:762
void GetMaxPoint(int *width, int *height)
Get the coordinates of the bottom right point of the worksheet.
Definition: Worksheet.h:391
void OnMouseWheel(wxMouseEvent &event)
Called if the mouse wheel sents events.
Definition: Worksheet.cpp:1506
void RequestRecalculation()
Schedule a recalculation of the whole worksheet.
Definition: Worksheet.h:900
void CloseAutoCompletePopup()
Close the autocompletion pop-up if it is currently open.
Definition: Worksheet.h:566
bool SectioningMoveOut(GroupCell *parent)
Make this section/subsection/... a chapter/section/... changing its subheadings, too.
Definition: Worksheet.cpp:5711
bool FollowEvaluation() const
Query if we want to automatically scroll to the cell that is currently evaluated.
Definition: Worksheet.h:1374
void DestroyTree()
Clear the whole worksheet.
Definition: Worksheet.cpp:3452
wxString GetString(bool lb=false) const
Convert the current selection to a string.
Definition: Worksheet.cpp:1713
void NotifySavedStateChanged() override
The document's saved-state flipped; refresh the controls that show it.
Definition: Worksheet.h:136
int GetLastCellsVisited() const
How many cells the last layout pass visited. See WorksheetLayout.
Definition: Worksheet.h:903
std::unique_ptr< wxDataObject > CreateSelectionDataObject() const
Build the multi-format clipboard object for a non-cell selection.
Definition: Worksheet.cpp:1760
GroupCell * GetWorkingGroup(bool resortToLast=false) const
Returns the cell maxima currently works on.
Definition: Worksheet.cpp:919
bool CopySVG() const
Copy a svg of the current selection to the clipboard.
Definition: Worksheet.cpp:3480
void Evaluate()
Trigger the evaluation of the current cell(s)
Definition: Worksheet.cpp:2345
void OnScrollChanged(wxScrollEvent &ev)
Called if the user is using the scrollbar for scrolling through the document.
Definition: Worksheet.cpp:4988
void OnDoubleClick(wxMouseEvent &event)
Is called on double click on a cell.
Definition: Worksheet.cpp:3909
void OnActivate(wxActivateEvent &event)
Is called if this element looses or gets the focus.
Definition: Worksheet.cpp:4849
void AddToEvaluationQueue(GroupCell *cell)
Adds a group cell to the evaluation queue marking its contents as "outdated".
Definition: Worksheet.cpp:3985
void RequestRecalculation(Cell *start)
Schedule a recalculation of the worksheet starting with the cell start.
Definition: Worksheet.h:889
Definition: CellPointers.h:32
bool CanTreeRedo() const
Can we redo a tree operation?
Definition: Worksheet.cpp:4235
void TreeUndo_CellEntered()
The cursor has entered one cell => save the value to see if it has changed.
Definition: Worksheet.cpp:2138
void TreeUndo_AppendAction()
Add another action to this undo action.
Definition: Worksheet.h:292
bool TreeUndoTextChange(UndoActions *sourcelist, UndoActions *undoForThisOperation)
Undo a text change.
Definition: Worksheet.cpp:4298
bool TreeUndo()
Undo a tree operation.
Definition: Worksheet.h:315
void TreeUndo_ClearRedoActionList()
Clear the list of actions for which an undo can be undone.
Definition: Worksheet.h:286
bool CanTreeUndo() const
Can we undo a tree operation?
Definition: Worksheet.cpp:4231
void TreeUndo_CellLeft()
The cursor is about to leave the current cell => Store the change if the value has changed.
Definition: Worksheet.cpp:2123
void TreeUndo_ClearUndoActionList()
Clear the list of actions for which undo can undo.
Definition: Worksheet.h:289
bool TreeUndoCellAddition(UndoActions *sourcelist, UndoActions *undoForThisOperation)
Undo adding cells.
Definition: Worksheet.cpp:4263
bool TreeUndoCellDeletion(UndoActions *sourcelist, UndoActions *undoForThisOperation)
Undo a call deletion.
Definition: Worksheet.cpp:4250
bool TreeRedo()
Redo an undone tree operation.
Definition: Worksheet.h:319
void TreeUndo_MarkCellsAsAdded(GroupCell *start, GroupCell *end, UndoActions *undoBuffer)
Remember that these cells were just added so this addition can be undone.
Definition: Worksheet.cpp:2114
Where a search starts: a group plus what the cursor is doing there.
Definition: WorksheetSearch.h:113
A search match: the group it is in and the matching part.
Definition: WorksheetSearch.h:97