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 UnescapeVarname(wxString var);
92 void VariableValue(const wxString &var, const wxString &val);
94 void VariableUndefined(const wxString &var);
95 void UpdateSize();
98private:
99 // The spreadsheet with the variable names
100 wxGrid *m_grid;
101 bool m_updateSizeNeeded = false;
102 typedef std::unordered_map <wxString, int, wxStringHash> IntHash;
103
105 IntHash m_vars;
107 int m_rightClickRow;
109 static int CompareInt(int * const int1, int * const int2){return (*int1 < *int2);}
110};
111
112#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:249
void OnTextChanging(wxGridEvent &event)
Called after the user has entered a variable name but before it is committed.
Definition: VariablesPane.cpp:240
~Variablespane()
The destructor.
Definition: VariablesPane.cpp:405
void VariableValue(const wxString &var, const wxString &val)
Tell the variables pane about a variable value.
Definition: VariablesPane.cpp:293
void OnChar(wxKeyEvent &event)
Called if a printable char was entered.
Definition: VariablesPane.cpp:84
void AddWatchCode(wxString code)
Add a variable whose name contains all the escapes maxima needs to the variables list.
Definition: VariablesPane.cpp:334
void OnKey(wxKeyEvent &event)
Called on key press.
Definition: VariablesPane.cpp:94
void ResetValues()
Set all variable's contents to "unknown".
Definition: VariablesPane.cpp:388
void VariableUndefined(const wxString &var)
Sets the variable var to "undefined".
Definition: VariablesPane.cpp:305
void AddWatch(wxString watch)
Add a variable without escapes to the list.
Definition: VariablesPane.cpp:349
static bool IsValidVariable(wxString var)
Is this string a valid variable name?
Definition: VariablesPane.cpp:367
void InsertMenu(wxCommandEvent &event)
Called if a right-click menu item was clicked at.
Definition: VariablesPane.cpp:124
void Clear()
Remove all entries from the variables list.
Definition: VariablesPane.cpp:399
std::vector< wxString > GetVarnames()
Returns the variable list in a human-readable format.
Definition: VariablesPane.cpp:324
void OnRightClick(wxGridEvent &event)
Called on right-clicking the variables list.
Definition: VariablesPane.cpp:176
std::vector< wxString > GetEscapedVarnames()
Returns a list of all variable names in a format maxima understands.
Definition: VariablesPane.cpp:314
static wxString UnescapeVarname(wxString var)
Convert a variable name maxima understands to human-readable.
Definition: VariablesPane.cpp:359