Line data Source code
1 : /****************************************************************************/
2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 : // Copyright (C) 2004-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 MFXMenuCheckIcon.h
15 : /// @author Pablo Alvarez Lopez
16 : /// @date Jan 2021
17 : ///
18 : //
19 : /****************************************************************************/
20 :
21 : #pragma once
22 : #include <config.h>
23 :
24 :
25 : #include "fxheader.h"
26 : #include <string>
27 :
28 : /**
29 : * The menu check widget is used to change a state in the
30 : * application from a menu. Menu checks may reflect
31 : * the state of the application by graying out, becoming hidden,
32 : * or by a check mark.
33 : * When activated, a menu check sends a SEL_COMMAND to its target;
34 : * the void* argument of the message contains the new state.
35 : */
36 : class MFXMenuCheckIcon : public FXMenuCommand {
37 : /// @brief FOX-declaration
38 0 : FXDECLARE(MFXMenuCheckIcon)
39 :
40 : public:
41 : /// @brief Construct a menu check
42 : MFXMenuCheckIcon(FXComposite* p, const std::string& text, const std::string& shortcut, const std::string& info, const FXIcon* icon, FXObject* tgt = NULL, FXSelector sel = 0, FXuint opts = 0);
43 :
44 : /// @brief Return default width
45 : virtual FXint getDefaultWidth();
46 :
47 : /// @brief Return default height
48 : virtual FXint getDefaultHeight();
49 :
50 : /// @brief Set check state (TRUE, FALSE or MAYBE)
51 : void setCheck(FXbool s = TRUE);
52 :
53 : /// @brief Get check state (TRUE, FALSE or MAYBE)
54 : FXbool getCheck() const;
55 :
56 : /// @brief Get the box background color
57 : FXColor getBoxColor() const;
58 :
59 : /// @brief Set the box background color
60 : void setBoxColor(FXColor clr);
61 :
62 : /// @brief Save menu to a stream
63 : virtual void save(FXStream& store) const;
64 :
65 : /// @brief Load menu from a stream
66 : virtual void load(FXStream& store);
67 :
68 : /// @name FOX calls
69 : /// @{
70 : long onPaint(FXObject*, FXSelector, void*);
71 : long onButtonPress(FXObject*, FXSelector, void*);
72 : long onButtonRelease(FXObject*, FXSelector, void*);
73 : long onKeyPress(FXObject*, FXSelector, void*);
74 : long onKeyRelease(FXObject*, FXSelector, void*);
75 : long onHotKeyPress(FXObject*, FXSelector, void*);
76 : long onHotKeyRelease(FXObject*, FXSelector, void*);
77 : long onCheck(FXObject*, FXSelector, void*);
78 : long onUncheck(FXObject*, FXSelector, void*);
79 : long onUnknown(FXObject*, FXSelector, void*);
80 : long onCmdSetValue(FXObject*, FXSelector, void*);
81 : long onCmdSetIntValue(FXObject*, FXSelector, void*);
82 : long onCmdGetIntValue(FXObject*, FXSelector, void*);
83 : long onCmdAccel(FXObject*, FXSelector, void*);
84 : /// @}
85 :
86 : protected:
87 : /// @brief default constructor
88 : MFXMenuCheckIcon();
89 :
90 : /// @brief Icon
91 : const FXIcon* myIcon;
92 :
93 : /// @brief State of menu
94 : FXuchar myCheck;
95 :
96 : /// @brief Box color
97 : FXColor myBoxColor;
98 :
99 : private:
100 : /// @brief Invalidated copy constructor.
101 : MFXMenuCheckIcon(const MFXMenuCheckIcon&) = delete;
102 :
103 : /// @brief Invalidated assignment operator.
104 : MFXMenuCheckIcon& operator=(const MFXMenuCheckIcon&) = delete;
105 : };
|