|
wxMaxima
|
The layout/recalculation engine of a worksheet. More...
#include <WorksheetLayout.h>
Public Member Functions | |
| WorksheetLayout (Configuration *config, WorksheetView &view, std::function< GroupCell *()> getTree, std::function< GroupCell *()> getLastCell) | |
| Construct the engine. | |
| WorksheetLayout (const WorksheetLayout &)=delete | |
| WorksheetLayout & | operator= (const WorksheetLayout &)=delete |
| void | RequestRecalculation (Cell *start) |
| Schedule a recalculation of the worksheet starting with the cell start. | |
| bool | RecalculateIfNeeded (bool timeout=false, long timeSliceMs=50) |
| Perform the scheduled recalculation, if one is pending. | |
| void | AdjustSize () |
| Adjust the virtual size and scrollbars to the document's extent. | |
| void | GetMaxPoint (int *width, int *height) |
| Get the coordinates of the bottom right point of the worksheet. | |
| void | UpdateConfigurationClientSize () |
| Inform the configuration about the view's current client size. | |
| int | GroupCellWidthWithMargins (int cellWidth) const |
| The horizontal space a group cell of the given width occupies. | |
| int | GetScrollUnit () const |
| The scroll granularity (device px per scroll unit) AdjustSize() last applied. | |
| void | RequestAdjustSize () |
| Flag the virtual (scroll) size as needing re-adjustment. | |
| void | CancelPendingRecalculation () |
| Drop any pending recalculation (e.g. when the document is cleared). | |
The layout/recalculation engine of a worksheet.
Talks to the cell tree via the callbacks handed to the constructor, to the window via a WorksheetView and to the Configuration for metrics and the canvas size. Worksheet holds one instance and forwards its layout entry points here; the headless unit test drives an instance without any window.
| WorksheetLayout::WorksheetLayout | ( | Configuration * | config, |
| WorksheetView & | view, | ||
| std::function< GroupCell *()> | getTree, | ||
| std::function< GroupCell *()> | getLastCell | ||
| ) |
Construct the engine.
| config | The Configuration supplying metrics, the canvas size and the recalculation drawing context. |
| view | The window surface (real Worksheet or a test mock). Held by reference: must outlive this object. |
| getTree | Returns the first GroupCell of the worksheet (or null). |
| getLastCell | Returns the last GroupCell of the worksheet (or null). |
| void WorksheetLayout::AdjustSize | ( | ) |
Adjust the virtual size and scrollbars to the document's extent.
Defers (via RequestAdjustSize()) while a recalculation is still pending, since the cell positions it reads would be stale - see the implementation comment for the full story.
| void WorksheetLayout::GetMaxPoint | ( | int * | width, |
| int * | height | ||
| ) |
Get the coordinates of the bottom right point of the worksheet.
Only valid once no recalculation is pending; asserts on that.
|
inline |
The scroll granularity (device px per scroll unit) AdjustSize() last applied.
Worksheet's scroll handlers read it to convert scroll positions to pixels.
| int WorksheetLayout::GroupCellWidthWithMargins | ( | int | cellWidth | ) | const |
The horizontal space a group cell of the given width occupies.
That is the cell's own width plus the equal left and right margins the worksheet reserves around every group cell. Used both when measuring the document width (GetMaxPoint) and while walking the recalculation.
| bool WorksheetLayout::RecalculateIfNeeded | ( | bool | timeout = false, |
| long | timeSliceMs = 50 |
||
| ) |
Perform the scheduled recalculation, if one is pending.
One walk from the scheduled start point drives both modes: with timeout set the pass is time-sliced (yields after timeSliceMs, resuming on the next call); otherwise the whole scheduled range is laid out in one go. Ends by adjusting the virtual size once the cell positions are valid.
|
inline |
Flag the virtual (scroll) size as needing re-adjustment.
Set when a cell changed height (via the callback Worksheet registers on the Configuration, so cells can flag it without depending on the view) or when layout is scheduled; consumed by RecalculateIfNeeded(), which calls AdjustSize() once the cell positions are valid.
| void WorksheetLayout::RequestRecalculation | ( | Cell * | start | ) |
Schedule a recalculation of the worksheet starting with the cell start.
This only records where the next layout pass has to start (it marks the group dirty and moves m_recalculateStart); it does not size or position any cell. The actual work - and, crucially, AdjustSize() once the cell positions are correct - happens in RecalculateIfNeeded(). Calling AdjustSize() (or otherwise reading cell geometry) right after this, without a RecalculateIfNeeded() in between, reads stale positions.