Path: blob/main/src/utils/gui/cursors/GUICursorSubSys.cpp
169684 views
/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file GUICursorSubSys.cpp14/// @author Pablo Alvarez Lopez15/// @date Nov 201816///17// Helper for cursors loading and usage18/****************************************************************************/19#include <config.h>2021#include <utils/common/UtilExceptions.h>2223#include "GUICursors.h"24#include "GUICursorSubSys.h"2526#include "Delete_cursor.cpp"27#include "Select_cursor.cpp"28#include "SelectLane_cursor.cpp"29#include "Inspect_cursor.cpp"30#include "InspectLane_cursor.cpp"31#include "MoveElement_cursor.cpp"3233// ===========================================================================34// static member variable definitions35// ===========================================================================3637GUICursorSubSys* GUICursorSubSys::myInstance = nullptr;3839// ===========================================================================40// member definitions41// ===========================================================================4243GUICursorSubSys::GUICursorSubSys(FXApp* a) {44// default cursors (already created)45myCursors[GUICursor::DEFAULT] = a->getDefaultCursor(DEF_ARROW_CURSOR);46myCursors[GUICursor::MOVEVIEW] = a->getDefaultCursor(DEF_MOVE_CURSOR);4748// custom cursors (must be created)49myCursors[GUICursor::DELETE_CURSOR] = new FXGIFCursor(a, Delete_cursor, 1, 2);50myCursors[GUICursor::SELECT] = new FXGIFCursor(a, Select_cursor, 1, 1);51myCursors[GUICursor::SELECT_LANE] = new FXGIFCursor(a, SelectLane_cursor, 1, 1);52myCursors[GUICursor::INSPECT] = new FXGIFCursor(a, Inspect_cursor, 1, 2);53myCursors[GUICursor::INSPECT_LANE] = new FXGIFCursor(a, InspectLane_cursor, 1, 2);54myCursors[GUICursor::MOVEELEMENT] = new FXGIFCursor(a, MoveElement_cursor, 1, 2);5556// ... and create them57for (const auto& cursor : myCursors) {58if (cursor.second != nullptr) {59cursor.second->create();60}61}6263}646566GUICursorSubSys::~GUICursorSubSys() {67// delete all cursors68for (const auto& cursor : myCursors) {69if (cursor.first != GUICursor::DEFAULT && cursor.first != GUICursor::MOVEVIEW) {70delete cursor.second;71}72}73}747576void77GUICursorSubSys::initCursors(FXApp* a) {78if (myInstance == nullptr) {79myInstance = new GUICursorSubSys(a);80} else {81throw ProcessError("GUICursorSubSys already init");82}83}848586FXCursor*87GUICursorSubSys::getCursor(GUICursor which) {88return myInstance->myCursors[which];89}909192void93GUICursorSubSys::close() {94// delete and reset instance95delete myInstance;96myInstance = nullptr;97}9899100/****************************************************************************/101102103