wxMaxima
Loading...
Searching...
No Matches
VariablesPane.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) 2004-2015 Andrej Vodopivec <andrej.vodopivec@gmail.com>
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 VARIABLESPANE_H
23#define VARIABLESPANE_H
24
25#include "precomp.h"
26#include "EventIDs.h"
27#include <wx/wx.h>
28#include <wx/grid.h>
29#include <wx/panel.h>
30#include <wx/arrstr.h>
31#include <unordered_map>
32#include <vector>
33
43class Variablespane : public wxPanel
44{
45public:
46 wxWindowIDRef m_varID_values;
47 wxWindowIDRef m_varID_functions;
48 wxWindowIDRef m_varID_arrays;
49 wxWindowIDRef m_varID_macros;
50 wxWindowIDRef m_varID_labels;
51 wxWindowIDRef m_varID_myoptions;
52 wxWindowIDRef m_varID_rules;
53 wxWindowIDRef m_varID_aliases;
54 wxWindowIDRef m_varID_structs;
55 wxWindowIDRef m_varID_dependencies;
56 wxWindowIDRef m_varID_gradefs;
57 wxWindowIDRef m_varID_prop;
58 wxWindowIDRef m_varID_let_rule_packages;
59 wxWindowIDRef m_varID_delete_row;
60 wxWindowIDRef m_varID_clear;
62 explicit Variablespane(wxWindow *parent, wxWindowID id = wxID_ANY);
64 void OnTextChange(wxGridEvent &event);
66 void OnTextChanging(wxGridEvent &event);
68 void OnRightClick(wxGridEvent &event);
70 void InsertMenu(wxCommandEvent &event);
72 void OnKey(wxKeyEvent &event);
74 void OnChar(wxKeyEvent &event);
76 void AddWatchCode(wxString code);
78 void AddWatch(wxString watch);
80 static bool IsValidVariable(wxString var);
82 std::vector<wxString> GetEscapedVarnames();
84 std::vector<wxString> GetVarnames();
86 void ResetValues();
88 void Clear();
90 static wxString EscapeVarname(wxString var);
92 static wxString UnescapeVarname(wxString var);
94 void VariableValue(const wxString &var, const wxString &val);
96 void VariableUndefined(const wxString &var);
97 void UpdateSize();
100private:
101 // The spreadsheet with the variable names
102 wxGrid *m_grid;
103 bool m_updateSizeNeeded = false;
104 static wxString InvertCase(const wxString &var);
105 typedef std::unordered_map <wxString, int, wxStringHash> IntHash;
106
108 IntHash m_vars;
110 int m_rightClickRow;
112 static int CompareInt(int * const int1, int * const int2){return (*int1 < *int2);}
113};
114
115#endif // VARIABLESPANE_H
This file declares the class EventIDs that contains unique IDs for many events wxMaxima needs.
A "variables" sidepane.
Definition: VariablesPane.h:44
void OnTextChange(wxGridEvent &event)
Called when a variable name was changed.
Definition: VariablesPane.cpp:248
void OnTextChanging(wxGridEvent &event)
Called after the user has entered a variable name but before it is committed.
Definition: VariablesPane.cpp:239
~Variablespane()
The destructor.
Definition: VariablesPane.cpp:453
void VariableValue(const wxString &var, const wxString &val)
Tell the variables pane about a variable value.
Definition: VariablesPane.cpp:292
void OnChar(wxKeyEvent &event)
Called if a printable char was entered.
Definition: VariablesPane.cpp:83
void AddWatchCode(wxString code)
Add a variable whose name contains all the escapes maxima needs to the variables list.
Definition: VariablesPane.cpp:347
void OnKey(wxKeyEvent &event)
Called on key press.
Definition: VariablesPane.cpp:93
void ResetValues()
Set all variable's contents to "unknown".
Definition: VariablesPane.cpp:436
void VariableUndefined(const wxString &var)
Sets the variable var to "undefined".
Definition: VariablesPane.cpp:304
void AddWatch(wxString watch)
Add a variable without escapes to the list.
Definition: VariablesPane.cpp:362
static bool IsValidVariable(wxString var)
Is this string a valid variable name?
Definition: VariablesPane.cpp:415
void InsertMenu(wxCommandEvent &event)
Called if a right-click menu item was clicked at.
Definition: VariablesPane.cpp:123
void Clear()
Remove all entries from the variables list.
Definition: VariablesPane.cpp:447
std::vector< wxString > GetVarnames()
Returns the variable list in a human-readable format.
Definition: VariablesPane.cpp:323
static wxString EscapeVarname(wxString var)
Convert a human-readable variable name to one maxima understands.
Definition: VariablesPane.cpp:380
void OnRightClick(wxGridEvent &event)
Called on right-clicking the variables list.
Definition: VariablesPane.cpp:175
std::vector< wxString > GetEscapedVarnames()
Returns a list of all variable names in a format maxima understands.
Definition: VariablesPane.cpp:313
static wxString UnescapeVarname(wxString var)
Convert a variable name maxima understands to human-readable.
Definition: VariablesPane.cpp:372