NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
CustomWindow Class Reference

This class represents a window, which can be created by the user during run-time by using a layout script and the window command. More...

#include <customwindow.hpp>

Inheritance diagram for CustomWindow:
Collaboration diagram for CustomWindow:

Public Types

enum  WindowItemType {
  CHECKBOX , TEXT , TEXTCTRL , TREELIST ,
  SPINCTRL , BUTTON , RADIOGROUP , DROPDOWN ,
  COMBOBOX , GAUGE , IMAGE , TABLE ,
  GRAPHER , SLIDER , MENUITEM
}
 

Public Member Functions

 CustomWindow (wxWindow *parent, const NumeRe::Window &windowRef)
 CustomWindow constructor. Connects this window with the NumeRe::Window instance and triggers the layouting algorithm. More...
 
std::vector< int > getWindowItems (WindowItemType _type) const
 Returns a list of all window item IDs, which correspond to the selected WindowItemType. More...
 
bool closeWindow ()
 Close this window. More...
 
WindowItemValue getItemValue (int windowItemID) const
 Get the value of the selected item. More...
 
wxString getItemLabel (int windowItemID) const
 Get the label of the selected item. More...
 
wxString getItemState (int windowItemID) const
 Get the state of the selected item. More...
 
wxString getItemColor (int windowItemID) const
 Get the color of the selected item. More...
 
wxString getPropValue (const wxString &varName) const
 Returns the value of the selected window property. More...
 
wxString getProperties () const
 Returns a list of all available window properties. More...
 
bool setItemValue (WindowItemValue &_value, int windowItemID)
 Change the value of the selected item. More...
 
bool setItemLabel (const wxString &_label, int windowItemID)
 Change the label of the selected item. More...
 
bool setItemState (const wxString &_state, int windowItemID)
 Change the state of the selected item. More...
 
bool setItemColor (const wxString &_color, int windowItemID)
 Change the color of the selected item. More...
 
bool setItemGraph (GraphHelper *_helper, int windowItemID)
 Updates the selected grapher item. More...
 
bool setPropValue (const wxString &_value, const wxString &varName)
 Sets the value of the selected window property. More...
 
void OnMenuEvent (wxCommandEvent &event)
 Menu event handler. More...
 
void OnClick (wxCommandEvent &event)
 Button click event handler. More...
 
void OnChange (wxCommandEvent &event)
 Generic onchange event handler. More...
 
void OnSpin (wxSpinEvent &event)
 wxSpinCtrl event handler. More...
 
void OnCellSelect (wxGridEvent &event)
 wxGrid event handler. More...
 
void OnClose (wxCloseEvent &event)
 OnClose event handler. More...
 
void OnMouseLeftDown (wxMouseEvent &event)
 Mouse event handler. More...
 
void OnTreeListEvent (wxTreeListEvent &event)
 Tree list control event handler. More...
 
void OnSizeEvent (wxSizeEvent &event)
 On size event handler. More...
 
 DECLARE_EVENT_TABLE ()
 

Private Member Functions

void layout ()
 This member function evaluates the layout supplied by the user via a tinyxml2::XMLDocument instance. More...
 
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 children. More...
 
void layoutMenu (const tinyxml2::XMLElement *currentChild, wxMenu *currMenu)
 This member function can be called recursively and creates menus and submenus for the current window layout. More...
 
void handleEvent (wxEvent &event, const wxString &sEventType)
 This member function is the central kernel interaction event handler. Will be called from the wxWidgets' event handler and all the registered procedures (if any). More...
 
bool getWindowParameters (WindowItemParams &params) const
 Returns the parameters of this window. More...
 
bool getItemParameters (int windowItemID, WindowItemParams &params) const
 Returns the parameters of the selected window item. More...
 
wxArrayString getChoices (wxString &choices) const
 A simple tokenizer to separate a list of strings into multiple strings. More...
 
wxArrayString decodeEventHandlerFunction (const wxString &sEventHandler) const
 This member function decodes the arguments of a event handler function and returns them as a wxArrayString. More...
 
wxString removeQuotationMarks (wxString sString) const
 Private member function to convert a kernel string into a usual string. More...
 
void Refresh ()
 Wrapper for wxWindow::Refresh to use it together with CallAfter(). More...
 

Private Attributes

std::map< int, std::pair< WindowItemType, wxObject * > > m_windowItems
 
std::map< int, wxString > m_eventTable
 
std::map< wxString, wxString > m_varTable
 
NumeRe::Window m_windowRef
 

Detailed Description

This class represents a window, which can be created by the user during run-time by using a layout script and the window command.

