20#include "../NumeReWindow.h"
21#include "../../kernel/core/utils/tinyxml2.h"
22#include "../../kernel/core/utils/stringtools.hpp"
24#include <wx/tokenzr.h>
25#include <wx/dataview.h>
26#include <wx/statline.h>
41 return wxString::Format(
"{%d,%d,%d}", c.Red(), c.Green(), c.Blue());
56 c.Set(
"rgb(" + s +
")");
73 s.Replace(
"\"",
"\\\"");
74 return "\"" + s +
"\"";
87 wxString sValue = sItem.substr(0, sItem.find(
'\t'));
89 if (sItem.find(
'\t') != std::string::npos)
90 sItem.erase(0, sItem.find(
'\t')+1);
113 bool useCheckBoxes = listCtrl->HasFlag(wxTL_CHECKBOX);
117 while ((pos = values[0].find(
'\t', pos)) != std::string::npos)
126 listCtrl->DeleteAllItems();
130 listCtrl->AppendColumn(
"");
132 for (
size_t i = 0; i < values.size(); i++)
134 wxString sItem = values[i];
143 if (check && useCheckBoxes)
144 listCtrl->CheckItem(item);
146 while (sItem.length() && currCol < nColumns)
174 bool useCheckBoxes = listCtrl->HasFlag(wxTL_CHECKBOX);
175 wxTreeListItems items;
182 for (
size_t i = 0; i < items.size(); i++)
210 for (
wxTreeListItem item = listCtrl->GetFirstItem(); item.IsOk(); item = listCtrl->GetNextItem(item))
215 values += listCtrl->GetCheckedState(item) == wxCHK_CHECKED ?
"1" :
"0";
218 return "\"{" + values +
"}\"";
266CustomWindow::
CustomWindow(wxWindow* parent, const
NumeRe::Window& windowRef) : wxFrame(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxFRAME_FLOAT_ON_PARENT | wxRESIZE_BORDER | wxCAPTION |
wxCLOSE_BOX | wxMAXIMIZE_BOX | wxMINIMIZE_BOX), m_windowRef(windowRef)
268 m_windowRef.connect(
this);
290 wxString sColor = layoutGroup->
Attribute(
"color");
293 background.Set(
"rgb(" + sColor +
")");
295 SetBackgroundColour(background);
300 SetTitle(layoutGroup->
Attribute(
"title"));
302 SetTitle(
"NumeRe: Custom Window");
308 wxFileName iconfile(layoutGroup->
Attribute(
"icon"));
310 if (iconfile.GetExt() ==
"ico")
311 SetIcon(wxIcon(layoutGroup->
Attribute(
"icon"), wxBITMAP_TYPE_ICO));
312 else if (iconfile.GetExt() ==
"png")
313 SetIcon(wxIcon(layoutGroup->
Attribute(
"icon"), wxBITMAP_TYPE_PNG));
314 else if (iconfile.GetExt() ==
"bmp")
315 SetIcon(wxIcon(layoutGroup->
Attribute(
"icon"), wxBITMAP_TYPE_BMP));
318 SetIcon(
static_cast<NumeReWindow*
>(m_parent)->getStandardIcon());
322 GroupPanel* _groupPanel =
new GroupPanel(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxBORDER_STATIC);
330 _groupPanel->SetScrollbars(20, 20, 200, 200);
338 wxString sSize = layoutGroup->
Attribute(
"size");
340 sSize.substr(0, sSize.find(
',')).ToLong(&x);
341 sSize.substr(sSize.find(
',')+1).ToLong(&y);
343 SetClientSize(wxSize(x,y));
346 SetClientSize(wxSize(800,600));
370 wxNotebook* noteBook =
nullptr;
380 wxString text = currentChild->
GetText() ? currentChild->
GetText() :
"";
382 wxFont font = GetFont();
384 int alignment = wxALIGN_CENTER_VERTICAL;
393 wxString sFont = currentChild->
Attribute(
"font");
395 if (sFont.find(
'i') != std::string::npos)
398 if (sFont.find(
'b') != std::string::npos)
405 wxString sAlign = currentChild->
Attribute(
"align");
409 if (sAlign.find_first_of(
"TB") == std::string::npos)
410 alignment |= wxALIGN_CENTER_VERTICAL;
412 if (sAlign.find_first_of(
"LR") == std::string::npos)
413 alignment |= wxALIGN_CENTER_HORIZONTAL;
415 if (sAlign.find(
"L") != std::string::npos)
416 alignment |= wxALIGN_LEFT;
418 if (sAlign.find(
"R") != std::string::npos)
419 alignment |= wxALIGN_RIGHT;
421 if (sAlign.find(
"T") != std::string::npos)
422 alignment |= wxALIGN_TOP;
424 if (sAlign.find(
"B") != std::string::npos)
425 alignment |= wxALIGN_BOTTOM;
432 if (std::string(currentChild->
Value()) ==
"button")
436 button->SetFont(font);
450 else if (std::string(currentChild->
Value()) ==
"checkbox")
454 checkbox->SetFont(font);
458 checkbox->SetValue(currentChild->
Attribute(
"value",
"1"));
471 else if (std::string(currentChild->
Value()) ==
"radio")
475 int style = wxHORIZONTAL;
478 label = currentChild->
Attribute(
"label");
481 style = currentChild->
Attribute(
"type",
"horizontal") ? wxHORIZONTAL : wxVERTICAL;
483 wxRadioBox* radiobox = _groupPanel->
CreateRadioBox(currParent, currSizer, label,
getChoices(text), style,
id, alignment);
484 radiobox->SetFont(font);
488 radiobox->SetSelection(currentChild->
IntAttribute(
"value")-1);
498 else if (std::string(currentChild->
Value()) ==
"spinbut")
502 int nMin = 0, nMax = 100, nValue = 0;
505 label = currentChild->
Attribute(
"label");
516 SpinBut* spinctrl = _groupPanel->
CreateSpinControl(currParent, currSizer, label, nMin, nMax, nValue,
id, alignment);
517 spinctrl->SetFont(font);
529 spinctrl->
Show(
false);
531 else if (std::string(currentChild->
Value()) ==
"slider")
534 int nMin = 0, nMax = 100, nValue = 0;
535 int style = wxHORIZONTAL;
538 style = currentChild->
Attribute(
"type",
"horizontal") ? wxHORIZONTAL | wxSL_LABELS | wxSL_AUTOTICKS : wxVERTICAL | wxSL_LABELS | wxSL_AUTOTICKS;
549 wxSlider* slider = _groupPanel->
CreateSlider(currParent, currSizer, nMin, nMax, nValue, style,
id, alignment);
550 slider->SetFont(font);
560 slider->Enable(
false);
564 else if (std::string(currentChild->
Value()) ==
"gauge")
568 int style = wxHORIZONTAL;
571 style = currentChild->
Attribute(
"type",
"horizontal") ? wxGA_HORIZONTAL | wxGA_SMOOTH : wxGA_VERTICAL | wxGA_SMOOTH;
573 wxGauge* gauge = _groupPanel->
CreateGauge(currParent, currSizer, style,
id, alignment);
584 else if (std::string(currentChild->
Value()) ==
"dropdown")
591 choice->SetSelection(currentChild->
IntAttribute(
"value")-1);
604 else if (std::string(currentChild->
Value()) ==
"combobox")
611 combo->SetSelection(currentChild->
IntAttribute(
"value")-1);
624 else if (std::string(currentChild->
Value()) ==
"textfield")
627 int style = wxTE_PROCESS_ENTER;
632 wxString sSize = currentChild->
Attribute(
"size");
634 sSize.substr(0, sSize.find(
',')).ToLong(&x);
635 sSize.substr(sSize.find(
',')+1).ToLong(&y);
642 style = currentChild->
Attribute(
"type",
"multiline") ? wxTE_MULTILINE | wxTE_BESTWRAP : wxTE_PROCESS_ENTER;
647 label = currentChild->
Attribute(
"label");
650 textctrl->SetFont(font);
662 textctrl->
Show(
false);
664 else if (std::string(currentChild->
Value()) ==
"statictext" || std::string(currentChild->
Value()) ==
"text")
668 statictext->SetFont(font);
674 else if (std::string(currentChild->
Value()) ==
"prop")
679 for (
size_t i = 0; i < varList.size(); i++)
681 if (varList[i].find(
'=') != std::string::npos)
683 wxString
name = varList[i].substr(0, varList[i].find(
'='));
684 wxString value = varList[i].substr(varList[i].find(
'=')+1);
692 else if (std::string(currentChild->
Value()) ==
"bitmap")
698 else if (std::string(currentChild->
Value()) ==
"separator")
701 int style = wxHORIZONTAL;
702 bool created =
false;
706 if (currentChild->
Attribute(
"type",
"space"))
711 _groupPanel->
AddSpacer(space, currSizer);
715 style = currentChild->
Attribute(
"type",
"vertical") ? wxVERTICAL : wxHORIZONTAL;
721 wxStaticLine* line =
new wxStaticLine(currParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, style);
722 currSizer->Add(line, 0, wxEXPAND | wxALL, 5);
725 else if (std::string(currentChild->
Value()) ==
"grapher")
728 wxMGL* mgl =
new wxMGL(currParent,
id, wxDefaultPosition, wxDefaultSize, wxBORDER_THEME,
true);
733 wxString sSize = currentChild->
Attribute(
"size");
735 sSize.substr(0, sSize.find(
',')).ToLong(&x);
736 sSize.substr(sSize.find(
',')+1).ToLong(&y);
738 mgl->SetMinClientSize(wxSize(x,y));
741 mgl->SetMinClientSize(wxSize(640,480));
743 currSizer->Add(mgl, 1, alignment | wxALL | wxEXPAND | wxRESERVE_SPACE_EVEN_IF_HIDDEN, 5);
748 else if (std::string(currentChild->
Value()) ==
"tablegrid")
751 TableViewer* table =
new TableViewer(currParent,
id,
nullptr,
nullptr, wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS | wxBORDER_THEME);
752 currSizer->Add(table, 1, alignment | wxALL | wxEXPAND | wxRESERVE_SPACE_EVEN_IF_HIDDEN, 5);
758 wxString sSize = currentChild->
Attribute(
"size");
760 sSize.substr(0, sSize.find(
',')).ToLong(&x);
761 sSize.substr(sSize.find(
',')+1).ToLong(&y);
774 else if (std::string(currentChild->
Value()) ==
"treelist")
777 int style = wxTL_SINGLE;
780 style |= currentChild->
Attribute(
"type",
"checkmark") ? wxTL_CHECKBOX : wxTL_MULTIPLE;
782 wxArrayString labels;
783 wxArrayString values;
791 wxString label = currentChild->
Attribute(
"label");
797 wxString value = currentChild->
Attribute(
"value");
805 for (
size_t j = 0; j < labels.size(); j++)
807 listCtrl->AppendColumn(labels[j]);
813 else if (currentChild->
Attribute(
"size"))
815 wxString sSize = currentChild->
Attribute(
"size");
817 sSize.substr(0, sSize.find(
',')).ToLong(&row);
818 sSize.substr(sSize.find(
',')+1).ToLong(&col);
820 wxSize ctrlSize = GetClientSize();
822 for (
size_t j = 0; j < (size_t)col; j++)
824 if (labels.size() > j)
825 listCtrl->AppendColumn(labels[j], ctrlSize.x/col - 2);
827 listCtrl->AppendColumn(
"", ctrlSize.x/col - 2);
830 for (
int i = 0; i < row; i++)
835 else if (labels.size())
837 wxSize ctrlSize = GetClientSize();
839 for (
size_t j = 0; j < labels.size(); j++)
841 listCtrl->AppendColumn(labels[j], ctrlSize.x / labels.size() - 2);
848 else if (std::string(currentChild->
Value()) ==
"group")
854 int style = wxHORIZONTAL;
855 bool isCollapsible =
false;
856 bool isNotebook =
false;
861 label = currentChild->
Attribute(
"label");
864 style = currentChild->
Attribute(
"type",
"horizontal") ? wxHORIZONTAL : wxVERTICAL;
868 isCollapsible = currentChild->
Attribute(
"style",
"collapse");
869 isNotebook = currentChild->
Attribute(
"style",
"tabs");
870 isMenu = currentChild->
Attribute(
"style",
"menu");
874 expand = currentChild->
Attribute(
"expand",
"true") ? 1 : 0;
878#warning TODO (numere#1#08/15/21): Fix the collapsible group
884 wxBoxSizer* sizer =
new wxBoxSizer(style);
888 pane->GetPane()->SetSizer(sizer);
889 sizer->SetSizeHints(pane->GetPane());
895 noteBook =
new wxNotebook(currParent, wxID_ANY);
896 currSizer->Add(noteBook, 1, wxEXPAND | wxRESERVE_SPACE_EVEN_IF_HIDDEN | wxALL, 5);
899 GroupPanel* _newPanel =
new GroupPanel(noteBook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, style == wxHORIZONTAL ?
false :
true);
903 noteBook->AddPage(_newPanel, label);
907 wxMenuBar* menuBar = GetMenuBar();
911 menuBar =
new wxMenuBar();
915 wxMenu* currMenu =
new wxMenu();
916 menuBar->Append(currMenu, label);
921 wxStaticBoxSizer* sizer = _groupPanel->
createGroup(label, style, currParent, currSizer, expand);
927 wxBoxSizer* sizer = _groupPanel->
createGroup(style, currSizer, expand);
962 wxString text = currentChild->
GetText() ? currentChild->
GetText() :
"";
964 wxFont font = GetFont();
974 wxString sFont = currentChild->
Attribute(
"font");
976 if (sFont.find(
'i') != std::string::npos)
979 if (sFont.find(
'b') != std::string::npos)
983 if (std::string(currentChild->
Value()) ==
"menuitem")
986 bool isCheck =
false;
987 bool isChecked =
false;
990 isCheck = currentChild->
Attribute(
"type",
"checkmark") ? true :
false;
993 isChecked = currentChild->
Attribute(
"value",
"0") ? false :
true;
995 wxMenuItem* item = currMenu->Append(
id,
removeQuotationMarks(text), wxEmptyString, isCheck ? wxITEM_CHECK : wxITEM_NORMAL);
998 if (isCheck && isChecked)
1010 item->Enable(
false);
1012 else if (std::string(currentChild->
Value()) ==
"checkbox")
1015 bool isChecked =
false;
1018 isChecked = currentChild->
Attribute(
"value",
"0") ? false :
true;
1020 wxMenuItem* item = currMenu->Append(
id,
removeQuotationMarks(text), wxEmptyString, wxITEM_CHECK);
1021 item->SetFont(font);
1035 item->Enable(
false);
1037 else if (std::string(currentChild->
Value()) ==
"separator")
1038 currMenu->AppendSeparator();
1039 else if (std::string(currentChild->
Value()) ==
"group")
1045 bool isMenu =
false;
1048 label = currentChild->
Attribute(
"label");
1051 isMenu = currentChild->
Attribute(
"style",
"menu");
1053 if (label.length() && isMenu)
1055 wxMenu* subMenu =
new wxMenu();
1056 currMenu->AppendSubMenu(subMenu, label);
1086#warning NOTE (numere#1#08/15/21): The "onclose" event is still undefined
1087 if (sEventType ==
"onclose")
1096 if (iter->second[0] ==
'$' && iter->second.length() > 1 && (wxIsalnum(iter->second[1]) || iter->second[1] ==
'_'))
1111 if (event.GetEventType() == wxEVT_GRID_SELECT_CELL)
1113 kvl_event =
"{\"event\",\"onclick\",\"object\",\"" + params.
type
1114 +
"\",\"value\"," + sEventType
1115 +
",\"state\",\"" + params.
state +
"\"}";
1119 kvl_event =
"{\"event\",\"" + sEventType
1120 +
"\",\"object\",\"" + params.
type
1121 +
"\",\"value\"," + params.
value
1122 +
",\"state\",\"" + params.
state +
"\"}";
1129 + kvl_event +
")",
true);
1131 else if (iter->second.find(
'(') != std::string::npos)
1135 if (funcDef.front() ==
"evt_close")
1137 else if (funcDef.front() ==
"evt_sendvaltoitem" && funcDef.size() >= 2)
1148 for (
size_t i = 1; i < funcDef.size(); i++)
1150 funcDef[i].ToLong(&targetID);
1154 else if (funcDef.front() ==
"evt_copyvalues" && funcDef.size() >= 3)
1156 long int sourceID, targetID;
1157 funcDef[1].ToLong(&sourceID);
1166 for (
size_t i = 2; i < funcDef.size(); i++)
1168 funcDef[i].ToLong(&targetID);
1172 else if (funcDef.front() ==
"evt_changestate" && funcDef.size() >= 3)
1175 funcDef[1].ToLong(&
id);
1192 params.
type =
"window";
1193 params.
value = wxString::Format(
"{%d,%d}", GetClientSize().x, GetClientSize().y);
1194 params.
state =
"running";
1196 params.
label =
"\"" + GetTitle() +
"\"";
1214 if (windowItemID == -1)
1222 std::pair<CustomWindow::WindowItemType, wxObject*>
object = iter->second;
1224 switch (
object.first)
1227 params.
type =
"button";
1230 params.
color =
toWxString(
static_cast<wxButton*
>(
object.second)->GetForegroundColour());
1234 params.
type =
"checkbox";
1235 params.
value =
static_cast<wxCheckBox*
>(
object.second)->IsChecked() ?
"true" :
"false";
1237 params.
color =
toWxString(
static_cast<wxCheckBox*
>(
object.second)->GetBackgroundColour());
1241 params.
type =
"statictext";
1244 params.
color =
toWxString(
static_cast<wxStaticText*
>(
object.second)->GetForegroundColour());
1248 params.
type =
"textfield";
1256 params.
type =
"radio";
1257 wxRadioBox* box =
static_cast<wxRadioBox*
>(
object.second);
1260 params.
color =
toWxString(
static_cast<wxRadioBox*
>(
object.second)->GetBackgroundColour());
1266 params.
type =
"dropdown";
1267 wxChoice* choices =
static_cast<wxChoice*
>(
object.second);
1270 params.
color =
toWxString(
static_cast<wxChoice*
>(
object.second)->GetBackgroundColour());
1276 params.
type =
"combobox";
1277 wxComboBox* combo =
static_cast<wxComboBox*
>(
object.second);
1279 if (combo->GetSelection() != wxNOT_FOUND)
1285 params.
color =
toWxString(
static_cast<wxComboBox*
>(
object.second)->GetBackgroundColour());
1290 params.
type =
"gauge";
1291 params.
value = wxString::Format(
"%d",
static_cast<wxGauge*
>(
object.second)->GetValue());
1293 params.
color =
toWxString(
static_cast<wxGauge*
>(
object.second)->GetBackgroundColour());
1297 params.
type =
"spinbut";
1298 params.
value = wxString::Format(
"%d",
static_cast<SpinBut*
>(
object.second)->GetValue());
1304 params.
type =
"slider";
1305 params.
value = wxString::Format(
"%d",
static_cast<wxSlider*
>(
object.second)->GetValue());
1313 params.
type =
"tablegrid";
1319 wxMGL* grapher =
static_cast<wxMGL*
>(
object.second);
1321 params.
type =
"grapher";
1331 if (params.
label.length())
1332 params.
label +=
", ";
1337 params.
type =
"treelist";
1343 wxMenuItem* item =
static_cast<wxMenuItem*
>(
object.second);
1344 params.
type =
"menuitem";
1347 if (item->IsCheckable())
1348 params.
value = item->IsChecked() ?
"true" :
"false";
1353 params.
state = item->IsEnabled() ?
"enabled" :
"disabled";
1362 params.
state = !
static_cast<wxWindow*
>(
object.second)->IsShown() ?
"hidden" :
static_cast<wxWindow*
>(
object.second)->IsEnabled() ?
"enabled" :
"disabled";
1378 wxArrayString choicesArray;
1381 for (
int i = 0; i < (int)choices.length(); i++)
1383 if (choices[i] ==
'"' && (!i || choices[i-1] !=
'\\'))
1386 if (!(nQuotes % 2) && choices[i] ==
',')
1389 choices.erase(0, i+1);
1394 if (choices.length())
1397 return choicesArray;
1412 wxArrayString funcDef;
1413 wxString sParams = sEventHandler.substr(sEventHandler.find(
'(')+1);
1414 sParams.erase(sParams.rfind(
')'));
1416 funcDef.Add(sEventHandler.substr(0, sEventHandler.find(
'(')));
1418 if (sParams.length())
1422 for (
size_t i = 0; i < choices.size(); i++)
1423 funcDef.Add(choices[i]);
1440 sString.Trim(
false);
1443 if (sString.length() && sString[0] ==
'"' && sString[sString.length()-1] ==
'"')
1444 sString = sString.substr(1, sString.length()-2);
1446 sString.Replace(
"\\\"",
"\"");
1461 wxWindow::Refresh();
1476 std::vector<int> vIDs;
1480 if (iter.second.first == _type)
1481 vIDs.push_back(iter.first);
1514 if (params.
value.substr(0, 2) ==
"\"{" && params.
value.substr(params.
value.length()-2) ==
"}\"")
1540 if (params.
label.substr(0, 2) ==
"\"{" && params.
label.substr(params.
label.length()-2) ==
"}\"")
1543 return params.
label;
1562 return params.
state;
1580 return params.
color;
1599 return iter->second;
1614 wxString sProperties;
1618 if (sProperties.length())
1621 sProperties +=
"\"" + iter.first +
"\"";
1624 if (!sProperties.length())
1641 if (windowItemID == -1)
1647 SetClientSize(wxSize(x,y));
1658 std::pair<CustomWindow::WindowItemType, wxObject*>
object = iter->second;
1660 switch (
object.first)
1680 static_cast<wxGauge*
>(
object.second)->Pulse();
1682 static_cast<wxGauge*
>(
object.second)->SetValue(nVal);
1690 static_cast<SpinBut*
>(
object.second)->SetValue(nVal);
1697 static_cast<wxSlider*
>(
object.second)->SetValue(nVal);
1702 wxRadioBox* box =
static_cast<wxRadioBox*
>(
object.second);
1705 if (sel != wxNOT_FOUND)
1706 box->SetSelection(sel);
1712 wxChoice* choices =
static_cast<wxChoice*
>(
object.second);
1715 if (sel != wxNOT_FOUND)
1716 choices->SetSelection(sel);
1722 wxComboBox* combo =
static_cast<wxComboBox*
>(
object.second);
1725 if (sel != wxNOT_FOUND)
1726 combo->SetSelection(sel);
1734 wxStaticBitmap* bitmap =
static_cast<wxStaticBitmap*
>(
object.second);
1752 wxMenuItem* item =
static_cast<wxMenuItem*
>(
object.second);
1754 if (item->IsCheckable())
1779 if (windowItemID == -1)
1790 std::pair<CustomWindow::WindowItemType, wxObject*>
object = iter->second;
1792 switch (
object.first)
1814 wxString lab = _label;
1818 for (
size_t i = 0; i < labels.size(); i++)
1821 listCtrl->AppendColumn(labels[i]);
1823 listCtrl->GetDataView()->
GetColumn(i)->SetTitle(labels[i]);
1853 if (windowItemID == -1)
1861 std::pair<CustomWindow::WindowItemType, wxObject*>
object = iter->second;
1865 if (_state ==
"hidden" || _state ==
"disabled")
1866 static_cast<wxMenuItem*
>(
object.second)->Enable(
false);
1868 static_cast<wxMenuItem*
>(
object.second)->Enable(
true);
1873 wxWindow* window =
static_cast<wxWindow*
>(
object.second);
1875 if (_state ==
"hidden")
1876 window->Show(
false);
1877 else if (_state ==
"disabled")
1880 window->Enable(
false);
1882 else if (_state ==
"enabled")
1885 window->Enable(
true);
1904 if (windowItemID == -1)
1906 SetBackgroundColour(color);
1917 std::pair<CustomWindow::WindowItemType, wxObject*>
object = iter->second;
1919 switch (
object.first)
1922 static_cast<wxButton*
>(
object.second)->SetForegroundColour(color);
1925 static_cast<wxCheckBox*
>(
object.second)->SetBackgroundColour(color);
1928 static_cast<wxStaticText*
>(
object.second)->SetForegroundColour(color);
1931 static_cast<wxTextCtrl*
>(
object.second)->SetBackgroundColour(color);
1934 static_cast<wxSpinCtrl*
>(
object.second)->SetBackgroundColour(color);
1937 static_cast<wxRadioBox*
>(
object.second)->SetBackgroundColour(color);
1940 static_cast<wxChoice*
>(
object.second)->SetBackgroundColour(color);
1943 static_cast<wxComboBox*
>(
object.second)->SetBackgroundColour(color);
1946 static_cast<wxMenuItem*
>(
object.second)->SetTextColour(color);
1978 wxMGL* mgl =
static_cast<wxMGL*
>(iter->second.second);
1979 wxSize s = mgl->GetSize();
2009 iter->second = _value;
2097 static_cast<NumeReWindow*
>(m_parent)->unregisterWindow(
this);
2125 && event.GetEventType() == wxEVT_TREELIST_SELECTION_CHANGED)
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 ¶ms) 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 ¶ms) 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.
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.
wxStaticText * AddStaticText(wxWindow *parent, wxSizer *sizer, const wxString &text, int id=wxID_STATIC, int alignment=wxALIGN_CENTER_VERTICAL)
Add some static test to the current sizer and window.
wxGauge * CreateGauge(wxWindow *parent, wxSizer *sizer, int style, int id=wxID_ANY, int alignment=wxALIGN_CENTER_VERTICAL)
This member function creates the layout for a progress bar.
wxStaticBitmap * CreateBitmap(wxWindow *parent, wxSizer *sizer, const wxString &filename, int id=wxID_ANY, int alignment=wxALIGN_CENTER_VERTICAL)
This member function creates the layout for a static bitmap.
SpinBut * CreateSpinControl(wxWindow *parent, wxSizer *sizer, const wxString &description, int nMin, int nMax, int nInitial, int id=wxID_ANY, int alignment=wxALIGN_CENTER_VERTICAL)
This member function creates the layout for a spin control including the assigned text.
wxTreeListCtrl * CreateTreeListCtrl(wxWindow *parent, wxSizer *sizer, int nStyle=wxTL_SINGLE, wxSize size=wxDefaultSize, int id=wxID_ANY, int alignment=wxALIGN_CENTER_VERTICAL)
This member function creates the layout for a treelist control.
void AddSpacer(int nSize=10, wxSizer *sizer=nullptr)
Add extra space between the last added (main) element and the next element to be added.
wxChoice * CreateChoices(wxWindow *parent, wxSizer *sizer, const wxArrayString &choices, int id=wxID_ANY, int alignment=wxALIGN_CENTER_VERTICAL)
This member function creates the layout for a dropdown list.
wxRadioBox * CreateRadioBox(wxWindow *parent, wxSizer *sizer, const wxString &description, const wxArrayString &choices, int style=wxHORIZONTAL, int id=wxID_ANY, int alignment=wxALIGN_CENTER_VERTICAL)
This member function creates the layout for a radio box.
wxSlider * CreateSlider(wxWindow *parent, wxSizer *sizer, int nMin, int nMax, int nInitial, int style, int id=wxID_ANY, int alignment=wxALIGN_CENTER_VERTICAL)
This member function creates the layout for a slider.
wxCheckBox * CreateCheckBox(wxWindow *parent, wxSizer *sizer, const wxString &description, int id=wxID_ANY, int alignment=wxALIGN_CENTER_VERTICAL)
This member function creates the layout for a usual checkbox.
wxBoxSizer * getMainSizer()
Return the pointer to the current main layout sizer.
wxStaticBoxSizer * createGroup(const wxString &sGroupName, int orient=wxVERTICAL, wxWindow *parent=nullptr, wxSizer *sizer=nullptr, int expand=0)
Member function to create a group (a static box with a label) in the panel.
wxComboBox * CreateComboBox(wxWindow *parent, wxSizer *sizer, const wxArrayString &choices, int id=wxID_ANY, int alignment=wxALIGN_CENTER_VERTICAL)
This member function creates the layout for a combobox.
wxCollapsiblePane * createCollapsibleGroup(const wxString &label, wxWindow *parent=nullptr, wxSizer *sizer=nullptr)
Member function to create a collapsible group.
wxButton * CreateButton(wxWindow *parent, wxSizer *sizer, const wxString &description, int id=wxID_ANY, int alignment=wxALIGN_CENTER_VERTICAL)
This member function creates the layout for a button.
TextField * CreateTextInput(wxWindow *parent, wxSizer *sizer, const wxString &description, const wxString &sDefault=wxEmptyString, int nStyle=0, int id=wxID_ANY, const wxSize &size=wxSize(310,-1), int alignment=wxALIGN_CENTER_VERTICAL)
This member function creates the layout for a text input.
This data container is a copy- efficient table to interchange data between Kernel and GUI.
void updateWindowInformation(int status, const std::string &_return)
This public member function can be used to update the stored window information in the window manager...
const tinyxml2::XMLDocument * getLayout() const
This class is the actual NumeRe main frame. The application's logic is implemented here.
void pass_command(const wxString &command, bool isEvent=false)
This member function is a wrapper for the corresponding terminal function to pass a command to the ke...
This class is a extension to the standard wxSpinCtrl to combine it with a read- and changeable label.
virtual bool Enable(bool enable)
Enable or disable the label and the control.
virtual bool Show(bool show)
Show or hide the label and the control.
This class is an adaption of the wxGrid class to present the tabular data in NumeRe's memory and enab...
void SetData(NumeRe::Container< std::string > &_stringTable, const std::string &sName, const std::string &sIntName)
This member function is the data setter for string and cluster tables.
void SetTableReadOnly(bool isReadOnly=true)
This member function declares the table to be read-only and enables the context menu entries,...
wxString getSelectedValues()
Returns the values of all selected cells as a string list.
NumeRe::Table GetDataCopy()
This member function returns a safe copy of the internal NumeRe::Table.
This class is a extension to the standard wxTextCtrl to combine it with a read- and changeable label.
virtual bool Show(bool show)
Show or hide the label and the control.
virtual bool Enable(bool enable)
Enable or disable the label and the control.
const char * GetText() const
double DoubleAttribute(const char *name, double defaultValue=0) const
See IntAttribute()
const char * Attribute(const char *name, const char *value=0) const
int IntAttribute(const char *name, int defaultValue=0) const
const char * Value() const
const XMLElement * FirstChildElement(const char *name=0) const
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
const XMLNode * FirstChild() const
Get the first child node, or null if none exists.
const XMLNode * NextSibling() const
Get the next (right) sibling node of this node.
Class is Wx widget which display MathGL graphics.
wxString getClickedCoords()
Return the clicked coordinates as a parsable string. This is used by the custom GUI event handler.
void SetSize(int w, int h)
Set popup menu pointer.
void SetGraph(mglGraph *GR)
void Animation(bool st=true)
Start animation.
void SetDraw(int(*func)(mglBase *gr, void *par), void *par=0)
Set drawing functions and its parameter.
int GetColumnCount() const
wxString GetItemText(const wxTreeItemId &item) const
wxTreeItemId AppendItem(const wxTreeItemId &parent, const wxString &text, int image=-1, int selectedImage=-1, wxTreeItemData *data=NULL)
wxTreeListColumnInfo GetColumn(int column)
size_t GetSelections(wxArrayTreeItemIds &) const
wxTreeItemId GetRootItem() const
virtual bool SetFont(const wxFont &font)
void SetItemText(const wxTreeItemId &item, const wxString &text)
static wxString nextItemValue(wxString &sItem)
Separates the different item values.
static wxColour toWxColour(const wxString &s)
This static function converts wxStrings to colors.
static wxString convertToCodeString(wxString s)
This static function conversts usual strings into "Kernel strings" (i.e. usual NumeRe code strings).
WindowState
Enumeration to define possible states of window items.
static void populateTreeListCtrl(wxTreeListCtrl *listCtrl, const wxArrayString &values)
This static function converts the list of values into items for the passed tree list control and popu...
static wxString toWxString(const wxColor &c)
This static function converts colors to wxStrings.
static wxString getTreeListCtrlValue(wxTreeListCtrl *listCtrl)
This static function returns the current value of the passed tree list control, whereas the value is ...
A structure to simplify the reading of all parameter values of each window item.
A structure to simplify reading and updating window item values.
std::string toString(int)
Converts an integer to a string without the Settings bloat.