Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEColorDialog.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 GNEColorDialog used in Netedit that supports internal tests
19/****************************************************************************/
20
23
24#include "GNEColorDialog.h"
25
26// ===========================================================================
27// FOX callback mapping
28// ===========================================================================
29
30FXDEFMAP(GNEColorDialog) GNEColorDialogMap[] = {
31 FXMAPFUNC(SEL_CHANGED, FXColorDialog::ID_COLORSELECTOR, GNEColorDialog::onChgColor),
32 FXMAPFUNC(SEL_COMMAND, FXColorDialog::ID_COLORSELECTOR, GNEColorDialog::onCmdColor),
33};
34
35// Object implementation
36FXIMPLEMENT(GNEColorDialog, GNEDialog, GNEColorDialogMap, ARRAYNUMBER(GNEColorDialogMap))
37
38// ===========================================================================
39// method definitions
40// ===========================================================================
41
43 GNEDialog(applicationWindow, TL("Edit color"), GUIIcon::COLORWHEEL, DialogType::COLOR,
44 Buttons::ACCEPT_CANCEL_RESET, OpenType::MODAL, ResizeMode::STATIC, 600, 300),
45 myOriginalColor(color) {
46 myColorbox = new FXColorSelector(getContentFrame(), this, FXColorDialog::ID_COLORSELECTOR, LAYOUT_FILL_X | LAYOUT_FILL_Y);
47 // set color
48 myColorbox->setRGBA(MFXUtils::getFXColor(color));
49 // hide buttons
50 myColorbox->acceptButton()->disable();
51 myColorbox->acceptButton()->hide();
52 myColorbox->cancelButton()->disable();
53 myColorbox->cancelButton()->hide();
54 // open dialog
55 openDialog();
56}
57
58
60 myColorbox = (FXColorSelector*) - 1L;
61}
62
63
64void
67 // parse color
68 const auto color = GNEAttributeCarrier::parse<RGBColor>(dialogArgument->getCustomAction());
69 // set color in colorbox
70 myColorbox->setRGBA(MFXUtils::getFXColor(color));
71 } else {
72 WRITE_ERROR("Cannot parse color " + dialogArgument->getCustomAction() + " in internal test");
73 }
74}
75
76
79 return MFXUtils::getRGBColor(myColorbox->getRGBA());
80}
81
82
83long
84GNEColorDialog::onCmdReset(FXObject*, FXSelector, void*) {
85 // restore original color
87 return 1;
88}
89
90
91long
92GNEColorDialog::onChgColor(FXObject*, FXSelector, void* ptr) {
93 if (target) {
94 return target->tryHandle(this, FXSEL(SEL_CHANGED, message), ptr);
95 } else {
96 return 0;
97 }
98}
99
100
101long
102GNEColorDialog::onCmdColor(FXObject*, FXSelector, void* ptr) {
103 if (target) {
104 return target->tryHandle(this, FXSEL(SEL_COMMAND, message), ptr);
105 } else {
106 return 0;
107 }
108}
FXDEFMAP(GNEColorDialog) GNEColorDialogMap[]
DialogType
GUIIcon
An enumeration of icons used by the gui applications.
Definition GUIIcons.h:33
@ COLORWHEEL
Definition GUIIcons.h:187
#define WRITE_ERROR(msg)
Definition MsgHandler.h:295
#define TL(string)
Definition MsgHandler.h:304
The main window of Netedit.
static T parse(const std::string &string)
parses a value of type T from string (used for basic types: int, double, bool, etc....
static bool canParse(const std::string &string)
true if a value of type T can be parsed from string
RGBColor getColor() const
Get the color.
GNEColorDialog(GNEApplicationWindow *applicationWindow, const RGBColor color)
Construct color dialog.
long onCmdReset(FXObject *, FXSelector, void *)
called when reset button is pressed
virtual ~GNEColorDialog()
Destructor.
long onChgColor(FXObject *, FXSelector, void *)
Called when color is changed.
long onCmdColor(FXObject *, FXSelector, void *)
Called when color is selected.
void runInternalTest(const InternalTestStep::DialogArgument *dialogArgument)
run internal test
const RGBColor myOriginalColor
Original color to restore pressing reset button.
FXColorSelector * myColorbox
Default constructor.
FXVerticalFrame * getContentFrame() const
get content frame
void openDialog(FXWindow *focusableElement=nullptr)
open dialog
OpenType
Open dialog type.
Definition GNEDialog.h:58
GNEDialog(GNEApplicationWindow *applicationWindow, const std::string &name, GUIIcon titleIcon, DialogType type, Buttons buttons, OpenType openType, ResizeMode resizeMode)
basic constructor
Definition GNEDialog.cpp:60
dialog arguments, used for certain modal dialogs that can not be edited using tab
const std::string & getCustomAction() const
get custom action
static FXColor getFXColor(const RGBColor &col)
converts FXColor to RGBColor
Definition MFXUtils.cpp:145
static RGBColor getRGBColor(FXColor col)
converts FXColor to RGBColor
Definition MFXUtils.cpp:139