Definition at line 71 of file customwindow.hpp.

Member Enumeration Documentation

◆ WindowItemType

Enumerator
CHECKBOX 
TEXT 
TEXTCTRL 
TREELIST 
SPINCTRL 
BUTTON 
RADIOGROUP 
DROPDOWN 
COMBOBOX 
GAUGE 
IMAGE 
TABLE 
GRAPHER 
SLIDER 
MENUITEM 

Definition at line 74 of file customwindow.hpp.

Constructor & Destructor Documentation

◆ CustomWindow()

CustomWindow::CustomWindow ( wxWindow *  parent,
const NumeRe::Window windowRef 
)

CustomWindow constructor. Connects this window with the NumeRe::Window instance and triggers the layouting algorithm.

Parameters
parentwxWindow*
windowRefconst NumeRe::Window&

Definition at line 266 of file customwindow.cpp.

Member Function Documentation

◆ closeWindow()

bool CustomWindow::closeWindow ( )

Close this window.

Returns
bool

Definition at line 1494 of file customwindow.cpp.

Referenced by NumeRe::Window::closeWindow(), and handleEvent().

◆ DECLARE_EVENT_TABLE()

CustomWindow::DECLARE_EVENT_TABLE ( )

◆ decodeEventHandlerFunction()

wxArrayString CustomWindow::decodeEventHandlerFunction ( const wxString &  sEventHandler) const
private

This member function decodes the arguments of a event handler function and returns them as a wxArrayString.

Parameters
sEventHandlerconst wxString&
Returns
wxArrayString

Definition at line 1410 of file customwindow.cpp.

References getChoices().

Referenced by handleEvent().

Here is the call graph for this function:

◆ getChoices()

wxArrayString CustomWindow::getChoices ( wxString &  choices) const
private

A simple tokenizer to separate a list of strings into multiple strings.

Parameters
choiceswxString&
Returns
wxArrayString

Definition at line 1376 of file customwindow.cpp.

References removeQuotationMarks().

Referenced by decodeEventHandlerFunction(), layoutChild(), setItemLabel(), and setItemValue().

Here is the call graph for this function:

◆ getItemColor()

wxString CustomWindow::getItemColor ( int  windowItemID) const

Get the color of the selected item.

Parameters
windowItemIDint
Returns
wxString

Definition at line 1575 of file customwindow.cpp.

References WindowItemParams::color, and getItemParameters().

Referenced by NumeRe::Window::getItemColor().

Here is the call graph for this function:

◆ getItemLabel()

wxString CustomWindow::getItemLabel ( int  windowItemID) const

Get the label of the selected item.

Parameters
windowItemIDint
Returns
wxString

Definition at line 1534 of file customwindow.cpp.

References getItemParameters(), and WindowItemParams::label.

Referenced by NumeRe::Window::getItemLabel().

Here is the call graph for this function:

◆ getItemParameters()

bool CustomWindow::getItemParameters ( int  windowItemID,
WindowItemParams params 
) const
private

◆ getItemState()

wxString CustomWindow::getItemState ( int  windowItemID) const

Get the state of the selected item.

Parameters
windowItemIDint
Returns
wxString

Definition at line 1557 of file customwindow.cpp.

References getItemParameters(), and WindowItemParams::state.

Referenced by NumeRe::Window::getItemState().

Here is the call graph for this function:

◆ getItemValue()

WindowItemValue CustomWindow::getItemValue ( int  windowItemID) const

Get the value of the selected item.

Parameters
windowItemIDint
Returns
WindowItemValue

Definition at line 1507 of file customwindow.cpp.

References getItemParameters(), WindowItemValue::stringValue, WindowItemParams::table, WindowItemValue::tableValue, WindowItemParams::type, WindowItemValue::type, and WindowItemParams::value.

Referenced by NumeRe::Window::getItemValue().

Here is the call graph for this function:

◆ getProperties()

wxString CustomWindow::getProperties ( ) const

Returns a list of all available window properties.

Returns
wxString

Definition at line 1612 of file customwindow.cpp.

References m_varTable.

Referenced by NumeRe::Window::getProperties().

◆ getPropValue()

wxString CustomWindow::getPropValue ( const wxString &  varName) const

Returns the value of the selected window property.

Parameters
varNameconst wxString&
Returns
wxString

Definition at line 1594 of file customwindow.cpp.

References m_varTable.

Referenced by NumeRe::Window::getPropValue().

◆ getWindowItems()

std::vector< int > CustomWindow::getWindowItems ( CustomWindow::WindowItemType  _type) const

