74 using Ptr = std::shared_ptr<Widget>;
81 using Base = std::vector<Ptr>;
89 { push_back(w); back()->setParent(&parent);
return(back().get()); }
95 class Path:
public std::vector<Widget *>
99 using Base = std::vector<Widget *>;
101 Path(
bool downorup):Base{},downorup_{downorup} {}
112 bool isUpwards(
void)
const noexcept {
return(!downorup_); }
177 const std::string & expl =
""):
187 const CharArea & ndd, uint8_t fds = 0):
217 { copyFrom(oaf);
return(*
this); }
221 {
if (
this != &oaf) moveFrom(std::move(oaf));
return(*
this); }
225 { copyFrom(oaf);
widget = wi; }
230 {
if (
this != &oaf) moveFrom(std::move(oaf));
245 { moveFrom(std::move(oaf)); }
247 void copyFrom(
const AreaFitting & oaf);
248 void moveFrom(AreaFitting && oaf);
330 DesktopInterface::KeyID::NUM_OF_KEY_IDS};
339 EvData(
const char * chutf8):
text(chutf8) {}
340 EvData(
const EvData & o) { copyFrom(o); }
341 EvData(EvData && o) { copyFrom(o); }
342 EvData & operator=(
const EvData & o)
343 { copyFrom(o);
return(*
this); }
344 EvData & operator=(EvData && o)
345 { copyFrom(o);
return(*
this); }
350 void copyFrom(
const EvData & o)
379 { copyFrom(o);
return(*
this); }
381 { copyFrom(o);
return(*
this); }
531 "WINCLOSE" :
"NOT_PROCESSED"} +
532 (
who ==
nullptr ? std::string{
", no leaf widget"} :
533 (std::string{
", leaf widget ID "} +
552 {
return((
moment ==
'A') && (
pevd !=
nullptr)); }
554 bool isBeforeWithData(
void)
const noexcept
555 {
return((
moment ==
'B') && (
pevd !=
nullptr)); }
583 std::string to_string(
void)
const
584 {
return(
"CallbackParms: moment = " + std::string(1,
moment) +
585 ", whoprocessed = " + (
whoprocessed ==
nullptr ?
"null" :
587 ", eventadata = " + (
pevd ==
nullptr ?
"null" :
617 using Type = uint8_t;
637 static inline Trace::Type
isTracing(Trace::Type traces)
noexcept
641 static void printTrace(Trace::Type trace,
const std::string & tr);
656 const std::string & tooltiptext =
"",
667 fitting_needs_{{0,0},
this},
671 explaindrawing_{
false},
673 { setTooltip(tooltiptext); }
691 virtual ~Widget(
void) =
default;
700 virtual const char * className(
void)
const noexcept = 0;
706 std::string idText(
bool withpointer =
false)
const;
711 virtual bool isContainer(
void)
const noexcept {
return(
false); }
715 bool isUserContainer(
void)
const noexcept;
719 ID getID(
void)
const noexcept {
return(id_); }
724 void changeID(
ID id)
noexcept { id_ = id; }
729 const std::string & getName(
void)
const noexcept {
return(name_); }
735 bool operator==(
const Widget & oth)
const noexcept {
return(
this == & oth);}
738 bool operator!=(
const Widget & oth)
const noexcept {
return(
this != & oth);}
741 virtual std::pair<bool,const CharRect *> hasFocusZone(
void)
const noexcept
748 {
return(std::make_pair(
false,
nullptr)); }
750 virtual void setWindow(
Window & win)
noexcept { pwin_ = & win; }
753 virtual void setWinColors(
const WinColors & wincols)
noexcept
755 { pwincols_ = & wincols; }
757 const WinColors & getWinColors(
void)
const noexcept {
return(*pwincols_); }
760 virtual void setUDGs(
const uint8_t * udgs) { udgs_ = udgs; }
765 const uint8_t * getUDGs(
void) {
return(udgs_); }
768 virtual void setTooltip(
const std::string & ttt)
774 const std::string & getTooltip(
void)
const noexcept {
return(tooltiptext_);}
783 void setParent(Widget * parent);
788 Widget * getParent(
void)
const noexcept {
return(parent_); }
797 bool isRoot(
void)
const noexcept {
return(parent_ ==
nullptr); }
800 bool isDescendantOf(
Widget & w)
const;
809 ID maxUsedID(
void)
const;
839 void setVisibility(
bool visible =
true);
851 void setVisibilityNoRedrawing(
bool vis)
noexcept { visible_ = vis; }
859 bool getVisibility(
void)
const noexcept;
866 void setEnabled(
bool enabled =
true);
873 bool getEnabled(
void)
const noexcept;
878 bool isFocusable(
bool drawntoo =
true)
const;
882 bool isInFocusPath(
void)
const noexcept {
return(focused_); }
887 bool isLeafFocused(
void)
const noexcept
889 {
return(isInFocusPath() && !isContainer()); }
891 Widget * whoIsFocused(
void);
904 void releaseFocus(
void);
916 void drawAll(
const CharRect & rect);
989 const AreaFitting & fittingNeeds(
void)
const noexcept
992 {
return(fitting_needs_); }
1023 const CharRect & drawingZone(
void)
const noexcept
1026 {
return(drawing_zone_); }
1028 const CharRect & alignedDrawingZone(
void)
const noexcept
1032 {
return(aligned_drawing_zone_); }
1034 virtual void moveDrawingZones(
IntDist incx,
IntDist incy)
noexcept;
1041 bool drawn(
void)
const noexcept {
return(drawn_); }
1044 void undraw(
void)
noexcept { drawn_ =
false; }
1055 void setExplanations(
bool setit =
true) noexcept
1061 { explaindrawing_ = setit; }
1063 bool getExplanations(
void)
const noexcept {
return(explaindrawing_); }
1066 std::string traceOfDrawing(
bool withoutprivate =
true) const
1070 { std::stringstream ss; traceOfDrawingRecursive(0,ss,withoutprivate);
1073 virtual void traceOfDrawingRecursive(
size_t level,
1074 std::stringstream & ss,
1075 bool withoutprivate =
true)
const;
1087 virtual ChainEventResult chainEvent(
const EventData & data);
1106 virtual void setCallback(
const CallbackRout & callback = NullCallback)
1108 { callback_ = callback; }
1110 const CallbackRout & getCallback(
void)
const noexcept {
return(callback_); }
1113 void addCallback(
const CallbackRout & cbk);
1123 static Trace::Type traces_;
1127 const std::string name_;
1129 const WinColors * pwincols_;
1130 const uint8_t * udgs_;
1135 CallbackRout callback_;
1136 std::string tooltiptext_;
1143 bool explaindrawing_;
1146 virtual void drawRaw(
void) {}
1184 void addLineToExplanation(
const std::string & line);
1191 static const std::string & traceName(Trace::Type trace);
1204 {
return(availablezone.
align_area(areaneeded,
1205 hal_ == HorAlign::CENTER ?
'C' :
1206 (hal_ == HorAlign::RIGHT ?
'R' :
'L'),
1207 val_ == VertAlign::MIDDLE ?
'M' :
1208 (val_ == VertAlign::BOTTOM ?
'B' :
'T'))); }
1209 bool decideCanQuitFocus(
const Path & mypathtoroot)
const;
1210 void updateFocus(
bool focusgotorlost);
1211 Widget * recalcDrawingZones(
bool directparent,
1213 Widget * & ptrcause);
1214 Widget * drawAllFrom(Widget * from,
const CharRect & rect,
1215 bool onlyifchanged);
1216 void draw(
bool cls =
true);
1217 bool coversTargetOfEvent(
const EventData & evdata,
CharCursor & cc)
const;
1284 CCType cctype = CCType::USER,
1285 OrType ortype = OrType::VERTICAL,
1286 FMType foctype = FMType::NORMAL,
1287 bool withframe =
false,
1288 const std::string & title =
"",
1291 const std::string & tooltiptext =
""):
1292 Widget{id,name,tooltiptext,hal,val},
1295 focustype_{foctype},
1297 withframe_{withframe},
1324 CCType ccType(
void)
const noexcept {
return(cctype_); }
1327 OrType orType(
void)
const noexcept {
return(ortype_); }
1330 FMType focusMngType(
void)
const noexcept {
return(focustype_); }
1333 bool getFrame(
void)
const noexcept {
return(withframe_); }
1338 const std::string & getTitle(
void)
const noexcept {
return(title_); }
1341 bool cursorInTopFrame(
const CharCursor & cc)
const;
1346 const PVector & children(
void)
noexcept {
return(children_); }
1354 {
return(children_.addChildOf(ch,*
this)); }
1356 void setDeepSelected(PVector::size_type who);
1362 PVector::size_type getDeepSelected(
void)
const;
1372 const char * className(
void)
const noexcept {
return(
"ContainerWidget"); }
1373 bool isContainer(
void)
const noexcept override {
return(
true); }
1378 void setWindow(
Window & win)
noexcept override;
1379 void setWinColors(
const WinColors & wincols)
noexcept override;
1387 static const std::vector<uint8_t> kContUDGs;
1394 PVector::size_type whodeep_;
1399 bool isTabbedDeep(
void)
const noexcept;
1400 bool isFramed(
void)
const noexcept;
1403 void calcFrameDims(
const CharArea & area,
1408 void drawFrameTitle(
Screen & scr)
const;
1411 size_t & howmanychildrenvisible,
1413 size_t & howmanyflexvert,
1414 size_t & howmanyflexhor,
1415 std::string & explanation);
1416 void calcShareExcessForChildren(
const CharArea & area,
1418 std::vector<CharDist> & sharing,
1419 size_t howmanychildrenareflex,
1420 size_t howmanychildrenarevisible,
1422 void traceOfDrawingRecursive(
size_t level, std::stringstream & ss,
1423 bool withoutprivate =
true)
const;
LongestUnsignedType utime_now(void)
Return the current time since epoch in microseconds.
KeyID
IDs for the most common keys in a keyboard.
Interface with the functionality that a desktop must provide.
Colors used in a GUI window.
unsigned long long LongestUnsignedType
Longest unsigned integral type in the target machine.
std::string nonCtrlString(const std::string &txt, char who='A')
Return a version of TXT without control codes.
uint16_t CharCoord
Represent both x and y screen char coordinates.
int16_t IntDist
Positive and negative distances on screen.
Rect align_area(const area_type &areaneeded, char horalign, char vertalign) const
Return the portion of this rectangle that contains AREANEEDED aligned.
uint16_t CharDist
A distance meadured in screen chars.
bool buttonright
State (TRUE->pressed) of main buttons.
bool buttonleft
State (TRUE->pressed) of main buttons.
Status of the pointing device.
The class that provides the main support for managing the ZX screen.
The main namespace of the library, that spans across all the zx modules.