cmUi.h/c : Added cmUiListEleLabelToIndex() and shell for cmUiSelectPanel().

This commit is contained in:
kevin 2014-02-06 22:47:03 -08:00
parent 4b59da2947
commit 02f9bceaac
2 changed files with 41 additions and 2 deletions

38
cmUi.c
View File

@ -618,7 +618,7 @@ cmUiRC_t _cmUiCreateCtl( cmUi_t* p, unsigned appId, unsigned panelId, cmUiCId_t
else
{
if( cmArrayIsValid(ap->ctlArrH) == false || usrId >= cmArrayCount(ap->ctlArrH) )
ctl = cmArrayClr(cmUiCtl_t,ap->ctlArrH,usrId);
ctl = cmArrayClr(cmUiCtl_t,ap->ctlArrH,usrId);
else
{
ctl = cmArrayPtr(cmUiCtl_t,ap->ctlArrH,usrId);
@ -1501,6 +1501,19 @@ cmUiRC_t cmUiClearPanel( cmUiH_t uiH, unsigned appId, unsigned panelId )
return rc;
}
cmUiRC_t cmUiSelectPanel( cmUiH_t uiH, const cmChar_t* label )
{
cmUiRC_t rc = kOkUiRC;
cmUi_t* p = _cmUiHandleToPtr(uiH);
return rc;
}
cmUiRC_t cmUiNextRect( cmUiH_t uiH, unsigned appId, unsigned panelId, int x, int y, int w, int h )
{
cmUi_t* p = _cmUiHandleToPtr(uiH);
@ -2095,6 +2108,29 @@ const cmChar_t* cmUiListEleLabel( cmUiH_t uiH, unsigned appId, unsigned id, unsi
return cmArrayPtr(cmUiListEle_t, ctl->idArrH, index )->label;
}
unsigned cmUiListEleLabelToIndex( cmUiH_t uiH, unsigned appId, unsigned id, const cmChar_t* label )
{
cmUi_t* p = _cmUiHandleToPtr(uiH);
cmUiCtl_t* ctl;
cmUiRC_t rc;
unsigned i,n;
if( label == NULL )
return cmInvalidIdx;
if((rc = _cmUiFastFindCtl(p,appId,id,&ctl,true)) != kOkUiRC )
return cmInvalidIdx;
if( cmArrayIsValid( ctl->idArrH )==false || (n = cmArrayCount( ctl->idArrH))==0 )
return cmInvalidIdx;
for(i=0; i<n; ++i)
if( cmTextCmp(cmArrayPtr(cmUiListEle_t, ctl->idArrH, i )->label,label) == 0 )
return i;
return cmInvalidIdx;
}
cmUiRC_t cmUiLastRC( cmUiH_t uiH )

5
cmUi.h
View File

@ -88,7 +88,7 @@ extern "C" {
4) Come up with a threading model. For example maybe
control creation should use a blocking scheme since it is
generally to time consuming to do during real-time operation
generally too time consuming to do during real-time operation
anyway. If the control flow generated from driver event
callbacks then allows value, but not structural changes,
then non blocking will be necessary.
@ -247,6 +247,8 @@ extern "C" {
// Destroy all the controls in a panel.
cmUiRC_t cmUiClearPanel( cmUiH_t uiH, unsigned appId, unsigned panelId );
cmUiRC_t cmUiSelectPanel( cmUiH_t uiH, const cmChar_t* label );
//------------------------------------------------------------------------------------------
// Location:
@ -376,6 +378,7 @@ extern "C" {
unsigned cmUiListEleCount( cmUiH_t uiH, unsigned appId, unsigned id );
unsigned cmUiListEleId( cmUiH_t uiH, unsigned appId, unsigned id, unsigned index );
const cmChar_t* cmUiListEleLabel( cmUiH_t uiH, unsigned appId, unsigned id, unsigned index );
unsigned cmUiListEleLabelToIndex( cmUiH_t uiH, unsigned appId, unsigned id, const cmChar_t* label );
// Query/set the current error state.
cmUiRC_t cmUiLastRC( cmUiH_t uiH );