/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2006-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 GNEDialog.h14/// @author Pablo Alvarez Lopez15/// @date Jul 202516///17// Custom FXDialogBox used in Netedit that supports internal tests18/****************************************************************************/19#pragma once20#include <config.h>2122#include <utils/gui/images/GUIIcons.h>23#include <utils/tests/InternalTestStep.h>2425#include "GNEDialogEnum.h"2627// ===========================================================================28// class declarations29// ===========================================================================3031class GNEApplicationWindow;3233// ===========================================================================34// class definitions35// ===========================================================================3637class GNEDialog : protected FXDialogBox {38FXDECLARE_ABSTRACT(GNEDialog)3940public:41/// @name basic dialog type42enum class Buttons {43OK, // ok button44YES_NO, // yes/no buttons45YES_NO_CANCEL, // yes/no/cancel buttons46ACCEPT, // accept button47ACCEPT_CANCEL, // accept/cancel buttons48ACCEPT_CANCEL_RESET, // accept/cancel/reset buttons49SAVE_DONTSAVE_CANCEL, // save/don't save/cancel buttons50RUN_CANCEL_RESET, // run/cancel/reset buttons (used in tools dialogs)51RUN_ADVANCED_CANCEL, // run/advanced/cancel buttons (used in tools dialogs)52RERUN_BACK_OK, // rerun-abort/back buttons (used in run dialogs)53OK_COPY_REPORT // ok, copy trace and report to github54};5556/// @brief Open dialog type57enum class OpenType {58MODAL, // Modal dialog59NON_MODAL // Non-modal dialog60};6162/// @name Resize mode63enum class ResizeMode {64STATIC, // dialog is static (size cannot be edited)65RESIZABLE // dialog is resizable (in both directions)66};6768/// @brief list of possible results when closing the dialog69enum class Result {70ACCEPT, // dialog was closed accepting changes (used in ok, accept, yes buttons)71CANCEL, // dialog was closed canceling changes (used in cancel, no buttons)72ABORT, // dialog was closed aborting changes (used in abort button)73ACCEPT_ALL, // dialog was closed acepting all changes (used in ok, accept, yes buttons)74CANCEL_ALL, // dialog was closed canceling all changes (used in cancel, no buttons)75};7677/// @brief basic constructor78GNEDialog(GNEApplicationWindow* applicationWindow,79const std::string& name, GUIIcon titleIcon, DialogType type, Buttons buttons,80OpenType openType, ResizeMode resizeMode);8182/// @brief basic constructor with dialog parent83GNEDialog(GNEApplicationWindow* applicationWindow, GNEDialog* parentDialog,84const std::string& name, GUIIcon titleIcon, DialogType type, Buttons buttons,85OpenType openType, ResizeMode resizeMode);8687/// @brief constructor with layout explicit88GNEDialog(GNEApplicationWindow* applicationWindow,89const std::string& name, GUIIcon titleIcon, DialogType type, Buttons buttons,90OpenType openType, ResizeMode resizeMode, const int width, const int height);9192/// @brief constructor with layout explicit and dialog parent93GNEDialog(GNEApplicationWindow* applicationWindow, GNEDialog* parentDialog,94const std::string& name, GUIIcon titleIcon, DialogType type, Buttons buttons,95OpenType openType, ResizeMode resizeMode, const int width, const int height);9697/// @brief get result to indicate if this dialog was closed accepting or rejecting changes98Result getResult() const;99100/// @brief get pointer to the application window101GNEApplicationWindow* getApplicationWindow() const;102103/// @brief get content frame104FXVerticalFrame* getContentFrame() const;105106/// @brief run internal test107virtual void runInternalTest(const InternalTestStep::DialogArgument* dialogArgument) = 0;108109/// @name FOX-callbacks110/// @{111112/// @brief called when accept or yes button is pressed (can be reimplemented in children)113virtual long onCmdAccept(FXObject*, FXSelector, void*);114115/// @brief called when cancel or no button is pressed (can be reimplemented in children)116virtual long onCmdCancel(FXObject*, FXSelector, void*);117118/// @brief called when abort is called either closing dialog or pressing abort button (can be reimplemented in children)119virtual long onCmdAbort(FXObject*, FXSelector, void*);120121/// @brief called when reset button is pressed (must be reimplemented in children depending of Buttons)122virtual long onCmdReset(FXObject*, FXSelector, void*);123124/// @brief called when run button is pressed (must be reimplemented in children depending of Buttons)125virtual long onCmdRun(FXObject*, FXSelector, void*);126127/// @brief called when back button is pressed (must be reimplemented in children depending of Buttons)128virtual long onCmdBack(FXObject*, FXSelector, void*);129130/// @brief called when advanced button is pressed (must be reimplemented in children depending of Buttons)131virtual long onCmdAdvanced(FXObject*, FXSelector, void*);132133/// @brief called when copy button is pressed (must be reimplemented in children depending of Buttons)134virtual long onCmdCopy(FXObject*, FXSelector, void*);135136/// @brief called when report button is pressed (must be reimplemented in children depending of Buttons)137virtual long onCmdReport(FXObject*, FXSelector, void*);138139/// @brief called when user presses a key on the dialog140long onKeyPress(FXObject* obj, FXSelector sel, void* ptr);141142/// @brief called when user releases a key on the dialog143long onKeyRelease(FXObject* obj, FXSelector sel, void* ptr);144145/// @}146147protected:148/// @brief FOX needs this149FOX_CONSTRUCTOR(GNEDialog)150151/// @brief pointer to the main window152GNEApplicationWindow* myApplicationWindow = nullptr;153154/// @brief parent dialog used for restoring focus after closing dialog155GNEDialog* myParentDialog = nullptr;156157/// @brief content frame158FXVerticalFrame* myContentFrame = nullptr;159160/// @brief accept button161FXButton* myAcceptButton = nullptr;162163/// @brief cancel button164FXButton* myCancelButton = nullptr;165166/// @brief abort button167FXButton* myAbortButton = nullptr;168169/// @brief reset button170FXButton* myResetButton = nullptr;171172/// @brief run button173FXButton* myRunButton = nullptr;174175/// @brief back button176FXButton* myBackButton = nullptr;177178/// @brief advanced button179FXButton* myAdvancedButton = nullptr;180181/// @brief copy button182FXButton* myCopyButton = nullptr;183184/// @brief report button185FXButton* myReportButton = nullptr;186187/// @brief dialog type188DialogType myType = DialogType::DEFAULT;189190/// @brief result to indicate if this dialog was closed accepting or rejecting changes191Result myResult = Result::CANCEL;192193/// @brief open dialog194void openDialog(FXWindow* focusableElement = nullptr);195196/// @brief close dialog accepting the changes197long closeDialogAccepting();198199/// @brief close dialog declining the changes200long closeDialogCanceling();201202/// @brief close dialog aborting the changes203long closeDialogAborting();204205/// @brief update title206void updateTitle(const std::string& newTitle);207208/// @brief update icon209void updateIcon(GUIIcon newIcon);210211private:212/// @brief focus button, used for focusing the default button when dialog is opened213FXButton* myFocusButton = nullptr;214215/// @brief open type216OpenType myOpenType;217218/// @brief flag to indicate if this dialog is being tested using internal test219bool myTesting = false;220221/// @brief build dialog222void buildDialog(GUIIcon titleIcon, Buttons buttons);223224/// @brief Invalidated copy constructor.225GNEDialog(const GNEDialog&) = delete;226227/// @brief Invalidated assignment operator228GNEDialog& operator=(const GNEDialog& src) = delete;229};230231232