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 <utility>
33#include <vector>
34
44class Variablespane : public wxPanel
45{
46public:
47 wxWindowIDRef m_varID_values;
48 wxWindowIDRef m_varID_functions;
49 wxWindowIDRef m_varID_arrays;
50 wxWindowIDRef m_varID_macros;
51 wxWindowIDRef m_varID_labels;
52 wxWindowIDRef m_varID_myoptions;
53 wxWindowIDRef m_varID_rules;
54 wxWindowIDRef m_varID_aliases;
55 wxWindowIDRef m_varID_structs;
56 wxWindowIDRef m_varID_dependencies;
57 wxWindowIDRef m_varID_gradefs;
58 wxWindowIDRef m_varID_prop;
59 wxWindowIDRef m_varID_let_rule_packages;
60 wxWindowIDRef m_varID_delete_row;
61 wxWindowIDRef m_varID_clear;
63 explicit Variablespane(wxWindow *parent, wxWindowID id = wxID_ANY);
65 void OnTextChange(wxGridEvent &event);
67 void OnTextChanging(wxGridEvent &event);
69 void OnRightClick(wxGridEvent &event);
71 void InsertMenu(wxCommandEvent &event);
73 void OnKey(wxKeyEvent &event);
75 void OnChar(wxKeyEvent &event);
77 void AddWatchCode(wxString code);
79 void AddWatch(wxString watch);
81 static bool IsValidVariable(wxString var);
83 std::vector<wxString> GetEscapedVarnames();
85 std::vector<wxString> GetVarnames();
87 std::vector<std::pair<wxString, wxString>> GetWatchedValues();
89 void RemoveWatch(const wxString &var);
91 void ResetValues();
93 void Clear();
95 static wxString UnescapeVarname(wxString var);
97 void VariableValue(const wxString &var, const wxString &val);
99 void VariableUndefined(const wxString &var);
100 void UpdateSize();
103private:
104 // The spreadsheet with the variable names
105 wxGrid *m_grid;
106 bool m_updateSizeNeeded = false;
107 typedef std::unordered_map <wxString, int, wxStringHash> IntHash;
108
110 IntHash m_vars;
112 int m_rightClickRow;
114 static int CompareInt(int * const int1, int * const int2){return (*int1 < *int2);}
115};
116
117#endif // VARIABLESPANE_H
This file declares the class EventIDs that contains unique IDs for many events wxMaxima needs.
A "variables" sidepane.
Definition: VariablesPane.h:45
std::vector< std::pair< wxString, wxString > > GetWatchedValues()
Returns the currently watched (name, currently displayed value) pairs.
Definition: VariablesPane.cpp:328
void OnTextChange(wxGridEvent &event)
Called when a variable name was changed.
Definition: VariablesPane.cpp:243
void OnTextChanging(wxGridEvent &event)
Called after the user has entered a variable name but before it is committed.
Definition: VariablesPane.cpp:234
~Variablespane()
The destructor.
Definition: VariablesPane.cpp:425
void VariableValue(const wxString &var, const wxString &val)
Tell the variables pane about a variable value.
Definition: VariablesPane.cpp:287
void OnChar(wxKeyEvent &event)
Called if a printable char was entered.
Definition: VariablesPane.cpp:78
void AddWatchCode(wxString code)
Add a variable whose name contains all the escapes maxima needs to the variables list.
Definition: VariablesPane.cpp:354
void OnKey(wxKeyEvent &event)
Called on key press.
Definition: VariablesPane.cpp:88
void ResetValues()
Set all variable's contents to "unknown".
Definition: VariablesPane.cpp:408
void VariableUndefined(const wxString &var)
Sets the variable var to "undefined".
Definition: VariablesPane.cpp:299
void AddWatch(wxString watch)
Add a variable without escapes to the list.
Definition: VariablesPane.cpp:369
void RemoveWatch(const wxString &var)
Removes one variable from the watchlist by its human-readable name, if present.
Definition: VariablesPane.cpp:338
static bool IsValidVariable(wxString var)
Is this string a valid variable name?
Definition: VariablesPane.cpp:387
void InsertMenu(wxCommandEvent &event)
Called if a right-click menu item was clicked at.
Definition: VariablesPane.cpp:118
void Clear()
Remove all entries from the variables list.
Definition: VariablesPane.cpp:419
std::vector< wxString > GetVarnames()
Returns the variable list in a human-readable format.
Definition: VariablesPane.cpp:318
void OnRightClick(wxGridEvent &event)
Called on right-clicking the variables list.
Definition: VariablesPane.cpp:170
std::vector< wxString > GetEscapedVarnames()
Returns a list of all variable names in a format maxima understands.
Definition: VariablesPane.cpp:308
static wxString UnescapeVarname(wxString var)
Convert a variable name maxima understands to human-readable.
Definition: VariablesPane.cpp:379