wxMaxima
Loading...
Searching...
No Matches
CharButton.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) 2009-2015 Andrej Vodopivec <andrej.vodopivec@gmail.com>
4// (C) 2014-2015 Gunter Königsmann <wxMaxima@physikbuch.de>
5//
6// This program is free software; you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation; either version 2 of the License, or
9// (at your option) any later version.
10//
11// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15//
16//
17// You should have received a copy of the GNU General Public License
18// along with this program; if not, write to the Free Software
19// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20//
21// SPDX-License-Identifier: GPL-2.0+
22
23#ifndef CHARBUTTON_H
24#define CHARBUTTON_H
25
31#include "precomp.h"
32#include "StringUtils.h"
33#include "Configuration.h"
34#include <wx/panel.h>
35#include <wx/stattext.h>
36
40class CharButton : public wxPanel
41{
42public:
45 {
51 wxString symbol;
52 const wxString description = wxm::emptyString;
53 bool matchesMaximaCommand = false;
54 };
55
62 CharButton(wxWindow *parent, wxWindow *worksheet, Configuration *config,
63 const Definition &def,
64 bool forceShow = false);
65 wxWindow *GetTextObject() const { return m_buttonText; }
67 const wxString &GetSymbol() const { return m_symbol; }
72 static CharButton *FromEventObject(wxObject *object);
77 static bool EditShortcut(wxWindow *parent, Configuration *configuration,
78 const wxString &symbol);
85 static wxString AppendShortcutMenuItem(wxMenu *menu, const wxMouseEvent &event);
91 void UpdateToolTip();
94 void ActivateButton();
95#if wxUSE_ACCESSIBILITY
98 wxString GetAccessibleLabel() const {
99 return m_description.IsEmpty() ? m_symbol : m_description;
100 }
101#endif
108 void UpdateMinSize();
109protected:
110 wxString m_symbol;
111 Configuration *m_configuration;
112 void CharButtonPressed(wxMouseEvent &event);
113 void OnSize(wxSizeEvent &event);
114 void OnIdleEvent(wxIdleEvent &event);
115 void MouseOverPanel(wxMouseEvent &event);
116 void MouseOverText(wxMouseEvent &event);
117 void MouseLeftPanel(wxMouseEvent &event);
118 void MouseLeftText(wxMouseEvent &event);
119protected:
120 void MouseOverTextIs(bool mouseOver = true);
121 void MouseOverPanelIs(bool mouseOver = true);
122 wxString m_description;
126 wxString m_toolTip;
127
128private:
129 bool m_mouseOverPanel = false;
130 bool m_mouseOverText = false;
131 bool m_backgroundColorChangeNeeded = false;
132 wxStaticText *m_buttonText;
133 wxWindow *m_worksheet;
134};
135
136#endif // CHARBUTTON_H
This class generates a pane containing the last commands that were issued.
Definition: CharButton.h:41
void UpdateMinSize()
Sets the min size the button needs to show its symbol.
Definition: CharButton.cpp:234
const wxString & GetSymbol() const
The symbol this button enters.
Definition: CharButton.h:67
wxString m_toolTipBase
The tooltip without the keyboard shortcut.
Definition: CharButton.h:124
wxString m_toolTip
The tooltip as last set.
Definition: CharButton.h:126
static wxString AppendShortcutMenuItem(wxMenu *menu, const wxMouseEvent &event)
Adds the "Keyboard shortcut for..." entry to a sidebar's context menu.
Definition: CharButton.cpp:145
void UpdateToolTip()
Shows the symbol's keyboard shortcut, if it has one, in the tooltip.
Definition: CharButton.cpp:160
static CharButton * FromEventObject(wxObject *object)
The button a mouse event in a sidebar happened on, or nullptr.
Definition: CharButton.cpp:118
static bool EditShortcut(wxWindow *parent, Configuration *configuration, const wxString &symbol)
Asks for the keyboard shortcut that types symbol and stores it.
Definition: CharButton.cpp:131
void ActivateButton()
Emit this button's symbol to the worksheet – the button's action, shared by the mouse handler and the...
Definition: CharButton.cpp:107
The configuration storage for the current worksheet.
Definition: Configuration.h:102
A definition of this button, used to construct it.
Definition: CharButton.h:45
wxString symbol
The symbol this button enters.
Definition: CharButton.h:51
bool matchesMaximaCommand
Whether this symbol is automatically translated into a maxima command/operator.
Definition: CharButton.h:53
const wxString description
The help text for the symbol.
Definition: CharButton.h:52