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-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//
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"));
75 myResetWidthButton = new MFXButtonTooltip(headerFrame,
76 frame->getViewNet()->getViewParent()->getGNEAppWindows()->getStaticTooltipMenu(),
78 myResetWidthButton->setTipText(TL("Shrink frame to default with"));
79 }
80 if (myOptions & Options::SAVE) {
82 }
83 if (myOptions & Options::LOAD) {
85 }
86 myLabel = new FXLabel(headerFrame, text.c_str(), nullptr, GUIDesignLabelMFXGroupBoxModule);
87 // build collapsable frame
88 myCollapsableFrame = new FXVerticalFrame(this, GUIDesignCollapsableFrame);
89}
90
91
92MFXGroupBoxModule::MFXGroupBoxModule(FXVerticalFrame* contentFrame, const std::string& text, const int options) :
93 FXVerticalFrame(contentFrame, GUIDesignGroupBoxModuleExtendY),
94 myOptions(options),
95 myCollapsed(false) {
96 // build button and labels
97 FXHorizontalFrame* headerFrame = new FXHorizontalFrame(this, GUIDesignAuxiliarHorizontalFrame);
100 }
102 throw ProcessError("This MFXGroupBoxModule doesn't support Extensible flag");
103 }
104 if (myOptions & Options::SAVE) {
106 }
107 if (myOptions & Options::LOAD) {
109 }
110 myLabel = new FXLabel(headerFrame, text.c_str(), nullptr, GUIDesignLabelMFXGroupBoxModule);
111 // build collapsable frame
112 myCollapsableFrame = new FXVerticalFrame(this, GUIDesignCollapsableFrame);
113}
114
115
117
118
119void
120MFXGroupBoxModule::setText(const std::string& text) {
121 myLabel->setText(text.c_str());
122}
123
124
125FXVerticalFrame*
129
130
131long
132MFXGroupBoxModule::onPaint(FXObject*, FXSelector, void* ptr) {
133 FXEvent* event = (FXEvent*)ptr;
134 FXDCWindow dc(this, event);
135 // Paint background
136 dc.setForeground(backColor);
137 dc.fillRectangle(event->rect.x, event->rect.y, event->rect.w, event->rect.h);
138 // draw groove rectangle
139 drawGrooveRectangle(dc, 0, 15, width, height - 15);
140 return 1;
141}
142
143
144long
145MFXGroupBoxModule::onCmdCollapseButton(FXObject*, FXSelector, void*) {
146 if (myCollapsed) {
147 myCollapsed = false;
149 myCollapsableFrame->show();
150 } else {
151 myCollapsed = true;
153 myCollapsableFrame->hide();
154 }
155 recalc();
156 return 1;
157}
158
159
160long
161MFXGroupBoxModule::onCmdExtendButton(FXObject*, FXSelector, void*) {
162 if (myFrameParent) {
163 int maximumWidth = -1;
164 // iterate over all collapsableFrame childrens
165 for (auto child = myCollapsableFrame->getFirst(); child != nullptr; child = child->getNext()) {
166 // currently only for GNETLSTables
167 const auto TLSTable = dynamic_cast<GNETLSTable*>(child);
168 if (TLSTable) {
169 // get scrollbar width
170 const int scrollBarWidth = TLSTable->getTLSPhasesParent()->getTLSEditorParent()->getScrollBarWidth();
171 if ((TLSTable->getWidth() + scrollBarWidth) > maximumWidth) {
172 maximumWidth = (TLSTable->getWidth() + scrollBarWidth);
173 }
174 }
175 }
176 // set frame ara width
177 if (maximumWidth != -1) {
178 // add extra padding (30, constant, 15 left, 15 right)
180 }
181 }
182 return 1;
183}
184
185
186long
187MFXGroupBoxModule::onCmdResetButton(FXObject*, FXSelector, void*) {
188 if (myFrameParent) {
190 }
191 return 1;
192}
193
194
195long
196MFXGroupBoxModule::onUpdResetButton(FXObject* sender, FXSelector, void*) {
197 if (myFrameParent) {
199 sender->handle(this, FXSEL(SEL_COMMAND, ID_DISABLE), nullptr);
200 } else {
201 sender->handle(this, FXSEL(SEL_COMMAND, ID_ENABLE), nullptr);
202 }
203 }
204 return 1;
205}
206
207
208long
209MFXGroupBoxModule::onCmdSaveButton(FXObject*, FXSelector, void*) {
210 return saveContents();
211}
212
213
214long
215MFXGroupBoxModule::onCmdLoadButton(FXObject*, FXSelector, void*) {
216 return loadContents();
217}
218
219
221 myOptions(Options::NOTHING),
222 myCollapsed(false) {
223}
224
225
226bool
228 // nothing to do
229 return false;
230}
231
232
233bool
235 // nothing to do
236 return false;
237}
238
239
240void
242 if (mySaveButton) {
243 if (value) {
244 mySaveButton->enable();
245 } else {
246 mySaveButton->disable();
247 }
248 }
249}
@ 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:287
#define GUIDesignAuxiliarHorizontalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames
Definition GUIDesigns.h:430
#define GUIDesignButtonMFXGroupBoxModule
button used in GroupBoxModule
Definition GUIDesigns.h:118
#define GUIDesignButtonMFXGroupBoxModuleExtend
button used in GroupBoxModule for extend
Definition GUIDesigns.h:121
#define GUIDesignGroupBoxModuleExtendY
Horizontal frame extended over XY-frame parent used in MFXGroupBoxModule.
Definition GUIDesigns.h:341
#define GUIDesignCollapsableFrame
design for CollapsableFrame (Used in MFXGroupBoxModule)
Definition GUIDesigns.h:445
#define GUIDesignGroupBoxModule
Definition GUIDesigns.h:338
@ SAVE
save icons
FXDEFMAP(MFXGroupBoxModule) MFXGroupBoxModuleMap[]
#define TL(string)
Definition MsgHandler.h:305
int getScrollBarWidth() const
get scrollBar width (zero if is hidden)
Definition GNEFrame.cpp:176
GNEViewNet * getViewNet() const
get view net
Definition GNEFrame.cpp:152
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