Returns a list of all window item IDs, which correspond to the selected WindowItemType.

Parameters
_typeCustomWindow::WindowItemType
Returns
std::vector<int>

Definition at line 1474 of file customwindow.cpp.

References m_windowItems.

Referenced by NumeRe::Window::getWindowItems().

◆ getWindowParameters()

bool CustomWindow::getWindowParameters ( WindowItemParams params) const
private

Returns the parameters of this window.

Parameters
paramsWindowItemParams&
Returns
bool

Definition at line 1190 of file customwindow.cpp.

References WindowItemParams::color, WindowItemParams::label, WindowItemParams::state, toWxString(), WindowItemParams::type, and WindowItemParams::value.

Referenced by getItemParameters().

Here is the call graph for this function:

◆ handleEvent()

void CustomWindow::handleEvent ( wxEvent &  event,
const wxString &  sEventType 
)
private

This member function is the central kernel interaction event handler. Will be called from the wxWidgets' event handler and all the registered procedures (if any).

Parameters
eventwxEvent&
sEventTypeconst wxString&
Returns
void

Definition at line 1084 of file customwindow.cpp.

References closeWindow(), decodeEventHandlerFunction(), NumeRe::Window::getId(), getItemParameters(), m_eventTable, m_windowRef, NumeReWindow::pass_command(), setItemState(), setItemValue(), WindowItemParams::state, WindowItemValue::stringValue, WindowItemParams::table, WindowItemValue::tableValue, toString(), WindowItemParams::type, WindowItemValue::type, and WindowItemParams::value.

Referenced by OnCellSelect(), OnChange(), OnClick(), OnClose(), OnMenuEvent(), OnMouseLeftDown(), OnSpin(), and OnTreeListEvent().

Here is the call graph for this function:

◆ layout()

void CustomWindow::layout ( )
private

This member function evaluates the layout supplied by the user via a tinyxml2::XMLDocument instance.

Returns
void

Definition at line 282 of file customwindow.cpp.

References tinyxml2::XMLElement::Attribute(), tinyxml2::XMLNode::FirstChild(), tinyxml2::XMLNode::FirstChildElement(), NumeRe::Window::getLayout(), GroupPanel::getMainSizer(), layoutChild(), m_windowRef, OnMouseLeftDown(), and tinyxml2::XMLNode::ToElement().

Here is the call graph for this function:

◆ layoutChild()

void CustomWindow::layoutChild ( const tinyxml2::XMLElement currentChild,
wxWindow *  currParent,
wxSizer *  currSizer,
GroupPanel _groupPanel 
)
private

This member function can be called recursively and creates the layout for the current XMLElement's children.

Parameters
currentChildconst tinyxml2::XMLElement*
currParentwxWindow*
currSizerwxSizer*
_groupPanelGroupPanel*
Returns
void

Definition at line 368 of file customwindow.cpp.

References GroupPanel::AddSpacer(), GroupPanel::AddStaticText(), wxTreeListCtrl::AppendItem(), tinyxml2::XMLElement::Attribute(), BUTTON, CHECKBOX, COMBOBOX, GroupPanel::CreateBitmap(), GroupPanel::CreateButton(), GroupPanel::CreateCheckBox(), GroupPanel::CreateChoices(), GroupPanel::createCollapsibleGroup(), GroupPanel::CreateComboBox(), GroupPanel::CreateGauge(), GroupPanel::createGroup(), GroupPanel::CreateRadioBox(), GroupPanel::CreateSlider(), GroupPanel::CreateSpinControl(), GroupPanel::CreateTextInput(), GroupPanel::CreateTreeListCtrl(), DISABLED, tinyxml2::XMLElement::DoubleAttribute(), DROPDOWN, SpinBut::Enable(), TextField::Enable(), ENABLED, tinyxml2::XMLNode::FirstChildElement(), GAUGE, getChoices(), GroupPanel::getMainSizer(), wxTreeListCtrl::GetRootItem(), tinyxml2::XMLElement::GetText(), GRAPHER, HIDDEN, IMAGE, tinyxml2::XMLElement::IntAttribute(), layoutChild(), layoutMenu(), m_eventTable, m_varTable, m_windowItems, name, tinyxml2::XMLNode::NextSibling(), populateTreeListCtrl(), RADIOGROUP, removeQuotationMarks(), TableViewer::SetData(), wxTreeListCtrl::SetFont(), TableViewer::SetTableReadOnly(), SpinBut::Show(), TextField::Show(), SLIDER, SPINCTRL, TABLE, TEXT, TEXTCTRL, tinyxml2::XMLNode::ToElement(), toWxColour(), TREELIST, and tinyxml2::XMLNode::Value().

