20#ifndef ZXWIDGETS_SIMPLE
21#define ZXWIDGETS_SIMPLE
49 const std::string & initlabel,
50 const std::string & tooltiptext =
"",
60 const std::string &
getLabel(
void)
noexcept {
return(label_.
get()); }
63 void setLabel(
const std::string & newlab);
67 const char *
className(
void)
const noexcept {
return(
"LabelWidget"); }
92 const std::string & initlabel,
93 bool withborder =
true,
94 const std::string & tooltiptext =
"",
99 withborder_{withborder},
107 {
if (label_.get().empty())
112 bool withborder =
false,
113 const std::string & tooltiptext =
"",
119 withborder_{withborder},
128 {
if (image_.attrmap.dims.empty())
129 RUNTIMEEXCEP(
"Cannot create image button with empty image"); }
131 const std::string &
getLabel(
void)
noexcept {
return(label_.get()); }
144 const char *
className(
void)
const noexcept {
return(
"ButtonWidget"); }
150 static const CharArea kBordersMargin;
152 const bool withborder_;
159 PixRect borderRect(
bool pressed)
const;
177 const std::string & labelleft,
const std::string & labelright,
178 const std::string & tooltiptext =
"",
190 bool state(
void)
const noexcept {
return(pressed_); }
198 const char *
className(
void)
const noexcept {
return(
"SwitchWidget"); }
204 static const uint8_t kUDGs[2*8];
206 std::string labelleft_,labelright_;
228 CharDist inputlen = 0,
bool editable =
true,
229 bool enterendsedition =
true,
230 CharDist markedlen = 0,
const uint8_t * printfont =
nullptr,
231 const std::string & tooltiptext =
"",
254 const std::string &
text(
void)
const noexcept {
return(typedtxt_); }
271 {
return(cbps.isAfterWithData() &&
272 (cbps.pevd->isLostFocus() || cbps.hasPressedEnter())); }
275 { typing_zone_.move(incx,incy); Widget::moveDrawingZones(incx,incy); }
276 std::pair<bool,const CharRect *>
hasFocusZone(
void)
const noexcept override
277 {
return(std::make_pair(
true,&typing_zone_.get())); }
279 const char *
className(
void)
const noexcept {
return(
"LineInputWidget"); }
285 const size_t marklen_;
287 const bool editable_;
288 const bool enterendsedition_;
289 const uint8_t * origfont_;
291 uint8_t * printfont_;
293 std::string typedtxt_,prevtypedtxt_;
295 std::string::size_type firstshown_;
296 std::string::size_type curposintxt_;
297 bool pendingextreme_;
299 void drawTextAndCursor(
void);
301 bool checkMouseClickInTyping(
const EventData & evdata);
303 std::string to_string(
void)
const;
321 bool horizorvert =
false,
322 const std::string & tooltiptext =
"",
335 bool isSelected(
size_t who)
const {
return(labels_.marked(who)); }
343 {
bool res = select ? labels_.mark(who) : labels_.unmark(who);
344 if (res && drawn()) drawSelects(); }
348 { labels_.toggle(who);
if (drawn()) drawSelects(); }
353 {
bool res = select ? labels_.markAll() : labels_.unmarkAll();
354 if (res && drawn()) drawSelects(); }
356 void toggleAll(
void) { labels_.toggleAll();
if (drawn()) drawSelects(); }
360 const LabelList & labels(
void)
const noexcept {
return(labels_); }
366 const char * className(
void)
const noexcept {
return(
"ChoiceWidget"); }
367 const AreaFitting & calcFittingNeeds(
const CharArea & area);
371 static const uint8_t kUDGs[4*8];
373 const bool horizorvert_;
379 void drawSelects(
void);
381 int processEvent(
const EventData & evdata,
Widget * who)
override;
402 {
if (separation <= 0)
RUNTIMEEXCEP(
"Invalid separation"); }
405 const char *
className(
void)
const noexcept {
return(
"SeparatorWidget"); }
428 const std::string & tooltip =
"",
431 Widget{id,name,tooltip,hal,val},
433 { setImage(img,region); }
438 const DoubleGraphic & getImage(
void)
const noexcept {
return(image_); }
445 const char * className(
void)
const noexcept {
return(
"ImageWidget"); }
446 const AreaFitting & calcFittingNeeds(
const CharArea & area);
#define RUNTIMEEXCEP(txt)
Raise a runtime exception with the given std::string TXT + additional info.
const std::string & get(void) const noexcept
Get the current label text.
std::vector< Label > Vector
A vector of labels.
A non-empty label for a widget.
A list of labels to be displayed vertically, with possible marks on them.
A zone of a widget where the user can type.
uint16_t CharCoord
Represent both x and y screen char coordinates.
int16_t IntDist
Positive and negative distances on screen.
uint16_t CharDist
A distance meadured in screen chars.
A bitmap plus an attrmap, possibly synchronized.
Status of the pointing device.
The main namespace of the library, that spans across all the zx modules.