|
wxMaxima
|
A window that shows a matrix the worksheet only shows part of (GH #2344) More...
#include <MatrixViewer.h>
Public Member Functions | |
| MatrixViewer (wxWindow *parent, const MatrCell &matrix, Configuration *config) | |
| Opens a viewer showing this matrix. | |
| Worksheet * | GetWorksheet () const |
| The worksheet the viewer shows the matrix in. | |
| MatrCell * | GetMatrix () const |
| The viewer's copy of the matrix. | |
Static Public Member Functions | |
| static void | ConfigureForViewer (Configuration &config) |
| Makes a copy of the worksheet's configuration suitable for the viewer. | |
| static std::unique_ptr< GroupCell > | CopyForViewer (const MatrCell &matrix, Configuration *config) |
| A group cell whose output is a copy of this matrix. | |
| static MatrCell * | PartiallyShownMatrixAt (const GroupCell *group, wxPoint point) |
| The matrix a double-click at this point should open a viewer for. | |
Searching the matrix | |
| void | OpenFindDialog () |
| Opens the search dialog (Ctrl+F), or brings it to the front. | |
| FindReplaceDialog * | GetFindDialog () const |
| The search dialog, or nullptr if it hasn't been opened. | |
| bool | FindNext (const wxString &str, bool down, bool ignoreCase, bool regex, bool warn=true) |
| Selects the next entry that matches, and scrolls it into view. | |
| static std::optional< MatrixEntry > | FindEntry (const MatrCell &matrix, std::optional< MatrixEntry > start, bool down, bool inclusive, const WorksheetSearch::Matcher &matcher, bool *wrapped=nullptr) |
| The next entry of a matrix whose text matches. | |
A window that shows a matrix the worksheet only shows part of (GH #2344)
A matrix too large for the window is elided or scrolls (see MatrCell). Double-clicking one opens this viewer, which shows a copy of the whole matrix – every row and every column – in a worksheet of its own that scrolls as far as the matrix needs.
The viewer is independent of the matrix it was opened from: it takes a copy (through the matrix's XML, so the copy's cells belong to the viewer's own Configuration), so re-evaluating or deleting the original doesn't affect it, and several viewers can be open at once. It is read-only: its worksheet doesn't react to clicks or keys, so nothing can be typed into it or evaluated there.
The viewer's Configuration is a copy of the worksheet's, so the matrix looks the same as in the worksheet (fonts, colours, zoom), except that ConfigureForViewer() makes it show every matrix in full, whatever wx_matrix()'s oversized option asked for, hides the input and the output label and doesn't indent the output. The matrix itself is shown without brackets and with alternating row and column bands (see CopyForViewer()).
Ctrl+F opens a search dialog that searches the matrix entry by entry: each match selects its entry, as a click on it would, and scrolls it into view (see FindNext()). Only the entries are searched, not the matrix as a whole: the worksheet's own search, which knows only whole output cells, would find the one matrix and nothing inside it.
| MatrixViewer::MatrixViewer | ( | wxWindow * | parent, |
| const MatrCell & | matrix, | ||
| Configuration * | config | ||
| ) |
Opens a viewer showing this matrix.
| parent | The window the viewer belongs to; it closes with it. |
| matrix | The matrix to show. Only copied: the viewer keeps no reference to it. |
| config | The worksheet's configuration, which the viewer's own is copied from. |
|
static |
Makes a copy of the worksheet's configuration suitable for the viewer.
Shows every matrix in full – the configuration doesn't let a matrix ask for anything else, so a nested matrix or one made by wx_matrix(..., oversized=elide) is shown in full, too – and hides the code cell's (empty) input, the output label and the cell brackets, and moves the output to the left margin. Makes the configuration temporary, so none of that is written to the config file when it is destroyed.
Call it only once the viewer's worksheet exists: the worksheet's constructor reads the config file into the configuration, undoing anything set before.
|
static |
A group cell whose output is a copy of this matrix.
The copy is made through the matrix's XML, parsed with config, so every cell of it belongs to config – which a Cell::Copy() would not ensure. The output label is empty: the viewer shows only the matrix. The copy has no brackets and is banded (MatrCell::AlwaysBanded()).
|
static |
The next entry of a matrix whose text matches.
| matrix | The matrix to search |
| start | The entry to start at; std::nullopt = before the first entry (searching down) or after the last one (searching up) |
| down | Search row by row, left to right, or backwards |
| inclusive | Can start itself be the match? True for a search that is refined while the search term is typed, false for one that steps to the next match. |
| matcher | What counts as a match |
| wrapped | If not nullptr, set to whether the search went past the end of the matrix and started over |
An entry matches if the text of all of it (Cell::ListToString()) does. Every entry counts, including ones the worksheet would elide, and even start itself is checked last, after a full round. std::nullopt if no entry matches.
| bool MatrixViewer::FindNext | ( | const wxString & | str, |
| bool | down, | ||
| bool | ignoreCase, | ||
| bool | regex, | ||
| bool | warn = true |
||
| ) |
Selects the next entry that matches, and scrolls it into view.
| str | What to search for |
| down | Search in reading order (row by row), or backwards |
| ignoreCase | Only for a plain search: a regex decides that itself |
| regex | Is str a regular expression? |
| warn | Tell the user if nothing matched, or if the search went past the end and started over |
Starts behind the selected entry, or at the first (or, searching backwards, the last) entry if none is selected, and wraps around, so repeating it steps through all matches. If the selected entry is the only match, it stays selected. Returns false if nothing matched.
The matrix a double-click at this point should open a viewer for.
| group | The group cell that was double-clicked. |
| point | The point that was clicked, in worksheet (unscrolled) coordinates. |
Returns the outermost matrix at that point that the worksheet only shows part of (MatrCell::IsShownPartially()), or nullptr if there is none: a matrix that fits the window has nothing more to show.