Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MFXDialogBox.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2006-2025 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
18// Custom FXDialogBox that supports internal tests
19/****************************************************************************/
20
21// ===========================================================================
22// included modules
23// ===========================================================================
24
28
29#include "MFXDialogBox.h"
30
31// ===========================================================================
32// FOX callback mapping
33// ===========================================================================
34
35FXDEFMAP(MFXDialogBox) MFXDialogBoxMap[] = {
36 FXMAPFUNC(SEL_CLOSE, 0, MFXDialogBox::onCmdCancel),
37 FXMAPFUNC(SEL_COMMAND, FXDialogBox::ID_ACCEPT, MFXDialogBox::onCmdAccept),
38 FXMAPFUNC(SEL_CHORE, FXDialogBox::ID_CANCEL, MFXDialogBox::onCmdCancel),
39 FXMAPFUNC(SEL_TIMEOUT, FXDialogBox::ID_CANCEL, MFXDialogBox::onCmdCancel),
40 FXMAPFUNC(SEL_COMMAND, FXDialogBox::ID_CANCEL, MFXDialogBox::onCmdCancel),
42};
43
44// Object implementation
45FXIMPLEMENT(MFXDialogBox, FXDialogBox, MFXDialogBoxMap, ARRAYNUMBER(MFXDialogBoxMap))
46
47// ===========================================================================
48// method definitions
49// ===========================================================================
50
51MFXDialogBox::MFXDialogBox(FXApp* a, const FXString& name, FXuint opts, FXint x, FXint y,
52 FXint w, FXint h, FXint pl, FXint pr, FXint pt, FXint pb, FXint hs, FXint vs):
53 FXDialogBox(a, name, opts, x, y, w, h, pl, pr, pt, pb, hs, vs) {
54}
55
56
57MFXDialogBox::MFXDialogBox(FXWindow* owner, const FXString& name, FXuint opts, FXint x, FXint y,
58 FXint w, FXint h, FXint pl, FXint pr, FXint pt, FXint pb, FXint hs, FXint vs):
59 FXDialogBox(owner, name, opts, x, y, w, h, pl, pr, pt, pb, hs, vs) {
60}
61
62
63FXuint
64MFXDialogBox::openModalDialog(InternalTest* internalTests, FXuint placement) {
65 create();
66 show(placement);
67 getApp()->refresh();
68 if (internalTests) {
69 myTesting = true;
70 // execute every modal dialog test step
71 for (const auto& modalStep : internalTests->getCurrentStep()->getModalDialogTestSteps()) {
72 if (modalStep->getEvent()) {
73 handle(internalTests, modalStep->getSelector(), modalStep->getEvent());
74 } else if (modalStep->getDialogTest()) {
75 handle(internalTests, modalStep->getSelector(), modalStep->getDialogTest());
76 }
77 }
78 return 1;
79 } else {
80 myTesting = false;
81 return getApp()->runModalFor(this);
82 }
83}
84
85
86void
88 // temporal until #16893
89}
90
91
92long
93MFXDialogBox::onCmdAccept(FXObject*, FXSelector, void*) {
94 // only stop modal if we're not testing
95 if (myTesting == false) {
96 getApp()->stopModal(this, TRUE);
97 }
98 hide();
99 return 1;
100}
101
102
103long
104MFXDialogBox::onCmdCancel(FXObject*, FXSelector, void*) {
105 // only stop modal if we're not testing
106 if (myTesting == false) {
107 getApp()->stopModal(this, FALSE);
108 }
109 hide();
110 return 1;
111}
112
113
114long
115MFXDialogBox::onCmdInternalTest(FXObject*, FXSelector, void* ptr) {
116 auto dialogTest = static_cast<const InternalTestStep::DialogTest*>(ptr);
117 // ensure dialogTest is not null
118 if (dialogTest) {
119 // run internal test
120 runInternalTest(dialogTest);
121 }
122 // complete
123 return 1;
124}
125
126
127FXuint
128MFXDialogBox::execute(FXuint placement) {
129 return FXDialogBox::execute(placement);
130}
@ MID_INTERNALTEST
execute internal test in modal dialog
FXDEFMAP(MFXDialogBox) MFXDialogBoxMap[]
InternalTestStep * getCurrentStep() const
get current step
dialog arguments (used for certain functions that opens modal dialogs)
const std::vector< const InternalTestStep * > & getModalDialogTestSteps() const
get key events used in certain dialogs (allowDialog, etc.)
virtual void runInternalTest(const InternalTestStep::DialogTest *dialogTest)
run internal test
long onCmdCancel(FXObject *, FXSelector, void *)
called when cancel button is pressed (or dialog is closed)
MFXDialogBox()
FOX needs this.
FXuint openModalDialog(InternalTest *internalTests, FXuint placement=PLACEMENT_CURSOR)
Run modal invocation of the dialog.
long onCmdAccept(FXObject *, FXSelector, void *)
called when accept button is pressed
bool myTesting
flag to indicate if this dialog is being tested using internal test
long onCmdInternalTest(FXObject *, FXSelector, void *ptr)
event used in internal tests
FXuint execute(FXuint placement=PLACEMENT_CURSOR)
make execute private