cwUi,cwIo,cwUiTest.cpp,html/uiTest/js/ui.js,html/uiTest/ui.cfg : Added 'string_disp' type.
This commit is contained in:
parent
ef4c937c6a
commit
babda9b32d
18
cwIo.cpp
18
cwIo.cpp
@ -2769,6 +2769,24 @@ cw::rc_t cw::io::uiCreateOption( handle_t h, unsigned& uuIdRef, unsigned par
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cw::rc_t cw::io::uiCreateStrDisplay( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title )
|
||||||
|
{
|
||||||
|
rc_t rc;
|
||||||
|
ui::handle_t uiH;
|
||||||
|
if((rc = _handleToUiHandle(h,uiH)) == kOkRC )
|
||||||
|
rc = ui::createStrDisplay(uiH,uuIdRef,parentUuId,eleName,appId,chanId,clas,title);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
cw::rc_t cw::io::uiCreateStrDisplay( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title, const char* value )
|
||||||
|
{
|
||||||
|
rc_t rc;
|
||||||
|
ui::handle_t uiH;
|
||||||
|
if((rc = _handleToUiHandle(h,uiH)) == kOkRC )
|
||||||
|
rc = ui::createStrDisplay(uiH,uuIdRef,parentUuId,eleName,appId,chanId,clas,title,value);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
cw::rc_t cw::io::uiCreateStr( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title )
|
cw::rc_t cw::io::uiCreateStr( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title )
|
||||||
{
|
{
|
||||||
rc_t rc;
|
rc_t rc;
|
||||||
|
3
cwIo.h
3
cwIo.h
@ -303,6 +303,9 @@ namespace cw
|
|||||||
|
|
||||||
rc_t uiCreateSelect( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title );
|
rc_t uiCreateSelect( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title );
|
||||||
rc_t uiCreateOption( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title );
|
rc_t uiCreateOption( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title );
|
||||||
|
|
||||||
|
rc_t uiCreateStrDisplay( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title );
|
||||||
|
rc_t uiCreateStrDisplay( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title, const char* value );
|
||||||
|
|
||||||
rc_t uiCreateStr( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title );
|
rc_t uiCreateStr( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title );
|
||||||
rc_t uiCreateStr( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title, const char* value );
|
rc_t uiCreateStr( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title, const char* value );
|
||||||
|
9
cwUi.cpp
9
cwUi.cpp
@ -39,6 +39,7 @@ namespace cw
|
|||||||
{ "check", false },
|
{ "check", false },
|
||||||
{ "select", false },
|
{ "select", false },
|
||||||
{ "option", false },
|
{ "option", false },
|
||||||
|
{ "str_disp", false },
|
||||||
{ "string", false },
|
{ "string", false },
|
||||||
{ "numb_disp", false },
|
{ "numb_disp", false },
|
||||||
{ "number", false },
|
{ "number", false },
|
||||||
@ -1254,7 +1255,7 @@ unsigned cw::ui::parentAndAppIdToUuId( handle_t h, unsigned parentAppId, unsigne
|
|||||||
for(unsigned i=0; i<p->eleN; ++i)
|
for(unsigned i=0; i<p->eleN; ++i)
|
||||||
if( p->eleA[i] != nullptr )
|
if( p->eleA[i] != nullptr )
|
||||||
if(((p->eleA[i]->phys_parent==nullptr && parentAppId==kRootAppId) ||
|
if(((p->eleA[i]->phys_parent==nullptr && parentAppId==kRootAppId) ||
|
||||||
(p->eleA[i]->logical_parent->appId==parentAppId))
|
(p->eleA[i]->logical_parent!=nullptr && p->eleA[i]->logical_parent->appId==parentAppId))
|
||||||
&& p->eleA[i]->appId == appId )
|
&& p->eleA[i]->appId == appId )
|
||||||
return p->eleA[i]->uuId;
|
return p->eleA[i]->uuId;
|
||||||
return kInvalidId;
|
return kInvalidId;
|
||||||
@ -1395,6 +1396,12 @@ cw::rc_t cw::ui::createSelect( handle_t h, unsigned& uuIdRef, unsigned parentUuI
|
|||||||
cw::rc_t cw::ui::createOption( 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::createOption( 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, "option", kInvalidId, parentUuId, eleName, appId, chanId, clas, title ); }
|
{ return _createOneEle( _handleToPtr(h), uuIdRef, "option", kInvalidId, parentUuId, eleName, appId, chanId, clas, title ); }
|
||||||
|
|
||||||
|
cw::rc_t cw::ui::createStrDisplay( 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, "str_disp", kInvalidId, parentUuId, eleName, appId, chanId, clas, title ); }
|
||||||
|
|
||||||
|
cw::rc_t cw::ui::createStrDisplay( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title, const char* value )
|
||||||
|
{ return _createOneEle( _handleToPtr(h), uuIdRef, "str_disp", kInvalidId, parentUuId, eleName, appId, chanId, clas, title, "value", value ); }
|
||||||
|
|
||||||
cw::rc_t cw::ui::createStr( 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::createStr( 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, "string", kInvalidId, parentUuId, eleName, appId, chanId, clas, title ); }
|
{ return _createOneEle( _handleToPtr(h), uuIdRef, "string", kInvalidId, parentUuId, eleName, appId, chanId, clas, title ); }
|
||||||
|
|
||||||
|
2
cwUi.h
2
cwUi.h
@ -104,6 +104,8 @@ namespace cw
|
|||||||
|
|
||||||
rc_t createSelect( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title );
|
rc_t createSelect( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title );
|
||||||
rc_t createOption( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title );
|
rc_t createOption( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title );
|
||||||
|
rc_t createStrDisplay( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title );
|
||||||
|
rc_t createStrDisplay( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title, const char* value );
|
||||||
rc_t createStr( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title );
|
rc_t createStr( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title );
|
||||||
rc_t createStr( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title, const char* value );
|
rc_t createStr( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title, const char* value );
|
||||||
rc_t createNumbDisplay(handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title, unsigned decPl );
|
rc_t createNumbDisplay(handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title, unsigned decPl );
|
||||||
|
22
cwUiTest.cpp
22
cwUiTest.cpp
@ -70,7 +70,8 @@ namespace cw
|
|||||||
kOpt1Id,
|
kOpt1Id,
|
||||||
kOpt2Id,
|
kOpt2Id,
|
||||||
kOpt3Id,
|
kOpt3Id,
|
||||||
kListId
|
kListId,
|
||||||
|
kStatusId
|
||||||
};
|
};
|
||||||
|
|
||||||
rc_t uiTestCreateUi( ui_test_t* p, unsigned wsSessId=kInvalidId )
|
rc_t uiTestCreateUi( ui_test_t* p, unsigned wsSessId=kInvalidId )
|
||||||
@ -251,10 +252,22 @@ namespace cw
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case kSelId:
|
case kSelId:
|
||||||
printf("sel: %i\n",v->u.i);
|
{
|
||||||
p->appSelId = v->u.i;
|
printf("sel: %i\n",v->u.i);
|
||||||
|
p->appSelId = v->u.i;
|
||||||
|
|
||||||
|
handle_t uiH = srv::uiHandle(p->wsUiSrvH);
|
||||||
|
unsigned uuId = parentAndAppIdToUuId( uiH, kPanelDivId, kStatusId );
|
||||||
|
const unsigned sN = 32;
|
||||||
|
char s[ sN ];
|
||||||
|
snprintf(s,sN,"sel:%i",v->u.i);
|
||||||
|
sendValueString( uiH, uuId, s );
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case kProgressId:
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
cwLogWarning("Unhandled value message: uuid:%i appId:%i\n",uuId,appId);
|
cwLogWarning("Unhandled value message: uuid:%i appId:%i\n",uuId,appId);
|
||||||
}
|
}
|
||||||
@ -383,7 +396,8 @@ cw::rc_t cw::ui::test( const object_t* cfg )
|
|||||||
{ kSelId, kOpt2Id, "myOpt2" },
|
{ kSelId, kOpt2Id, "myOpt2" },
|
||||||
{ kSelId, kOpt3Id, "myOpt3" },
|
{ kSelId, kOpt3Id, "myOpt3" },
|
||||||
{ kPanelDivId, kUiRptBtnId, "uiRptBtnId" },
|
{ kPanelDivId, kUiRptBtnId, "uiRptBtnId" },
|
||||||
{ kPanelDivId, kListId, "myListId" }
|
{ kPanelDivId, kListId, "myListId" },
|
||||||
|
{ kPanelDivId, kStatusId, "status" }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -244,6 +244,13 @@ function ui_send_click( ele )
|
|||||||
ws_send("click " + ele.id )
|
ws_send("click " + ele.id )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ui_send_select( ele, selectedFl )
|
||||||
|
{
|
||||||
|
let selected_value = selectedFl ? 1 : 0;
|
||||||
|
ws_send("select " + ele.id + " " + selected_value )
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function ui_send_echo( ele )
|
function ui_send_echo( ele )
|
||||||
{
|
{
|
||||||
@ -524,6 +531,37 @@ function _ui_on_focus( ele )
|
|||||||
_focusVal = ele.value;
|
_focusVal = ele.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function ui_set_str_display( ele_id, value )
|
||||||
|
{
|
||||||
|
|
||||||
|
var ele = dom_id_to_ele(ele_id);
|
||||||
|
|
||||||
|
if( typeof(value)=="string")
|
||||||
|
{
|
||||||
|
ele.innerHTML = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function ui_create_str_display( parent_ele, d )
|
||||||
|
{
|
||||||
|
var ele = ui_create_ctl( parent_ele, "label", d.title, d, "uiStringDisp" );
|
||||||
|
|
||||||
|
if( ele != null )
|
||||||
|
{
|
||||||
|
if( d.hasOwnProperty('value') )
|
||||||
|
{
|
||||||
|
ui_set_str_display(ele.id, d.value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ui_send_echo(ele);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ele;
|
||||||
|
}
|
||||||
|
|
||||||
function _ui_on_string_blur( ele )
|
function _ui_on_string_blur( ele )
|
||||||
{
|
{
|
||||||
if( ele.id == _focusId )
|
if( ele.id == _focusId )
|
||||||
@ -843,6 +881,10 @@ function ui_set_value( d )
|
|||||||
case "option":
|
case "option":
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "str_disp":
|
||||||
|
ui_set_str_display(ele.id,d.value);
|
||||||
|
break
|
||||||
|
|
||||||
case "string":
|
case "string":
|
||||||
ele.value = d.value
|
ele.value = d.value
|
||||||
break;
|
break;
|
||||||
@ -888,7 +930,8 @@ function _ui_modify_class( ele, classLabelArg, enableFl )
|
|||||||
|
|
||||||
function ui_set_select( ele, enableFl )
|
function ui_set_select( ele, enableFl )
|
||||||
{
|
{
|
||||||
_ui_modify_class("uiSelected")
|
_ui_modify_class(ele,"uiSelected",enableFl)
|
||||||
|
ui_send_select( ele, enableFl )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -927,6 +970,28 @@ function ui_set_enable( ele, enableFl )
|
|||||||
ele.disabled = !enableFl
|
ele.disabled = !enableFl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ui_set_order_key(ele, orderKey)
|
||||||
|
{
|
||||||
|
let parent = ele.parentElement // get the parent of the element to reorder
|
||||||
|
ele = parent.removeChild( ele ) // remove the element to reorder from the parent list
|
||||||
|
|
||||||
|
ele.order = orderKey
|
||||||
|
|
||||||
|
let i = 0;
|
||||||
|
for(i=0; i<parent.children.length; ++i)
|
||||||
|
{
|
||||||
|
if( parent.children[i].hasOwnProperty("order") && parent.children[i].order >= orderKey)
|
||||||
|
{
|
||||||
|
parent.insertBefore( ele, parent.children[i] )
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// no element was found greater than this element ....
|
||||||
|
if( i == parent.children.length )
|
||||||
|
parent.appendChild(ele) // ... insert the element at the end of the child lsit
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function ui_set( d )
|
function ui_set( d )
|
||||||
{
|
{
|
||||||
@ -949,19 +1014,23 @@ function ui_set( d )
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "select":
|
case "select":
|
||||||
ui_set_select(ele,d.enableFl)
|
ui_set_select(ele,d.value)
|
||||||
break
|
break
|
||||||
|
|
||||||
case "clickable":
|
case "clickable":
|
||||||
ui_set_clickable(ele,d.enableFl)
|
ui_set_clickable(ele,d.value)
|
||||||
break
|
break
|
||||||
|
|
||||||
case "visible":
|
case "visible":
|
||||||
ui_set_visible(ele,d.enableFl)
|
ui_set_visible(ele,d.value)
|
||||||
break
|
break
|
||||||
|
|
||||||
case "enable":
|
case "enable":
|
||||||
ui_set_enable(ele,d.enableFl)
|
ui_set_enable(ele,d.value)
|
||||||
|
break
|
||||||
|
|
||||||
|
case "order":
|
||||||
|
ui_set_order_key(ele,d.value)
|
||||||
break
|
break
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1020,6 +1089,10 @@ function ui_create( d )
|
|||||||
ele = ui_create_option( parent_ele, d );
|
ele = ui_create_option( parent_ele, d );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "str_disp":
|
||||||
|
ele = ui_create_str_display( parent_ele, d );
|
||||||
|
break;
|
||||||
|
|
||||||
case "string":
|
case "string":
|
||||||
ele = ui_create_string( parent_ele, d );
|
ele = ui_create_string( parent_ele, d );
|
||||||
break;
|
break;
|
||||||
@ -1060,6 +1133,16 @@ function ui_create( d )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ui_destroy( d )
|
||||||
|
{
|
||||||
|
if( typeof(d.uuId) == "number" )
|
||||||
|
d.uuId = d.uuId.toString()
|
||||||
|
|
||||||
|
var ele = dom_id_to_ele(d.uuId)
|
||||||
|
|
||||||
|
if( ele != null )
|
||||||
|
ele.parentElement.removeChild( ele )
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1082,6 +1165,10 @@ function ws_on_msg( jsonMsg )
|
|||||||
ui_create( d )
|
ui_create( d )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'destroy':
|
||||||
|
ui_destroy( d )
|
||||||
|
break
|
||||||
|
|
||||||
case 'value':
|
case 'value':
|
||||||
ui_set_value( d )
|
ui_set_value( d )
|
||||||
break;
|
break;
|
||||||
|
@ -35,8 +35,11 @@
|
|||||||
|
|
||||||
|
|
||||||
row: {
|
row: {
|
||||||
list:{ name: myListId, title:"My List", clickable: 1 },
|
list: { name: myListId, title:"My List", clickable: 1 },
|
||||||
},
|
},
|
||||||
|
row: {
|
||||||
|
str_disp: { name: status, title:"Status", value:"Set w/ 'Select'." }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user