From 0dab461a6ec6503f43d337b9ad04cb8524e6a015 Mon Sep 17 00:00:00 2001 From: kevin Date: Sat, 12 Oct 2024 15:18:05 -0400 Subject: [PATCH] cwUi.h/cpp : 1. Renamed createList() to createHList(). Added createVList(). 2. Added setTitle(). --- cwUi.cpp | 32 +++++++++++++++++++++++++++----- cwUi.h | 6 +++++- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/cwUi.cpp b/cwUi.cpp index ac59c39..74886b4 100644 --- a/cwUi.cpp +++ b/cwUi.cpp @@ -47,7 +47,8 @@ namespace cw { "number", false }, { "progress", false }, { "log", false }, - { "list", false }, + { "vlist", false }, + { "hlist", false }, { nullptr, false }, }; @@ -710,7 +711,7 @@ namespace cw // if the given appId was not valid ... - if( appId == kInvalidId && parent != nullptr ) + if( appId == kInvalidId && parent != nullptr && eleName != nullptr ) { appIdMapRecd_t* m; @@ -848,7 +849,7 @@ namespace cw - // 'od' is an object dictionary where each pair in the dictionary has + // 'po' is an object dictionary where each pair in the dictionary has // the form: 'eleType':{ } rc_t _createElementsFromChildList( ui_t* p, const object_t* po, unsigned wsSessId, ele_t* parentEle, unsigned chanId ) { @@ -877,7 +878,7 @@ namespace cw return rc; } - // This functions assumes that the cfg object 'o' contains a field named: 'parent' + // This functions assumes that parentUuId is valid or the cfg object 'o' contains a field named: 'parent' // which contains the element name of the parent node. rc_t _createFromObj( ui_t* p, const object_t* o, unsigned wsSessId, unsigned parentUuId, unsigned chanId ) { @@ -1856,9 +1857,30 @@ cw::rc_t cw::ui::createProg( handle_t h, unsigned& uuIdRef, unsigned parentUuId cw::rc_t cw::ui::createLog( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title ) { return _createOneEle( _handleToPtr(h), uuIdRef, "log", kInvalidId, parentUuId, eleName, appId, chanId, clas, title); } -cw::rc_t cw::ui::createList( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title ) +cw::rc_t cw::ui::createVList( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title ) { return _createOneEle( _handleToPtr(h), uuIdRef, "list", kInvalidId, parentUuId, eleName, appId, chanId, clas, title); } +cw::rc_t cw::ui::createHList( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title ) +{ return _createOneEle( _handleToPtr(h), uuIdRef, "hlist", kInvalidId, parentUuId, eleName, appId, chanId, clas, title); } + +cw::rc_t cw::ui::setTitle( handle_t h, unsigned uuId, const char* title ) +{ + rc_t rc = kOkRC; + ui_t* p = _handleToPtr(h); + + const char* mFmt = "{ \"op\":\"set\", \"type\":\"title\", \"uuId\":%i, \"value\":\"%s\" }"; + const int mbufN = 256; + char mbuf[mbufN]; + + if( snprintf(mbuf,mbufN,mFmt,uuId,title) >= mbufN-1 ) + return cwLogError(kBufTooSmallRC,"The msg buffer is too small."); + + rc = _websockSend(p,kInvalidId,mbuf); + + return rc; +} + + cw::rc_t cw::ui::setNumbRange( handle_t h, unsigned uuId, double minValue, double maxValue, double stepValue, unsigned decPl, double value ) { rc_t rc = kOkRC; diff --git a/cwUi.h b/cwUi.h index 3fd01f9..f1ba51a 100644 --- a/cwUi.h +++ b/cwUi.h @@ -125,8 +125,11 @@ namespace cw rc_t createProg( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title, double minValue, double maxValue ); rc_t createProg( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title, double minValue, double maxValue, double value ); rc_t createLog( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title ); - rc_t createList( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title ); + rc_t createVList( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title ); + rc_t createHList( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title ); + rc_t setTitle( handle_t h, unsigned uuId, const char* title ); + 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 ); @@ -155,6 +158,7 @@ namespace cw // (uuId must identify a list element whose parent is a 'uiList') rc_t setScrollTop( handle_t h, unsigned uuId ); + // setBlob() allocates internal memeory and copies the contents of blob[blobByeN] rc_t setBlob( handle_t h, unsigned uuId, const void* blob, unsigned blobByteN ); const void* getBlob( handle_t h, unsigned uuId, unsigned& blobByteN_Ref ); rc_t clearBlob( handle_t h, unsigned uuId );