wxMaxima
Loading...
Searching...
No Matches
SymbolShortcutDialog.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 SYMBOLSHORTCUTDIALOG_H
27#define SYMBOLSHORTCUTDIALOG_H
28
29#include <functional>
30#include <vector>
31#include <wx/dialog.h>
32#include <wx/stattext.h>
33#include "SymbolShortcuts.h"
34
35class wxMenuBar;
36
49class SymbolShortcutDialog : public wxDialog
50{
51public:
55 using UsageLookup = std::function<wxString(const wxString &rawShortcut)>;
56
57 SymbolShortcutDialog(wxWindow *parent, const wxString &symbol,
58 const wxString &currentShortcut, UsageLookup usage);
59
64 const wxString &GetShortcut() const { return m_shortcut; }
65
71 bool RecordKey(const wxKeyEvent &event);
72
78 static wxString MenuItemUsingShortcut(const wxMenuBar *menuBar,
79 const wxString &rawShortcut);
81 static wxMenuBar *FindMenuBar(wxWindow *window);
85 static UsageLookup MakeUsageLookup(wxWindow *window,
86 std::vector<wxm::SymbolShortcut> shortcuts,
87 const wxString &symbol);
88
89private:
90 void OnCharHook(wxKeyEvent &event);
91 void OnRemove(wxCommandEvent &event);
93 void ShowShortcut();
94
95 wxString m_shortcut;
96 UsageLookup m_usage;
97 wxStaticText *m_shortcutText;
98 wxStaticText *m_warning;
99};
100
101#endif // SYMBOLSHORTCUTDIALOG_H
Keyboard shortcuts that type a symbol into the worksheet (GH #2578).
Asks the user to press the keys that should type a symbol.
Definition: SymbolShortcutDialog.h:50
static UsageLookup MakeUsageLookup(wxWindow *window, std::vector< wxm::SymbolShortcut > shortcuts, const wxString &symbol)
The usual UsageLookup: the menu entries of window's main window and the symbols in shortcuts other th...
Definition: SymbolShortcutDialog.cpp:163
bool RecordKey(const wxKeyEvent &event)
Records a key press as if the user had pressed it.
Definition: SymbolShortcutDialog.cpp:85
std::function< wxString(const wxString &rawShortcut)> UsageLookup
Describes what a shortcut is already used for: a menu entry's or another symbol's name,...
Definition: SymbolShortcutDialog.h:55
static wxString MenuItemUsingShortcut(const wxMenuBar *menuBar, const wxString &rawShortcut)
What the menu bar already uses this shortcut for.
Definition: SymbolShortcutDialog.cpp:149
static wxMenuBar * FindMenuBar(wxWindow *window)
The menu bar of the main window window belongs to, if any.
Definition: SymbolShortcutDialog.cpp:118
const wxString & GetShortcut() const
The recorded shortcut, in the raw form wxm::SymbolShortcut stores.
Definition: SymbolShortcutDialog.h:64