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 MFXButtonTooltip.cpp
15 : /// @author Angelo Banse
16 : /// @date 2022-06-21
17 : ///
18 : // Button similar to FXButton but with the possibility of showing tooltips
19 : /****************************************************************************/
20 : #include <config.h>
21 :
22 : #include "MFXButtonTooltip.h"
23 :
24 :
25 : FXDEFMAP(MFXButtonTooltip) MFXButtonTooltipMap[] = {
26 : FXMAPFUNC(SEL_ENTER, 0, MFXButtonTooltip::onEnter),
27 : FXMAPFUNC(SEL_LEAVE, 0, MFXButtonTooltip::onLeave),
28 : FXMAPFUNC(SEL_MOTION, 0, MFXButtonTooltip::onMotion),
29 : };
30 :
31 :
32 : // Object implementation
33 51278798 : FXIMPLEMENT(MFXButtonTooltip, FXButton, MFXButtonTooltipMap, ARRAYNUMBER(MFXButtonTooltipMap))
34 :
35 157083 : MFXButtonTooltip::MFXButtonTooltip(FXComposite* p, MFXStaticToolTip* staticToolTip,
36 : const std::string& text, FXIcon* ic,
37 : FXObject* tgt, FXSelector sel, FXuint opts,
38 : FXint x, FXint y, FXint w, FXint h,
39 157083 : FXint pl, FXint pr, FXint pt, FXint pb) :
40 : FXButton(p, text.c_str(), ic, tgt, sel, opts, x, y, w, h, pl, pr, pt, pb),
41 157083 : myStaticToolTip(staticToolTip) {
42 157083 : }
43 :
44 :
45 313594 : MFXButtonTooltip::~MFXButtonTooltip() {}
46 :
47 :
48 : long
49 0 : MFXButtonTooltip::onEnter(FXObject* sender, FXSelector sel, void* ptr) {
50 : // show tip show
51 0 : myStaticToolTip->showStaticToolTip(getTipText());
52 0 : return FXButton::onEnter(sender, sel, ptr);
53 : }
54 :
55 :
56 : long
57 0 : MFXButtonTooltip::onLeave(FXObject* sender, FXSelector sel, void* ptr) {
58 : // hide static toolTip
59 0 : myStaticToolTip->hideStaticToolTip();
60 0 : return FXButton::onLeave(sender, sel, ptr);
61 : }
62 :
63 :
64 : long
65 0 : MFXButtonTooltip::onMotion(FXObject* sender, FXSelector sel, void* ptr) {
66 : // update static tooltip
67 0 : myStaticToolTip->onUpdate(sender, sel, ptr);
68 0 : return FXButton::onMotion(sender, sel, ptr);
69 : }
70 :
71 : /****************************************************************************/
|