Referenced by layout(), and layoutChild().

Here is the call graph for this function:

◆ layoutMenu()

void CustomWindow::layoutMenu ( const tinyxml2::XMLElement currentChild,
wxMenu *  currMenu 
)
private

This member function can be called recursively and creates menus and submenus for the current window layout.

Parameters
currentChildconst tinyxml2::XMLElement*
currMenuwxMenu*
Returns
void

Definition at line 953 of file customwindow.cpp.

References tinyxml2::XMLElement::Attribute(), DISABLED, tinyxml2::XMLElement::DoubleAttribute(), ENABLED, tinyxml2::XMLNode::FirstChildElement(), tinyxml2::XMLElement::GetText(), layoutMenu(), m_eventTable, m_windowItems, MENUITEM, tinyxml2::XMLNode::NextSibling(), removeQuotationMarks(), tinyxml2::XMLNode::ToElement(), toWxColour(), and tinyxml2::XMLNode::Value().

Referenced by layoutChild(), and layoutMenu().

Here is the call graph for this function:

◆ OnCellSelect()

void CustomWindow::OnCellSelect ( wxGridEvent &  event)

wxGrid event handler.

Parameters
eventwxGridEvent&
Returns
void

Definition at line 2079 of file customwindow.cpp.

References convertToCodeString(), handleEvent(), and m_windowItems.

Here is the call graph for this function:

◆ OnChange()

void CustomWindow::OnChange ( wxCommandEvent &  event)

Generic onchange event handler.

Parameters
eventwxCommandEvent&
Returns
void

Definition at line 2050 of file customwindow.cpp.

References handleEvent(), m_windowItems, and SPINCTRL.

Here is the call graph for this function:

◆ OnClick()

void CustomWindow::OnClick ( wxCommandEvent &  event)

Button click event handler.

Parameters
eventwxCommandEvent&
Returns
void

Definition at line 2037 of file customwindow.cpp.

References handleEvent().

Here is the call graph for this function:

◆ OnClose()

void CustomWindow::OnClose ( wxCloseEvent &  event)

OnClose event handler.

Parameters
eventwxCloseEvent&
Returns
void

Definition at line 2093 of file customwindow.cpp.

References handleEvent(), m_windowRef, NumeRe::STATUS_CANCEL, and NumeRe::Window::updateWindowInformation().

Here is the call graph for this function:

◆ OnMenuEvent()

void CustomWindow::OnMenuEvent ( wxCommandEvent &  event)

Menu event handler.

Parameters
eventwxCommandEvent&
Returns
void

Definition at line 2024 of file customwindow.cpp.

References handleEvent().

Here is the call graph for this function:

◆ OnMouseLeftDown()

void CustomWindow::OnMouseLeftDown ( wxMouseEvent &  event)

Mouse event handler.

Parameters
eventwxMouseEvent&
Returns
void

Definition at line 2109 of file customwindow.cpp.

References handleEvent().

Referenced by layout().

Here is the call graph for this function:

◆ OnSizeEvent()

void CustomWindow::OnSizeEvent ( wxSizeEvent &  event)

On size event handler.

Parameters
eventwxSizeEvent&
Returns
void

Definition at line 2139 of file customwindow.cpp.

References Refresh().

Here is the call graph for this function:

◆ OnSpin()

void CustomWindow::OnSpin ( wxSpinEvent &  event)

wxSpinCtrl event handler.

Parameters
eventwxSpinEvent&
Returns
void

Definition at line 2066 of file customwindow.cpp.

References handleEvent().

Here is the call graph for this function:

◆ OnTreeListEvent()

void CustomWindow::OnTreeListEvent ( wxTreeListEvent &  event)

Tree list control event handler.

Parameters
eventwxTreeListEvent&
Returns
void

Definition at line 2122 of file customwindow.cpp.

References handleEvent(), and m_windowItems.

Here is the call graph for this function:

◆ Refresh()

void CustomWindow::Refresh ( )
private

Wrapper for wxWindow::Refresh to use it together with CallAfter().

Returns
void

Definition at line 1459 of file customwindow.cpp.

Referenced by OnSizeEvent(), setItemColor(), and setItemValue().

◆ removeQuotationMarks()

wxString CustomWindow::removeQuotationMarks ( wxString  sString) const
private

Private member function to convert a kernel string into a usual string.

Parameters
sStringwxString
Returns
wxString

Definition at line 1438 of file customwindow.cpp.

Referenced by getChoices(), layoutChild(), layoutMenu(), setItemLabel(), and setItemValue().

