wxMaxima
Loading...
Searching...
No Matches
CellPointers.h
1// -*- mode: c++; c-file-style: "linux"; c-basic-offset: 2; indent-tabs-mode: nil -*-
2//
3// Copyright (C) 2004-2015 Andrej Vodopivec <andrej.vodopivec@gmail.com>
4// Copyright (C) 2014-2018 Gunter Königsmann <wxMaxima@physikbuch.de>
5// Copyright (C) 2020 Kuba Ober <kuba@bertec.com>
6//
7// This program is free software; you can redistribute it and/or modify
8// it under the terms of the GNU General Public License as published by
9// the Free Software Foundation; either version 2 of the License, or
10// (at your option) any later version.
11//
12// This program is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17//
18// You should have received a copy of the GNU General Public License
19// along with this program; if not, write to the Free Software
20// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21//
22// SPDX-License-Identifier: GPL-2.0+
23
24#ifndef WXMAXIMA_CELLPOINTERS_H
25#define WXMAXIMA_CELLPOINTERS_H
26
27#include "cells/Cell.h"
28#include <wx/string.h>
29#include <vector>
30
31class wxWindow;
32template<class T> class wxScrolled;
34
35class EditorCell;
36class TextCell;
37
45{
46public:
47 void ScrollToCell(Cell *cell) { m_cellToScrollTo = cell; }
48 Cell *CellToScrollTo() { return m_cellToScrollTo; }
49 explicit CellPointers(wxScrolledCanvas *worksheet);
55 GroupCell *GetWorkingGroup(bool resortToLast = false) const;
56
58 void SetWorkingGroup(GroupCell *group);
59
60 void WXMXResetCounter() { m_wxmxImgCounter = 0; }
61
62 wxString WXMXGetNewFileName();
63
64 std::size_t WXMXImageCount() const { return m_wxmxImgCounter; }
65
66 bool HasCellsSelected() const { return m_selectionStart && m_selectionEnd; }
67
70 {
71 public:
72 ErrorList() = default;
74 bool Empty() const { return m_errors.empty(); }
76 void Remove(GroupCell * cell);
78 bool Contains(GroupCell * cell) const;
80 void Add(GroupCell * cell);
82 GroupCell *FirstError() const;
84 GroupCell *LastError() const;
86 void Clear() { m_errors.clear(); }
87 private:
89 std::vector<CellPtr<GroupCell>> m_errors;
90 };
91
123
126 {
129 }
130
134
138
159
169
170 void SetTimerIdForCell(Cell *cell, int timerId);
171 int GetTimerIdForCell(Cell *cell) const;
172 Cell *GetCellForTimerId(int timerId) const;
173 void RemoveTimerIdForCell(const Cell *const cell);
174
175 wxScrolledCanvas *GetWorksheet() { return m_worksheet; }
176
177private:
178 struct CellTimerId {
179 Cell *cell = NULL;
180 int timerId = -1;
181 CellTimerId() = default;
182 CellTimerId(Cell *cell, int timerId) : cell(cell), timerId(timerId) {}
183 };
185 std::vector<CellTimerId> m_timerIds;
187 CellPtr<Cell> m_cellToScrollTo;
189 wxScrolledCanvas *const m_worksheet;
191 std::size_t m_wxmxImgCounter = 0;
192public:
194 bool m_scrollToCell = false;
195};
196
197#endif
The definition of the base class of all cells the worksheet consists of.
A list of editor cells containing error messages.
Definition: CellPointers.h:70
GroupCell * LastError() const
The last GroupCell with errors in the list.
Definition: CellPointers.cpp:105
GroupCell * FirstError() const
The first GroupCell with error that is still in the list.
Definition: CellPointers.cpp:101
void Remove(GroupCell *cell)
Remove one specific GroupCell from the list of errors.
Definition: CellPointers.cpp:77
void Add(GroupCell *cell)
Mark this GroupCell as containing errors.
Definition: CellPointers.cpp:86
bool Empty() const
Is the list of errors empty?
Definition: CellPointers.h:74
void Clear()
Empty the list of GroupCells with errors.
Definition: CellPointers.h:86
bool Contains(GroupCell *cell) const
Does the list of GroupCell with errors contain cell?
Definition: CellPointers.cpp:82
The storage for pointers to cells.
Definition: CellPointers.h:45
void ResetKeyboardSelectionStart()
Forget where the keyboard selection was started.
Definition: CellPointers.h:136
GroupCell * GetWorkingGroup(bool resortToLast=false) const
Returns the cell maxima currently works on.
Definition: CellPointers.cpp:96
CellPtr< GroupCell > m_lastWorkingGroup
The last group cell maxima was working on.
Definition: CellPointers.h:109
void ResetMouseSelectionStart()
Forget where the mouse selection was started.
Definition: CellPointers.h:132
ErrorList m_errorList
The list of cells maxima has complained about errors in.
Definition: CellPointers.h:93
bool m_scrollToCell
Is scrolling to a cell scheduled?
Definition: CellPointers.h:194
CellPtr< EditorCell > m_activeCell
Which EditCell the blinking cursor is in?
Definition: CellPointers.h:103
CellPtr< EditorCell > m_cellKeyboardSelectionStartedIn
The EditorCell the keyboard selection has started in.
Definition: CellPointers.h:97
void SetWorkingGroup(GroupCell *group)
Sets the cell maxima currently works on. NULL if there isn't such a cell.
Definition: CellPointers.cpp:90
CellPtr< GroupCell > m_groupCellUnderPointer
The GroupCell that is under the mouse pointer.
Definition: CellPointers.h:105
CellPtr< Cell > m_selectionStart
The first cell of the currently selected range of Cells.
Definition: CellPointers.h:147
int m_indexSearchStartedAt
Which cursor position incremental search has started at?
Definition: CellPointers.h:101
CellPtr< EditorCell > m_cellMouseSelectionStartedIn
The EditorCell the mouse selection has started in.
Definition: CellPointers.h:95
CellPtr< Cell > m_cellUnderPointer
The last cell of the currently selected range of groupCells.
Definition: CellPointers.h:158
CellPtr< EditorCell > m_answerCell
The EditorCell that contains the currently active question from maxima.
Definition: CellPointers.h:107
CellPtr< GroupCell > m_workingGroup
The group cell maxima is currently working on.
Definition: CellPointers.h:116
void ResetSearchStart()
Forget where the search was started.
Definition: CellPointers.h:125
wxString m_selectionString
The currently selected string.
Definition: CellPointers.h:122
CellPtr< EditorCell > m_cellSearchStartedIn
The EditorCell the search was started in.
Definition: CellPointers.h:99
CellPtr< TextCell > m_currentTextCell
The textcell the text maxima is sending us was ending in.
Definition: CellPointers.h:111
CellPtr< Cell > m_selectionEnd
The last cell of the currently selected range of Cells.
Definition: CellPointers.h:168
A weak non-owning pointer that becomes null whenever the observed object is destroyed.
Definition: CellPtr.h:480
The base class all cell types the worksheet can consist of are derived from.
Definition: Cell.h:142
This class defines what the user sees as input cell.
Definition: EditorCell.h:59
A cell grouping input (and, if there is one, also the output) cell to a foldable item.
Definition: GroupCell.h:74
A Text cell.
Definition: TextCell.h:38
Definition: CellPointers.h:32