Path: blob/main/src/gui/dialogs/GUIDialog_AppSettings.cpp
193728 views
/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2026 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file GUIDialog_AppSettings.cpp14/// @author Daniel Krajzewicz15/// @author Michael Behrisch16/// @date Mon, 08.03.200417///18// The application-settings dialog19/****************************************************************************/20#include <config.h>2122#include <utils/common/MsgHandler.h>23#include <utils/gui/images/GUIIconSubSys.h>24#include <utils/gui/images/GUITexturesHelper.h>25#include <utils/gui/windows/GUIAppEnum.h>26#include <utils/gui/div/GUIMessageWindow.h>27#include <utils/gui/div/GUIDesigns.h>28#include <gui/GUIGlobals.h>29#include "GUIDialog_AppSettings.h"303132// ===========================================================================33// FOX callback mapping34// ===========================================================================35FXDEFMAP(GUIDialog_AppSettings) GUIDialog_AppSettingsMap[] = {36FXMAPFUNC(SEL_COMMAND, MID_QUITONSIMEND, GUIDialog_AppSettings::onCmdSelect),37FXMAPFUNC(SEL_COMMAND, MID_AUTOSTART, GUIDialog_AppSettings::onCmdSelect),38FXMAPFUNC(SEL_COMMAND, MID_DEMO, GUIDialog_AppSettings::onCmdSelect),39FXMAPFUNC(SEL_COMMAND, MID_ALLOWTEXTURES, GUIDialog_AppSettings::onCmdSelect),40FXMAPFUNC(SEL_COMMAND, MID_LOCATELINKS, GUIDialog_AppSettings::onCmdSelect),41FXMAPFUNC(SEL_COMMAND, MID_SETTINGS_OK, GUIDialog_AppSettings::onCmdOk),42FXMAPFUNC(SEL_COMMAND, MID_SETTINGS_CANCEL, GUIDialog_AppSettings::onCmdCancel),43};4445FXIMPLEMENT(GUIDialog_AppSettings, FXDialogBox, GUIDialog_AppSettingsMap, ARRAYNUMBER(GUIDialog_AppSettingsMap))464748// ===========================================================================49// method definitions50// ===========================================================================51GUIDialog_AppSettings::GUIDialog_AppSettings(GUIMainWindow* parent)52: FXDialogBox(parent, TL("Application Settings")),53myParent(parent),54myAppQuitOnEnd(GUIGlobals::gQuitOnEnd),55myAppAutoStart(GUIGlobals::gRunAfterLoad),56myAppDemo(GUIGlobals::gDemoAutoReload),57myAllowTextures(GUITexturesHelper::texturesAllowed()),58myLocateLinks(GUIMessageWindow::locateLinksEnabled()) {59FXCheckButton* b = nullptr;60FXVerticalFrame* f1 = new FXVerticalFrame(this, LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0, 0, 0, 0, 0);61b = new FXCheckButton(f1, TL("Quit on Simulation End"), this, MID_QUITONSIMEND);62b->setCheck(myAppQuitOnEnd);63b = new FXCheckButton(f1, TL("Autostart Simulation on Load and Reload"), this, MID_AUTOSTART);64b->setCheck(myAppAutoStart);65b = new FXCheckButton(f1, TL("Reload Simulation after finish (Demo mode)"), this, MID_DEMO);66b->setCheck(myAppDemo);67b = new FXCheckButton(f1, TL("Locate elements when clicking on messages"), this, MID_LOCATELINKS);68b->setCheck(myLocateLinks);6970FXMatrix* m1 = new FXMatrix(f1, 2, (LAYOUT_FILL_X | LAYOUT_LEFT | MATRIX_BY_COLUMNS), 0, 0, 0, 0, 10, 10, 10, 10, 5, 5);71myBreakPointOffset = new FXRealSpinner(m1, 5, this, MID_TIMELINK_BREAKPOINT, GUIDesignViewSettingsSpinDial2 | SPIN_NOMIN);72myBreakPointOffset->setValue(STEPS2TIME(GUIMessageWindow::getBreakPointOffset()));73new FXLabel(m1, TL("Breakpoint offset when clicking on time message"), nullptr, GUIDesignViewSettingsLabel1);74myTable = new FXTable(f1, this, MID_TABLE, GUIDesignBreakpointTable);75const auto& onlineMaps = parent->getOnlineMaps();76const int numRows = (int)onlineMaps.size() + 1;77myTable->setVisibleRows(numRows);78myTable->setVisibleColumns(2);79myTable->setTableSize(numRows, 2);80myTable->setBackColor(GUIDesignBackgroundColorWhite);81myTable->getRowHeader()->setWidth(0);82myTable->setTableSize(numRows, 2);83myTable->setColumnText(0, "Name");84myTable->setColumnText(1, "URL");85FXHeader* header = myTable->getColumnHeader();86header->setHeight(GUIDesignHeight);87header->setItemSize(0, 60);88header->setItemSize(1, 275);89int row = 0;90for (const auto& item : onlineMaps) {91myTable->setItemText(row, 0, item.first.c_str());92myTable->setItemText(row, 1, item.second.c_str());93row++;94}9596new FXHorizontalSeparator(f1, SEPARATOR_GROOVE | LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_FILL_X);97b = new FXCheckButton(f1, TL("Allow Textures"), this, MID_ALLOWTEXTURES);98b->setCheck(myAllowTextures);99FXHorizontalFrame* f2 = new FXHorizontalFrame(f1, LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_FILL_X | PACK_UNIFORM_WIDTH, 0, 0, 0, 0, 10, 10, 5, 5);100FXButton* initial = GUIDesigns::buildFXButton(f2, TL("&OK"), "", "", nullptr, this, MID_SETTINGS_OK, BUTTON_INITIAL | BUTTON_DEFAULT | FRAME_RAISED | FRAME_THICK | LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_CENTER_X, 0, 0, 0, 0, 30, 30, 4, 4);101GUIDesigns::buildFXButton(f2, TL("&Cancel"), "", "", nullptr, this, MID_SETTINGS_CANCEL, BUTTON_DEFAULT | FRAME_RAISED | FRAME_THICK | LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_CENTER_X, 0, 0, 0, 0, 30, 30, 4, 4);102initial->setFocus();103setIcon(GUIIconSubSys::getIcon(GUIIcon::EMPTY));104}105106107GUIDialog_AppSettings::~GUIDialog_AppSettings() {}108109110long111GUIDialog_AppSettings::onCmdOk(FXObject*, FXSelector, void*) {112GUIGlobals::gQuitOnEnd = myAppQuitOnEnd;113GUIGlobals::gRunAfterLoad = myAppAutoStart;114GUIGlobals::gDemoAutoReload = myAppDemo;115GUIGlobals::gRunAfterLoad = myAppAutoStart;116GUITexturesHelper::allowTextures(myAllowTextures);117GUIMessageWindow::enableLocateLinks(myLocateLinks);118GUIMessageWindow::setBreakPointOffset(TIME2STEPS(myBreakPointOffset->getValue()));119FXString maps;120for (int r = 0; r < myTable->getNumRows(); r++) {121if (myTable->getItem(r, 0) != nullptr && myTable->getItem(r, 1) != nullptr) {122myParent->addOnlineMap(myTable->getItem(r, 0)->getText().text(), myTable->getItem(r, 1)->getText().text());123if (!maps.empty()) {124maps += "\n";125}126maps += myTable->getItem(r, 0)->getText() + "\t" + myTable->getItem(r, 1)->getText();127}128}129getApp()->reg().writeStringEntry("gui", "onlineMaps", maps.text());130destroy();131return 1;132}133134135long136GUIDialog_AppSettings::onCmdCancel(FXObject*, FXSelector, void*) {137destroy();138return 1;139}140141long142GUIDialog_AppSettings::onCmdSelect(FXObject*, FXSelector sel, void*) {143switch (FXSELID(sel)) {144case MID_QUITONSIMEND:145myAppQuitOnEnd = !myAppQuitOnEnd;146break;147case MID_AUTOSTART:148myAppAutoStart = !myAppAutoStart;149break;150case MID_DEMO:151myAppDemo = !myAppDemo;152break;153case MID_LOCATELINKS:154myLocateLinks = !myLocateLinks;155break;156case MID_ALLOWTEXTURES:157myAllowTextures = !myAllowTextures;158break;159}160return 1;161}162163164/****************************************************************************/165166167