◆ setItemColor()

bool CustomWindow::setItemColor ( const wxString &  _color,
int  windowItemID 
)

Change the color of the selected item.

Parameters
_colorconst wxString&
windowItemIDint
Returns
bool

Definition at line 1900 of file customwindow.cpp.

References BUTTON, CHECKBOX, COMBOBOX, DROPDOWN, GAUGE, GRAPHER, IMAGE, m_windowItems, MENUITEM, RADIOGROUP, Refresh(), SLIDER, SPINCTRL, TABLE, TEXT, TEXTCTRL, toWxColour(), and TREELIST.

Referenced by NumeRe::Window::setItemColor().

Here is the call graph for this function:

◆ setItemGraph()

bool CustomWindow::setItemGraph ( GraphHelper _helper,
int  windowItemID 
)

Updates the selected grapher item.

Parameters
_helperGraphHelper*
windowItemIDint
Returns
bool

Definition at line 1971 of file customwindow.cpp.

References wxMGL::AnimateAsynch(), wxMGL::Animation(), wxMGL::getNumFrames(), GRAPHER, m_windowItems, wxMGL::SetDraw(), wxMGL::SetGraph(), GraphHelper::setGrapher(), and wxMGL::SetSize().

Referenced by NumeRe::Window::setItemGraph().

Here is the call graph for this function:

◆ setItemLabel()

bool CustomWindow::setItemLabel ( const wxString &  _label,
int  windowItemID 
)

Change the label of the selected item.

Parameters
_labelconst wxString&
windowItemIDint
Returns
bool

Definition at line 1777 of file customwindow.cpp.

References BUTTON, CHECKBOX, COMBOBOX, DROPDOWN, GAUGE, getChoices(), wxTreeListCtrl::GetColumn(), wxTreeListCtrl::GetColumnCount(), GRAPHER, IMAGE, m_windowItems, MENUITEM, RADIOGROUP, removeQuotationMarks(), SLIDER, SPINCTRL, TABLE, TEXT, TEXTCTRL, and TREELIST.

Referenced by NumeRe::Window::setItemLabel().

Here is the call graph for this function:

◆ setItemState()

bool CustomWindow::setItemState ( const wxString &  _state,
int  windowItemID 
)

Change the state of the selected item.

Parameters
_stateconst wxString&
windowItemIDint
Returns
bool

Definition at line 1851 of file customwindow.cpp.

References m_windowItems, and MENUITEM.

Referenced by handleEvent(), and NumeRe::Window::setItemState().

◆ setItemValue()

bool CustomWindow::setItemValue ( WindowItemValue _value,
int  windowItemID 
)

Change the value of the selected item.

Parameters
_valueWindowItemValue&
windowItemIDint
Returns
bool

Definition at line 1639 of file customwindow.cpp.

References BUTTON, CHECKBOX, COMBOBOX, DROPDOWN, GAUGE, getChoices(), GRAPHER, IMAGE, m_windowItems, MENUITEM, populateTreeListCtrl(), RADIOGROUP, Refresh(), removeQuotationMarks(), TableViewer::SetData(), SLIDER, SPINCTRL, WindowItemValue::stringValue, TABLE, WindowItemValue::tableValue, TEXT, TEXTCTRL, and TREELIST.

Referenced by handleEvent(), and NumeRe::Window::setItemValue().

Here is the call graph for this function:

◆ setPropValue()

bool CustomWindow::setPropValue ( const wxString &  _value,
const wxString &  varName 
)

Sets the value of the selected window property.

Parameters
_valueconst wxString&
varNameconst wxString&
Returns
bool

Definition at line 2003 of file customwindow.cpp.

References m_varTable.

Referenced by NumeRe::Window::setPropValue().

Member Data Documentation

◆ m_eventTable

std::map<int, wxString> CustomWindow::m_eventTable
private

Definition at line 95 of file customwindow.hpp.

Referenced by handleEvent(), layoutChild(), and layoutMenu().

◆ m_varTable

std::map<wxString, wxString> CustomWindow::m_varTable
private

Definition at line 96 of file customwindow.hpp.

Referenced by getProperties(), getPropValue(), layoutChild(), and setPropValue().

◆ m_windowItems

std::map<int, std::pair<WindowItemType,wxObject*> > CustomWindow::m_windowItems
private

◆ m_windowRef

NumeRe::Window CustomWindow::m_windowRef
private

Definition at line 98 of file customwindow.hpp.

Referenced by handleEvent(), layout(), and OnClose().


The documentation for this class was generated from the following files: