From 4f2174c82dbd65b161083fe337fe2a33172a7a0b Mon Sep 17 00:00:00 2001 From: kevin Date: Sat, 21 Sep 2024 17:18:12 -0400 Subject: [PATCH] cwIo.h/cpp, cwUi.h/cpp : Added emptyParent(). --- cwIo.cpp | 10 ++++++++++ cwIo.h | 3 ++- cwUi.cpp | 27 +++++++++++++++++++++++++++ cwUi.h | 1 + 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/cwIo.cpp b/cwIo.cpp index 4c9c471..341df42 100644 --- a/cwIo.cpp +++ b/cwIo.cpp @@ -3843,6 +3843,16 @@ cw::rc_t cw::io::uiSetLogLine( handle_t h, unsigned uuId, const char* text ) rc = ui::setLogLine(uiH,uuId,text); return rc; } + +cw::rc_t cw::io::uiEmptyParent( handle_t h, unsigned uuId) +{ + rc_t rc; + ui::handle_t uiH; + if((rc = _handleToUiHandle(h,uiH)) == kOkRC ) + rc = ui::emptyParent(uiH,uuId); + return rc; +} + cw::rc_t cw::io::uiSetClickable( handle_t h, unsigned uuId, bool clickableFl ) { diff --git a/cwIo.h b/cwIo.h index 39e522b..ef345a0 100644 --- a/cwIo.h +++ b/cwIo.h @@ -386,7 +386,8 @@ namespace cw rc_t uiSetNumbRange( handle_t h, unsigned uuId, double minValue, double maxValue, double stepValue, unsigned decPl, double value ); rc_t uiSetProgRange( handle_t h, unsigned uuId, double minValue, double maxValue, double value ); - rc_t uiSetLogLine( handle_t h, unsigned uuId, const char* text ); + rc_t uiSetLogLine( handle_t h, unsigned uuId, const char* text ); + rc_t uiEmptyParent( handle_t h, unsigned uuId); // empty a list or select of all children rc_t uiSetClickable( handle_t h, unsigned uuId, bool clickableFl=true ); rc_t uiClearClickable( handle_t h, unsigned uuId ); diff --git a/cwUi.cpp b/cwUi.cpp index a81c02a..ac59c39 100644 --- a/cwUi.cpp +++ b/cwUi.cpp @@ -1951,6 +1951,33 @@ cw::rc_t cw::ui::setLogLine( handle_t h, unsigned uuId, const char* text ) return rc; } +cw::rc_t cw::ui::emptyParent( handle_t h, unsigned uuId ) +{ + + ui_t* p = _handleToPtr(h); + rc_t rc = kOkRC; + + const char* mFmt = "{ \"op\":\"empty\", \"uuId\":%i }"; + const int mbufN = 256; + char mbuf[mbufN]; + + if( snprintf(mbuf,mbufN,mFmt,uuId) >= mbufN-1 ) + { + rc = cwLogError(kBufTooSmallRC,"The msg buffer is too small for 'empty' msg."); + goto errLabel; + } + + if((rc = _websockSend(p,kInvalidId,mbuf)) != kOkRC ) + { + cwLogError(rc,"'empty' msg transmit failed."); + goto errLabel; + } + +errLabel: + return rc; +} + + cw::rc_t cw::ui::setClickable( handle_t h, unsigned uuId, bool clickableFl ) { return _setPropertyFlag( h, UI_CLICKABLE_LABEL, uuId, clickableFl ); } diff --git a/cwUi.h b/cwUi.h index 58ef92d..3fd01f9 100644 --- a/cwUi.h +++ b/cwUi.h @@ -130,6 +130,7 @@ namespace cw rc_t setNumbRange( handle_t h, unsigned uuId, double minValue, double maxValue, double stepValue, unsigned decPl, double value ); rc_t setProgRange( handle_t h, unsigned uuId, double minValue, double maxValue, double value ); rc_t setLogLine( handle_t h, unsigned uuId, const char* text ); + rc_t emptyParent( handle_t h, unsigned uuId ); rc_t setClickable( handle_t h, unsigned uuId, bool clickableFl=true ); rc_t clearClickable( handle_t h, unsigned uuId );