From 1d0b583474a6355453050f5b5875f23460cdd318 Mon Sep 17 00:00:00 2001 From: kevin Date: Tue, 25 Mar 2025 18:15:38 -0400 Subject: [PATCH] cwUi.cpp,cwUiDecl.cpp,ui.cfg,main.cpp : Added log GUI interface. --- src/caw/cawUi.cpp | 8 +++++--- src/caw/cawUiDecl.h | 2 ++ src/caw/html/ui.cfg | 4 ++++ src/caw/main.cpp | 26 +++++++++++++++++++++++++- 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/caw/cawUi.cpp b/src/caw/cawUi.cpp index 1d6c82b..356345c 100644 --- a/src/caw/cawUi.cpp +++ b/src/caw/cawUi.cpp @@ -151,8 +151,6 @@ namespace caw { { rc_t rc = kOkRC; unsigned value_type_flag = ui_var->value_tid & flow::kTypeMask; - const object_t* cfg = nullptr; - const object_t* ui_cfg = nullptr; const char* widget_type_label = nullptr; idLabelPair_t typeA[] = { @@ -173,15 +171,19 @@ namespace caw { case flow::kStringTFl: widget_type_id_ref = kStringWidgetId; break; } + /* if( ui_var->ui_cfg == nullptr ) { rc = cwLogError(rc,"Error locating 'var' '%s' on proc desc.",cwStringNullGuard(ui_var->label)); goto errLabel; } else + */ + + if( ui_var->ui_cfg != nullptr ) { // get the type of this 'ui' widget - if((rc = ui_cfg->getv("type",widget_type_label)) != kOkRC ) + if((rc = ui_var->ui_cfg->getv("type",widget_type_label)) != kOkRC ) { rc = cwLogError(rc,"Error parsing variable 'ui' type cfg."); goto errLabel; diff --git a/src/caw/cawUiDecl.h b/src/caw/cawUiDecl.h index 9261fbd..75fb88f 100644 --- a/src/caw/cawUiDecl.h +++ b/src/caw/cawUiDecl.h @@ -18,6 +18,8 @@ namespace caw { kPgmLoadBtnId, kPgmPrintBtnId, kRunCheckId, + + kLogId, kRootNetPanelId, kNetListId, diff --git a/src/caw/html/ui.cfg b/src/caw/html/ui.cfg index c432a28..dbdbd76 100644 --- a/src/caw/html/ui.cfg +++ b/src/caw/html/ui.cfg @@ -27,6 +27,10 @@ name: rootNetPanelId, vlist: { name: netListId, addClassName: netList } } + }, + + row: { + log: { name: logId, title:"Log" } } } diff --git a/src/caw/main.cpp b/src/caw/main.cpp index 7b39bb2..25c9557 100644 --- a/src/caw/main.cpp +++ b/src/caw/main.cpp @@ -77,6 +77,8 @@ ui::appIdMap_t appIdMapA[] = { { kPanelDivId, kPgmPrintBtnId, "pgmPrintBtnId" }, { kPanelDivId, kRunCheckId, "runCheckId" }, + { kPanelDivId, kLogId, "logId" }, + { kPanelDivId, kRootNetPanelId, "rootNetPanelId" }, { kRootNetPanelId, kNetListId, "netListId" }, @@ -418,6 +420,10 @@ rc_t _ui_value_callback(app_t* app, const io::ui_msg_t& m ) _on_pgm_run(app,m.value->u.b); break; + case kLogId: + + break; + case kButtonWidgetId: _on_variable_value(app,m,m.value->u.b); break; @@ -767,6 +773,24 @@ void _test_stub( app_t& app ) } +void _log_output_func( void* arg, unsigned level, const char* text ) +{ + app_t* app = (app_t*)arg; + + if( app->ioH.isValid() && is_started_flag(app->ioH) ) + { + + unsigned logUuId = uiFindElementUuId( app->ioH, kLogId); + + uiSetLogLine( app->ioH, logUuId, text ); + } + else + { + log::defaultOutput(nullptr,level,text); + } +} + + int main( int argc, char* argv[] ) { rc_t rc = kOkRC; @@ -774,7 +798,7 @@ int main( int argc, char* argv[] ) app_t app = {}; // all zero app.pgm_preset_idx = kInvalidIdx; - cw::log::createGlobal(); + cw::log::createGlobal(log::kPrint_LogLevel,_log_output_func,&app); unsigned appIdMapN = sizeof(appIdMapA)/sizeof(appIdMapA[0]);