wxMaxima
Loading...
Searching...
No Matches
SymbolShortcutsPanel.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
26#ifndef SYMBOLSHORTCUTSPANEL_H
27#define SYMBOLSHORTCUTSPANEL_H
28
29#include <vector>
30#include <wx/grid.h>
31#include <wx/panel.h>
32#include "SymbolShortcuts.h"
33
34class Configuration;
35
49class SymbolShortcutsPanel : public wxPanel
50{
51public:
53 enum class Location { GreekLowercase, GreekUppercase, SymbolsBuiltIn, SymbolsExtra };
59 static Location Locate(const wxString &symbol, const Configuration *configuration);
61 static wxString LocationName(Location location);
62
64 struct Row
65 {
66 wxString symbol;
67 wxString shortcut;
68 bool operator==(const Row &) const = default;
69 };
70
71 SymbolShortcutsPanel(wxWindow *parent, const Configuration *configuration);
72
74 void Write(Configuration *configuration) const;
75
77 const std::vector<Row> &GetRows() const { return m_rows; }
83 void SetSymbolText(int row, const wxString &text);
85 void AddRow();
87 void RemoveRow(int row);
93 void SetShortcut(int row, const wxString &shortcut);
94
99 static std::vector<Row> RowsFor(const wxString &extraSymbols,
100 const std::vector<wxm::SymbolShortcut> &shortcuts);
102 wxString ExtraSymbols() const;
103
104private:
106 void Fill();
107 void OnCellChanged(wxGridEvent &event);
108 void OnCellDClick(wxGridEvent &event);
109 void OnGridKey(wxKeyEvent &event);
111 void EditSelectedShortcut();
113 int SelectedRow() const;
114
115 std::vector<Row> m_rows;
117 const Configuration *m_configuration;
118 wxGrid *m_grid;
119};
120
121#endif // SYMBOLSHORTCUTSPANEL_H
Keyboard shortcuts that type a symbol into the worksheet (GH #2578).
The configuration storage for the current worksheet.
Definition: Configuration.h:102
The extra symbols of the Symbols sidebar, and the keyboard shortcuts of every symbol (GH #2578).
Definition: SymbolShortcutsPanel.h:50
static Location Locate(const wxString &symbol, const Configuration *configuration)
Which sidebar shows this symbol.
Definition: SymbolShortcutsPanel.cpp:53
wxString ExtraSymbols() const
The extra symbols Write() stores for these rows.
Definition: SymbolShortcutsPanel.cpp:291
void Write(Configuration *configuration) const
Stores the extra symbols and the shortcuts in the configuration.
Definition: SymbolShortcutsPanel.cpp:300
void SetSymbolText(int row, const wxString &text)
Puts what is typed into a row's "Symbol" cell there.
Definition: SymbolShortcutsPanel.cpp:178
void AddRow()
Adds an empty row and starts editing its symbol.
Definition: SymbolShortcutsPanel.cpp:206
static std::vector< Row > RowsFor(const wxString &extraSymbols, const std::vector< wxm::SymbolShortcut > &shortcuts)
The rows Write() would store for this text field content and shortcuts.
Definition: SymbolShortcutsPanel.cpp:81
void RemoveRow(int row)
Removes a row.
Definition: SymbolShortcutsPanel.cpp:216
void SetShortcut(int row, const wxString &shortcut)
Gives a row's symbol a shortcut, or none if shortcut is empty.
Definition: SymbolShortcutsPanel.cpp:223
const std::vector< Row > & GetRows() const
The rows, in the order the table shows them.
Definition: SymbolShortcutsPanel.h:77
Location
Where a symbol is shown.
Definition: SymbolShortcutsPanel.h:53
static wxString LocationName(Location location)
The text the "Where" column shows for a location.
Definition: SymbolShortcutsPanel.cpp:67
One row of the table.
Definition: SymbolShortcutsPanel.h:65
wxString shortcut
raw, see wxm::SymbolShortcut
Definition: SymbolShortcutsPanel.h:67