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 MFXLCDLabel.h
15 : /// @author Mathew Robertson
16 : /// @author Daniel Krajzewicz
17 : /// @author Michael Behrisch
18 : /// @author Pablo Alvarez Lopez
19 : /// @date 2004-03-19
20 : ///
21 : //
22 : /****************************************************************************/
23 : #pragma once
24 : #include <config.h>
25 :
26 : #include "fxheader.h"
27 : #include "MFXStaticToolTip.h"
28 :
29 :
30 : /** @brief A widget which has the seven-segment display used as the drawing object for each letter
31 : * in the label. Supports display of leading zeros, such as when you need to display a
32 : * number. Also supports the 'JUSTIFY_RIGHT' option, for right alignment.
33 : */
34 : class MFXLCDLabel : public FXHorizontalFrame {
35 : /// @brief FOX-declaration
36 0 : FXDECLARE(MFXLCDLabel)
37 :
38 : public:
39 : /// @brief LCD Label styles
40 : enum {
41 : LCDLABEL_NORMAL = FRAME_SUNKEN | FRAME_THICK,
42 : LCDLABEL_LEADING_ZEROS = 0x01000000 /// leading zero's on label - useful for integers
43 : };
44 :
45 : /// @brief call messages
46 : enum {
47 : ID_SEVENSEGMENT = FXHorizontalFrame::ID_LAST,
48 : ID_LAST
49 : };
50 :
51 : public:
52 : /// @brief constructor
53 : MFXLCDLabel(FXComposite* p, MFXStaticToolTip* staticToolTip, FXuint nfig, FXObject* tgt, FXSelector sel, FXuint opts = LCDLABEL_NORMAL, FXint pl = DEFAULT_PAD, FXint pr = DEFAULT_PAD, FXint pt = DEFAULT_PAD, FXint pb = DEFAULT_PAD, FXint hs = DEFAULT_PAD);
54 :
55 : /// @brief destructor
56 : virtual ~MFXLCDLabel();
57 :
58 : /// @brief create resrouces
59 : virtual void create();
60 :
61 : /// @brief detach resources
62 : virtual void detach();
63 :
64 : /// @brief destroy resources
65 : virtual void destroy();
66 :
67 : /// @brief manipulate text in LCD label
68 : void setText(FXString lbl);
69 :
70 : /// @brief get text
71 : FXString getText() const;
72 :
73 : /// @brief set forground color
74 : void setFgColor(FXColor clr);
75 :
76 : /// @brief get forground color
77 : FXColor getFgColor() const;
78 :
79 : /// @brief set background color
80 : void setBgColor(FXColor clr);
81 :
82 : /// @brief get background color
83 : FXColor getBgColor() const;
84 :
85 : /// @brief set segment horizontal length - must be more than twice the segment width
86 : void setHorizontal(const FXint len);
87 :
88 : /// @brief get segment horizontal length - must be more than twice the segment width
89 : FXint getHorizontal() const;
90 :
91 : /// @brief set segment vertical length - must be more than twice the segment width
92 : void setVertical(const FXint len);
93 :
94 : /// @brief get segment vertical length - must be more than twice the segment width
95 : FXint getVertical() const;
96 :
97 : /// @brief set segment width - must be less than half the segment length
98 : void setThickness(const FXint w);
99 :
100 : /// @brief get segment width - must be less than half the segment length
101 : FXint getThickness() const;
102 :
103 : /// @brief set groove width - must be less than segment width
104 : void setGroove(const FXint w);
105 :
106 : /// @brief get groove width - must be less than segment width
107 : FXint getGroove() const;
108 :
109 : /// @brief return minimum width
110 : virtual FXint getDefaultWidth();
111 :
112 : /// @brief return minimum height
113 : virtual FXint getDefaultHeight();
114 :
115 : /// @brief set tooltip text
116 : void setToolTipText(const FXString& text);
117 :
118 : /// @brief save resources
119 : virtual void save(FXStream& store) const;
120 :
121 : /// @brief load resources
122 : virtual void load(FXStream& store);
123 :
124 : /// @brief handle paint event
125 : long onPaint(FXObject*, FXSelector, void*);
126 :
127 : /// @brief called when mouse enter in MFXMenuButtonTooltip
128 : long onEnter(FXObject* obj, FXSelector sel, void* ptr);
129 :
130 : /// @brief called when mouse leaves in MFXMenuButtonTooltip
131 : long onLeave(FXObject* obj, FXSelector sel, void* ptr);
132 :
133 : /// @brief called when mouse motion in MFXMenuButtonTooltip
134 : long onMotion(FXObject* obj, FXSelector sel, void* ptr);
135 :
136 : /// @brief Update value from a message
137 : long onCmdSetValue(FXObject*, FXSelector, void* ptr);
138 :
139 : /// @brief Update int value from a message
140 : long onCmdSetIntValue(FXObject*, FXSelector, void* ptr);
141 :
142 : /// @brief Update real value from a message
143 : long onCmdSetRealValue(FXObject*, FXSelector, void* ptr);
144 :
145 : /// @brief Update string value from a message
146 : long onCmdSetStringValue(FXObject*, FXSelector, void* ptr);
147 :
148 : /// @brief Obtain int value from text field
149 : long onCmdGetIntValue(FXObject*, FXSelector, void* ptr);
150 :
151 : /// @brief Obtain real value from text field
152 : long onCmdGetRealValue(FXObject*, FXSelector, void* ptr);
153 :
154 : /// @brief Obtain string value from text field
155 : long onCmdGetStringValue(FXObject*, FXSelector, void* ptr);
156 :
157 : /// @brief redirect events to main window
158 : long onRedirectEvent(FXObject*, FXSelector, void* ptr);
159 :
160 : /// @brief let parent show tip if appropriate
161 : long onQueryTip(FXObject*, FXSelector, void* ptr);
162 :
163 : /// @brief let parent show help if appropriate
164 : long onQueryHelp(FXObject*, FXSelector, void* ptr);
165 :
166 : protected:
167 : /// @brief FOX constructor
168 0 : FOX_CONSTRUCTOR(MFXLCDLabel)
169 :
170 : /// @brief The currently shown label
171 : FXString myLabel;
172 :
173 : /// @brief The number of shown figuresi, greater than zero
174 : FXint myNFigures;
175 :
176 : /// @brief pointer to staticToolTip
177 : MFXStaticToolTip* myStaticToolTip;
178 :
179 : /// @brief toolTip text
180 : FXString myToolTipText;
181 :
182 : /// @brief Draw a string
183 : void drawString(const FXString& lbl);
184 : };
|