The ZX Ecosystem v5.1.0;_GUI_v3.1.0
Loading...
Searching...
No Matches
ZXWidgetCounter.h
Go to the documentation of this file.
1
2/* **************************************************************************/
19#ifndef ZXWIDGET_COUNTER
20#define ZXWIDGET_COUNTER
21
23
24
25namespace zxeco
26{
27
28namespace gui
29{
30
31/*****************************************************************************
32*
33* Class: CounterWidget
34*
35*******************************************************************************/
36
39{
40 public:
41
43
45 enum : uint8_t {
48 };
49
50
51 CounterWidget(ID id, const std::string & name,
52 int rangemin, int rangemax,
53 bool editable = false, uint8_t addarrows = 0, int fastinc = 2,
54 const std::string & tooltiptext = "",
55 HorAlign hal = HorAlign::LEFT,
56 VertAlign val = VertAlign::TOP);
58
67 int value(void) const noexcept { return(value_); }
69
70 int minValue(void) const noexcept { return(rangemin_); }
72
73 int maxValue(void) const noexcept { return(rangemax_); }
75
76 void setValue(int value);
78
82 const char * className(void) const noexcept { return("CounterWidget"); }
83
84
85 private:
86
87 enum ChildName {
88 INC_ARROW = 0,
89 DEC_ARROW,
90 FASTINC_ARROW,
91 FASTDEC_ARROW,
92 EXTRINC_ARROW,
93 EXTRDEC_ARROW,
94 VALUE,
95 NUMCHILDREN
96 };
97
98 static const uint8_t kUDGs[6*8];
99 static const ID kIDSubs[NUMCHILDREN];
100
101 const uint8_t addarrows_;
102 const int rangemin_,rangemax_;
103 const int fastincval_;
104 CharDist maxlenval_;
105
106 int value_;
107
108 ButtonWidget * wincarrow_;
109 ButtonWidget * wdecarrow_;
110 ButtonWidget * wfastincarrow_;
111 ButtonWidget * wfastdecarrow_;
112 ButtonWidget * wextrincarrow_;
113 ButtonWidget * wextrdecarrow_;
114 LineInputWidget * wvalue_;
115
116 CharDist valueLengthAsString(int v) const;
117 std::string valueAsString(void) const;
118 void putValue(int v);
119 void drawRaw(void);
120 int processEvent(const EventData & evdata, Widget * who) override;
121};
122
123
124
125} // end namespace gui
126} // end namespace zxeco
127
128#endif
129 // ZXWidgetCounter
131
132
133
HorAlign
Horizontal alignment of widgets within the areas of their containers.
VertAlign
Vertical alignment of widgets within the areas of their containers.
A container of other widgets.
int ID
A numeric ID associated to the widget.
Definition: ZXWidgetsBase.h:67
int minValue(void) const noexcept
Return the minimum value possible.
const char * className(void) const noexcept
Must return a text with the name of the class.
CounterWidget(ID id, const std::string &name, int rangemin, int rangemax, bool editable=false, uint8_t addarrows=0, int fastinc=2, const std::string &tooltiptext="", HorAlign hal=HorAlign::LEFT, VertAlign val=VertAlign::TOP)
Constructor. The initial numerical value will be rangemin.
void setValue(int value)
Change the current numerical value of the counter.
int value(void) const noexcept
Return the current numerical value of the counter.
@ FAST_ARROWS
Provide increments/decrements > 1.
@ EXTREME_ARROWS
Provide motion to the extremes of the range.
int maxValue(void) const noexcept
Return the minimum value possible.
A counter (on integer values).
uint16_t CharDist
A distance meadured in screen chars.
Definition: ZXGraphics.h:97
The main namespace of the library, that spans across all the zx modules.
Definition: ZXChars.h:31