/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2006-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 MFXStaticToolTip.cpp14/// @author Pablo Alvarez Lopez15/// @date May 202216///17//18/****************************************************************************/1920/* =========================================================================21* included modules22* ======================================================================= */23#include <config.h>2425#include <utils/gui/div/GUIDesigns.h>26#include <utils/gui/images/GUIIconSubSys.h>27#include <utils/gui/windows/GUIAppEnum.h>2829#include "MFXStaticToolTip.h"3031// ===========================================================================32// FOX callback mapping33// ===========================================================================3435FXDEFMAP(MFXStaticToolTip) MFXStaticToolTipMap[] = {36FXMAPFUNC(SEL_PAINT, 0, MFXStaticToolTip::onPaint),37FXMAPFUNC(SEL_UPDATE, 0, MFXStaticToolTip::onUpdate),38};3940// Object implementation41FXIMPLEMENT(MFXStaticToolTip, FXToolTip, MFXStaticToolTipMap, ARRAYNUMBER(MFXStaticToolTipMap))4243// ===========================================================================44// method definitions45// ===========================================================================4647MFXStaticToolTip::MFXStaticToolTip(FXApp* app) :48FXToolTip(app) {49// set empty test50setText("");51// start hide52hide();53}545556MFXStaticToolTip::~MFXStaticToolTip() {}575859void60MFXStaticToolTip::enableStaticToolTip(const bool value) {61if (value) {62myEnableStaticTooltip = true;63} else {64myEnableStaticTooltip = false;65hideStaticToolTip();66}67}686970bool71MFXStaticToolTip::isStaticToolTipEnabled() const {72return myEnableStaticTooltip;73}747576void77MFXStaticToolTip::showStaticToolTip(const FXString& toolTipText) {78if (!myEnableStaticTooltip || toolTipText.empty()) {79hideStaticToolTip();80} else {81// set tip text82setText(toolTipText);83// update before show (for position)84onUpdate(nullptr, 0, nullptr);85// show StaticToolTip86show();87}88}899091void92MFXStaticToolTip::hideStaticToolTip() {93// clear text94setText("");95// hide staticTooltip96hide();97}9899100long101MFXStaticToolTip::onPaint(FXObject* sender, FXSelector sel, void* obj) {102// draw tooltip using myToolTippedObject103if (!label.empty() && myEnableStaticTooltip) {104return FXToolTip::onPaint(sender, sel, obj);105} else {106return 0;107}108}109110111long112MFXStaticToolTip::onUpdate(FXObject* sender, FXSelector sel, void* ptr) {113// Regular GUI update114FXWindow::onUpdate(sender, sel, ptr);115// Ask the help source for a new status text first116if (label.empty()) {117popped = FALSE;118hide();119} else {120popped = TRUE;121FXint x, y;122FXuint state;123getRoot()->getCursorPosition(x, y, state);124place(x, y);125}126return 1;127}128129130MFXStaticToolTip::MFXStaticToolTip() :131FXToolTip() {132}133134135