NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
customwindow.hpp
Go to the documentation of this file.
1/*****************************************************************************
2 NumeRe: Framework fuer Numerische Rechnungen
3 Copyright (C) 2021 Erik Haenel et al.
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 3 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 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17******************************************************************************/
18
19#ifndef CUSTOMWINDOW_HPP
20#define CUSTOMWINDOW_HPP
21
22#include <wx/wx.h>
23#include <map>
24#include <vector>
25#include <utility>
26#include <wx/treelist.h>
27
28#include "../../kernel/windowmanager.hpp"
29#include "../../kernel/core/datamanagement/table.hpp"
30#include "tableviewer.hpp"
31
32// Forward declarations
33class GroupPanel;
34class GraphHelper;
35
36namespace tinyxml2
37{
38 class XMLElement;
39}
40
41
47{
48 wxString type, value, state, label, color;
50};
51
52
58{
59 wxString type;
60 wxString stringValue;
62};
63
64
71class CustomWindow : public wxFrame
72{
73 public:
75 {
76 CHECKBOX, // OK
77 TEXT, // OK
78 TEXTCTRL, // OK
79 TREELIST, // OK
80 SPINCTRL, // OK
81 BUTTON, // OK
83 DROPDOWN, // OK
85 GAUGE, // OK
86 IMAGE, // OK
87 TABLE, // OK
88 GRAPHER, // OK
91 };
92
93 private:
94 std::map<int, std::pair<WindowItemType,wxObject*>> m_windowItems;
95 std::map<int, wxString> m_eventTable;
96 std::map<wxString, wxString> m_varTable;
97
99
100 void layout();
101 void layoutChild(const tinyxml2::XMLElement* currentChild, wxWindow* currParent, wxSizer* currSizer, GroupPanel* _groupPanel);
102 void layoutMenu(const tinyxml2::XMLElement* currentChild, wxMenu* currMenu);
103 void handleEvent(wxEvent& event, const wxString& sEventType);
104 bool getWindowParameters(WindowItemParams& params) const;
105 bool getItemParameters(int windowItemID, WindowItemParams& params) const;
106 wxArrayString getChoices(wxString& choices) const;
107 wxArrayString decodeEventHandlerFunction(const wxString& sEventHandler) const;
108 wxString removeQuotationMarks(wxString sString) const;
109 void Refresh();
110
111 public:
112 CustomWindow(wxWindow* parent, const NumeRe::Window& windowRef);
113
114 std::vector<int> getWindowItems(WindowItemType _type) const;
115 bool closeWindow();
116 WindowItemValue getItemValue(int windowItemID) const;
117 wxString getItemLabel(int windowItemID) const;
118 wxString getItemState(int windowItemID) const;
119 wxString getItemColor(int windowItemID) const;
120 wxString getPropValue(const wxString& varName) const;
121 wxString getProperties() const;
122
123 bool setItemValue(WindowItemValue& _value, int windowItemID);
124 bool setItemLabel(const wxString& _label, int windowItemID);
125 bool setItemState(const wxString& _state, int windowItemID);
126 bool setItemColor(const wxString& _color, int windowItemID);
127 bool setItemGraph(GraphHelper* _helper, int windowItemID);
128 bool setPropValue(const wxString& _value, const wxString& varName);
129
130 void OnMenuEvent(wxCommandEvent& event);
131 void OnClick(wxCommandEvent& event);
132 void OnChange(wxCommandEvent& event);
133 void OnSpin(wxSpinEvent& event);
134 void OnCellSelect(wxGridEvent& event);
135 void OnClose(wxCloseEvent& event);
136 void OnMouseLeftDown(wxMouseEvent& event);
137 void OnTreeListEvent(wxTreeListEvent& event);
138 void OnSizeEvent(wxSizeEvent& event);
139
141};
142
143
144#endif // CUSTOMWINDOW_HPP
145
This class represents a window, which can be created by the user during run-time by using a layout sc...
bool setItemState(const wxString &_state, int windowItemID)
Change the state of the selected item.
void layoutChild(const tinyxml2::XMLElement *currentChild, wxWindow *currParent, wxSizer *currSizer, GroupPanel *_groupPanel)
This member function can be called recursively and creates the layout for the current XMLElement's ch...
void OnChange(wxCommandEvent &event)
Generic onchange event handler.
bool setItemValue(WindowItemValue &_value, int windowItemID)
Change the value of the selected item.
void OnSpin(wxSpinEvent &event)
wxSpinCtrl event handler.
wxString getItemLabel(int windowItemID) const
Get the label of the selected item.
void handleEvent(wxEvent &event, const wxString &sEventType)
This member function is the central kernel interaction event handler. Will be called from the wxWidge...
void OnMouseLeftDown(wxMouseEvent &event)
Mouse event handler.
wxString removeQuotationMarks(wxString sString) const
Private member function to convert a kernel string into a usual string.
void OnMenuEvent(wxCommandEvent &event)
Menu event handler.
bool setItemGraph(GraphHelper *_helper, int windowItemID)
Updates the selected grapher item.
std::vector< int > getWindowItems(WindowItemType _type) const
Returns a list of all window item IDs, which correspond to the selected WindowItemType.
bool getItemParameters(int windowItemID, WindowItemParams &params) const
Returns the parameters of the selected window item.
bool setPropValue(const wxString &_value, const wxString &varName)
Sets the value of the selected window property.
bool setItemLabel(const wxString &_label, int windowItemID)
Change the label of the selected item.
bool getWindowParameters(WindowItemParams &params) const
Returns the parameters of this window.
wxString getProperties() const
Returns a list of all available window properties.
void layoutMenu(const tinyxml2::XMLElement *currentChild, wxMenu *currMenu)
This member function can be called recursively and creates menus and submenus for the current window ...
wxString getPropValue(const wxString &varName) const
Returns the value of the selected window property.
void OnTreeListEvent(wxTreeListEvent &event)
Tree list control event handler.
std::map< wxString, wxString > m_varTable
NumeRe::Window m_windowRef
wxString getItemColor(int windowItemID) const
Get the color of the selected item.
void OnClose(wxCloseEvent &event)
OnClose event handler.
CustomWindow(wxWindow *parent, const NumeRe::Window &windowRef)
CustomWindow constructor. Connects this window with the NumeRe::Window instance and triggers the layo...
wxString getItemState(int windowItemID) const
Get the state of the selected item.
void OnCellSelect(wxGridEvent &event)
wxGrid event handler.
bool setItemColor(const wxString &_color, int windowItemID)
Change the color of the selected item.
wxArrayString decodeEventHandlerFunction(const wxString &sEventHandler) const
This member function decodes the arguments of a event handler function and returns them as a wxArrayS...
void OnSizeEvent(wxSizeEvent &event)
On size event handler.
std::map< int, std::pair< WindowItemType, wxObject * > > m_windowItems
std::map< int, wxString > m_eventTable
void OnClick(wxCommandEvent &event)
Button click event handler.
wxArrayString getChoices(wxString &choices) const
A simple tokenizer to separate a list of strings into multiple strings.
void Refresh()
Wrapper for wxWindow::Refresh to use it together with CallAfter().
void layout()
This member function evaluates the layout supplied by the user via a tinyxml2::XMLDocument instance.
WindowItemValue getItemValue(int windowItemID) const
Get the value of the selected item.
bool closeWindow()
Close this window.
This class encapsulates the mglGraph object during transmission from the kernel to the GUI.
This class simplifies the creation of simple windows and creates a common layout among all windows.
Definition: grouppanel.hpp:188
This data container is a copy- efficient table to interchange data between Kernel and GUI.
Definition: table.hpp:87
This class represents an abstract window handled by the window manager.
A structure to simplify the reading of all parameter values of each window item.
NumeRe::Table table
A structure to simplify reading and updating window item values.
wxString stringValue
NumeRe::Table tableValue