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>
39
40
41
42// ===========================================================================
43// method definitions
44// ===========================================================================
45
46GUIPersistentWindowPos::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
64
68
69
70void
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
83void
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)));
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/****************************************************************************/
T MIN2(T a, T b)
Definition StdDefs.h:76
T MAX2(T a, T b)
Definition StdDefs.h:82
bool myStoreSize
whether window size shall be stored
std::string myWindowName
Name for storing in the registry.
FXWindow * myParent
The window for which the position is being stored.
~GUIPersistentWindowPos()
Destructor (Notifies both the parent and the storage about being destroyed)