wxMaxima
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 <wx/wx.h>
27 #include <wx/grid.h>
28 #include <wx/panel.h>
29 #include <wx/arrstr.h>
30 
40 class Variablespane : public wxPanel
41 {
42 public:
43  enum VarIds
44  {
45  varID_newVar = wxID_HIGHEST + 3000,
46  varID_values,
47  varID_functions,
48  varID_arrays,
49  varID_macros,
50  varID_labels,
51  varID_myoptions,
52  varID_rules,
53  varID_aliases,
54  varID_structs,
55  varID_dependencies,
56  varID_gradefs,
57  varID_prop,
58  varID_let_rule_packages,
59  varID_add_all,
60  varID_delete_row,
61  varID_clear
62  };
63 
65  explicit Variablespane(wxWindow *parent, wxWindowID id = wxID_ANY);
67  void OnTextChange(wxGridEvent &event);
69  void OnTextChanging(wxGridEvent &event);
71  void OnRightClick(wxGridEvent &event);
73  void InsertMenu(wxCommandEvent &event);
75  void OnKey(wxKeyEvent &event);
77  void OnChar(wxKeyEvent &event);
79  void AddWatchCode(wxString code);
81  void AddWatch(wxString watch);
83  bool IsValidVariable(wxString var);
85  wxArrayString GetEscapedVarnames();
87  wxArrayString GetVarnames();
89  void ResetValues();
91  void Clear();
93  wxString EscapeVarname(wxString var);
95  wxString UnescapeVarname(wxString var);
97  void VariableValue(wxString var, wxString val);
99  void VariableUndefined(wxString var);
100  void UpdateSize();
102  ~Variablespane();
103 private:
104  // The spreadsheet with the variable names
105  wxGrid *m_grid;
106  bool m_updateSizeNeeded = false;
107  wxString InvertCase(wxString var);
108  WX_DECLARE_STRING_HASH_MAP(int, IntHash);
110  IntHash m_vars;
112  int m_rightClickRow;
114  static int CompareInt(int *int1, int *int2){return *int1<*int2;}
115 };
116 
117 #endif // VARIABLESPANE_H
Variablespane::InsertMenu
void InsertMenu(wxCommandEvent &event)
Called if a right-click menu item was clicked at.
Definition: VariablesPane.cpp:119
Variablespane::OnChar
void OnChar(wxKeyEvent &event)
Called if a printable char was entered.
Definition: VariablesPane.cpp:69
Variablespane::VariableValue
void VariableValue(wxString var, wxString val)
Tell the variables pane about a variable value.
Definition: VariablesPane.cpp:285
Variablespane::VariableUndefined
void VariableUndefined(wxString var)
Sets the variable var to "undefined".
Definition: VariablesPane.cpp:300
Variablespane
Definition: VariablesPane.h:40
Variablespane::~Variablespane
~Variablespane()
The destructor.
Definition: VariablesPane.cpp:475
Variablespane::OnTextChange
void OnTextChange(wxGridEvent &event)
Called when a variable name was changed.
Definition: VariablesPane.cpp:235
Variablespane::AddWatch
void AddWatch(wxString watch)
Add a variable without escapes to the list.
Definition: VariablesPane.cpp:371
Variablespane::IsValidVariable
bool IsValidVariable(wxString var)
Is this string a valid variable name?
Definition: VariablesPane.cpp:426
Variablespane::GetVarnames
wxArrayString GetVarnames()
Returns the variable list in a human-readable format.
Definition: VariablesPane.cpp:323
Variablespane::AddWatchCode
void AddWatchCode(wxString code)
Add a variable whose name contains all the escapes maxima needs to the variables list.
Definition: VariablesPane.cpp:353
Variablespane::EscapeVarname
wxString EscapeVarname(wxString var)
Convert a human-readable variable name to one maxima understands.
Definition: VariablesPane.cpp:390
Variablespane::Clear
void Clear()
Remove all entries from the variables list.
Definition: VariablesPane.cpp:468
Variablespane::OnRightClick
void OnRightClick(wxGridEvent &event)
Called on right-clicking the variables list.
Definition: VariablesPane.cpp:161
Variablespane::OnTextChanging
void OnTextChanging(wxGridEvent &event)
Called after the user has entered a variable name but before it is committed.
Definition: VariablesPane.cpp:224
Variablespane::ResetValues
void ResetValues()
Set all variable's contents to "unknown".
Definition: VariablesPane.cpp:453
Variablespane::Variablespane
Variablespane(wxWindow *parent, wxWindowID id=wxID_ANY)
The constructor.
Definition: VariablesPane.cpp:25
Variablespane::UnescapeVarname
wxString UnescapeVarname(wxString var)
Convert a variable name maxima understands to human-readable.
Definition: VariablesPane.cpp:381
Variablespane::OnKey
void OnKey(wxKeyEvent &event)
Called on key press.
Definition: VariablesPane.cpp:81
Variablespane::GetEscapedVarnames
wxArrayString GetEscapedVarnames()
Returns a list of all variable names in a format maxima understands.
Definition: VariablesPane.cpp:311