33#include <xercesc/parsers/SAXParser.hpp>
41#define TREELISTWIDTH 200
58FXIMPLEMENT(
GNEOptionsEditor, FXVerticalFrame, GNEOptionsEditorMap, ARRAYNUMBER(GNEOptionsEditorMap))
68 myOptionsContainer(optionsContainer),
69 myCopyOfOptionsContainer(optionsContainer.clone()),
70 myOriginalOptionsContainer(originalOptionsContainer) {
72 auto staticTooltipMenu = dialog->getApplicationWindow()->getStaticTooltipMenu();
76 (std::string(
"\t") +
TL(
"Toggle Menu Tooltips") + std::string(
"\t") +
TL(
"Toggles whether tooltips in the menu shall be shown.")).c_str(),
78 auto saveFile =
new MFXButtonTooltip(buttonsFrame, staticTooltipMenu,
TL(
"Save options"),
80 saveFile->setTipText(
TL(
"Save configuration file"));
81 auto loadFile =
new MFXButtonTooltip(buttonsFrame, staticTooltipMenu,
TL(
"Load options"),
83 loadFile->setTipText(
TL(
"Load configuration file"));
84 auto resetDefault =
new MFXButtonTooltip(buttonsFrame, staticTooltipMenu,
TL(
"Default options"),
86 resetDefault->setTipText(
TL(
"Reset all options to default"));
88 new FXSeparator(
this);
100 myRootItem = myTopicsTreeList->appendItem(
nullptr, titleName.c_str());
101 myRootItem->setExpanded(TRUE);
103 FXScrollWindow* scrollTabEntries =
new FXScrollWindow(groupBoxOptions->
getCollapsableFrame(), LAYOUT_FILL_X | LAYOUT_FILL_Y);
107 for (
const auto& topic : myOptionsContainer.getSubTopics()) {
109 if (myIgnoredTopics.count(topic) == 0) {
111 myTreeItemTopics[myTopicsTreeList->appendItem(myRootItem, topic.c_str())] = topic;
113 const std::vector<std::string> entries = myOptionsContainer.getSubTopicsEntries(topic);
114 for (
const auto& entry : entries) {
116 if (myIgnoredEntries.count(entry) == 0) {
118 const std::string type = myOptionsContainer.getTypeName(entry);
120 const std::string description = myOptionsContainer.getDescription(entry);
122 const std::string defaultValue = myOptionsContainer.getValueString(entry);
126 }
else if (type ==
"TIME") {
128 }
else if ((type ==
"FILE") || (type ==
"NETWORK") || (type ==
"ADDITIONAL") || (type ==
"ROUTE") || (type ==
"DATA")) {
130 }
else if (type ==
"BOOL") {
132 }
else if (type ==
"INT") {
134 }
else if (type ==
"FLOAT") {
136 }
else if (type ==
"INT[]") {
138 }
else if (type ==
"STR[]") {
149 myDescriptionSearchCheckButton->setToolTipText(
TL(
"Include description in search"));
152 for (
const auto& entry : myOptionRowEntries) {
153 entry->adjustNameSize();
156 myShowToolTipsMenu->setChecked(getApp()->reg().readIntEntry(
"gui",
"menuToolTips", 0) != 1);
179 entry->onCmdResetOption(
nullptr, 0,
nullptr);
213 viewNet->getViewParent()->getShowToolTipsMenu()->update();
253 entry->updateOption();
264 entry->restoreOption();
272 myOriginalOptionsContainer(
OptionsCont::EMPTY_OPTIONS) {
280 if (treeItemTopic.first->isSelected()) {
283 if (entry->getTopic() == treeItemTopic.second) {
310 if (searchText.empty()) {
313 }
else if (entry->getNameLower().find(searchText) != std::string::npos) {
316 (entry->getDescriptionLower().find(searchText) != std::string::npos)) {
332 XERCES_CPP_NAMESPACE::SAXParser parser;
333 parser.setValidationScheme(XERCES_CPP_NAMESPACE::SAXParser::Val_Never);
334 parser.setDisableDefaultEntityResolution(
true);
338 parser.setDocumentHandler(&handler);
339 parser.setErrorHandler(&handler);
342 WRITE_ERROR(
TL(
"Could not load configuration '") + file +
"'.");
345 }
catch (
const XERCES_CPP_NAMESPACE::XMLException& e) {
FXDEFMAP(GNEOptionsEditor) GNEOptionsEditorMap[]
@ MID_GNE_SET_ATTRIBUTE
attribute edited
@ MID_CHOOSEN_SAVE
Save set.
@ MID_SHOWTOOLTIPS_MENU
Show tool tips in menus - button.
@ MID_GNE_SEARCH_USEDESCRIPTION
use search description
@ MID_GNE_BUTTON_DEFAULT
default button
@ MID_CHOOSEN_LOAD
Load set.
@ MID_GNE_SELECT
select element
@ MID_MTEXTFIELDSEARCH_UPDATED
callback for MFXTextFieldSearch
#define GUIDesignCheckButtonThick
checkButton placed in left position
#define GUIDesignTextField
#define GUIDesignAuxiliarHorizontalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames
#define GUIDesignButtonConfiguration
Configuration Button.
#define GUIDesignTreeListFixedWidth
#define GUIDesignAuxiliarVerticalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames
#define GUIDesignMFXCheckableButtonSquare
#define GUIDesignAuxiliarFrame
design for auxiliar (Without borders) frame extended in all directions
#define GUIDesignLabelThickedFixed(width)
label thicked, icon before text, text centered and custom width
#define GUIDesignHorizontalFrameNoPadding
Horizontal frame extended over frame parent without padding and spacing.
#define WRITE_MESSAGE(msg)
int GUIDesignHeight
the default height for GUI elements
GNEViewNet * getViewNet()
get pointer to viewNet
GNEApplicationWindow * getApplicationWindow() const
get pointer to the application window
long onCmdSaveOptions(FXObject *, FXSelector, void *)
save options
void resetAllOptions()
reset options
bool loadConfiguration(const std::string &file)
load configuration
long onCmdShowToolTipsMenu(FXObject *, FXSelector, void *)
enable/disable show toolTip
FXVerticalFrame * myEntriesFrame
vertical frame for entries
long onCmdSearch(FXObject *, FXSelector, void *)
called when user searches
long onCmdLoadOptions(FXObject *, FXSelector, void *)
load options
MFXTextFieldSearch * mySearchButton
search button
GNEDialog * myDialog
reference to dialog
OptionsCont & myOptionsContainer
reference to edited Option container
bool myOptionsModified
flag for check if options was modified
MFXCheckButtonTooltip * myDescriptionSearchCheckButton
checkbox for enable/disable search by description
void runInternalTest(const InternalTestStep::DialogArgument *dialogArgument)
run internal test
long onCmdResetDefault(FXObject *, FXSelector, void *)
reset default
MFXCheckableButton * myShowToolTipsMenu
checkable button for show toolTips
long onCmdSelectTopic(FXObject *, FXSelector, void *)
called when user select a topic in the list
OptionsCont * myCopyOfOptionsContainer
copy of edited Option container, used for reset
GNEOptionsEditor()
FOX needs this.
std::map< FXTreeItem *, std::string > myTreeItemTopics
map with topics and their associated FXTreeItem
bool updateVisibleEntriesByTopic()
update visible entries by selected topic
void updateVisibleEntriesBySearch(std::string searchText)
update visible entries by search
bool isOptionModified() const
check if option was modified
std::vector< GNEOptionsEditorRow::OptionRow * > myOptionRowEntries
Input option entries.
~GNEOptionsEditor()
Destructor.
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
MFXStaticToolTip * getStaticTooltipMenu() const
get static toolTip for menus
dialog arguments, used for certain modal dialogs that can not be edited using tab
MFXGroupBoxModule (based on FXGroupBox)
FXVerticalFrame * getCollapsableFrame()
get collapsable frame (used by all elements that will be collapsed if button is toggled)
FXString getText() const
Get the text for this label.
FXTextFieldIcon (based on FXTextFieldIcon)
A storage for options typed value containers)
void writeConfiguration(std::ostream &os, const bool filled, const bool complete, const bool addComments, const std::string &relativeTo="", const bool forceRelative=false, const bool inComment=false) const
Writes the configuration.
void resetWritable()
Resets all options to be writeable.
A SAX-Handler for loading options.
bool errorOccurred() const
Returns the information whether an error occurred.
static StringBijection< XMLFileExtension > XMLFileExtensions
XML file Extensions.
static std::string to_lower_case(const std::string &str)
Transfers the content to lower case.
static std::string transcode(const XMLCh *const data)
converts a 0-terminated XMLCh* array (usually UTF-16, stemming from Xerces) into std::string in UTF-8
static std::string transcodeToLocal(const std::string &utf8String)
convert a string from UTF-8 to the local codepage