/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2006-2025 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_CLOSE // rerun-abort/back buttons (used in run dialogs)53};5455/// @brief Open dialog type56enum class OpenType {57MODAL, // Modal dialog58NON_MODAL // Non-modal dialog59};6061/// @name Resize mode62enum class ResizeMode {63STATIC, // dialog is static (size cannot be edited)64RESIZABLE // dialog is resizable (in both directions)65};6667/// @brief list of possible results when closing the dialog68enum class Result {69ACCEPT, // dialog was closed accepting changes (used in ok, accept, yes buttons)70CANCEL, // dialog was closed canceling changes (used in cancel, no buttons)71ABORT, // dialog was closed aborting changes (used in abort button)72};7374/// @brief constructor for resizable dialogs75GNEDialog(GNEApplicationWindow* applicationWindow, const std::string& name,76GUIIcon titleIcon, DialogType type, Buttons buttons, OpenType openType,77ResizeMode resizeMode);7879/// @brief constructor for resizable dialogs with layout explicit80GNEDialog(GNEApplicationWindow* applicationWindow, const std::string& name,81GUIIcon titleIcon, DialogType type, Buttons buttons, OpenType openType,82ResizeMode resizeMode, const int width, const int height);8384/// @brief get result to indicate if this dialog was closed accepting or rejecting changes85Result getResult() const;8687/// @brief get pointer to the application window88GNEApplicationWindow* getApplicationWindow() const;8990/// @brief get content frame91FXVerticalFrame* getContentFrame() const;9293/// @brief run internal test94virtual void runInternalTest(const InternalTestStep::DialogArgument* dialogArgument) = 0;9596/// @name FOX-callbacks97/// @{9899/// @brief called when accept or yes button is pressed (can be reimplemented in children)100virtual long onCmdAccept(FXObject*, FXSelector, void*);101102/// @brief called when cancel or no button is pressed (can be reimplemented in children)103virtual long onCmdCancel(FXObject*, FXSelector, void*);104105/// @brief called when abort is called either closing dialog or pressing abort button (can be reimplemented in children)106virtual long onCmdAbort(FXObject*, FXSelector, void*);107108/// @brief called when reset button is pressed (must be reimplemented in children)109virtual long onCmdReset(FXObject*, FXSelector, void*);110111/// @brief called when run button is pressed (must be reimplemented in children)112virtual long onCmdRun(FXObject*, FXSelector, void*);113114/// @brief called when back button is pressed (must be reimplemented in children)115virtual long onCmdBack(FXObject*, FXSelector, void*);116117/// @brief called when advanced button is pressed (must be reimplemented in children)118virtual long onCmdAdvanced(FXObject*, FXSelector, void*);119120/// @brief called when user presses a key on the dialog121long onKeyPress(FXObject* obj, FXSelector sel, void* ptr);122123/// @brief called when user releases a key on the dialog124long onKeyRelease(FXObject* obj, FXSelector sel, void* ptr);125126/// @}127128protected:129/// @brief FOX needs this130FOX_CONSTRUCTOR(GNEDialog)131132/// @brief pointer to the main window133GNEApplicationWindow* myApplicationWindow = nullptr;134135/// @brief content frame136FXVerticalFrame* myContentFrame = nullptr;137138/// @brief accept button139FXButton* myAcceptButton = nullptr;140141/// @brief cancel button142FXButton* myCancelButton = nullptr;143144/// @brief abort button145FXButton* myAbortButton = nullptr;146147/// @brief reset button148FXButton* myResetButton = nullptr;149150/// @brief run button151FXButton* myRunButton = nullptr;152153/// @brief back button154FXButton* myBackButton = nullptr;155156/// @brief advanced button157FXButton* myAdvancedButton = nullptr;158159/// @brief dialog type160DialogType myType = DialogType::DEFAULT;161162/// @brief result to indicate if this dialog was closed accepting or rejecting changes163Result myResult = Result::CANCEL;164165/// @brief open dialog166void openDialog(FXWindow* focusableElement = nullptr);167168/// @brief close dialog accepting the changes169long closeDialogAccepting();170171/// @brief close dialog declining the changes172long closeDialogCanceling();173174/// @brief close dialog aborting the changes175long closeDialogAborting();176177/// @brief update title178void updateTitle(const std::string& newTitle);179180/// @brief update icon181void updateIcon(GUIIcon newIcon);182183private:184/// @brief focus button, used for focusing the default button when dialog is opened185FXButton* myFocusButton = nullptr;186187/// @brief open type188OpenType myOpenType;189190/// @brief flag to indicate if this dialog is being tested using internal test191bool myTesting = false;192193/// @brief build dialog194void buildDialog(GUIIcon titleIcon, Buttons buttons);195196/// @brief Invalidated copy constructor.197GNEDialog(const GNEDialog&) = delete;198199/// @brief Invalidated assignment operator200GNEDialog& operator=(const GNEDialog& src) = delete;201};202203204