wxMaxima
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 
26 #include "wx/stattext.h"
27 
33 #include "precomp.h"
34 #include "StringUtils.h"
35 #include "Configuration.h"
36 #include <wx/panel.h>
37 
41 class CharButton : public wxPanel
42 {
43 public:
45  struct Definition
46  {
47  wchar_t symbol = {};
48  const wxString description = wxm::emptyString;
49  bool matchesMaximaCommand = false;
50  };
51 
58  CharButton(wxWindow *parent, wxWindow *worksheet, Configuration *config,
59  const Definition &def,
60  bool forceShow = false);
61 protected:
62  Configuration *m_configuration;
63  void ForwardToParent(wxMouseEvent &event);
64  void CharButtonPressed(wxCommandEvent &event);
65  wchar_t m_char;
66  void OnSize(wxSizeEvent &event);
67  void OnIdle(wxIdleEvent &event);
68  void MouseOverPanel(wxMouseEvent &event);
69  void MouseOverText(wxMouseEvent &event);
70  void MouseLeftPanel(wxMouseEvent &event);
71  void MouseLeftText(wxMouseEvent &event);
72 protected:
73  void MouseOverTextIs(bool mouseOver = true);
74  void MouseOverPanelIs(bool mouseOver = true);
76  bool FontDisplaysChar(const wxFont &font = *wxNORMAL_FONT);
78  bool CharVisiblyDifferent(wxChar otherChar, const wxFont &font = *wxNORMAL_FONT);
79  wxString m_description;
80 
81 private:
82  bool m_mouseOverPanel = false;
83  bool m_mouseOverText = false;
84  bool m_backgroundColorChangeNeeded = false;
85  wxStaticText *m_buttonText;
86  wxWindow *m_worksheet;
87 };
88 
89 #endif // CHARBUTTON_H
CharButton::Definition
A definition of this button, used to construct it.
Definition: CharButton.h:45
CharButton::CharButton
CharButton(wxWindow *parent, wxWindow *worksheet, Configuration *config, const Definition &def, bool forceShow=false)
Definition: CharButton.cpp:129
CharButton::Definition::matchesMaximaCommand
bool matchesMaximaCommand
Whether this symbol is automatically translated into a maxima command/operator.
Definition: CharButton.h:49
CharButton::FontDisplaysChar
bool FontDisplaysChar(const wxFont &font= *wxNORMAL_FONT)
True if drawing the char this button displays alters at least one pixel.
Definition: CharButton.cpp:197
CharButton
Definition: CharButton.h:41
CharButton::Definition::symbol
wchar_t symbol
The unicode symbol.
Definition: CharButton.h:47
CharButton::CharVisiblyDifferent
bool CharVisiblyDifferent(wxChar otherChar, const wxFont &font= *wxNORMAL_FONT)
True if drawing the char this button displays differs visibly from otherChar.
Definition: CharButton.cpp:249
CharButton::Definition::description
const wxString description
The help text for the symbol.
Definition: CharButton.h:48
Configuration
Definition: Configuration.h:83