wxMaxima
Loading...
Searching...
No Matches
MatrixViewer.h
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
22#ifndef MATRIXVIEWER_H
23#define MATRIXVIEWER_H
24
25#include "precomp.h"
26#include <wx/wx.h>
27#include <wx/fdrepdlg.h>
28#include <memory>
29#include <optional>
30#include "cells/MatrixBlock.h"
32
33class Cell;
34class Configuration;
36class GroupCell;
37class MatrCell;
38class Worksheet;
39namespace WorksheetSearch { class Matcher; }
40
69class MatrixViewer : public wxFrame
70{
71public:
80 MatrixViewer(wxWindow *parent, const MatrCell &matrix, Configuration *config);
81 ~MatrixViewer() override;
82
84 Worksheet *GetWorksheet() const { return m_worksheet; }
86 MatrCell *GetMatrix() const;
87
92 void OpenFindDialog();
94 FindReplaceDialog *GetFindDialog() const { return m_findDialog; }
95
110 bool FindNext(const wxString &str, bool down, bool ignoreCase, bool regex,
111 bool warn = true);
112
132 static std::optional<MatrixEntry> FindEntry(const MatrCell &matrix,
133 std::optional<MatrixEntry> start,
134 bool down, bool inclusive,
135 const WorksheetSearch::Matcher &matcher,
136 bool *wrapped = nullptr);
138
153 static void ConfigureForViewer(Configuration &config);
154
162 static std::unique_ptr<GroupCell> CopyForViewer(const MatrCell &matrix,
163 Configuration *config);
164
175 static MatrCell *PartiallyShownMatrixAt(const GroupCell *group, wxPoint point);
176
177private:
179 static MatrCell *PartiallyShownMatrixIn(Cell *list, wxPoint point);
181 void OnIdle(wxIdleEvent &event);
183 void OnCharHook(wxKeyEvent &event);
185 void OnFind(wxFindDialogEvent &event);
187 void IncrementalSearch();
189 void SelectEntry(const MatrixEntry &entry);
191 std::optional<MatrixEntry> SelectedEntry() const;
193 void FitToMatrix();
194
200 std::unique_ptr<Configuration> m_configuration;
202 Worksheet *m_worksheet = nullptr;
208 FindReplaceDialog *m_findDialog = nullptr;
217 std::optional<MatrixEntry> m_searchOrigin;
219 wxString m_oldFindString;
220 long m_oldFindFlags = 0;
221 bool m_oldRegexSearch = false;
222};
223
224#endif // MATRIXVIEWER_H
This file defines the class FindReplacePane.
int group
Neighbouring sections of the same group aren't separated.
Definition: ToolBarSections.cpp:45
The base class all cell types the worksheet can consist of are derived from.
Definition: Cell.h:148
The configuration storage for the current worksheet.
Definition: Configuration.h:101
The find+replace dialog.
Definition: FindReplaceDialog.h:42
Definition: FindReplacePane.h:51
A cell grouping input (and, if there is one, also the output) cell to a foldable item.
Definition: GroupCell.h:88
A Cell that displays a matrix.
Definition: MatrCell.h:95
A window that shows a matrix the worksheet only shows part of (GH #2344)
Definition: MatrixViewer.h:70
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.
Definition: MatrixViewer.cpp:339
static std::unique_ptr< GroupCell > CopyForViewer(const MatrCell &matrix, Configuration *config)
A group cell whose output is a copy of this matrix.
Definition: MatrixViewer.cpp:106
Worksheet * GetWorksheet() const
The worksheet the viewer shows the matrix in.
Definition: MatrixViewer.h:84
static MatrCell * PartiallyShownMatrixAt(const GroupCell *group, wxPoint point)
The matrix a double-click at this point should open a viewer for.
Definition: MatrixViewer.cpp:132
static void ConfigureForViewer(Configuration &config)
Makes a copy of the worksheet's configuration suitable for the viewer.
Definition: MatrixViewer.cpp:88
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.
Definition: MatrixViewer.cpp:372
MatrCell * GetMatrix() const
The viewer's copy of the matrix.
Definition: MatrixViewer.cpp:209
FindReplaceDialog * GetFindDialog() const
The search dialog, or nullptr if it hasn't been opened.
Definition: MatrixViewer.h:94
void OpenFindDialog()
Opens the search dialog (Ctrl+F), or brings it to the front.
Definition: MatrixViewer.cpp:225
Matches a search expression against worksheet text.
Definition: WorksheetSearch.h:56
The canvas that contains the spreadsheet the whole program is about.
Definition: Worksheet.h:121
One entry of a matrix, by its zero-based row and column.
Definition: MatrixBlock.h:30