|
wxMaxima
|
The pure arithmetic that turns a laid-out worksheet's extent into the scrollable (virtual) size and scroll granularity. More...
#include <algorithm>#include <vector>Go to the source code of this file.
Data Structures | |
| struct | TrailingGroupGeometry |
| One trailing group cell's geometry, as GetMaxPoint's height walk needs it. More... | |
| struct | WorksheetVirtualSize |
| The scrollable size + scroll granularity computed for a worksheet. More... | |
| class | WorksheetView |
| The narrow view surface the worksheet's layout pipeline needs. More... | |
| struct | WorksheetVirtualSizeCache |
| Remembers the last virtual size applied, so an unchanged size is a no-op. More... | |
Functions | |
| int | ComputeWorksheetContentWidth (const std::vector< int > &cellWidthsWithMargins, int baseIndent) |
| Compute the worksheet's content width. | |
| int | ComputeWorksheetContentHeight (const std::vector< TrailingGroupGeometry > &trailing, int groupSkip, int baseIndent) |
| Compute the worksheet's content height from its trailing cells' geometry. | |
| WorksheetVirtualSize | ComputeWorksheetVirtualSize (bool hasTree, int maxPointWidth, int maxPointHeight, int clientHeight, int currentScrollPixelY) |
| Compute a worksheet's virtual size and scroll unit. | |
| void | ApplyWorksheetVirtualSize (WorksheetView &view, bool hasTree, int maxWidth, int maxHeight, WorksheetVirtualSizeCache &cache, int &scrollUnit) |
| Measure the view, compute the virtual size and apply it, skipping no-ops. | |
The pure arithmetic that turns a laid-out worksheet's extent into the scrollable (virtual) size and scroll granularity.
Kept deliberately free of any GUI/wxWidgets dependency so the scroll-range math - historically a source of "the pane won't scroll" bugs - can be unit-tested in isolation. WorksheetLayout::AdjustSize() measures the document (GetMaxPoint) and the window (GetClientSize) and feeds the numbers here, then applies the result with SetVirtualSize()/SetScrollRate().
|
inline |
Measure the view, compute the virtual size and apply it, skipping no-ops.
This is the view-facing half of WorksheetLayout::AdjustSize(): it reads the client size and scroll position from view, feeds them (with the already-measured document extent maxWidth / maxHeight) to ComputeWorksheetVirtualSize(), and - only if the result actually changed and is positive - pushes it back to the view and updates the scroll rate.
| view | The window abstraction (real worksheet or a test mock). |
| hasTree | Whether the worksheet has content (ignores the extent if not). |
| maxWidth | The document's right extent (WorksheetLayout::GetMaxPoint x). |
| maxHeight | The document's bottom extent (WorksheetLayout::GetMaxPoint y). |
| cache | The last-applied size, updated in place to dedupe. |
| scrollUnit | Read to turn the scroll position into pixels, and updated to the new granularity. WorksheetLayout keeps it as a member because Worksheet's scroll handlers read it too. |
|
inline |
Compute the worksheet's content height from its trailing cells' geometry.
This is the backward walk WorksheetLayout::GetMaxPoint() runs from the last cell: it accumulates the heights of the cells at the bottom whose position is not yet trustworthy (stale-and-unpositioned, or still-being-laid-out) until it reaches an "anchor" - a cell whose size is stale but whose top position (y) is already valid - and pins the total to that anchor's top plus everything accumulated below it. If the walk runs off the top of the document (no such anchor), the height falls back to the document's base indent plus the accumulated heights.
| trailing | The cells starting at the LAST cell and running backward. The walk stops at (and includes) the first entry that is the anchor, i.e. sizeIsStale && currentY >= 0. |
| groupSkip | The vertical gap between group cells (Configuration::GetGroupSkip). |
| baseIndent | The document's top margin (Configuration::GetBaseIndent), used only when there is no anchor. |
Kept GUI-free (no Cell/Configuration dependency) so this fiddly stale-cell accounting can be unit-tested in isolation - see test_WorksheetSizeMath.
|
inline |
Compute the worksheet's content width.
That is the document's base indent, widened to fit the widest group cell. Each entry in cellWidthsWithMargins is a cell's width including its left and right margins (WorksheetLayout::GroupCellWidthWithMargins).
| cellWidthsWithMargins | Per-cell widths (already including margins). |
| baseIndent | The minimum width (Configuration::GetBaseIndent). |
Kept GUI-free (no Cell/Configuration dependency) so it can be unit-tested in isolation - see test_WorksheetSizeMath.
|
inline |
Compute a worksheet's virtual size and scroll unit.
| hasTree | Whether the worksheet has any content. Without it the result is a small fixed size with a sane scroll unit. |
| maxPointWidth | The document's right extent (WorksheetLayout::GetMaxPoint x). |
| maxPointHeight | The document's bottom extent (WorksheetLayout::GetMaxPoint y). |
| clientHeight | The visible height of the worksheet window. |
| currentScrollPixelY | The current vertical scroll offset in pixels. |
Invariants (that the callers rely on):