wxMaxima
Loading...
Searching...
No Matches
WorksheetCursor.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) 2026 Gunter Königsmann <wxMaxima@physikbuch.de>
4//
5// This program is free software; you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation; either version 2 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15//
16// You should have received a copy of the GNU General Public License
17// along with this program; if not, write to the Free Software
18// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19//
20// SPDX-License-Identifier: GPL-2.0+
21
40#ifndef WORKSHEETCURSOR_H
41#define WORKSHEETCURSOR_H
42
43#include "cells/CellPtr.h"
44
45class GroupCell;
46
49{
50public:
52 bool IsActive() const { return m_active; }
54 void Activate() { m_active = true; }
56 void Deactivate() { m_active = false; }
57
62 GroupCell *Position() const { return m_position; }
64 void SetPosition(GroupCell *where) { m_position = where; }
65
71 GroupCell *SelectionStart() const { return m_selectionStart; }
73 GroupCell *SelectionEnd() const { return m_selectionEnd; }
74 void SetSelectionStart(GroupCell *start) { m_selectionStart = start; }
75 void SetSelectionEnd(GroupCell *end) { m_selectionEnd = end; }
78 { m_selectionStart = start; m_selectionEnd = end; }
80 void ClearSelectionAnchors() { SetSelectionAnchors(nullptr, nullptr); }
81
82private:
83 bool m_active = true;
84 CellPtr<GroupCell> m_position;
85 CellPtr<GroupCell> m_selectionStart;
86 CellPtr<GroupCell> m_selectionEnd;
87};
88
89#endif // WORKSHEETCURSOR_H
Implementation of an observing weak Cell pointer.
A weak non-owning pointer that becomes null whenever the observed object is destroyed.
Definition: CellPtr.h:511
A cell grouping input (and, if there is one, also the output) cell to a foldable item.
Definition: GroupCell.h:87
The between-the-cells cursor: active flag, position, selection anchors.
Definition: WorksheetCursor.h:49
void SetPosition(GroupCell *where)
Move the cursor below the given group cell (null = document start).
Definition: WorksheetCursor.h:64
void ClearSelectionAnchors()
Forget the select-with-the-caret gesture.
Definition: WorksheetCursor.h:80
void SetSelectionAnchors(GroupCell *start, GroupCell *end)
Set both ends of the select-with-the-caret gesture at once.
Definition: WorksheetCursor.h:77
void Deactivate()
Deactivate; the position is kept for a later re-activation.
Definition: WorksheetCursor.h:56
GroupCell * SelectionEnd() const
Where a select-with-the-caret gesture currently ends.
Definition: WorksheetCursor.h:73
void Activate()
Make this the active cursor. The caller deactivates the editor cursor.
Definition: WorksheetCursor.h:54
bool IsActive() const
Is this (rather than the in-cell text cursor) the active cursor?
Definition: WorksheetCursor.h:52
GroupCell * Position() const
The group cell the cursor sits below; null = above the first cell.
Definition: WorksheetCursor.h:62
GroupCell * SelectionStart() const
Where a select-with-the-caret gesture started.
Definition: WorksheetCursor.h:71