Line data Source code
1 : /****************************************************************************/
2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 : // Copyright (C) 2001-2026 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 MFXCheckButtonTooltip.cpp
15 : /// @author Pablo Alvarez Lopez
16 : /// @date May 23
17 : ///
18 : // CheckButton similar to FXCheckButton but with the possibility of showing tooltips
19 : /****************************************************************************/
20 : #include <config.h>
21 :
22 : #include "MFXStaticToolTip.h"
23 : #include "MFXCheckButtonTooltip.h"
24 :
25 : // ===========================================================================
26 : // FOX callback mapping
27 : // ===========================================================================
28 :
29 : FXDEFMAP(MFXCheckButtonTooltip) MFXCheckButtonTooltipMap[] = {
30 : FXMAPFUNC(SEL_ENTER, 0, MFXCheckButtonTooltip::onEnter),
31 : FXMAPFUNC(SEL_LEAVE, 0, MFXCheckButtonTooltip::onLeave),
32 : FXMAPFUNC(SEL_MOTION, 0, MFXCheckButtonTooltip::onMotion),
33 : };
34 :
35 : // Object implementation
36 0 : FXIMPLEMENT(MFXCheckButtonTooltip, FXCheckButton, MFXCheckButtonTooltipMap, ARRAYNUMBER(MFXCheckButtonTooltipMap))
37 :
38 : // ===========================================================================
39 : // method definitions
40 : // ===========================================================================
41 :
42 0 : MFXCheckButtonTooltip::MFXCheckButtonTooltip(FXComposite* p, MFXStaticToolTip* staticToolTip, const FXString& text, FXObject* tgt,
43 0 : FXSelector sel, FXuint opts, FXint x, FXint y, FXint w, FXint h, FXint pl, FXint pr, FXint pt, FXint pb) :
44 : FXCheckButton(p, text, tgt, sel, opts, x, y, w, h, pl, pr, pt, pb),
45 0 : myStaticToolTip(staticToolTip) {
46 0 : }
47 :
48 :
49 0 : MFXCheckButtonTooltip::~MFXCheckButtonTooltip() {}
50 :
51 :
52 : void
53 0 : MFXCheckButtonTooltip::setToolTipText(const FXString& toolTip) {
54 0 : myToolTipText = toolTip;
55 0 : }
56 :
57 :
58 : long
59 0 : MFXCheckButtonTooltip::onEnter(FXObject* sender, FXSelector sel, void* ptr) {
60 : // check if show toolTip text
61 0 : if (!myToolTipText.empty()) {
62 : // show toolTip text
63 0 : setTipText(myToolTipText);
64 : // show tip show
65 0 : myStaticToolTip->showStaticToolTip(getTipText());
66 : }
67 : // continue with FXCheckButton function
68 0 : return FXCheckButton::onEnter(sender, sel, ptr);
69 : }
70 :
71 :
72 : long
73 0 : MFXCheckButtonTooltip::onLeave(FXObject* sender, FXSelector sel, void* ptr) {
74 : // hide static toolTip
75 0 : myStaticToolTip->hideStaticToolTip();
76 : // continue with FXCheckButton function
77 0 : return FXCheckButton::onLeave(sender, sel, ptr);
78 : }
79 :
80 :
81 : long
82 0 : MFXCheckButtonTooltip::onMotion(FXObject* sender, FXSelector sel, void* ptr) {
83 : // update static tooltip
84 0 : myStaticToolTip->onUpdate(sender, sel, ptr);
85 0 : return FXCheckButton::onMotion(sender, sel, ptr);
86 : }
87 :
88 : /****************************************************************************/
|