Path: blob/main/src/utils/foxtools/MFXMenuButtonTooltip.cpp
169678 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 MFXMenuButtonTooltip.cpp14/// @author Pablo Alvarez Lopez15/// @date 2022-07-2716///17// MenuButton similar to FXMenuButton but with the possibility of showing tooltips18/****************************************************************************/19#include <config.h>2021#include <utils/gui/windows/GUIAppEnum.h>2223#include "MFXStaticToolTip.h"24#include "MFXMenuButtonTooltip.h"2526// ===========================================================================27// FOX callback mapping28// ===========================================================================2930FXDEFMAP(MFXMenuButtonTooltip) MFXMenuButtonTooltipMap[] = {31FXMAPFUNC(SEL_ENTER, 0, MFXMenuButtonTooltip::onEnter),32FXMAPFUNC(SEL_LEAVE, 0, MFXMenuButtonTooltip::onLeave),33FXMAPFUNC(SEL_MOTION, 0, MFXMenuButtonTooltip::onMotion),34FXMAPFUNC(SEL_LEFTBUTTONPRESS, 0, MFXMenuButtonTooltip::onLeftBtnPress),35FXMAPFUNC(SEL_KEYPRESS, 0, MFXMenuButtonTooltip::onKeyPress),36FXMAPFUNC(SEL_COMMAND, FXWindow::ID_POST, MFXMenuButtonTooltip::onCmdPost),37};3839// Object implementation40FXIMPLEMENT(MFXMenuButtonTooltip, FXMenuButton, MFXMenuButtonTooltipMap, ARRAYNUMBER(MFXMenuButtonTooltipMap))4142// ===========================================================================43// method definitions44// ===========================================================================4546MFXMenuButtonTooltip::MFXMenuButtonTooltip(FXComposite* p, MFXStaticToolTip* staticToolTip, const std::string& text, FXIcon* ic,47FXPopup* pup, FXObject* optionalTarget, FXuint opts,48FXint x, FXint y, FXint w, FXint h, FXint pl, FXint pr, FXint pt, FXint pb) :49FXMenuButton(p, text.c_str(), ic, pup, opts, x, y, w, h, pl, pr, pt, pb),50myStaticToolTip(staticToolTip),51myOptionalTarget(optionalTarget) {52}535455MFXMenuButtonTooltip::~MFXMenuButtonTooltip() {}565758long59MFXMenuButtonTooltip::onEnter(FXObject* sender, FXSelector sel, void* ptr) {60// show tip show61myStaticToolTip->showStaticToolTip(getTipText());62return FXMenuButton::onEnter(sender, sel, ptr);63}646566long67MFXMenuButtonTooltip::onLeave(FXObject* sender, FXSelector sel, void* ptr) {68// hide static toolTip69myStaticToolTip->hideStaticToolTip();70return FXMenuButton::onLeave(sender, sel, ptr);71}727374long75MFXMenuButtonTooltip::onMotion(FXObject* sender, FXSelector sel, void* ptr) {76// update static tooltip77myStaticToolTip->onUpdate(sender, sel, ptr);78return FXMenuButton::onMotion(sender, sel, ptr);79}808182long83MFXMenuButtonTooltip::onLeftBtnPress(FXObject* sender, FXSelector sel, void* ptr) {84// inform optional target85if (myOptionalTarget) {86myOptionalTarget->tryHandle(this, FXSEL(MID_MBTTIP_FOCUS, message), nullptr);87}88// continue handling onLeftBtnPress89return FXMenuButton::onLeftBtnPress(sender, sel, ptr);90}9192long93MFXMenuButtonTooltip::onKeyPress(FXObject* sender, FXSelector sel, void* ptr) {94// inform optional target95if (myOptionalTarget) {96myOptionalTarget->tryHandle(this, FXSEL(MID_MBTTIP_FOCUS, message), nullptr);97}98// continue handling onKeyPress99return FXMenuButton::onKeyPress(sender, sel, ptr);100}101102103long104MFXMenuButtonTooltip::onCmdPost(FXObject* sender, FXSelector sel, void* ptr) {105// inform optional target106if (myOptionalTarget) {107myOptionalTarget->tryHandle(this, FXSEL(MID_MBTTIP_SELECTED, message), nullptr);108}109// continue handling onCheck110return FXMenuButton::onCmdPost(sender, sel, ptr);111}112113/****************************************************************************/114115116