Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MFXGroupBoxModule.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-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//
19/****************************************************************************/
20
21/* =========================================================================
22 * included modules
23 * ======================================================================= */
24#include <config.h>
25
30#include <netedit/GNEViewNet.h>
34
35#include "MFXGroupBoxModule.h"
36#include "MFXButtonTooltip.h"
37
38
39// ===========================================================================
40// FOX callback mapping
41// ===========================================================================
42
52
53// Object implementation
54FXIMPLEMENT(MFXGroupBoxModule, FXVerticalFrame, MFXGroupBoxModuleMap, ARRAYNUMBER(MFXGroupBoxModuleMap))
55
56// ===========================================================================
57// method definitions
58// ===========================================================================
59
60MFXGroupBoxModule::MFXGroupBoxModule(GNEFrame* frame, const std::string& text, const int options) :
61 FXVerticalFrame(frame->getContentFrame(), GUIDesignGroupBoxModule),
62 myOptions(options),
63 myFrameParent(frame),
64 myCollapsed(false) {
65 // build button and labels
66 FXHorizontalFrame* headerFrame = new FXHorizontalFrame(this, GUIDesignAuxiliarHorizontalFrame);
67 if (myOptions & Options::COLLAPSIBLE) {
69 }
70 if (myOptions & Options::EXTENSIBLE) {
71 myExtendButton = new MFXButtonTooltip(headerFrame,
72 frame->getViewNet()->getViewParent()->getGNEAppWindows()->getStaticTooltipMenu(),
74 myExtendButton->setTipText(TL("Expand frame to show all contents"));
76 }
77 if (myOptions & Options::SAVE) {
79 }
80 if (myOptions & Options::LOAD) {
82 }
83 myLabel = new FXLabel(headerFrame, text.c_str(), nullptr, GUIDesignLabelMFXGroupBoxModule);
84 // build collapsable frame
85 myCollapsableFrame = new FXVerticalFrame(this, GUIDesignCollapsableFrame);
86}
87
88
89MFXGroupBoxModule::MFXGroupBoxModule(FXVerticalFrame* contentFrame, const std::string& text, const int options) :
90 FXVerticalFrame(contentFrame, GUIDesignGroupBoxModuleExtendY),
91 myOptions(options),
92 myCollapsed(false) {
93 // build button and labels
94 FXHorizontalFrame* headerFrame = new FXHorizontalFrame(this, GUIDesignAuxiliarHorizontalFrame);
97 }
99 throw ProcessError("This MFXGroupBoxModule doesn't support Extensible flag");
100 }
101 if (myOptions & Options::SAVE) {
103 }
104 if (myOptions & Options::LOAD) {
106 }
107 myLabel = new FXLabel(headerFrame, text.c_str(), nullptr, GUIDesignLabelMFXGroupBoxModule);
108 // build collapsable frame
109 myCollapsableFrame = new FXVerticalFrame(this, GUIDesignCollapsableFrame);
110}
111
112
114
115
116void
117MFXGroupBoxModule::setText(const std::string& text) {
118 myLabel->setText(text.c_str());
119}
120
121
122FXVerticalFrame*
126
127
128long
129MFXGroupBoxModule::onPaint(FXObject*, FXSelector, void* ptr) {
130 FXEvent* event = (FXEvent*)ptr;
131 FXDCWindow dc(this, event);
132 // Paint background
133 dc.setForeground(backColor);
134 dc.fillRectangle(event->rect.x, event->rect.y, event->rect.w, event->rect.h);
135 // draw groove rectangle
136 drawGrooveRectangle(dc, 0, 15, width, height - 15);
137 return 1;
138}
139
140
141long
142MFXGroupBoxModule::onCmdCollapseButton(FXObject*, FXSelector, void*) {
143 if (myCollapsed) {
144 myCollapsed = false;
146 myCollapsableFrame->show();
147 } else {
148 myCollapsed = true;
150 myCollapsableFrame->hide();
151 }
152 recalc();
153 return 1;
154}
155
156
157long
158MFXGroupBoxModule::onCmdExtendButton(FXObject*, FXSelector, void*) {
159 if (myFrameParent) {
160 int maximumWidth = -1;
161 // iterate over all collapsableFrame childrens
162 for (auto child = myCollapsableFrame->getFirst(); child != nullptr; child = child->getNext()) {
163 // currently only for GNETLSTables
164 const auto TLSTable = dynamic_cast<GNETLSTable*>(child);
165 if (TLSTable) {
166 // get scrollbar width
167 const int scrollBarWidth = TLSTable->getTLSPhasesParent()->getTLSEditorParent()->getScrollBarWidth();
168 if ((TLSTable->getWidth() + scrollBarWidth) > maximumWidth) {
169 maximumWidth = (TLSTable->getWidth() + scrollBarWidth);
170 }
171 }
172 }
173 // set frame ara width
174 if (maximumWidth != -1) {
175 // add extra padding (30, constant, 15 left, 15 right)
177 }
178 }
179 return 1;
180}
181
182
183long
184MFXGroupBoxModule::onCmdResetButton(FXObject*, FXSelector, void*) {
185 if (myFrameParent) {
187 }
188 return 1;
189}
190
191
192long
193MFXGroupBoxModule::onUpdResetButton(FXObject* sender, FXSelector, void*) {
194 if (myFrameParent) {
196 sender->handle(this, FXSEL(SEL_COMMAND, ID_DISABLE), nullptr);
197 } else {
198 sender->handle(this, FXSEL(SEL_COMMAND, ID_ENABLE), nullptr);
199 }
200 }
201 return 1;
202}
203
204
205long
206MFXGroupBoxModule::onCmdSaveButton(FXObject*, FXSelector, void*) {
207 return saveContents();
208}
209
210
211long
212MFXGroupBoxModule::onCmdLoadButton(FXObject*, FXSelector, void*) {
213 return loadContents();
214}
215
216
218 myOptions(Options::NOTHING),
219 myCollapsed(false) {
220}
221
222
223bool
225 // nothing to do
226 return false;
227}
228
229
230bool
232 // nothing to do
233 return false;
234}
235
236
237void
239 if (mySaveButton) {
240 if (value) {
241 mySaveButton->enable();
242 } else {
243 mySaveButton->disable();
244 }
245 }
246}
@ MID_GROUPBOXMODULE_LOAD
load contents
Definition GUIAppEnum.h:698
@ MID_GROUPBOXMODULE_SAVE
save contents
Definition GUIAppEnum.h:696
@ MID_GROUPBOXMODULE_RESETWIDTH
reset widh groupBoxModule
Definition GUIAppEnum.h:694
@ MID_GROUPBOXMODULE_COLLAPSE
Definition GUIAppEnum.h:690
@ MID_GROUPBOXMODULE_EXTEND
extends groupBoxModule
Definition GUIAppEnum.h:692
#define GUIDesignLabelMFXGroupBoxModule
label used in MFXGroupBoxModule
Definition GUIDesigns.h:285
#define GUIDesignAuxiliarHorizontalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames
Definition GUIDesigns.h:399
#define GUIDesignButtonMFXGroupBoxModule
button used in GroupBoxModule
Definition GUIDesigns.h:100
#define GUIDesignButtonMFXGroupBoxModuleExtend
button used in GroupBoxModule for extend
Definition GUIDesigns.h:103
#define GUIDesignGroupBoxModuleExtendY
Horizontal frame extended over XY-frame parent used in MFXGroupBoxModule.
Definition GUIDesigns.h:322
#define GUIDesignCollapsableFrame
design for CollapsableFrame (Used in MFXGroupBoxModule)
Definition GUIDesigns.h:414
#define GUIDesignGroupBoxModule
Definition GUIDesigns.h:319
@ SAVE
save icons
FXDEFMAP(MFXGroupBoxModule) MFXGroupBoxModuleMap[]
#define TL(string)
Definition MsgHandler.h:315
int getScrollBarWidth() const
get scrollBar width (zero if is hidden)
Definition GNEFrame.cpp:174
GNEViewNet * getViewNet() const
get view net
Definition GNEFrame.cpp:150
GNETLSEditorFrame * getTLSEditorParent() const
get TLSEditor Parent
GNETLSEditorFrame::TLSPhases * getTLSPhasesParent() const
@frame get pointer to TLSEditorFrame phases parent
GNEViewParent * getViewParent() const
get the net object
void setFrameAreaWidth(const int frameAreaWith)
set frame area width
int getFrameAreaWidth() const
get frame area width
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
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
MFXGroupBoxModule (based on FXGroupBox)
long onCmdSaveButton(FXObject *, FXSelector, void *)
save contents
FXVerticalFrame * getCollapsableFrame()
get collapsable frame (used by all elements that will be collapsed if button is toggled)
long onCmdExtendButton(FXObject *, FXSelector, void *)
extends GroupBoxModule
MFXGroupBoxModule()
FOX need this.
long onCmdLoadButton(FXObject *, FXSelector, void *)
load contents
void setText(const std::string &text)
set text
long onPaint(FXObject *, FXSelector, void *)
draw MFXGroupBoxModule
FXButton * mySaveButton
button for save elements
long onCmdResetButton(FXObject *, FXSelector, void *)
reset GroupBoxModule
Options
GroupBoxModule options.
bool myCollapsed
flag to check if this groupbox is collapsed
long onCmdCollapseButton(FXObject *, FXSelector, void *)
collapse GroupBoxModule
long onUpdResetButton(FXObject *, FXSelector, void *)
update reset GroupBoxModule
FXLabel * myLabel
label used in non collapsable MFXGroupBoxModule
FXButton * myLoadButton
button for load elements
void toggleSaveButton(const bool value)
enable or disable save buttons
virtual bool loadContents() const
load contents (can be reimplemented in children)
GNEFrame * myFrameParent
GNEFrame in which this GroupBox is placed.
FXVerticalFrame * myCollapsableFrame
vertical collapsable frame
FXButton * myCollapseButton
button for collapse elements
const int myOptions
GroupBoxModule options.
virtual bool saveContents() const
save contents (can be reimplemented in children)
Definition json.hpp:4471