cmUi.h/c: Base row/col now have both set and get accessors. Added cmUiNewline().

This commit is contained in:
kevin 2013-03-31 22:16:54 -07:00
parent 43678d3c38
commit 3491613a50
2 changed files with 380 additions and 249 deletions

592
cmUi.c
View File

@ -36,23 +36,26 @@ typedef struct cmUiApp_str
cmArrayH_t pnlArrH; // cmUiPanel_t[] cmArrayH_t pnlArrH; // cmUiPanel_t[]
} cmUiApp_t; } cmUiApp_t;
struct cmUiCtl_str;
typedef struct cmUiPanel_str typedef struct cmUiPanel_str
{ {
cmUiApp_t* appPtr; // owner app. cmUiApp_t* appPtr; // owner app.
unsigned flags; // See kXXXUiFl above struct cmUiCtl_str* ctl; // control recd assoc'd with this panel
unsigned usrId; // app. supplied id unsigned flags; // See kXXXUiFl above
cmUiRect_t rect; // rect to position next control (only used if kUseRectUiFl is set) unsigned usrId; // app. supplied id
cmUiRect_t prevRect; cmUiRect_t rect; // rect to position next control (only used if kUseRectUiFl is set)
int baseCol; cmUiRect_t prevRect;
int baseRow; int baseCol;
int dfltW; int baseRow;
int dfltH; int dfltW;
int nextW; int dfltH;
int nextH; int nextW;
int dfltHBorder; int nextH;
int dfltVBorder; int dfltHBorder;
int nextHBorder; int dfltVBorder;
int nextVBorder; int nextHBorder;
int nextVBorder;
} cmUiPanel_t; } cmUiPanel_t;
@ -63,7 +66,8 @@ typedef struct cmUiCtl_str
unsigned usrId; // control instance id and index into cmUiApp_t.ctlArrH[]. unsigned usrId; // control instance id and index into cmUiApp_t.ctlArrH[].
unsigned panelId; // panel this ctl belongs to unsigned panelId; // panel this ctl belongs to
cmArrayH_t idArrH; // id's associated with each sub-element of this control (used by menu's, list's, etc...) cmArrayH_t idArrH; // id's associated with each sub-element of this control (used by menu's, list's, etc...)
cmUiDriverArg_t arg; // cached callback arg for this control
// current value of this control // current value of this control
union union
{ {
@ -96,6 +100,7 @@ typedef struct
cmUiDriverFunc_t cbFunc; // Client callback function cmUiDriverFunc_t cbFunc; // Client callback function
void * cbArg; // void * cbArg; //
cmArrayH_t appArrH; // cmUiApp_t[] cmArrayH_t appArrH; // cmUiApp_t[]
cmUiCtl_t dummy; // dummy recd used to create controls which will never be accessed after creation (like read-only labels)
} cmUi_t; } cmUi_t;
cmUiH_t cmUiNullHandle = cmSTATIC_NULL_HANDLE; cmUiH_t cmUiNullHandle = cmSTATIC_NULL_HANDLE;
@ -107,25 +112,6 @@ cmUi_t* _cmUiHandleToPtr( cmUiH_t h )
return p; return p;
} }
void _cmUiDriverArgInit( cmUiDriverArg_t* a, cmUi_t* p, cmUiDId_t dId, cmUiCId_t cId, unsigned panelId, unsigned usrId )
{
memset(a,0,sizeof(*a));
a->cbArg = p->drvrArg;
a->dId = dId;
a->cId = cId;
a->appId = p->curAppId;
a->panelId = panelId;
a->usrId = usrId;
a->flags = 0;
a->x = -1;
a->y = -1;
a->w = -1;
a->h = -1;
a->ival = 0;
a->fval = 0;
a->sval = NULL;
}
//--------------------------------------------------------------- //---------------------------------------------------------------
// int accessors // int accessors
@ -222,6 +208,57 @@ void _cmUiSetStrAccessors( cmUiCtl_t* ctl )
ctl->setStr = _cmUiSetStrFromStr; ctl->setStr = _cmUiSetStrFromStr;
} }
//---------------------------------------------------------------
cmUiRC_t _cmUiCallDriver( cmUi_t* p, cmUiDId_t dId, cmUiCtl_t* ctl )
{
cmUiRC_t rc = kOkUiRC;
if( p->drvr != NULL )
{
ctl->arg.dId = dId;
if((rc = p->drvr(p->drvrArg,&ctl->arg)) != kOkUiRC )
rc = cmErrMsg(&p->err,kDrvrErrUiRC,"UI manager driver error.");
}
return rc;
}
cmUiRC_t _cmUiSetDriverValue( cmUi_t* p, cmUiCtl_t* ctl, unsigned flag )
{
unsigned orgFlags = ctl->arg.flags;
ctl->arg.flags |= flag;
cmUiRC_t rc = _cmUiCallDriver(p,kSetValDId,ctl);
ctl->arg.flags = orgFlags;
return rc;
}
cmUiRC_t _cmUiSetDriverValueInt( cmUi_t* p, cmUiCtl_t* ctl, unsigned flag, int value )
{
ctl->arg.ival = value;
return _cmUiSetDriverValue(p,ctl,flag);
}
cmUiRC_t _cmUiSetDriverValueDouble( cmUi_t* p, cmUiCtl_t* ctl, unsigned flag, double value )
{
ctl->arg.fval = value;
return _cmUiSetDriverValue(p,ctl,flag);
}
cmUiRC_t _cmUiSetDriverValueStr( cmUi_t* p, cmUiCtl_t* ctl, unsigned flag, const cmChar_t* value )
{
ctl->arg.sval = value;
return _cmUiSetDriverValue(p,ctl,flag);
}
cmUiRC_t _cmUiSetDriverValueIntAndStr( cmUi_t* p, cmUiCtl_t* ctl, unsigned flag, int ival, const cmChar_t* sval )
{
ctl->arg.ival = ival;
ctl->arg.sval = sval;
return _cmUiSetDriverValue(p,ctl,flag);
}
//--------------------------------------------------------------- //---------------------------------------------------------------
cmUiRC_t _cmUiFindApp( cmUi_t* p, unsigned appId, cmUiApp_t** appRef, bool errFl ) cmUiRC_t _cmUiFindApp( cmUi_t* p, unsigned appId, cmUiApp_t** appRef, bool errFl )
@ -333,29 +370,13 @@ cmUiRC_t _cmUiFindPanel( cmUi_t* p, unsigned panelId, cmUiPanel_t** ppRef, bool
return rc; return rc;
} }
cmUiRC_t _cmUiCallDriver( cmUi_t* p, cmUiDriverArg_t* a ) //---------------------------------------------------------------
{
cmUiRC_t rc = kOkUiRC;
if( p->drvr != NULL )
if((rc = p->drvr(a)) != kOkUiRC )
rc = cmErrMsg(&p->err,kDrvrErrUiRC,"UI manager driver error.");
return rc;
}
cmUiRC_t _cmUiDestroyDrvrCtl( cmUi_t* p, cmUiCId_t cId, unsigned panelId, unsigned usrId )
{
cmUiDriverArg_t a;
_cmUiDriverArgInit(&a, p, kDestroyCtlDId, cId, panelId, usrId );
return _cmUiCallDriver(p,&a);
}
cmUiRC_t _cmUiDestroyCtl( cmUi_t* p, cmUiCtl_t* ctl ) cmUiRC_t _cmUiDestroyCtl( cmUi_t* p, cmUiCtl_t* ctl )
{ {
cmUiRC_t rc = kOkUiRC; cmUiRC_t rc = kOkUiRC;
rc =_cmUiDestroyDrvrCtl(p,ctl->cId,ctl->panelId,ctl->usrId); rc = _cmUiCallDriver(p,kDestroyCtlDId,ctl);
switch(ctl->cId) switch(ctl->cId)
{ {
@ -370,6 +391,7 @@ cmUiRC_t _cmUiDestroyCtl( cmUi_t* p, cmUiCtl_t* ctl )
break; break;
} }
ctl->cId = kInvalidUiCId;
ctl->usrId = cmInvalidId; ctl->usrId = cmInvalidId;
ctl->panelId = cmInvalidId; ctl->panelId = cmInvalidId;
cmArrayRelease(&ctl->idArrH); cmArrayRelease(&ctl->idArrH);
@ -389,7 +411,7 @@ cmUiRC_t _cmUiDestroyPanel( cmUi_t* p, unsigned panelId )
cmUiApp_t* ap = pp->appPtr; cmUiApp_t* ap = pp->appPtr;
// notify the driver to destroy the panel // notify the driver to destroy the panel
if((rc = _cmUiDestroyDrvrCtl(p,kPanelUiCId,panelId,panelId)) != kOkUiRC ) if((rc = _cmUiCallDriver(p,kDestroyCtlDId,pp->ctl)) != kOkUiRC )
return rc; return rc;
cmUiCtl_t* ctl = NULL; cmUiCtl_t* ctl = NULL;
@ -472,6 +494,7 @@ cmUiRC_t _cmUiDestroyAllApps( cmUi_t* p )
return rc; return rc;
} }
//---------------------------------------------------------------
cmUiRC_t _cmUiGetCtlXYWH( cmUi_t* p, cmUiDriverArg_t* a, cmUiPanel_t* pp ) cmUiRC_t _cmUiGetCtlXYWH( cmUi_t* p, cmUiDriverArg_t* a, cmUiPanel_t* pp )
{ {
@ -545,7 +568,7 @@ cmUiRC_t _cmUiGetCtlXYWH( cmUi_t* p, cmUiDriverArg_t* a, cmUiPanel_t* pp )
} }
cmUiRC_t _cmUiCreateCtl( cmUi_t* p, cmUiDriverArg_t* a, unsigned panelId, cmUiCId_t cId, unsigned usrId, const cmChar_t* label, unsigned flags, cmUiCtl_t** ctlRef ) cmUiRC_t _cmUiCreateCtl( cmUi_t* p, unsigned panelId, cmUiCId_t cId, unsigned usrId, const cmChar_t* label, unsigned flags, cmUiCtl_t** ctlRef )
{ {
cmUiRC_t rc; cmUiRC_t rc;
cmUiPanel_t* pp = NULL; cmUiPanel_t* pp = NULL;
@ -554,9 +577,6 @@ cmUiRC_t _cmUiCreateCtl( cmUi_t* p, cmUiDriverArg_t* a, unsigned panelId, cmUiCI
if( ctlRef != NULL ) if( ctlRef != NULL )
*ctlRef = NULL; *ctlRef = NULL;
// initialize the driver arg record
_cmUiDriverArgInit(a, p, kCreateCtlDId, cId, panelId, usrId );
// locate the app // locate the app
if((rc = _cmUiFindApp(p,p->curAppId,&ap,true)) != kOkUiRC ) if((rc = _cmUiFindApp(p,p->curAppId,&ap,true)) != kOkUiRC )
return rc; return rc;
@ -565,28 +585,50 @@ cmUiRC_t _cmUiCreateCtl( cmUi_t* p, cmUiDriverArg_t* a, unsigned panelId, cmUiCI
if((rc = _cmUiFindPanel(p,panelId,&pp,true)) != kOkUiRC ) if((rc = _cmUiFindPanel(p,panelId,&pp,true)) != kOkUiRC )
return rc; return rc;
// calc the control location - for non-panel controls or // get the new ctl record
// for panel controls using the custom 'next rect'. cmUiCtl_t* ctl;
if( cId != kPanelUiCId || cmIsFlag(pp->flags,kUseRectUiFl ) ) if( usrId == cmInvalidId )
if((rc = _cmUiGetCtlXYWH(p,a,pp)) != kOkUiRC ) {
ctl = &p->dummy;
memset(ctl,0,sizeof(*ctl));
}
else
{
if( cmArrayIsValid(ap->ctlArrH)==false || usrId >= cmArrayCount(ap->ctlArrH) )
ctl = cmArrayClr(cmUiCtl_t,ap->ctlArrH,usrId);
else
{
ctl = cmArrayPtr(cmUiCtl_t,ap->ctlArrH,usrId);
// if the ctl recd is already in use
if( ctl->cId != kInvalidUiCId )
_cmUiDestroyCtl(p,ctl);
}
}
// setup this controls cached callback arg record
cmUiDriverArgSetup(&ctl->arg,kInvalidDId,ap->appId,usrId,panelId,cId,flags,0,0,label,-1,-1,-1,-1);
// calc the control location - for non-panel controls
if( cId != kPanelUiCId )
if((rc = _cmUiGetCtlXYWH(p,&ctl->arg,pp)) != kOkUiRC )
return rc; return rc;
// get the new ctl record
cmUiCtl_t* ctl = cmArrayClr(cmUiCtl_t,ap->ctlArrH,usrId);
// setup the new ctl record // setup the new ctl record
ctl->cId = cId; ctl->cId = cId;
ctl->usrId = usrId; ctl->usrId = usrId;
ctl->panelId = panelId; ctl->panelId = panelId;
cmArrayAlloc(p->ctx,&ctl->idArrH,sizeof(unsigned));
// display-only controls don't need an id array
if( usrId != cmInvalidId )
cmArrayAlloc(p->ctx,&ctl->idArrH,sizeof(unsigned));
a->sval = label;
a->flags = flags;
if( ctlRef != NULL ) if( ctlRef != NULL )
*ctlRef = ctl; *ctlRef = ctl;
return _cmUiCallDriver(p,a); return _cmUiCallDriver(p,kCreateCtlDId,ctl);
} }
@ -727,77 +769,76 @@ unsigned cmUiAppCount( cmUiH_t h )
cmUiRC_t cmUiOnDriverEvent( cmUiH_t h, const cmUiDriverArg_t* arg ) cmUiRC_t cmUiOnDriverEvent( cmUiH_t h, const cmUiDriverArg_t* arg )
{ {
cmUiRC_t rc = kOkUiRC; cmUiRC_t rc = kOkUiRC;
cmUi_t* p = _cmUiHandleToPtr(h); cmUi_t* p = _cmUiHandleToPtr(h);
cmUiDriverArg_t a = *arg;
cmUiCtl_t* ctl; cmUiCtl_t* ctl;
if((rc = cmUiSetAppId(h,arg->appId)) != kOkUiRC ) if((rc = cmUiSetAppId(h,arg->appId)) != kOkUiRC )
return rc; return rc;
a.cbArg = p->cbArg; if((rc = _cmUiFindCtl(p,arg->usrId,&ctl,true)) != kOkUiRC )
if((rc = _cmUiFindCtl(p,a.usrId,&ctl,true)) != kOkUiRC )
goto errLabel; goto errLabel;
switch( a.cId ) switch( arg->cId )
{ {
case kInvalidUiCId: break; case kInvalidUiCId:
case kPanelUiCId: break; break;
case kBtnUiCId: break;
case kPanelUiCId:
case kBtnUiCId:
case kCheckUiCId: case kCheckUiCId:
ctl->u.ival = a.ival; ctl->arg.ival = ctl->u.ival = cmUiDriverArgGetInt(arg);
break; break;
case kMenuBtnUiCId: case kMenuBtnUiCId:
case kListUiCId: case kListUiCId:
{ {
ctl->u.ival = a.ival; unsigned eleIdx = cmUiDriverArgGetInt(arg);
if(a.ival >= cmArrayCount(ctl->idArrH))
if(eleIdx >= cmArrayCount(ctl->idArrH))
{ {
rc = cmErrMsg(&p->err,kInvalidIdUiRC,"Invalid menu or list driver element id=%i element count:%i.",a.ival,cmArrayCount(ctl->idArrH)); rc = cmErrMsg(&p->err,kInvalidIdUiRC,"Invalid menu or list driver element id=%i element count:%i.",eleIdx,cmArrayCount(ctl->idArrH));
goto errLabel; goto errLabel;
} }
a.ival = cmArrayEle(unsigned,ctl->idArrH,a.ival); // convert the selected items index to the associated client id value
//a.ival = ctl->id_arr[ a.ival ]; ctl->arg.ival = ctl->u.ival = cmArrayEle(unsigned,ctl->idArrH,eleIdx);
} }
break; break;
case kLabelUiCId: case kLabelUiCId:
ctl->u.sval = cmMemResizeStr(ctl->u.sval,cmStringNullGuard(a.sval)); case kTextUiCId:
break; case kFilenameUiCId:
case kDirUiCId:
case kTextUiCId: {
ctl->u.sval = cmMemResizeStr(ctl->u.sval,cmStringNullGuard(a.sval)); const cmChar_t* s;
if((s = cmUiDriverArgGetString(arg)) != NULL )
ctl->arg.sval = ctl->u.sval = cmMemResizeStr(ctl->u.sval,s);
}
break; break;
case kSliderUiCId: case kSliderUiCId:
case kNumberUiCId: case kNumberUiCId:
ctl->u.fval = a.fval; ctl->arg.fval = ctl->u.fval = cmUiDriverArgGetDouble(arg);
a.cId = kNumberUiCId; // sliders callback the client as numbers
break; break;
case kProgressUiCId: case kProgressUiCId:
ctl->u.ival = a.ival;
break;
case kMeterUiCId: case kMeterUiCId:
ctl->u.fval = a.fval; assert(0); // progress and meters are display only
break; break;
case kFilenameUiCId: case kMaxUiCId:
ctl->u.sval = cmMemResizeStr(ctl->u.sval,cmStringNullGuard(a.sval)); assert(0);
break; break;
case kDirUiCId:
ctl->u.sval = cmMemResizeStr(ctl->u.sval,cmStringNullGuard(a.sval));
break;
} }
rc = p->cbFunc(&a); ctl->arg.dId = kSetValDId;
rc = p->cbFunc(p->cbArg,&ctl->arg);
errLabel: errLabel:
cmUiSetAppId(h,cmInvalidId); cmUiSetAppId(h,cmInvalidId);
@ -808,7 +849,6 @@ cmUiRC_t cmUiOnDriverEvent( cmUiH_t h, const cmUiDriverArg_t* arg )
cmUiRC_t cmUiCreatePanel( cmUiH_t uiH, unsigned newPanelId, const cmChar_t* label ) cmUiRC_t cmUiCreatePanel( cmUiH_t uiH, unsigned newPanelId, const cmChar_t* label )
{ {
cmUiRC_t rc; cmUiRC_t rc;
cmUiDriverArg_t a;
cmUi_t* p = _cmUiHandleToPtr(uiH); cmUi_t* p = _cmUiHandleToPtr(uiH);
cmUiCtl_t* ctl = NULL; cmUiCtl_t* ctl = NULL;
cmUiApp_t* ap = NULL; cmUiApp_t* ap = NULL;
@ -820,6 +860,7 @@ cmUiRC_t cmUiCreatePanel( cmUiH_t uiH, unsigned newPanelId, const cmChar_t* la
assert( pp != NULL ); assert( pp != NULL );
pp->appPtr = ap; pp->appPtr = ap;
pp->ctl = NULL;
pp->usrId = newPanelId; pp->usrId = newPanelId;
pp->baseCol = 2; pp->baseCol = 2;
pp->baseRow = 0; pp->baseRow = 0;
@ -837,7 +878,7 @@ cmUiRC_t cmUiCreatePanel( cmUiH_t uiH, unsigned newPanelId, const cmChar_t* la
pp->prevRect.h = -1; pp->prevRect.h = -1;
if((rc = _cmUiCreateCtl(p, &a, newPanelId, kPanelUiCId, newPanelId, label, 0, NULL )) != kOkUiRC ) if((rc = _cmUiCreateCtl(p, newPanelId, kPanelUiCId, newPanelId, label, 0, &pp->ctl )) != kOkUiRC )
{ {
// TODO - destroy panel record here // TODO - destroy panel record here
return rc; return rc;
@ -855,10 +896,9 @@ cmUiRC_t cmUiCreateBtn( cmUiH_t uiH, unsigned panelId, unsigned id, const cm
{ {
cmUiRC_t rc; cmUiRC_t rc;
cmUi_t* p = _cmUiHandleToPtr(uiH); cmUi_t* p = _cmUiHandleToPtr(uiH);
cmUiDriverArg_t a;
cmUiCtl_t* c; cmUiCtl_t* c;
if((rc = _cmUiCreateCtl(p,&a,panelId,kBtnUiCId,id,label,flags,&c)) == kOkUiRC ) if((rc = _cmUiCreateCtl(p,panelId,kBtnUiCId,id,label,flags,&c)) == kOkUiRC )
{ {
_cmUiSetIntAccessors(c); _cmUiSetIntAccessors(c);
} }
@ -869,12 +909,14 @@ cmUiRC_t cmUiCreateCheck( cmUiH_t uiH, unsigned panelId, unsigned id, const cm
{ {
cmUiRC_t rc; cmUiRC_t rc;
cmUi_t* p = _cmUiHandleToPtr(uiH); cmUi_t* p = _cmUiHandleToPtr(uiH);
cmUiDriverArg_t a;
cmUiCtl_t* c; cmUiCtl_t* c;
a.ival = dflt; if((rc = _cmUiCreateCtl(p,panelId,kCheckUiCId,id,label,flags,&c)) == kOkUiRC )
if((rc = _cmUiCreateCtl(p,&a,panelId,kCheckUiCId,id,label,flags,&c)) == kOkUiRC ) {
_cmUiSetIntAccessors(c); _cmUiSetIntAccessors(c);
rc = _cmUiSetDriverValueInt(p,c,kValUiFl,dflt);
}
return rc; return rc;
} }
@ -882,10 +924,9 @@ cmUiRC_t cmUiCreateLabel( cmUiH_t uiH, unsigned panelId, unsigned id, const cm
{ {
cmUiRC_t rc; cmUiRC_t rc;
cmUi_t* p = _cmUiHandleToPtr(uiH); cmUi_t* p = _cmUiHandleToPtr(uiH);
cmUiDriverArg_t a;
cmUiCtl_t* c; cmUiCtl_t* c;
if((rc = _cmUiCreateCtl(p,&a,panelId,kLabelUiCId,id,label,flags,&c)) == kOkUiRC ) if((rc = _cmUiCreateCtl(p,panelId,kLabelUiCId,id,label,flags,&c)) == kOkUiRC )
_cmUiSetStrAccessors(c); _cmUiSetStrAccessors(c);
return rc; return rc;
} }
@ -894,17 +935,13 @@ cmUiRC_t cmUiCreateText( cmUiH_t uiH, unsigned panelId, unsigned id, const cm
{ {
cmUiRC_t rc = kOkUiRC; cmUiRC_t rc = kOkUiRC;
cmUi_t* p = _cmUiHandleToPtr(uiH); cmUi_t* p = _cmUiHandleToPtr(uiH);
cmUiDriverArg_t a;
cmUiCtl_t* c; cmUiCtl_t* c;
if(( rc = _cmUiCreateCtl(p,&a,panelId,kTextUiCId,id,label,flags,&c)) == kOkUiRC ) if(( rc = _cmUiCreateCtl(p,panelId,kTextUiCId,id,label,flags,&c)) == kOkUiRC )
{ {
_cmUiSetStrAccessors(c); _cmUiSetStrAccessors(c);
a.dId = kSetValDId; rc = _cmUiSetDriverValueStr(p,c,kValUiFl,text);
a.flags = kValUiFl;
a.sval = text;
rc = _cmUiCallDriver(p,&a);
} }
return rc; return rc;
@ -914,7 +951,6 @@ cmUiRC_t _cmUiCreateNumber( cmUiH_t uiH, unsigned panelId, unsigned id, const c
{ {
cmUiRC_t rc = kOkUiRC; cmUiRC_t rc = kOkUiRC;
cmUi_t* p = _cmUiHandleToPtr(uiH); cmUi_t* p = _cmUiHandleToPtr(uiH);
cmUiDriverArg_t a;
cmUiCId_t cid = kNumberUiCId; cmUiCId_t cid = kNumberUiCId;
cmUiCtl_t* c; cmUiCtl_t* c;
cmUiPanel_t* pp; cmUiPanel_t* pp;
@ -935,31 +971,22 @@ cmUiRC_t _cmUiCreateNumber( cmUiH_t uiH, unsigned panelId, unsigned id, const c
cid = kSliderUiCId; cid = kSliderUiCId;
} }
if(( rc = _cmUiCreateCtl(p,&a,panelId,cid,id,label,flags,&c)) == kOkUiRC ) if(( rc = _cmUiCreateCtl(p,panelId,cid,id,label,flags,&c)) == kOkUiRC )
{ {
cmUiRC_t rc0; cmUiRC_t rc0;
_cmUiSetDblAccessors(c); _cmUiSetDblAccessors(c);
a.dId = kSetValDId; if((rc0 = _cmUiSetDriverValueDouble(p,c,kMinUiFl,min)) != kOkUiRC )
a.flags = kMinUiFl;
a.fval = min;
if((rc0 = _cmUiCallDriver(p,&a)) != kOkUiRC )
rc = rc0; rc = rc0;
a.flags = kMaxUiFl; if((rc0 = _cmUiSetDriverValueDouble(p,c,kMaxUiFl,max)) != kOkUiRC )
a.fval = max;
if((rc0 = _cmUiCallDriver(p,&a)) != kOkUiRC )
rc = rc0; rc = rc0;
a.flags = kIncUiFl; if((rc0 = _cmUiSetDriverValueDouble(p,c,kIncUiFl,incr)) != kOkUiRC )
a.fval = incr;
if((rc0 = _cmUiCallDriver(p,&a)) != kOkUiRC )
rc = rc0; rc = rc0;
a.flags = kValUiFl; if((rc0 = _cmUiSetDriverValueDouble(p,c,kValUiFl,dflt)) != kOkUiRC )
a.fval = dflt;
if((rc0 = _cmUiCallDriver(p,&a)) != kOkUiRC )
rc = rc0; rc = rc0;
} }
@ -987,30 +1014,21 @@ cmUiRC_t cmUiCreateProgress(cmUiH_t uiH, unsigned panelId, unsigned id, const cm
{ {
cmUiRC_t rc = kOkUiRC; cmUiRC_t rc = kOkUiRC;
cmUi_t* p = _cmUiHandleToPtr(uiH); cmUi_t* p = _cmUiHandleToPtr(uiH);
cmUiDriverArg_t a;
cmUiCtl_t* c; cmUiCtl_t* c;
if(( rc = _cmUiCreateCtl(p,&a,panelId,kProgressUiCId,id,label,flags,&c)) == kOkUiRC ) if(( rc = _cmUiCreateCtl(p,panelId,kProgressUiCId,id,label,flags,&c)) == kOkUiRC )
{ {
cmUiRC_t rc0; cmUiRC_t rc0;
_cmUiSetIntAccessors(c); _cmUiSetIntAccessors(c);
a.dId = kSetValDId; if((rc0 = _cmUiSetDriverValueInt(p,c,kMinUiFl,min)) != kOkUiRC )
a.flags = kMinUiFl;
a.ival = min;
if((rc0 = _cmUiCallDriver(p,&a)) != kOkUiRC )
rc = rc0; rc = rc0;
a.flags = kMaxUiFl; if((rc0 = _cmUiSetDriverValueInt(p,c,kMaxUiFl,max)) != kOkUiRC )
a.ival = max;
if((rc0 = _cmUiCallDriver(p,&a)) != kOkUiRC )
rc = rc0; rc = rc0;
a.flags = kValUiFl; if((rc0 = _cmUiSetDriverValueInt(p,c,kValUiFl,dflt)) != kOkUiRC )
a.ival = dflt;
if((rc0 = _cmUiCallDriver(p,&a)) != kOkUiRC )
rc = rc0; rc = rc0;
} }
@ -1022,7 +1040,6 @@ cmUiRC_t _cmUiCreateMeter( cmUiH_t uiH, unsigned panelId, unsigned id, const c
{ {
cmUiRC_t rc; cmUiRC_t rc;
cmUi_t* p = _cmUiHandleToPtr(uiH); cmUi_t* p = _cmUiHandleToPtr(uiH);
cmUiDriverArg_t a;
cmUiCtl_t* c; cmUiCtl_t* c;
cmUiPanel_t* pp; cmUiPanel_t* pp;
@ -1037,27 +1054,19 @@ cmUiRC_t _cmUiCreateMeter( cmUiH_t uiH, unsigned panelId, unsigned id, const c
cmUiSetNextWH( uiH, panelId, cmUiH(uiH,panelId), cmUiW(uiH,panelId) ); cmUiSetNextWH( uiH, panelId, cmUiH(uiH,panelId), cmUiW(uiH,panelId) );
} }
if((rc = _cmUiCreateCtl(p,&a,panelId,kMeterUiCId,id,label,flags,&c)) == kOkUiRC ) if((rc = _cmUiCreateCtl(p,panelId,kMeterUiCId,id,label,flags,&c)) == kOkUiRC )
{ {
cmUiRC_t rc0; cmUiRC_t rc0;
_cmUiSetIntAccessors(c); _cmUiSetIntAccessors(c);
a.dId = kSetValDId; if((rc0 = _cmUiSetDriverValueInt(p,c,kMinUiFl,min)) != kOkUiRC )
a.flags = kMinUiFl;
a.ival = min;
if((rc0 = _cmUiCallDriver(p,&a)) != kOkUiRC )
rc = rc0; rc = rc0;
a.flags = kMaxUiFl; if((rc0 = _cmUiSetDriverValueInt(p,c,kMaxUiFl,max)) != kOkUiRC )
a.ival = max;
if((rc0 = _cmUiCallDriver(p,&a)) != kOkUiRC )
rc = rc0; rc = rc0;
a.flags = kValUiFl; if((rc0 = _cmUiSetDriverValueInt(p,c,kValUiFl,dflt)) != kOkUiRC )
a.ival = dflt;
if((rc0 = _cmUiCallDriver(p,&a)) != kOkUiRC )
rc = rc0; rc = rc0;
} }
@ -1079,10 +1088,9 @@ cmUiRC_t cmUiCreateFileBtn(cmUiH_t uiH, unsigned panelId, unsigned id, const cmC
{ {
cmUiRC_t rc = kOkUiRC; cmUiRC_t rc = kOkUiRC;
cmUi_t* p = _cmUiHandleToPtr(uiH); cmUi_t* p = _cmUiHandleToPtr(uiH);
cmUiDriverArg_t a;
cmUiCtl_t* c; cmUiCtl_t* c;
if(( rc = _cmUiCreateCtl(p,&a,panelId,kFilenameUiCId,id,label,flags,&c)) == kOkUiRC ) if(( rc = _cmUiCreateCtl(p,panelId,kFilenameUiCId,id,label,flags,&c)) == kOkUiRC )
{ {
cmUiRC_t rc0; cmUiRC_t rc0;
@ -1090,19 +1098,13 @@ cmUiRC_t cmUiCreateFileBtn(cmUiH_t uiH, unsigned panelId, unsigned id, const cmC
if( dfltDir != NULL ) if( dfltDir != NULL )
{ {
a.dId = kSetValDId; if((rc0 = _cmUiSetDriverValueStr(p,c,kValUiFl,dfltDir)) != kOkUiRC )
a.flags = kValUiFl;
a.sval = dfltDir;
if((rc0 = _cmUiCallDriver(p,&a)) != kOkUiRC )
rc = rc0; rc = rc0;
} }
if( patStr != NULL ) if( patStr != NULL )
{ {
a.dId = kSetValDId; if((rc0 = _cmUiSetDriverValueStr(p,c,kValUiFl,patStr)) != kOkUiRC )
a.flags = kFnPatUiFl;
a.sval = patStr;
if((rc0 = _cmUiCallDriver(p,&a)) != kOkUiRC )
rc = rc0; rc = rc0;
} }
} }
@ -1113,10 +1115,9 @@ cmUiRC_t cmUiCreateDirBtn( cmUiH_t uiH, unsigned panelId, unsigned id, const cm
{ {
cmUiRC_t rc = kOkUiRC; cmUiRC_t rc = kOkUiRC;
cmUi_t* p = _cmUiHandleToPtr(uiH); cmUi_t* p = _cmUiHandleToPtr(uiH);
cmUiDriverArg_t a;
cmUiCtl_t* c; cmUiCtl_t* c;
if(( rc = _cmUiCreateCtl(p,&a,panelId,kDirUiCId,id,label,flags,&c)) == kOkUiRC ) if(( rc = _cmUiCreateCtl(p,panelId,kDirUiCId,id,label,flags,&c)) == kOkUiRC )
{ {
cmUiRC_t rc0; cmUiRC_t rc0;
@ -1124,10 +1125,7 @@ cmUiRC_t cmUiCreateDirBtn( cmUiH_t uiH, unsigned panelId, unsigned id, const cm
if( dfltDir != NULL ) if( dfltDir != NULL )
{ {
a.dId = kSetValDId; if((rc0 = _cmUiSetDriverValueStr(p,c,kValUiFl,dfltDir)) != kOkUiRC )
a.flags = kValUiFl;
a.sval = dfltDir;
if((rc0 = _cmUiCallDriver(p,&a)) != kOkUiRC )
rc = rc0; rc = rc0;
} }
} }
@ -1138,10 +1136,9 @@ cmUiRC_t cmUiCreateMenuBtn( cmUiH_t uiH, unsigned panelId, unsigned id, const cm
{ {
cmUiRC_t rc; cmUiRC_t rc;
cmUi_t* p = _cmUiHandleToPtr(uiH); cmUi_t* p = _cmUiHandleToPtr(uiH);
cmUiDriverArg_t a;
cmUiCtl_t* c; cmUiCtl_t* c;
if((rc = _cmUiCreateCtl(p,&a,panelId,kMenuBtnUiCId,id,label,flags,&c)) == kOkUiRC ) if((rc = _cmUiCreateCtl(p,panelId,kMenuBtnUiCId,id,label,flags,&c)) == kOkUiRC )
_cmUiSetIntAccessors(c); _cmUiSetIntAccessors(c);
return rc; return rc;
} }
@ -1173,7 +1170,6 @@ cmUiRC_t cmUiCreateList(cmUiH_t uiH, unsigned panelId, unsigned id, const cmChar
{ {
cmUi_t* p = _cmUiHandleToPtr(uiH); cmUi_t* p = _cmUiHandleToPtr(uiH);
cmUiRC_t rc; cmUiRC_t rc;
cmUiDriverArg_t a;
cmUiCtl_t* c; cmUiCtl_t* c;
cmUiPanel_t* pp; cmUiPanel_t* pp;
@ -1183,7 +1179,7 @@ cmUiRC_t cmUiCreateList(cmUiH_t uiH, unsigned panelId, unsigned id, const cmChar
if( cmIsNotFlag(pp->flags,kNextWHUiFl) ) if( cmIsNotFlag(pp->flags,kNextWHUiFl) )
cmUiSetNextWH( uiH, panelId, cmUiNextW(uiH,panelId), cmUiH(uiH,panelId) * visibleRowCnt ); cmUiSetNextWH( uiH, panelId, cmUiNextW(uiH,panelId), cmUiH(uiH,panelId) * visibleRowCnt );
if((rc = _cmUiCreateCtl(p,&a,panelId,kListUiCId,id,label,flags,&c)) == kOkUiRC ) if((rc = _cmUiCreateCtl(p,panelId,kListUiCId,id,label,flags,&c)) == kOkUiRC )
_cmUiSetIntAccessors(c); _cmUiSetIntAccessors(c);
return rc; return rc;
@ -1217,7 +1213,6 @@ cmUiRC_t cmUiAppendListEle( cmUiH_t uiH, unsigned panelId, unsigned id, const
cmUiRC_t rc = kOkUiRC; cmUiRC_t rc = kOkUiRC;
cmUi_t* p = _cmUiHandleToPtr(uiH); cmUi_t* p = _cmUiHandleToPtr(uiH);
cmUiCtl_t* ctl = NULL; cmUiCtl_t* ctl = NULL;
cmUiDriverArg_t a;
if((rc = _cmUiFindCtl(p,id,&ctl,true)) != kOkUiRC ) if((rc = _cmUiFindCtl(p,id,&ctl,true)) != kOkUiRC )
return rc; return rc;
@ -1225,25 +1220,10 @@ cmUiRC_t cmUiAppendListEle( cmUiH_t uiH, unsigned panelId, unsigned id, const
if( ctl->cId != kListUiCId && ctl->cId != kMenuBtnUiCId ) if( ctl->cId != kListUiCId && ctl->cId != kMenuBtnUiCId )
return cmErrMsg(&p->err,kInvalidCtlOpUiRC,"List elements may only be set on 'list' and 'menu button' controls."); return cmErrMsg(&p->err,kInvalidCtlOpUiRC,"List elements may only be set on 'list' and 'menu button' controls.");
_cmUiDriverArgInit(&a, p, kSetValDId, ctl->cId, panelId, id ); if( cmArrayIsValid(ctl->idArrH) )
cmArrayPush(ctl->idArrH,&eleId,1);
//if( ctl->id_arr == NULL || ctl->id_cnt == ctl->id_alloc ) return _cmUiSetDriverValueIntAndStr(p,ctl,kAppendUiFl,eleId,text);
// ctl->id_arr = cmMemResizeZ(unsigned,ctl->id_arr,ctl->id_alloc+=10);
//ctl->id_arr[ ctl->id_cnt++ ] = eleId;
cmArrayPush(ctl->idArrH,&eleId,1);
//a.dId = kSetValDId;
//a.cId = ctl->cId;
//a.panelId = panelId;
//a.usrId = id;
a.flags = kAppendUiFl;
a.sval = text;
a.ival = eleId;
return _cmUiCallDriver(p,&a);
} }
cmUiRC_t cmUiDestroyCtl( cmUiH_t uiH, unsigned id ) cmUiRC_t cmUiDestroyCtl( cmUiH_t uiH, unsigned id )
@ -1319,6 +1299,31 @@ cmUiRC_t cmUiNextRect( cmUiH_t uiH, unsigned panelId, int x, int y, int w, in
return rc; return rc;
} }
cmUiRC_t cmUiPrevRect( cmUiH_t uiH, unsigned panelId, int* xRef, int* yRef, int* wRef, int* hRef )
{
cmUi_t* p = _cmUiHandleToPtr(uiH);
cmUiPanel_t* pp;
cmUiRC_t rc;
if((rc = _cmUiFindPanel(p, panelId, &pp, true)) != kOkUiRC )
return rc;
if( xRef != NULL )
*xRef = pp->prevRect.x;
if( yRef != NULL )
*yRef = pp->prevRect.y;
if( wRef != NULL )
*wRef = pp->prevRect.w;
if( hRef != NULL )
*hRef = pp->prevRect.h;
return rc;
}
bool cmUiFillRows( cmUiH_t uiH, unsigned panelId ) bool cmUiFillRows( cmUiH_t uiH, unsigned panelId )
{ {
cmUi_t* p = _cmUiHandleToPtr(uiH); cmUi_t* p = _cmUiHandleToPtr(uiH);
@ -1345,20 +1350,6 @@ bool cmUiSetFillRows( cmUiH_t uiH, unsigned panelId, bool enableFl )
return retFl; return retFl;
} }
int cmUiBaseCol( cmUiH_t uiH, unsigned panelId, int x )
{
cmUi_t* p = _cmUiHandleToPtr(uiH);
cmUiPanel_t* pp;
if( _cmUiFindPanel(p, panelId, &pp, true) != kOkUiRC )
return -1;
int bc = pp->baseCol;
pp->baseCol = x;
pp->flags = cmSetFlag(pp->flags,kPlaceBaseRowUiFl);
return bc;
}
void cmUiPlaceRight( cmUiH_t uiH, unsigned panelId ) void cmUiPlaceRight( cmUiH_t uiH, unsigned panelId )
{ {
cmUi_t* p = _cmUiHandleToPtr(uiH); cmUi_t* p = _cmUiHandleToPtr(uiH);
@ -1383,7 +1374,49 @@ void cmUiPlaceBelow( cmUiH_t uiH, unsigned panelId )
pp->flags = cmSetFlag(pp->flags,kPlaceBelowUiFl); pp->flags = cmSetFlag(pp->flags,kPlaceBelowUiFl);
} }
int cmUiBaseRow( cmUiH_t uiH, unsigned panelId, int y ) void cmUiNewLine( cmUiH_t uiH, unsigned panelId )
{
cmUiSetBaseRow( uiH, panelId, cmUiPrevB(uiH,panelId) + cmUiNextVBorder(uiH,panelId) );
cmUiSetBaseCol( uiH, panelId, cmUiBaseCol(uiH,panelId));
}
int cmUiBaseCol( cmUiH_t uiH, unsigned panelId )
{
cmUi_t* p = _cmUiHandleToPtr(uiH);
cmUiPanel_t* pp;
if(_cmUiFindPanel(p, panelId, &pp, true) != kOkUiRC )
return -1;
return pp->baseCol;
}
int cmUiSetBaseCol( cmUiH_t uiH, unsigned panelId, int x )
{
cmUi_t* p = _cmUiHandleToPtr(uiH);
cmUiPanel_t* pp;
if( _cmUiFindPanel(p, panelId, &pp, true) != kOkUiRC )
return -1;
int bc = pp->baseCol;
pp->baseCol = x;
pp->flags = cmSetFlag(pp->flags,kPlaceBaseRowUiFl);
return bc;
}
int cmUiBaseRow( cmUiH_t uiH, unsigned panelId )
{
cmUi_t* p = _cmUiHandleToPtr(uiH);
cmUiPanel_t* pp;
if(_cmUiFindPanel(p, panelId, &pp, true) != kOkUiRC )
return -1;
return pp->baseRow;
}
int cmUiSetBaseRow( cmUiH_t uiH, unsigned panelId, int y )
{ {
cmUi_t* p = _cmUiHandleToPtr(uiH); cmUi_t* p = _cmUiHandleToPtr(uiH);
cmUiPanel_t* pp; cmUiPanel_t* pp;
@ -1397,6 +1430,8 @@ int cmUiBaseRow( cmUiH_t uiH, unsigned panelId, int y )
return br; return br;
} }
int cmUiW( cmUiH_t uiH, unsigned panelId ) int cmUiW( cmUiH_t uiH, unsigned panelId )
{ {
cmUi_t* p = _cmUiHandleToPtr(uiH); cmUi_t* p = _cmUiHandleToPtr(uiH);
@ -1419,6 +1454,34 @@ int cmUiH( cmUiH_t uiH, unsigned panelId )
return pp->dfltH; return pp->dfltH;
} }
int cmUiSetW( cmUiH_t uiH, unsigned panelId, int w )
{
cmUi_t* p = _cmUiHandleToPtr(uiH);
cmUiPanel_t* pp;
if(_cmUiFindPanel(p, panelId, &pp, true) != kOkUiRC )
return -1;
int rv = pp->dfltW;
pp->dfltW = w;
pp->nextW = w;
return rv;
}
int cmUiSetH( cmUiH_t uiH, unsigned panelId, int h )
{
cmUi_t* p = _cmUiHandleToPtr(uiH);
cmUiPanel_t* pp;
if(_cmUiFindPanel(p, panelId, &pp, true) != kOkUiRC )
return -1;
int rv = pp->dfltH;
pp->dfltH = h;
pp->nextW = h;
return rv;
}
void cmUiSetWH( cmUiH_t uiH, unsigned panelId, int w, int h ) void cmUiSetWH( cmUiH_t uiH, unsigned panelId, int w, int h )
{ {
cmUi_t* p = _cmUiHandleToPtr(uiH); cmUi_t* p = _cmUiHandleToPtr(uiH);
@ -1429,6 +1492,9 @@ void cmUiSetWH( cmUiH_t uiH, unsigned panelId, int w, int h )
pp->dfltW = w; pp->dfltW = w;
pp->dfltH = h; pp->dfltH = h;
pp->nextW = w;
pp->nextH = h;
} }
int cmUiNextW( cmUiH_t uiH, unsigned panelId ) int cmUiNextW( cmUiH_t uiH, unsigned panelId )
@ -1453,6 +1519,12 @@ int cmUiNextH( cmUiH_t uiH, unsigned panelId )
return pp->nextH; return pp->nextH;
} }
void cmUiSetNextW( cmUiH_t uiH, unsigned panelId, int w )
{ return cmUiSetNextWH( uiH, panelId, w, cmUiNextH(uiH,panelId)); }
void cmUiSetNextH( cmUiH_t uiH, unsigned panelId, int h )
{ return cmUiSetNextWH( uiH, panelId, cmUiNextW(uiH,panelId), h); }
void cmUiSetNextWH( cmUiH_t uiH, unsigned panelId, int w, int h ) void cmUiSetNextWH( cmUiH_t uiH, unsigned panelId, int w, int h )
{ {
cmUi_t* p = _cmUiHandleToPtr(uiH); cmUi_t* p = _cmUiHandleToPtr(uiH);
@ -1562,25 +1634,83 @@ int cmUiSetNextVBorder( cmUiH_t uiH, unsigned panelId, int h )
return rv; return rv;
} }
int cmUiPrevL( cmUiH_t uiH, unsigned panelId )
{
cmUi_t* p = _cmUiHandleToPtr(uiH);
cmUiPanel_t* pp;
if(_cmUiFindPanel(p, panelId, &pp, true) != kOkUiRC )
return -1;
return pp->prevRect.x;
}
int cmUiPrevT( cmUiH_t uiH, unsigned panelId )
{
cmUi_t* p = _cmUiHandleToPtr(uiH);
cmUiPanel_t* pp;
if(_cmUiFindPanel(p, panelId, &pp, true) != kOkUiRC )
return -1;
return pp->prevRect.y;
}
int cmUiPrevR( cmUiH_t uiH, unsigned panelId )
{
cmUi_t* p = _cmUiHandleToPtr(uiH);
cmUiPanel_t* pp;
if(_cmUiFindPanel(p, panelId, &pp, true) != kOkUiRC )
return -1;
return pp->prevRect.x + pp->prevRect.w;
}
int cmUiPrevB( cmUiH_t uiH, unsigned panelId )
{
cmUi_t* p = _cmUiHandleToPtr(uiH);
cmUiPanel_t* pp;
if(_cmUiFindPanel(p, panelId, &pp, true) != kOkUiRC )
return -1;
return pp->prevRect.y + pp->prevRect.h;
}
int cmUiPrevW( cmUiH_t uiH, unsigned panelId )
{
cmUi_t* p = _cmUiHandleToPtr(uiH);
cmUiPanel_t* pp;
if(_cmUiFindPanel(p, panelId, &pp, true) != kOkUiRC )
return -1;
return pp->prevRect.w;
}
int cmUiPrevH( cmUiH_t uiH, unsigned panelId )
{
cmUi_t* p = _cmUiHandleToPtr(uiH);
cmUiPanel_t* pp;
if(_cmUiFindPanel(p, panelId, &pp, true) != kOkUiRC )
return -1;
return pp->prevRect.h;
}
cmUiRC_t cmUiSetInt( cmUiH_t uiH, unsigned id, int v ) cmUiRC_t cmUiSetInt( cmUiH_t uiH, unsigned id, int v )
{ {
cmUi_t* p = _cmUiHandleToPtr(uiH); cmUi_t* p = _cmUiHandleToPtr(uiH);
cmUiCtl_t* ctl; cmUiCtl_t* ctl;
cmUiRC_t rc; cmUiRC_t rc;
cmUiDriverArg_t a;
if((rc = _cmUiFastFindCtl(p,id,&ctl,true)) != kOkUiRC ) if((rc = _cmUiFastFindCtl(p,id,&ctl,true)) != kOkUiRC )
return rc; return rc;
// TODO: cache the cmUiDriverArg_t for this control in the ctl_t return _cmUiSetDriverValueInt(p,ctl,kValUiFl,v);
// object to avoid having to recreate the arg. recd on every call.
_cmUiDriverArgInit(&a, p, kSetValDId, ctl->cId, ctl->panelId, id );
a.ival = v;
a.flags |= kValUiFl;
return _cmUiCallDriver(p,&a);
} }
@ -1589,17 +1719,11 @@ cmUiRC_t cmUiSetUInt( cmUiH_t uiH, unsigned id, unsigned v )
cmUi_t* p = _cmUiHandleToPtr(uiH); cmUi_t* p = _cmUiHandleToPtr(uiH);
cmUiCtl_t* ctl; cmUiCtl_t* ctl;
cmUiRC_t rc; cmUiRC_t rc;
cmUiDriverArg_t a;
if((rc = _cmUiFastFindCtl(p,id,&ctl,true)) != kOkUiRC ) if((rc = _cmUiFastFindCtl(p,id,&ctl,true)) != kOkUiRC )
return rc; return rc;
_cmUiDriverArgInit(&a, p, kSetValDId, ctl->cId, ctl->panelId, id ); return _cmUiSetDriverValueInt(p,ctl,kValUiFl,v);
a.ival = (int)v;
a.flags |= kValUiFl;
return _cmUiCallDriver(p,&a);
} }
cmUiRC_t cmUiSetDouble( cmUiH_t uiH, unsigned id, double v ) cmUiRC_t cmUiSetDouble( cmUiH_t uiH, unsigned id, double v )
@ -1607,17 +1731,11 @@ cmUiRC_t cmUiSetDouble( cmUiH_t uiH, unsigned id, double v )
cmUi_t* p = _cmUiHandleToPtr(uiH); cmUi_t* p = _cmUiHandleToPtr(uiH);
cmUiCtl_t* ctl; cmUiCtl_t* ctl;
cmUiRC_t rc; cmUiRC_t rc;
cmUiDriverArg_t a;
if((rc = _cmUiFastFindCtl(p,id,&ctl,true)) != kOkUiRC ) if((rc = _cmUiFastFindCtl(p,id,&ctl,true)) != kOkUiRC )
return rc; return rc;
_cmUiDriverArgInit(&a, p, kSetValDId, ctl->cId, ctl->panelId, id ); return _cmUiSetDriverValueDouble(p,ctl,kValUiFl,v);
a.fval = v;
a.flags |= kValUiFl;
return _cmUiCallDriver(p,&a);
} }
cmUiRC_t cmUiSetString( cmUiH_t uiH, unsigned id, const cmChar_t* v ) cmUiRC_t cmUiSetString( cmUiH_t uiH, unsigned id, const cmChar_t* v )
@ -1625,17 +1743,11 @@ cmUiRC_t cmUiSetString( cmUiH_t uiH, unsigned id, const cmChar_t* v )
cmUi_t* p = _cmUiHandleToPtr(uiH); cmUi_t* p = _cmUiHandleToPtr(uiH);
cmUiCtl_t* ctl; cmUiCtl_t* ctl;
cmUiRC_t rc; cmUiRC_t rc;
cmUiDriverArg_t a;
if((rc = _cmUiFastFindCtl(p,id,&ctl,true)) != kOkUiRC ) if((rc = _cmUiFastFindCtl(p,id,&ctl,true)) != kOkUiRC )
return rc; return rc;
_cmUiDriverArgInit(&a, p, kSetValDId, ctl->cId, ctl->panelId, id ); return _cmUiSetDriverValueStr(p,ctl,kValUiFl,v);
a.sval = v;
a.flags |= kValUiFl;
return _cmUiCallDriver(p,&a);
} }
int cmUiInt( cmUiH_t uiH, unsigned id ) int cmUiInt( cmUiH_t uiH, unsigned id )

37
cmUi.h
View File

@ -251,15 +251,20 @@ extern "C" {
// Note that 'place right' and 'place below' are mutually // Note that 'place right' and 'place below' are mutually
// exclusive. Enabling one disables the other. // exclusive. Enabling one disables the other.
void cmUiPlaceRight( cmUiH_t uiH, unsigned panelId ); void cmUiPlaceRight( cmUiH_t uiH, unsigned panelId );
void cmUiPlaceBelow( cmUiH_t uiH, unsigned panelId ); void cmUiPlaceBelow( cmUiH_t uiH, unsigned panelId );
// Set current base col and return previous value. Place the next // Place the next control at the base column below the previous ctl.
void cmUiNewLine( cmUiH_t uiH, unsigned panelId );
// Set/Get current base col and return previous value. Place the next
// control on the base row. // control on the base row.
int cmUiBaseCol( cmUiH_t uiH, unsigned panelId, int x ); int cmUiBaseCol( cmUiH_t uiH, unsigned panelId );
int cmUiSetBaseCol( cmUiH_t uiH, unsigned panelId, int x );
// Set current base row and return previous value. // Set/Get current base row and return previous value.
int cmUiBaseRow( cmUiH_t uiH, unsigned panelId, int y ); int cmUiBaseRow( cmUiH_t uiH, unsigned panelId );
int cmUiSetBaseRow( cmUiH_t uiH, unsigned panelId, int y );
// Size: // Size:
// 1) If a 'next rect' is set the control will be placed according // 1) If a 'next rect' is set the control will be placed according
@ -272,14 +277,18 @@ extern "C" {
// Get/Set the default control width and height. // Get/Set the default control width and height.
// Set returns previous value. // Set returns previous value.
int cmUiW( cmUiH_t uiH, unsigned panelId ); int cmUiW( cmUiH_t uiH, unsigned panelId );
int cmUiH( cmUiH_t uiH, unsigned panelId ); int cmUiH( cmUiH_t uiH, unsigned panelId );
int cmUiSetW( cmUiH_t uiH, unsigned panelId, int w );
int cmUiSetH( cmUiH_t uiH, unsigned panelId, int h );
void cmUiSetWH( cmUiH_t uiH, unsigned panelId, int w, int h ); void cmUiSetWH( cmUiH_t uiH, unsigned panelId, int w, int h );
// Get/Set the control width and height for only the next control. // Get/Set the control width and height for only the next control.
// Set returns previous value. // Set returns previous value.
int cmUiNextW( cmUiH_t uiH, unsigned panelId ); int cmUiNextW( cmUiH_t uiH, unsigned panelId );
int cmUiNextH( cmUiH_t uiH, unsigned panelId ); int cmUiNextH( cmUiH_t uiH, unsigned panelId );
void cmUiSetNextW( cmUiH_t uiH, unsigned panelId, int w );
void cmUiSetNextH( cmUiH_t uiH, unsigned panelId, int h );
void cmUiSetNextWH( cmUiH_t uiH, unsigned panelId, int w, int h ); void cmUiSetNextWH( cmUiH_t uiH, unsigned panelId, int w, int h );
// Get/Set the default inter-control borders // Get/Set the default inter-control borders
@ -301,6 +310,16 @@ extern "C" {
// cmUiCreateXXX() call. Setting the 'next rect' overrides all // cmUiCreateXXX() call. Setting the 'next rect' overrides all
// other layout directives. // other layout directives.
cmUiRC_t cmUiNextRect( cmUiH_t uiH, unsigned panelId, int x, int y, int w, int h ); cmUiRC_t cmUiNextRect( cmUiH_t uiH, unsigned panelId, int x, int y, int w, int h );
// Get the location/size of the previously created control.
// All ref. args are optional.
cmUiRC_t cmUiPrevRect( cmUiH_t uiH, unsigned panelId, int* xRef, int* yRef, int* wRef, int* hRef );
int cmUiPrevL( cmUiH_t uiH, unsigned panelId );
int cmUiPrevT( cmUiH_t uiH, unsigned panelId );
int cmUiPrevR( cmUiH_t uiH, unsigned panelId );
int cmUiPrevB( cmUiH_t uiH, unsigned panelId );
int cmUiPrevW( cmUiH_t uiH, unsigned panelId );
int cmUiPrevH( cmUiH_t uiH, unsigned panelId );
// //