Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GUIPersistentWindowPos.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
/****************************************************************************/
20
// Editor for the list of chosen objects
21
/****************************************************************************/
22
#include <config.h>
23
24
#include <string>
25
#include <vector>
26
#include <iostream>
27
#include <fstream>
28
#include <
utils/common/MsgHandler.h
>
29
#include <
utils/gui/windows/GUIAppEnum.h
>
30
#include <
utils/gui/globjects/GUIGlObject.h
>
31
#include <
utils/foxtools/MFXUtils.h
>
32
#include "
GUIPersistentWindowPos.h
"
33
#include <
utils/gui/div/GUIGlobalSelection.h
>
34
#include <
utils/gui/globjects/GUIGlObjectStorage.h
>
35
#include <
utils/gui/div/GUIIOGlobals.h
>
36
#include <
utils/gui/div/GUIDesigns.h
>
37
#include <
utils/gui/windows/GUIMainWindow.h
>
38
#include <
utils/gui/images/GUIIconSubSys.h
>
39
40
41
42
// ===========================================================================
43
// method definitions
44
// ===========================================================================
45
46
GUIPersistentWindowPos::GUIPersistentWindowPos
(FXWindow* parent,
const
std::string& name,
bool
storeSize,
47
int
x,
int
y,
48
int
width,
int
height,
49
int
minSize,
int
minTitlebarHeight) :
50
myParent(parent),
51
myWindowName(name),
52
myStoreSize(storeSize),
53
myDefaultX(x),
54
myDefaultY(y),
55
myDefaultWidth(width),
56
myDefaultHeight(height),
57
myMinSize(minSize),
58
myMinTitlebarHeight(minTitlebarHeight)
59
{}
60
61
GUIPersistentWindowPos::GUIPersistentWindowPos
() :
62
myParent(nullptr)
63
{ }
64
65
GUIPersistentWindowPos::~GUIPersistentWindowPos
() {
66
saveWindowPos
();
67
}
68
69
70
void
71
GUIPersistentWindowPos::saveWindowPos
() {
72
if
(
myParent
!=
nullptr
) {
73
FXRegistry& reg =
myParent
->getApp()->reg();
74
reg.writeIntEntry(
myWindowName
.c_str(),
"x"
,
myParent
->getX());
75
reg.writeIntEntry(
myWindowName
.c_str(),
"y"
,
myParent
->getY());
76
if
(
myStoreSize
) {
77
reg.writeIntEntry(
myWindowName
.c_str(),
"width"
,
myParent
->getWidth());
78
reg.writeIntEntry(
myWindowName
.c_str(),
"height"
,
myParent
->getHeight());
79
}
80
}
81
}
82
83
void
84
GUIPersistentWindowPos::loadWindowPos
() {
85
if
(
myParent
!=
nullptr
) {
86
FXRegistry& reg =
myParent
->getApp()->reg();
87
// ensure window is visible after switching screen resolutions
88
myParent
->setX(
MAX2
(0,
MIN2
(reg.readIntEntry(
myWindowName
.c_str(),
"x"
,
myDefaultX
),
89
myParent
->getApp()->getRootWindow()->getWidth() -
myMinSize
)));
90
myParent
->setY(
MAX2
(
myMinTitlebarHeight
,
91
MIN2
(reg.readIntEntry(
myWindowName
.c_str(),
"y"
,
myDefaultY
),
92
myParent
->getApp()->getRootWindow()->getHeight() -
myMinSize
)));
93
if
(
myStoreSize
) {
94
myParent
->setWidth(
MAX2
(reg.readIntEntry(
myWindowName
.c_str(),
"width"
,
myDefaultWidth
),
myMinSize
));
95
myParent
->setHeight(
MAX2
(reg.readIntEntry(
myWindowName
.c_str(),
"height"
,
myDefaultHeight
),
myMinSize
));
96
}
97
}
98
}
99
100
/****************************************************************************/
GUIAppEnum.h
GUIDesigns.h
GUIGlObject.h
GUIGlObjectStorage.h
GUIGlobalSelection.h
GUIIOGlobals.h
GUIIconSubSys.h
GUIMainWindow.h
GUIPersistentWindowPos.h
MFXUtils.h
MsgHandler.h
MIN2
T MIN2(T a, T b)
Definition
StdDefs.h:76
MAX2
T MAX2(T a, T b)
Definition
StdDefs.h:82
GUIPersistentWindowPos::loadWindowPos
void loadWindowPos()
Definition
GUIPersistentWindowPos.cpp:84
GUIPersistentWindowPos::GUIPersistentWindowPos
GUIPersistentWindowPos()
Definition
GUIPersistentWindowPos.cpp:61
GUIPersistentWindowPos::myStoreSize
bool myStoreSize
whether window size shall be stored
Definition
GUIPersistentWindowPos.h:59
GUIPersistentWindowPos::saveWindowPos
void saveWindowPos()
Definition
GUIPersistentWindowPos.cpp:71
GUIPersistentWindowPos::myWindowName
std::string myWindowName
Name for storing in the registry.
Definition
GUIPersistentWindowPos.h:56
GUIPersistentWindowPos::myDefaultHeight
int myDefaultHeight
Definition
GUIPersistentWindowPos.h:65
GUIPersistentWindowPos::myDefaultY
int myDefaultY
Definition
GUIPersistentWindowPos.h:62
GUIPersistentWindowPos::myMinSize
int myMinSize
Definition
GUIPersistentWindowPos.h:67
GUIPersistentWindowPos::myDefaultWidth
int myDefaultWidth
Definition
GUIPersistentWindowPos.h:64
GUIPersistentWindowPos::myMinTitlebarHeight
int myMinTitlebarHeight
Definition
GUIPersistentWindowPos.h:68
GUIPersistentWindowPos::myDefaultX
int myDefaultX
Definition
GUIPersistentWindowPos.h:61
GUIPersistentWindowPos::myParent
FXWindow * myParent
The window for which the position is being stored.
Definition
GUIPersistentWindowPos.h:53
GUIPersistentWindowPos::~GUIPersistentWindowPos
~GUIPersistentWindowPos()
Destructor (Notifies both the parent and the storage about being destroyed)
Definition
GUIPersistentWindowPos.cpp:65
src
utils
gui
div
GUIPersistentWindowPos.cpp
Generated on Mon Dec 23 2024 00:16:00 for Eclipse SUMO - Simulation of Urban MObility by
1.9.8