wxMaxima
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 "Cell.h"
28 #include <wx/string.h>
29 #include <vector>
30 
31 class wxWindow;
32 template<class T> class wxScrolled;
34 
35 class EditorCell;
36 class TextCell;
37 
45 {
46 public:
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  int WXMXImageCount() const { return m_wxmxImgCounter; }
65 
66  bool HasCellsSelected() const { return m_selectionStart && m_selectionEnd; }
67 
69  class ErrorList
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(Cell *cell);
174 
175  wxScrolledCanvas *GetWorksheet() { return m_worksheet; }
176 
177 private:
178  struct CellTimerId {
179  Cell *cell;
180  int timerId;
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  int m_wxmxImgCounter = 0;
192 public:
194  bool m_scrollToCell = false;
195 };
196 
197 #endif
CellPointers::m_cellMouseSelectionStartedIn
CellPtr< EditorCell > m_cellMouseSelectionStartedIn
The EditorCell the mouse selection has started in.
Definition: CellPointers.h:95
CellPtr< EditorCell >
CellPointers::m_scrollToCell
bool m_scrollToCell
Is scrolling to a cell scheduled?
Definition: CellPointers.h:194
CellPointers::m_groupCellUnderPointer
CellPtr< GroupCell > m_groupCellUnderPointer
The GroupCell that is under the mouse pointer.
Definition: CellPointers.h:105
Cell.h
CellPointers::ResetSearchStart
void ResetSearchStart()
Forget where the search was started.
Definition: CellPointers.h:125
TextCell
Definition: TextCell.h:36
CellPointers::GetWorkingGroup
GroupCell * GetWorkingGroup(bool resortToLast=false) const
Definition: CellPointers.cpp:100
CellPointers::m_activeCell
CellPtr< EditorCell > m_activeCell
Which EditCell the blinking cursor is in?
Definition: CellPointers.h:103
CellPointers::m_workingGroup
CellPtr< GroupCell > m_workingGroup
Definition: CellPointers.h:116
CellPointers::m_indexSearchStartedAt
int m_indexSearchStartedAt
Which cursor position incremental search has started at?
Definition: CellPointers.h:101
CellPointers::ErrorList::Clear
void Clear()
Empty the list of GroupCells with errors.
Definition: CellPointers.h:86
CellPointers::m_selectionStart
CellPtr< Cell > m_selectionStart
Definition: CellPointers.h:147
CellPointers::m_lastWorkingGroup
CellPtr< GroupCell > m_lastWorkingGroup
The last group cell maxima was working on.
Definition: CellPointers.h:109
CellPointers::m_selectionString
wxString m_selectionString
Definition: CellPointers.h:122
CellPointers::m_selectionEnd
CellPtr< Cell > m_selectionEnd
Definition: CellPointers.h:168
Cell
Definition: Cell.h:139
CellPointers::ErrorList::FirstError
GroupCell * FirstError() const
The first GroupCell with error that is still in the list.
Definition: CellPointers.cpp:103
EditorCell
Definition: EditorCell.h:57
CellPointers::ErrorList::Empty
bool Empty() const
Is the list of errors empty?
Definition: CellPointers.h:74
CellPointers
Definition: CellPointers.h:44
CellPointers::m_currentTextCell
CellPtr< TextCell > m_currentTextCell
The textcell the text maxima is sending us was ending in.
Definition: CellPointers.h:111
CellPointers::m_cellUnderPointer
CellPtr< Cell > m_cellUnderPointer
The cell currently under the mouse pointer.
Definition: CellPointers.h:158
CellPointers::m_cellSearchStartedIn
CellPtr< EditorCell > m_cellSearchStartedIn
The EditorCell the search was started in.
Definition: CellPointers.h:99
CellPointers::ErrorList::Contains
bool Contains(GroupCell *cell) const
Does the list of GroupCell with errors contain cell?
Definition: CellPointers.cpp:85
CellPointers::ResetKeyboardSelectionStart
void ResetKeyboardSelectionStart()
Forget where the keyboard selection was started.
Definition: CellPointers.h:136
CellPointers::ErrorList::Add
void Add(GroupCell *cell)
Mark this GroupCell as containing errors.
Definition: CellPointers.cpp:90
CellPointers::m_answerCell
CellPtr< EditorCell > m_answerCell
The EditorCell that contains the currently active question from maxima.
Definition: CellPointers.h:107
CellPointers::ErrorList::LastError
GroupCell * LastError() const
The last GroupCell with errors in the list.
Definition: CellPointers.cpp:106
CellPointers::ErrorList::Remove
void Remove(GroupCell *cell)
Remove one specific GroupCell from the list of errors.
Definition: CellPointers.cpp:80
GroupCell
Definition: GroupCell.h:68
CellPointers::ResetMouseSelectionStart
void ResetMouseSelectionStart()
Forget where the mouse selection was started.
Definition: CellPointers.h:132
CellPointers::m_cellKeyboardSelectionStartedIn
CellPtr< EditorCell > m_cellKeyboardSelectionStartedIn
The EditorCell the keyboard selection has started in.
Definition: CellPointers.h:97
CellPointers::SetWorkingGroup
void SetWorkingGroup(GroupCell *group)
Sets the cell maxima currently works on. NULL if there isn't such a cell.
Definition: CellPointers.cpp:93
CellPointers::ErrorList
A list of editor cells containing error messages.
Definition: CellPointers.h:69
wxScrolled
Definition: CellPointers.h:32
CellPointers::m_errorList
ErrorList m_errorList
The list of cells maxima has complained about errors in.
Definition: CellPointers.h:93