Eclipse SUMO - Simulation of Urban MObility
GUISaveDialog.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2001-2024 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 // Dialog for ask user about saving elements
19 /****************************************************************************/
20 
21 #include "GUISaveDialog.h"
22 
25 
26 // Padding for message box buttons
27 #define HORZ_PAD 30
28 #define VERT_PAD 2
29 
30 // Map
31 FXDEFMAP(GUISaveDialog) GUISaveDialogMap[] = {
35 };
36 
37 // Object implementation
38 FXIMPLEMENT(GUISaveDialog, FXDialogBox, GUISaveDialogMap, ARRAYNUMBER(GUISaveDialogMap))
39 
40 
41 GUISaveDialog::GUISaveDialog(FXApp* a, const FXString& caption, const FXString& text, FXIcon* ic):
42  FXDialogBox(a, caption, DECOR_TITLE | DECOR_BORDER, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4) {
43  initialize(text, ic);
44 }
45 
46 
47 long
48 GUISaveDialog::onCmdClicked(FXObject*, FXSelector sel, void*) {
49  if (sel == FXSEL(SEL_COMMAND, GUISaveDialog::CLICKED_SAVE)) {
50  getApp()->stopModal(this, GUISaveDialog::CLICKED_SAVE);
51  } else if (sel == FXSEL(SEL_COMMAND, GUISaveDialog::CLICKED_DISCARD)) {
52  getApp()->stopModal(this, GUISaveDialog::CLICKED_DISCARD);
53  } else {
54  getApp()->stopModal(this, GUISaveDialog::CLICKED_ABORT);
55  }
56  hide();
57  return 1;
58 }
59 
60 
61 long
62 GUISaveDialog::onCmdCancel(FXObject* sender, FXSelector, void* ptr) {
63  return GUISaveDialog::onCmdClicked(sender, FXSEL(SEL_COMMAND, FXMessageBox::ID_CLICKED_CANCEL), ptr);
64 }
65 
66 
67 FXuint
68 GUISaveDialog::question(FXApp* app, const char* caption, const char* message, ...) {
69  FXGIFIcon icon(app, myQuestionIcon);
70  va_list arguments;
71  va_start(arguments, message);
72  GUISaveDialog box(app, caption, FXStringVFormat(message, arguments), &icon);
73  va_end(arguments);
74  return box.execute(PLACEMENT_SCREEN);
75 }
76 
77 
78 void
79 GUISaveDialog::initialize(const FXString& text, FXIcon* ic) {
80  FXVerticalFrame* content = new FXVerticalFrame(this, LAYOUT_FILL_X | LAYOUT_FILL_Y);
81  FXHorizontalFrame* info = new FXHorizontalFrame(content, LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0, 10, 10, 10, 10);
82  new FXLabel(info, FXString::null, ic, ICON_BEFORE_TEXT | LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_FILL_X | LAYOUT_FILL_Y);
83  new FXLabel(info, text, NULL, JUSTIFY_LEFT | ICON_BEFORE_TEXT | LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_FILL_X | LAYOUT_FILL_Y);
84  new FXHorizontalSeparator(content, SEPARATOR_GROOVE | LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_FILL_X);
85  FXHorizontalFrame* buttons = new FXHorizontalFrame(content, LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_FILL_X | PACK_UNIFORM_WIDTH, 0, 0, 0, 0, 10, 10, 5, 5);
86  buttons->setPackingHints(PACK_NORMAL);
87  FXButton* saveChanges = GUIDesigns::buildFXButton(buttons, TL("&Save changes"), "", "", NULL, this, CLICKED_SAVE, GUIDesignSaveDialogButtonInitial);
88  GUIDesigns::buildFXButton(buttons, TL("&Don't save"), "", "", NULL, this, CLICKED_DISCARD, GUIDesignSaveDialogButton);
89  GUIDesigns::buildFXButton(buttons, TL("&Abort"), "", "", NULL, this, CLICKED_ABORT, GUIDesignSaveDialogButton);
90  saveChanges->setFocus();
91 }
92 
93 
94 const unsigned char
96  0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x20, 0x00, 0x20, 0x00, 0xf2, 0x00, 0x00, 0x80, 0x80, 0x80,
97  0xc0, 0xc0, 0xc0, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
98  0x00, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x20, 0x00, 0x00, 0x03,
99  0x97, 0x08, 0xba, 0xdc, 0xfe, 0xf0, 0x05, 0x41, 0x6b, 0x88, 0x58, 0xcd, 0xca, 0xf9, 0xcd, 0xcc,
100  0xd6, 0x8d, 0x16, 0x08, 0x90, 0x02, 0x30, 0x0c, 0x80, 0xc8, 0x11, 0x18, 0x19, 0xac, 0xf4, 0xe0,
101  0x56, 0xf0, 0x23, 0xdb, 0x54, 0x7d, 0x53, 0xb9, 0x10, 0x69, 0xc5, 0xa9, 0xc9, 0x82, 0x0a, 0x94,
102  0x51, 0xb0, 0x1c, 0x21, 0x7f, 0x3d, 0x9a, 0x60, 0x26, 0x3d, 0x2e, 0x50, 0xd3, 0xd5, 0xa4, 0x49,
103  0x0a, 0x62, 0x3d, 0x55, 0xac, 0xf7, 0x1b, 0x1d, 0x90, 0x05, 0x63, 0xb2, 0xf6, 0x9c, 0xfe, 0x12,
104  0xd9, 0x0b, 0xe8, 0xd9, 0x7a, 0xfd, 0x52, 0xe5, 0xb8, 0x06, 0x9e, 0x19, 0xa6, 0x33, 0xdc, 0x7d,
105  0x4e, 0x0f, 0x04, 0x58, 0x77, 0x62, 0x11, 0x84, 0x73, 0x82, 0x18, 0x04, 0x7b, 0x23, 0x01, 0x48,
106  0x88, 0x8d, 0x67, 0x90, 0x91, 0x19, 0x04, 0x98, 0x3f, 0x95, 0x96, 0x26, 0x0a, 0x98, 0x93, 0x40,
107  0x9d, 0x26, 0x89, 0x68, 0xa2, 0x20, 0xa4, 0x9c, 0xa6, 0x0d, 0x89, 0xa9, 0xaa, 0x0c, 0x84, 0xad,
108  0xae, 0x0b, 0x98, 0xb2, 0xb5, 0xb6, 0xaa, 0x09, 0x00, 0x3b
109 };
110 
111 /*******************************************************************************/
#define GUIDesignSaveDialogButtonInitial
button for saving elements in GUISaveDialog
Definition: GUIDesigns.h:186
#define GUIDesignSaveDialogButton
button for saving elements in GUISaveDialog
Definition: GUIDesigns.h:189
FXDEFMAP(GUISaveDialog) GUISaveDialogMap[]
#define TL(string)
Definition: MsgHandler.h:315
static FXButton * buildFXButton(FXComposite *p, const std::string &text, const std::string &tip, const std::string &help, FXIcon *ic, FXObject *tgt, FXSelector sel, FXuint opts=BUTTON_NORMAL, FXint x=0, FXint y=0, FXint w=0, FXint h=0, FXint pl=DEFAULT_PAD, FXint pr=DEFAULT_PAD, FXint pt=DEFAULT_PAD, FXint pb=DEFAULT_PAD)
build button
Definition: GUIDesigns.cpp:128
static FXuint question(FXApp *app, const char *caption, const char *message,...)
Show modal question message, in free floating window.
static const unsigned char myQuestionIcon[]
question icon
Definition: GUISaveDialog.h:67
long onCmdClicked(FXObject *, FXSelector, void *)
called when user click over button
long onCmdCancel(FXObject *, FXSelector, void *)
called when user press cancel
void initialize(const FXString &text, FXIcon *ic)
initialize save dialog