wxMaxima
Loading...
Searching...
No Matches
WorksheetLayout.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
36#ifndef WORKSHEETLAYOUT_H
37#define WORKSHEETLAYOUT_H
38
39#include "WorksheetSizeMath.h"
40#include "cells/CellPtr.h"
41#include <functional>
42
43class Cell;
44class GroupCell;
45class Configuration;
46
55public:
66 std::function<GroupCell *()> getTree,
67 std::function<GroupCell *()> getLastCell);
68 // Holds a reference to its view and is bound to one worksheet's tree
69 // callbacks; copying would alias that ownership.
70 WorksheetLayout(const WorksheetLayout &) = delete;
71 WorksheetLayout &operator=(const WorksheetLayout &) = delete;
72
83 void RequestRecalculation(Cell *start);
84
94
104 bool RecalculateIfNeeded(bool timeout = false, long timeSliceMs = 50);
105
112 void AdjustSize();
113
118 void GetMaxPoint(int *width, int *height);
119
122
129 int GroupCellWidthWithMargins(int cellWidth) const;
130
134 int GetScrollUnit() const { return m_scrollUnit; }
135
143 void RequestAdjustSize() { m_adjustWorksheetSizeNeeded = true; }
144
147 m_recalculateStart = nullptr;
148 m_recalculateEnd = nullptr;
149 }
150
156 int GetLastCellsVisited() const { return m_lastCellsVisited; }
157 int GetLastCellsRecalculated() const { return m_lastCellsRecalculated; }
158
159private:
161 Configuration *m_configuration;
163 WorksheetView &m_view;
165 std::function<GroupCell *()> m_getTree;
167 std::function<GroupCell *()> m_getLastCell;
169 CellPtr<GroupCell> m_recalculateStart;
180 CellPtr<GroupCell> m_recalculateEnd;
182 int m_maxWidth_Cached = -1;
184 WorksheetVirtualSizeCache m_virtualSizeCache;
190 int m_scrollUnit = 10;
192 bool m_adjustWorksheetSizeNeeded = false;
195 int m_lastCellsVisited = 0;
196 int m_lastCellsRecalculated = 0;
197};
198
199#endif // WORKSHEETLAYOUT_H
Implementation of an observing weak Cell pointer.
The pure arithmetic that turns a laid-out worksheet's extent into the scrollable (virtual) size and s...
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
The configuration storage for the current worksheet.
Definition: Configuration.h:98
A cell grouping input (and, if there is one, also the output) cell to a foldable item.
Definition: GroupCell.h:88
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
int GetScrollUnit() const
The scroll granularity (device px per scroll unit) AdjustSize() last applied.
Definition: WorksheetLayout.h:134
int GroupCellWidthWithMargins(int cellWidth) const
The horizontal space a group cell of the given width occupies.
Definition: WorksheetLayout.cpp:252
bool RecalculateIfNeeded(bool timeout=false, long timeSliceMs=50)
Perform the scheduled recalculation, if one is pending.
Definition: WorksheetLayout.cpp:41
void CancelPendingRecalculation()
Drop any pending recalculation (e.g. when the document is cleared).
Definition: WorksheetLayout.h:146
The narrow view surface the worksheet's layout pipeline needs.
Definition: WorksheetSizeMath.h:172
Remembers the last virtual size applied, so an unchanged size is a no-op.
Definition: WorksheetSizeMath.h:188