LCOV - code coverage report
Current view: top level - src/utils/gui/div - GUIPersistentWindowPos.cpp (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 36 0.0 %
Date: 2024-05-02 15:31:40 Functions: 0 5 0.0 %

          Line data    Source code
       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             : /****************************************************************************/
      14             : /// @file    GUIPersistentWindowPos.cpp
      15             : /// @author  Daniel Krajzewicz
      16             : /// @author  Jakob Erdmann
      17             : /// @author  Michael Behrisch
      18             : /// @date    Thu, 11.03.2004
      19             : ///
      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           0 : GUIPersistentWindowPos::GUIPersistentWindowPos(FXWindow* parent, const std::string& name, bool storeSize,
      47             :         int x, int y,
      48             :         int width, int height,
      49           0 :         int minSize, int minTitlebarHeight) :
      50           0 :     myParent(parent),
      51           0 :     myWindowName(name),
      52           0 :     myStoreSize(storeSize),
      53           0 :     myDefaultX(x),
      54           0 :     myDefaultY(y),
      55           0 :     myDefaultWidth(width),
      56           0 :     myDefaultHeight(height),
      57           0 :     myMinSize(minSize),
      58           0 :     myMinTitlebarHeight(minTitlebarHeight)
      59           0 : {}
      60             : 
      61           0 : GUIPersistentWindowPos::GUIPersistentWindowPos() :
      62           0 :     myParent(nullptr)
      63           0 : { }
      64             : 
      65           0 : GUIPersistentWindowPos::~GUIPersistentWindowPos() {
      66           0 :     saveWindowPos();
      67           0 : }
      68             : 
      69             : 
      70             : void
      71           0 : GUIPersistentWindowPos::saveWindowPos() {
      72           0 :     if (myParent != nullptr) {
      73             :         FXRegistry& reg = myParent->getApp()->reg();
      74           0 :         reg.writeIntEntry(myWindowName.c_str(), "x", myParent->getX());
      75           0 :         reg.writeIntEntry(myWindowName.c_str(), "y", myParent->getY());
      76           0 :         if (myStoreSize) {
      77           0 :             reg.writeIntEntry(myWindowName.c_str(), "width", myParent->getWidth());
      78           0 :             reg.writeIntEntry(myWindowName.c_str(), "height", myParent->getHeight());
      79             :         }
      80             :     }
      81           0 : }
      82             : 
      83             : void
      84           0 : GUIPersistentWindowPos::loadWindowPos() {
      85           0 :     if (myParent != nullptr) {
      86             :         FXRegistry& reg = myParent->getApp()->reg();
      87             :         // ensure window is visible after switching screen resolutions
      88           0 :         myParent->setX(MAX2(0, MIN2(reg.readIntEntry(myWindowName.c_str(), "x", myDefaultX),
      89           0 :                                     myParent->getApp()->getRootWindow()->getWidth() - myMinSize)));
      90           0 :         myParent->setY(MAX2(myMinTitlebarHeight,
      91             :                             MIN2(reg.readIntEntry(myWindowName.c_str(), "y", myDefaultY),
      92           0 :                                  myParent->getApp()->getRootWindow()->getHeight() - myMinSize)));
      93           0 :         if (myStoreSize) {
      94           0 :             myParent->setWidth(MAX2(reg.readIntEntry(myWindowName.c_str(), "width", myDefaultWidth), myMinSize));
      95           0 :             myParent->setHeight(MAX2(reg.readIntEntry(myWindowName.c_str(), "height", myDefaultHeight), myMinSize));
      96             :         }
      97             :     }
      98           0 : }
      99             : 
     100             : /****************************************************************************/

Generated by: LCOV version 1.14