libcm is a C development framework with an emphasis on audio signal processing applications.
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813
  1. #include "cmGlobal.h"
  2. #include "cmRpt.h"
  3. #include "cmErr.h"
  4. #include "cmCtx.h"
  5. #include "cmMem.h"
  6. #include "cmMallocDebug.h"
  7. #include "cmArray.h"
  8. #include "cmJson.h"
  9. #include "cmUiDrvr.h"
  10. #include "cmUi.h"
  11. typedef struct
  12. {
  13. int x;
  14. int y;
  15. int w;
  16. int h;
  17. } cmUiRect_t;
  18. enum
  19. {
  20. kUseRectUiFl = 0x01,
  21. kPlaceRightUiFl = 0x02, // place only next control to right of prev control
  22. kPlaceBelowUiFl = 0x04, // place only next control to below prev control
  23. kPlaceBaseRowUiFl = 0x08, // place only next control at base row
  24. kNextWHUiFl = 0x10, // size next control according to nextW,nextH
  25. kFillRowsUiFl = 0x20, // current dflt fill direction
  26. };
  27. typedef struct cmUiApp_str
  28. {
  29. unsigned appId; // app id and index into cmUI_t.appArrH[].
  30. bool activeFl; // true if this app recd is active and valid
  31. cmArrayH_t ctlArrH; // cmUiCtl_t[]
  32. cmArrayH_t pnlArrH; // cmUiPanel_t[]
  33. } cmUiApp_t;
  34. struct cmUiCtl_str;
  35. typedef struct cmUiPanel_str
  36. {
  37. cmUiApp_t* appPtr; // owner app.
  38. struct cmUiCtl_str* ctl; // control recd assoc'd with this panel
  39. unsigned flags; // See kXXXUiFl above
  40. unsigned usrId; // app. supplied id
  41. cmUiRect_t rect; // rect to position next control (only used if kUseRectUiFl is set)
  42. cmUiRect_t prevRect;
  43. int baseCol;
  44. int baseRow;
  45. int dfltW;
  46. int dfltH;
  47. int nextW;
  48. int nextH;
  49. int dfltHBorder;
  50. int dfltVBorder;
  51. int nextHBorder;
  52. int nextVBorder;
  53. } cmUiPanel_t;
  54. typedef struct cmUiCtl_str
  55. {
  56. cmUiCId_t cId; // control type and used to decode the value union below.
  57. unsigned usrId; // control instance id and index into cmUiApp_t.ctlArrH[].
  58. unsigned panelId; // panel this ctl belongs to
  59. cmArrayH_t idArrH; // id's associated with each sub-element of this control (used by menu's, list's, etc...)
  60. cmUiDriverArg_t arg; // cached callback arg for this control
  61. // current value of this control
  62. union
  63. {
  64. int ival;
  65. double fval;
  66. cmChar_t* sval;
  67. cmUiPanel_t* pnl;
  68. } u;
  69. int (*getInt)( struct cmUiCtl_str* c );
  70. double (*getDbl)( struct cmUiCtl_str* c );
  71. const cmChar_t* (*getStr)( struct cmUiCtl_str* c );
  72. void (*setInt)( struct cmUiCtl_str* c, int v );
  73. void (*setDbl)( struct cmUiCtl_str* c, double v );
  74. void (*setStr)( struct cmUiCtl_str* c, const cmChar_t* s );
  75. } cmUiCtl_t;
  76. typedef struct
  77. {
  78. cmErr_t err; //
  79. cmCtx_t* ctx; // Global context.
  80. cmUiDriverFunc_t drvr; // Driver callback function
  81. void* drvrArg; // Driver callback function arg.
  82. int panelW; // Panel width.
  83. int panelH; // Panel height
  84. unsigned curAppId; // Id of application currently receiveing commands/queries.
  85. cmUiDriverFunc_t cbFunc; // Client callback function
  86. void * cbArg; //
  87. cmArrayH_t appArrH; // cmUiApp_t[]
  88. cmUiCtl_t dummy; // dummy recd used to create controls which will never be accessed after creation (like read-only labels)
  89. } cmUi_t;
  90. cmUiH_t cmUiNullHandle = cmSTATIC_NULL_HANDLE;
  91. cmUi_t* _cmUiHandleToPtr( cmUiH_t h )
  92. {
  93. cmUi_t* p = (cmUi_t*)h.h;
  94. assert(p != NULL );
  95. return p;
  96. }
  97. //---------------------------------------------------------------
  98. // int accessors
  99. int _cmUiGetIntFromInt( cmUiCtl_t* ctl )
  100. { return ctl->u.ival; }
  101. double _cmUiGetDblFromInt( cmUiCtl_t* ctl )
  102. { return ctl->u.ival; }
  103. const cmChar_t* _cmUiGetStrFromInt( cmUiCtl_t* ctl )
  104. { assert(0); return ""; }
  105. void _cmUiSetIntFromInt( cmUiCtl_t* ctl, int v )
  106. { ctl->u.ival = v; }
  107. void _cmUiSetIntFromDbl( cmUiCtl_t* ctl, double v )
  108. { ctl->u.ival = round(v); }
  109. void _cmUiSetIntFromStr( cmUiCtl_t* ctl, const cmChar_t* v )
  110. { assert(0); }
  111. void _cmUiSetIntAccessors( cmUiCtl_t* ctl )
  112. {
  113. ctl->getInt = _cmUiGetIntFromInt;
  114. ctl->getDbl = _cmUiGetDblFromInt;
  115. ctl->getStr = _cmUiGetStrFromInt;
  116. ctl->setInt = _cmUiSetIntFromInt;
  117. ctl->setDbl = _cmUiSetIntFromDbl;
  118. ctl->setStr = _cmUiSetIntFromStr;
  119. }
  120. //---------------------------------------------------------------
  121. // double accessors
  122. int _cmUiGetIntFromDbl( cmUiCtl_t* ctl )
  123. { return round(ctl->u.fval); }
  124. double _cmUiGetDblFromDbl( cmUiCtl_t* ctl )
  125. { return ctl->u.fval; }
  126. const cmChar_t* _cmUiGetStrFromDbl( cmUiCtl_t* ctl )
  127. { assert(0); return ""; }
  128. void _cmUiSetDblFromInt( cmUiCtl_t* ctl, int v )
  129. { ctl->u.fval = v; }
  130. void _cmUiSetDblFromDbl( cmUiCtl_t* ctl, double v )
  131. { ctl->u.fval = v; }
  132. void _cmUiSetDblFromStr( cmUiCtl_t* ctl, const cmChar_t* v )
  133. { assert(0); }
  134. void _cmUiSetDblAccessors( cmUiCtl_t* ctl )
  135. {
  136. ctl->getInt = _cmUiGetIntFromDbl;
  137. ctl->getDbl = _cmUiGetDblFromDbl;
  138. ctl->getStr = _cmUiGetStrFromDbl;
  139. ctl->setInt = _cmUiSetDblFromInt;
  140. ctl->setDbl = _cmUiSetDblFromDbl;
  141. ctl->setStr = _cmUiSetDblFromStr;
  142. }
  143. //---------------------------------------------------------------
  144. // string accessors
  145. int _cmUiGetIntFromStr( cmUiCtl_t* ctl )
  146. { assert(0); return -1; }
  147. double _cmUiGetDblFromStr( cmUiCtl_t* ctl )
  148. { assert(0); return -1; }
  149. const cmChar_t* _cmUiGetStrFromStr( cmUiCtl_t* ctl )
  150. { return ctl->u.sval; }
  151. void _cmUiSetStrFromInt( cmUiCtl_t* ctl, int v )
  152. { assert(0); }
  153. void _cmUiSetStrFromDbl( cmUiCtl_t* ctl, double v )
  154. { assert(0); }
  155. void _cmUiSetStrFromStr( cmUiCtl_t* ctl, const cmChar_t* v )
  156. { ctl->u.sval = cmMemResizeStr(ctl->u.sval, v==NULL ? "" : v); }
  157. void _cmUiSetStrAccessors( cmUiCtl_t* ctl )
  158. {
  159. ctl->getInt = _cmUiGetIntFromStr;
  160. ctl->getDbl = _cmUiGetDblFromStr;
  161. ctl->getStr = _cmUiGetStrFromStr;
  162. ctl->setInt = _cmUiSetStrFromInt;
  163. ctl->setDbl = _cmUiSetStrFromDbl;
  164. ctl->setStr = _cmUiSetStrFromStr;
  165. }
  166. //---------------------------------------------------------------
  167. cmUiRC_t _cmUiCallDriver( cmUi_t* p, cmUiDId_t dId, cmUiCtl_t* ctl )
  168. {
  169. cmUiRC_t rc = kOkUiRC;
  170. if( p->drvr != NULL )
  171. {
  172. ctl->arg.dId = dId;
  173. if((rc = p->drvr(p->drvrArg,&ctl->arg)) != kOkUiRC )
  174. rc = cmErrMsg(&p->err,kDrvrErrUiRC,"UI manager driver error.");
  175. }
  176. return rc;
  177. }
  178. cmUiRC_t _cmUiSetDriverValue( cmUi_t* p, cmUiCtl_t* ctl, unsigned flag )
  179. {
  180. unsigned orgFlags = ctl->arg.flags;
  181. ctl->arg.flags |= flag;
  182. cmUiRC_t rc = _cmUiCallDriver(p,kSetValDId,ctl);
  183. ctl->arg.flags = orgFlags;
  184. return rc;
  185. }
  186. cmUiRC_t _cmUiSetDriverValueInt( cmUi_t* p, cmUiCtl_t* ctl, unsigned flag, int value )
  187. {
  188. ctl->arg.ival = value;
  189. return _cmUiSetDriverValue(p,ctl,flag);
  190. }
  191. cmUiRC_t _cmUiSetDriverValueDouble( cmUi_t* p, cmUiCtl_t* ctl, unsigned flag, double value )
  192. {
  193. ctl->arg.fval = value;
  194. return _cmUiSetDriverValue(p,ctl,flag);
  195. }
  196. cmUiRC_t _cmUiSetDriverValueStr( cmUi_t* p, cmUiCtl_t* ctl, unsigned flag, const cmChar_t* value )
  197. {
  198. ctl->arg.sval = value;
  199. return _cmUiSetDriverValue(p,ctl,flag);
  200. }
  201. cmUiRC_t _cmUiSetDriverValueIntAndStr( cmUi_t* p, cmUiCtl_t* ctl, unsigned flag, int ival, const cmChar_t* sval )
  202. {
  203. ctl->arg.ival = ival;
  204. ctl->arg.sval = sval;
  205. return _cmUiSetDriverValue(p,ctl,flag);
  206. }
  207. //---------------------------------------------------------------
  208. cmUiRC_t _cmUiFindApp( cmUi_t* p, unsigned appId, cmUiApp_t** appRef, bool errFl )
  209. {
  210. cmUiRC_t rc = kOkUiRC;
  211. cmUiApp_t* ap = NULL;
  212. // verify that the appId is a valid index
  213. if( appId < cmArrayCount(p->appArrH) )
  214. ap = cmArrayPtr(cmUiApp_t,p->appArrH,appId);
  215. // if the app record was not already allocated
  216. if( ap != NULL && ap->activeFl == false )
  217. ap = NULL;
  218. // report errors
  219. if( ap == NULL )
  220. {
  221. rc = kAppNotFoundUiRC;
  222. if( errFl )
  223. cmErrMsg(&p->err,rc,"App %i not found.", appId );
  224. }
  225. *appRef = ap;
  226. return rc;
  227. }
  228. cmUiRC_t _cmUiFindCtl( cmUi_t* p, unsigned usrId, cmUiCtl_t** ctlRef, bool errFl )
  229. {
  230. cmUiRC_t rc = kOkUiRC;
  231. cmUiApp_t* ap = NULL;
  232. cmUiCtl_t* ctl = NULL;
  233. // find the app this ctl belongs to
  234. if(( rc =_cmUiFindApp(p,p->curAppId,&ap,errFl)) != kOkUiRC )
  235. goto errLabel;
  236. // verify that the usrId is a valid index
  237. if( usrId < cmArrayCount(ap->ctlArrH) )
  238. ctl = cmArrayPtr(cmUiCtl_t,ap->ctlArrH,usrId);
  239. // verify that the usrId of the recd matches the requested usr id
  240. if( ctl!=NULL && ctl->usrId != usrId )
  241. ctl = NULL;
  242. // report errors
  243. if( ctl==NULL )
  244. {
  245. rc = kCtlNotFoundUiRC;
  246. if( errFl )
  247. cmErrMsg(&p->err,rc,"Control %i not found.",usrId);
  248. }
  249. errLabel:
  250. *ctlRef = ctl;
  251. return rc;
  252. }
  253. cmUiRC_t _cmUiFastFindCtl( cmUi_t* p, unsigned usrId, cmUiCtl_t** ctlRef, bool errFl )
  254. {
  255. assert( p->curAppId < cmArrayCount(p->appArrH) );
  256. cmUiApp_t* ap = cmArrayPtr(cmUiApp_t,p->appArrH,p->curAppId);
  257. assert( ap->activeFl && usrId < cmArrayCount(ap->ctlArrH) );
  258. *ctlRef = cmArrayPtr(cmUiCtl_t,ap->ctlArrH,usrId);
  259. assert( (*ctlRef)->usrId == usrId );
  260. return kOkUiRC;
  261. }
  262. cmUiRC_t _cmUiFindPanel( cmUi_t* p, unsigned panelId, cmUiPanel_t** ppRef, bool errFl )
  263. {
  264. cmUiRC_t rc = kOkUiRC;
  265. cmUiApp_t* ap = NULL;
  266. unsigned i,n;
  267. *ppRef = NULL;
  268. // find the app this ctl belongs to
  269. if(( rc =_cmUiFindApp(p,p->curAppId,&ap,errFl)) != kOkUiRC )
  270. goto errLabel;
  271. n = cmArrayCount(ap->pnlArrH);
  272. for(i=0; i<n; ++i)
  273. if( (*ppRef = cmArrayPtr(cmUiPanel_t,ap->pnlArrH,i))->usrId == panelId )
  274. break;
  275. errLabel:
  276. if(*ppRef == NULL)
  277. {
  278. rc = kPanelNotFoundUiRC;
  279. if( errFl )
  280. cmErrMsg(&p->err,rc,"Panel %i was not found.",panelId);
  281. }
  282. return rc;
  283. }
  284. //---------------------------------------------------------------
  285. cmUiRC_t _cmUiDestroyCtl( cmUi_t* p, cmUiCtl_t* ctl )
  286. {
  287. cmUiRC_t rc = kOkUiRC;
  288. rc = _cmUiCallDriver(p,kDestroyCtlDId,ctl);
  289. switch(ctl->cId)
  290. {
  291. case kLabelUiCId:
  292. case kTextUiCId:
  293. case kFilenameUiCId:
  294. case kDirUiCId:
  295. cmMemFree(ctl->u.sval);
  296. break;
  297. default:
  298. break;
  299. }
  300. ctl->cId = kInvalidUiCId;
  301. ctl->usrId = cmInvalidId;
  302. ctl->panelId = cmInvalidId;
  303. cmArrayRelease(&ctl->idArrH);
  304. return rc;
  305. }
  306. cmUiRC_t _cmUiDestroyPanel( cmUi_t* p, unsigned panelId )
  307. {
  308. cmUiRC_t rc = kOkUiRC;
  309. cmUiPanel_t* pp = NULL;
  310. // get the panel recd ptr
  311. if((rc = _cmUiFindPanel(p,panelId,&pp,true)) != kOkUiRC )
  312. return rc;
  313. cmUiApp_t* ap = pp->appPtr;
  314. // notify the driver to destroy the panel
  315. if((rc = _cmUiCallDriver(p,kDestroyCtlDId,pp->ctl)) != kOkUiRC )
  316. return rc;
  317. cmUiCtl_t* ctl = NULL;
  318. unsigned i = 0;
  319. unsigned n = cmArrayCount(ap->ctlArrH);
  320. cmUiRC_t rc0;
  321. // Destroy all controls that belong to this panel.
  322. // Notice that _cmUiDestroyCtl() does not need to call the driver
  323. // because destroying the drivers panel has implicitely also
  324. // destroyed all the contols assigned to it.
  325. for(i=0; i<n; ++i)
  326. if( _cmUiFindCtl(p,i,&ctl,false) == kOkUiRC && ctl != NULL && ctl->panelId == panelId)
  327. if((rc0 = _cmUiDestroyCtl(p,ctl)) != kOkUiRC )
  328. rc = rc0;
  329. // release the panel record
  330. pp->appPtr = NULL;
  331. pp->usrId = cmInvalidId;
  332. return rc;
  333. }
  334. cmUiRC_t _cmUiDestroyApp( cmUi_t* p, unsigned appId, bool errFl )
  335. {
  336. cmUiRC_t rc = kOkUiRC;
  337. cmUiRC_t rc0;
  338. cmUiApp_t* ap;
  339. unsigned orgAppId = p->curAppId;
  340. p->curAppId = appId;
  341. // find the app to destroy
  342. if( _cmUiFindApp(p,appId,&ap,false) != kOkUiRC )
  343. {
  344. if( errFl )
  345. rc = cmErrMsg(&p->err,kAppNotFoundUiRC,"The app %i was not found for destruction.",appId);
  346. goto errLabel;
  347. }
  348. assert( ap != NULL );
  349. // destroy all panels owned by this app
  350. unsigned i;
  351. unsigned n = cmArrayCount(ap->pnlArrH);
  352. for(i=0; i<n; ++i)
  353. {
  354. cmUiPanel_t* pp = cmArrayPtr(cmUiPanel_t,ap->pnlArrH,i);
  355. if( pp->usrId != cmInvalidId )
  356. if((rc0 = _cmUiDestroyPanel(p,pp->usrId)) != kOkUiRC )
  357. rc = rc0;
  358. }
  359. ap->appId = -1;
  360. ap->activeFl = false;
  361. cmArrayRelease(&ap->ctlArrH);
  362. cmArrayRelease(&ap->pnlArrH);
  363. errLabel:
  364. p->curAppId = orgAppId;
  365. return rc;
  366. }
  367. cmUiRC_t _cmUiDestroyAllApps( cmUi_t* p )
  368. {
  369. cmUiRC_t rc = kOkUiRC;
  370. unsigned n = cmArrayCount(p->appArrH);
  371. unsigned i;
  372. for(i=0; i<n; ++i)
  373. {
  374. cmUiRC_t rc0;
  375. if((rc0 = _cmUiDestroyApp(p,i,false)) != kOkUiRC )
  376. rc = rc0;
  377. }
  378. cmArrayClear(p->appArrH,false);
  379. return rc;
  380. }
  381. //---------------------------------------------------------------
  382. cmUiRC_t _cmUiGetCtlXYWH( cmUi_t* p, cmUiDriverArg_t* a, cmUiPanel_t* pp )
  383. {
  384. if( cmIsFlag(pp->flags,kUseRectUiFl ) )
  385. {
  386. pp->flags = cmClrFlag(pp->flags,kUseRectUiFl);
  387. a->x = pp->rect.x;
  388. a->y = pp->rect.y;
  389. a->w = pp->rect.w;
  390. a->h = pp->rect.h;
  391. return kOkUiRC;
  392. }
  393. if( pp->prevRect.x == -1 )
  394. pp->prevRect.x = pp->baseCol;
  395. if( pp->prevRect.y == -1 )
  396. pp->prevRect.y = pp->baseRow;
  397. if( pp->prevRect.w == -1 )
  398. pp->prevRect.w = 0;
  399. if( pp->prevRect.h == -1 )
  400. pp->prevRect.h = 0;
  401. // Get direction flag. Fill across rows? or down columns?
  402. bool fillRowFl = cmIsFlag(pp->flags,kFillRowsUiFl);
  403. // the 'place to right' flag overrides the directon flag for just this instance
  404. if( cmIsFlag(pp->flags,kPlaceRightUiFl ) )
  405. fillRowFl = true;
  406. // the 'place under' flag overides the direction flag for just this instance
  407. if( cmIsFlag(pp->flags,kPlaceBelowUiFl ) )
  408. fillRowFl = false;
  409. // set x coord - if filling acros rows ...
  410. if( fillRowFl )
  411. a->x = pp->prevRect.x + pp->prevRect.w + pp->nextHBorder;
  412. else
  413. a->x = pp->baseCol; // ... or down columns
  414. // if a new column was set then move to the base row
  415. if( cmIsFlag(pp->flags,kPlaceBaseRowUiFl) )
  416. a->y = pp->baseRow;
  417. else
  418. {
  419. // set y coord - if filling acros rows ...
  420. if( fillRowFl )
  421. a->y = pp->prevRect.y;
  422. else
  423. a->y = pp->prevRect.y + pp->prevRect.h + pp->nextVBorder; // ... or down columns
  424. }
  425. a->w = pp->nextW;
  426. a->h = pp->nextH;
  427. pp->prevRect.x = a->x;
  428. pp->prevRect.y = a->y;
  429. pp->prevRect.w = a->w;
  430. pp->prevRect.h = a->h;
  431. pp->nextW = pp->dfltW;
  432. pp->nextH = pp->dfltH;
  433. pp->nextHBorder= pp->dfltHBorder;
  434. pp->nextVBorder= pp->dfltVBorder;
  435. pp->flags = cmClrFlag(pp->flags,kNextWHUiFl | kPlaceRightUiFl | kPlaceBelowUiFl | kPlaceBaseRowUiFl );
  436. return kOkUiRC;
  437. }
  438. cmUiRC_t _cmUiCreateCtl( cmUi_t* p, unsigned panelId, cmUiCId_t cId, unsigned usrId, const cmChar_t* label, unsigned flags, cmUiCtl_t** ctlRef )
  439. {
  440. cmUiRC_t rc;
  441. cmUiPanel_t* pp = NULL;
  442. cmUiApp_t* ap = NULL;
  443. if( ctlRef != NULL )
  444. *ctlRef = NULL;
  445. // locate the app
  446. if((rc = _cmUiFindApp(p,p->curAppId,&ap,true)) != kOkUiRC )
  447. return rc;
  448. // locate the panel the control belongs to
  449. if((rc = _cmUiFindPanel(p,panelId,&pp,true)) != kOkUiRC )
  450. return rc;
  451. // get the new ctl record
  452. cmUiCtl_t* ctl;
  453. if( usrId == cmInvalidId )
  454. {
  455. ctl = &p->dummy;
  456. memset(ctl,0,sizeof(*ctl));
  457. }
  458. else
  459. {
  460. if( cmArrayIsValid(ap->ctlArrH)==false || usrId >= cmArrayCount(ap->ctlArrH) )
  461. ctl = cmArrayClr(cmUiCtl_t,ap->ctlArrH,usrId);
  462. else
  463. {
  464. ctl = cmArrayPtr(cmUiCtl_t,ap->ctlArrH,usrId);
  465. // if the ctl recd is already in use
  466. if( ctl->cId != kInvalidUiCId )
  467. _cmUiDestroyCtl(p,ctl);
  468. }
  469. }
  470. // setup this controls cached callback arg record
  471. cmUiDriverArgSetup(&ctl->arg,kInvalidDId,ap->appId,usrId,panelId,cId,flags,0,0,label,-1,-1,-1,-1);
  472. // calc the control location - for non-panel controls
  473. if( cId != kPanelUiCId )
  474. if((rc = _cmUiGetCtlXYWH(p,&ctl->arg,pp)) != kOkUiRC )
  475. return rc;
  476. // setup the new ctl record
  477. ctl->cId = cId;
  478. ctl->usrId = usrId;
  479. ctl->panelId = panelId;
  480. // display-only controls don't need an id array
  481. if( usrId != cmInvalidId )
  482. cmArrayAlloc(p->ctx,&ctl->idArrH,sizeof(unsigned));
  483. if( ctlRef != NULL )
  484. *ctlRef = ctl;
  485. return _cmUiCallDriver(p,kCreateCtlDId,ctl);
  486. }
  487. cmUiRC_t cmUiAlloc(
  488. cmCtx_t* ctx,
  489. cmUiH_t* uiHPtr,
  490. cmUiDriverFunc_t drvrFunc,
  491. void* drvrArg,
  492. cmUiDriverFunc_t cbFunc,
  493. void * cbArg)
  494. {
  495. cmUiRC_t rc;
  496. if((rc = cmUiFree(uiHPtr)) != kOkUiRC )
  497. return rc;
  498. cmUi_t* p = cmMemAllocZ(cmUi_t,1);
  499. cmErrSetup(&p->err,&ctx->rpt,"cmUi");
  500. p->ctx = ctx;
  501. p->drvr = drvrFunc;
  502. p->drvrArg = drvrArg;
  503. p->cbFunc = cbFunc;
  504. p->cbArg = cbArg;
  505. p->panelW = 1000;
  506. p->panelH = 500;
  507. cmArrayAlloc(p->ctx,&p->appArrH,sizeof(cmUiApp_t));
  508. uiHPtr->h = p;
  509. return rc;
  510. }
  511. cmUiRC_t cmUiFree( cmUiH_t* hp )
  512. {
  513. cmUiRC_t rc = kOkUiRC;
  514. if( hp == NULL || cmUiIsValid(*hp)==false )
  515. return kOkUiRC;
  516. cmUi_t* p = _cmUiHandleToPtr(*hp);
  517. if((rc = _cmUiDestroyAllApps(p)) != kOkUiRC )
  518. return rc;
  519. cmArrayRelease(&p->appArrH);
  520. cmMemFree(p);
  521. hp->h = NULL;
  522. return rc;
  523. }
  524. bool cmUiIsValid( cmUiH_t h )
  525. { return h.h != NULL; }
  526. void cmUiSetDriver( cmUiH_t h, cmUiDriverFunc_t drvrFunc, void* drvrArg )
  527. {
  528. cmUi_t* p = _cmUiHandleToPtr(h);
  529. p->drvr = drvrFunc;
  530. p->drvrArg = drvrArg;
  531. }
  532. cmUiRC_t cmUiCreateApp( cmUiH_t h, unsigned appId )
  533. {
  534. cmUiRC_t rc = kOkUiRC;
  535. if( cmUiIsValid(h)==false)
  536. return rc;
  537. cmUi_t* p = _cmUiHandleToPtr(h);
  538. cmUiApp_t* ap = NULL;
  539. // verify that the requested app does not exist
  540. if( _cmUiFindApp(p,appId, &ap, false ) == kOkUiRC )
  541. return cmErrMsg(&p->err,kInvalidIdUiRC,"The id (%i) of the new application is already in use.",appId);
  542. ap = cmArrayClr(cmUiApp_t,p->appArrH,appId);
  543. ap->appId = appId;
  544. ap->activeFl = true;
  545. cmArrayAlloc(p->ctx,&ap->ctlArrH,sizeof(cmUiCtl_t));
  546. cmArrayAlloc(p->ctx,&ap->pnlArrH,sizeof(cmUiPanel_t));
  547. return rc;
  548. }
  549. cmUiRC_t cmUiDestroyApp( cmUiH_t h, unsigned appId )
  550. {
  551. if( cmUiIsValid(h)==false)
  552. return kOkUiRC;
  553. cmUi_t* p = _cmUiHandleToPtr(h);
  554. return _cmUiDestroyApp(p,appId,true);
  555. }
  556. cmUiRC_t cmUiDestroyAllApps( cmUiH_t h )
  557. {
  558. if( cmUiIsValid(h)==false)
  559. return kOkUiRC;
  560. cmUi_t* p = _cmUiHandleToPtr(h);
  561. return _cmUiDestroyAllApps(p);
  562. }
  563. cmUiRC_t cmUiSetAppId( cmUiH_t h, unsigned appId )
  564. {
  565. cmUiRC_t rc = kOkUiRC;
  566. if( cmUiIsValid(h)==false)
  567. return rc;
  568. cmUi_t* p = _cmUiHandleToPtr(h);
  569. cmUiApp_t* ap = NULL;
  570. // verify that the requested app exists
  571. if( appId != cmInvalidId )
  572. if((rc = _cmUiFindApp(p,appId, &ap, true )) != kOkUiRC )
  573. return rc;
  574. p->curAppId = appId;
  575. return rc;
  576. }
  577. unsigned cmUiAppCount( cmUiH_t h )
  578. {
  579. if( cmUiIsValid(h)==false)
  580. return 0;
  581. cmUi_t* p = _cmUiHandleToPtr(h);
  582. return cmArrayCount(p->appArrH);
  583. }
  584. cmUiRC_t cmUiOnDriverEvent( cmUiH_t h, const cmUiDriverArg_t* arg )
  585. {
  586. cmUiRC_t rc = kOkUiRC;
  587. cmUi_t* p = _cmUiHandleToPtr(h);
  588. cmUiCtl_t* ctl;
  589. if((rc = cmUiSetAppId(h,arg->appId)) != kOkUiRC )
  590. return rc;
  591. if((rc = _cmUiFindCtl(p,arg->usrId,&ctl,true)) != kOkUiRC )
  592. goto errLabel;
  593. switch( arg->cId )
  594. {
  595. case kInvalidUiCId:
  596. break;
  597. case kPanelUiCId:
  598. case kBtnUiCId:
  599. case kCheckUiCId:
  600. ctl->arg.ival = ctl->u.ival = cmUiDriverArgGetInt(arg);
  601. break;
  602. case kMenuBtnUiCId:
  603. case kListUiCId:
  604. {
  605. unsigned eleIdx = cmUiDriverArgGetInt(arg);
  606. if(eleIdx >= cmArrayCount(ctl->idArrH))
  607. {
  608. rc = cmErrMsg(&p->err,kInvalidIdUiRC,"Invalid menu or list driver element id=%i element count:%i.",eleIdx,cmArrayCount(ctl->idArrH));
  609. goto errLabel;
  610. }
  611. // convert the selected items index to the associated client id value
  612. ctl->arg.ival = ctl->u.ival = cmArrayEle(unsigned,ctl->idArrH,eleIdx);
  613. }
  614. break;
  615. case kLabelUiCId:
  616. case kTextUiCId:
  617. case kFilenameUiCId:
  618. case kDirUiCId:
  619. {
  620. const cmChar_t* s;
  621. if((s = cmUiDriverArgGetString(arg)) != NULL )
  622. ctl->arg.sval = ctl->u.sval = cmMemResizeStr(ctl->u.sval,s);
  623. }
  624. break;
  625. case kSliderUiCId:
  626. case kNumberUiCId:
  627. ctl->arg.fval = ctl->u.fval = cmUiDriverArgGetDouble(arg);
  628. break;
  629. case kProgressUiCId:
  630. case kMeterUiCId:
  631. assert(0); // progress and meters are display only
  632. break;
  633. case kMaxUiCId:
  634. assert(0);
  635. break;
  636. }
  637. ctl->arg.dId = kSetValDId;
  638. rc = p->cbFunc(p->cbArg,&ctl->arg);
  639. errLabel:
  640. cmUiSetAppId(h,cmInvalidId);
  641. return rc;
  642. }
  643. cmUiRC_t cmUiCreatePanel( cmUiH_t uiH, unsigned newPanelId, const cmChar_t* label )
  644. {
  645. cmUiRC_t rc;
  646. cmUi_t* p = _cmUiHandleToPtr(uiH);
  647. cmUiCtl_t* ctl = NULL;
  648. cmUiApp_t* ap = NULL;
  649. if(( rc = _cmUiFindApp(p,p->curAppId,&ap,true)) != kOkUiRC )
  650. return rc;
  651. cmUiPanel_t* pp = cmArrayPush(ap->pnlArrH,NULL,1);
  652. assert( pp != NULL );
  653. pp->appPtr = ap;
  654. pp->ctl = NULL;
  655. pp->usrId = newPanelId;
  656. pp->baseCol = 2;
  657. pp->baseRow = 0;
  658. pp->dfltW = 150;
  659. pp->dfltH = 25;
  660. pp->nextW = pp->dfltW;
  661. pp->nextH = pp->dfltH;
  662. pp->dfltHBorder= 2;
  663. pp->dfltVBorder= 2;
  664. pp->nextHBorder= pp->dfltHBorder;
  665. pp->nextVBorder= pp->dfltVBorder;
  666. pp->prevRect.x = -1;
  667. pp->prevRect.y = -1;
  668. pp->prevRect.w = -1;
  669. pp->prevRect.h = -1;
  670. if((rc = _cmUiCreateCtl(p, newPanelId, kPanelUiCId, newPanelId, label, 0, &pp->ctl )) != kOkUiRC )
  671. {
  672. // TODO - destroy panel record here
  673. return rc;
  674. }
  675. _cmUiFindCtl(p,newPanelId,&ctl,true);
  676. assert(ctl!=NULL);
  677. ctl->u.pnl = pp;
  678. return rc;
  679. }
  680. cmUiRC_t cmUiCreateBtn( cmUiH_t uiH, unsigned panelId, unsigned id, const cmChar_t* label, unsigned flags )
  681. {
  682. cmUiRC_t rc;
  683. cmUi_t* p = _cmUiHandleToPtr(uiH);
  684. cmUiCtl_t* c;
  685. if((rc = _cmUiCreateCtl(p,panelId,kBtnUiCId,id,label,flags,&c)) == kOkUiRC )
  686. {
  687. _cmUiSetIntAccessors(c);
  688. }
  689. return rc;
  690. }
  691. cmUiRC_t cmUiCreateCheck( cmUiH_t uiH, unsigned panelId, unsigned id, const cmChar_t* label, unsigned flags, bool dflt )
  692. {
  693. cmUiRC_t rc;
  694. cmUi_t* p = _cmUiHandleToPtr(uiH);
  695. cmUiCtl_t* c;
  696. if((rc = _cmUiCreateCtl(p,panelId,kCheckUiCId,id,label,flags,&c)) == kOkUiRC )
  697. {
  698. _cmUiSetIntAccessors(c);
  699. rc = _cmUiSetDriverValueInt(p,c,kValUiFl,dflt);
  700. }
  701. return rc;
  702. }
  703. cmUiRC_t cmUiCreateLabel( cmUiH_t uiH, unsigned panelId, unsigned id, const cmChar_t* label, unsigned flags )
  704. {
  705. cmUiRC_t rc;
  706. cmUi_t* p = _cmUiHandleToPtr(uiH);
  707. cmUiCtl_t* c;
  708. if((rc = _cmUiCreateCtl(p,panelId,kLabelUiCId,id,label,flags,&c)) == kOkUiRC )
  709. _cmUiSetStrAccessors(c);
  710. return rc;
  711. }
  712. cmUiRC_t cmUiCreateText( cmUiH_t uiH, unsigned panelId, unsigned id, const cmChar_t* label, unsigned flags, const cmChar_t* text )
  713. {
  714. cmUiRC_t rc = kOkUiRC;
  715. cmUi_t* p = _cmUiHandleToPtr(uiH);
  716. cmUiCtl_t* c;
  717. if(( rc = _cmUiCreateCtl(p,panelId,kTextUiCId,id,label,flags,&c)) == kOkUiRC )
  718. {
  719. _cmUiSetStrAccessors(c);
  720. rc = _cmUiSetDriverValueStr(p,c,kValUiFl,text);
  721. }
  722. return rc;
  723. }
  724. cmUiRC_t _cmUiCreateNumber( cmUiH_t uiH, unsigned panelId, unsigned id, const cmChar_t* label, unsigned flags, double min, double max, double incr, double dflt )
  725. {
  726. cmUiRC_t rc = kOkUiRC;
  727. cmUi_t* p = _cmUiHandleToPtr(uiH);
  728. cmUiCId_t cid = kNumberUiCId;
  729. cmUiCtl_t* c;
  730. cmUiPanel_t* pp;
  731. if( cmIsFlag(flags,kVertUiFl|kHorzUiFl) )
  732. {
  733. if( cmIsFlag(flags,kVertUiFl) )
  734. {
  735. if((rc = _cmUiFindPanel(p,panelId,&pp,true)) != kOkUiRC )
  736. return rc;
  737. // if the size of the control was not excplicitly set
  738. // then swap width and height
  739. if( cmIsNotFlag(pp->flags,kNextWHUiFl) && cmIsNotFlag(pp->flags,kUseRectUiFl) )
  740. cmUiSetNextWH( uiH, panelId, cmUiH(uiH,panelId), cmUiW(uiH,panelId) );
  741. }
  742. cid = kSliderUiCId;
  743. }
  744. if(( rc = _cmUiCreateCtl(p,panelId,cid,id,label,flags,&c)) == kOkUiRC )
  745. {
  746. cmUiRC_t rc0;
  747. _cmUiSetDblAccessors(c);
  748. if((rc0 = _cmUiSetDriverValueDouble(p,c,kMinUiFl,min)) != kOkUiRC )
  749. rc = rc0;
  750. if((rc0 = _cmUiSetDriverValueDouble(p,c,kMaxUiFl,max)) != kOkUiRC )
  751. rc = rc0;
  752. if((rc0 = _cmUiSetDriverValueDouble(p,c,kIncUiFl,incr)) != kOkUiRC )
  753. rc = rc0;
  754. if((rc0 = _cmUiSetDriverValueDouble(p,c,kValUiFl,dflt)) != kOkUiRC )
  755. rc = rc0;
  756. }
  757. return rc;
  758. }
  759. cmUiRC_t cmUiCreateNumber( cmUiH_t uiH, unsigned panelId, unsigned id, const cmChar_t* label, unsigned flags, double min, double max, double incr, double dflt )
  760. {
  761. return _cmUiCreateNumber(uiH,panelId,id,label,flags,min,max,incr,dflt);
  762. }
  763. cmUiRC_t cmUiCreateHSlider( cmUiH_t uiH, unsigned panelId, unsigned id, const cmChar_t* label, unsigned flags, double min, double max, double incr, double dflt )
  764. {
  765. return _cmUiCreateNumber(uiH,panelId,id,label,flags | kHorzUiFl, min,max,incr,dflt);
  766. }
  767. cmUiRC_t cmUiCreateVSlider( cmUiH_t uiH, unsigned panelId, unsigned id, const cmChar_t* label, unsigned flags, double min, double max, double incr, double dflt )
  768. {
  769. return _cmUiCreateNumber(uiH,panelId,id,label,flags | kVertUiFl, min,max,incr,dflt);
  770. }
  771. cmUiRC_t cmUiCreateProgress(cmUiH_t uiH, unsigned panelId, unsigned id, const cmChar_t* label, unsigned flags, int min, int max, int dflt )
  772. {
  773. cmUiRC_t rc = kOkUiRC;
  774. cmUi_t* p = _cmUiHandleToPtr(uiH);
  775. cmUiCtl_t* c;
  776. if(( rc = _cmUiCreateCtl(p,panelId,kProgressUiCId,id,label,flags,&c)) == kOkUiRC )
  777. {
  778. cmUiRC_t rc0;
  779. _cmUiSetIntAccessors(c);
  780. if((rc0 = _cmUiSetDriverValueInt(p,c,kMinUiFl,min)) != kOkUiRC )
  781. rc = rc0;
  782. if((rc0 = _cmUiSetDriverValueInt(p,c,kMaxUiFl,max)) != kOkUiRC )
  783. rc = rc0;
  784. if((rc0 = _cmUiSetDriverValueInt(p,c,kValUiFl,dflt)) != kOkUiRC )
  785. rc = rc0;
  786. }
  787. return rc;
  788. }
  789. cmUiRC_t _cmUiCreateMeter( cmUiH_t uiH, unsigned panelId, unsigned id, const cmChar_t* label, unsigned flags, int min, int max, int dflt)
  790. {
  791. cmUiRC_t rc;
  792. cmUi_t* p = _cmUiHandleToPtr(uiH);
  793. cmUiCtl_t* c;
  794. cmUiPanel_t* pp;
  795. if( cmIsFlag(flags,kVertUiFl) )
  796. {
  797. if((rc = _cmUiFindPanel(p,panelId,&pp,true)) != kOkUiRC )
  798. return rc;
  799. // if the size of the control has not been explicitely set
  800. // then swap height and width for vertical meters.
  801. if( cmIsNotFlag(pp->flags,kNextWHUiFl) && cmIsNotFlag(pp->flags,kUseRectUiFl) )
  802. cmUiSetNextWH( uiH, panelId, cmUiH(uiH,panelId), cmUiW(uiH,panelId) );
  803. }
  804. if((rc = _cmUiCreateCtl(p,panelId,kMeterUiCId,id,label,flags,&c)) == kOkUiRC )
  805. {
  806. cmUiRC_t rc0;
  807. _cmUiSetIntAccessors(c);
  808. if((rc0 = _cmUiSetDriverValueInt(p,c,kMinUiFl,min)) != kOkUiRC )
  809. rc = rc0;
  810. if((rc0 = _cmUiSetDriverValueInt(p,c,kMaxUiFl,max)) != kOkUiRC )
  811. rc = rc0;
  812. if((rc0 = _cmUiSetDriverValueInt(p,c,kValUiFl,dflt)) != kOkUiRC )
  813. rc = rc0;
  814. }
  815. return rc;
  816. }
  817. cmUiRC_t cmUiCreateHMeter( cmUiH_t uiH, unsigned panelId, unsigned id, const cmChar_t* label, unsigned flags, int min, int max, int dflt )
  818. {
  819. return _cmUiCreateMeter(uiH,panelId,id,label,flags | kHorzUiFl,min,max,dflt);
  820. }
  821. cmUiRC_t cmUiCreateVMeter( cmUiH_t uiH, unsigned panelId, unsigned id, const cmChar_t* label, unsigned flags, int min, int max, int dflt )
  822. {
  823. return _cmUiCreateMeter(uiH,panelId,id,label,flags | kVertUiFl,min,max,dflt);
  824. }
  825. cmUiRC_t cmUiCreateFileBtn(cmUiH_t uiH, unsigned panelId, unsigned id, const cmChar_t* label, unsigned flags, const cmChar_t* dfltDir, const cmChar_t* patStr )
  826. {
  827. cmUiRC_t rc = kOkUiRC;
  828. cmUi_t* p = _cmUiHandleToPtr(uiH);
  829. cmUiCtl_t* c;
  830. if(( rc = _cmUiCreateCtl(p,panelId,kFilenameUiCId,id,label,flags,&c)) == kOkUiRC )
  831. {
  832. cmUiRC_t rc0;
  833. _cmUiSetStrAccessors(c);
  834. if( dfltDir != NULL )
  835. {
  836. if((rc0 = _cmUiSetDriverValueStr(p,c,kValUiFl,dfltDir)) != kOkUiRC )
  837. rc = rc0;
  838. }
  839. if( patStr != NULL )
  840. {
  841. if((rc0 = _cmUiSetDriverValueStr(p,c,kValUiFl,patStr)) != kOkUiRC )
  842. rc = rc0;
  843. }
  844. }
  845. return rc;
  846. }
  847. cmUiRC_t cmUiCreateDirBtn( cmUiH_t uiH, unsigned panelId, unsigned id, const cmChar_t* label, unsigned flags, const cmChar_t* dfltDir )
  848. {
  849. cmUiRC_t rc = kOkUiRC;
  850. cmUi_t* p = _cmUiHandleToPtr(uiH);
  851. cmUiCtl_t* c;
  852. if(( rc = _cmUiCreateCtl(p,panelId,kDirUiCId,id,label,flags,&c)) == kOkUiRC )
  853. {
  854. cmUiRC_t rc0;
  855. _cmUiSetStrAccessors(c);
  856. if( dfltDir != NULL )
  857. {
  858. if((rc0 = _cmUiSetDriverValueStr(p,c,kValUiFl,dfltDir)) != kOkUiRC )
  859. rc = rc0;
  860. }
  861. }
  862. return rc;
  863. }
  864. cmUiRC_t cmUiCreateMenuBtn( cmUiH_t uiH, unsigned panelId, unsigned id, const cmChar_t* label, unsigned flags )
  865. {
  866. cmUiRC_t rc;
  867. cmUi_t* p = _cmUiHandleToPtr(uiH);
  868. cmUiCtl_t* c;
  869. if((rc = _cmUiCreateCtl(p,panelId,kMenuBtnUiCId,id,label,flags,&c)) == kOkUiRC )
  870. _cmUiSetIntAccessors(c);
  871. return rc;
  872. }
  873. cmUiRC_t cmUiCreateMenuBtnV(cmUiH_t uiH, unsigned panelId, unsigned id, const cmChar_t* label, unsigned flags, const cmChar_t* label0, unsigned id0, va_list vl )
  874. {
  875. cmUiRC_t rc = kOkUiRC;
  876. // TODO:
  877. return rc;
  878. }
  879. cmUiRC_t cmUiCreateMenuBtnA(cmUiH_t uiH, unsigned panelId, unsigned id, const cmChar_t* label, unsigned flags, const cmChar_t* label0, unsigned id0, ... )
  880. {
  881. va_list vl;
  882. va_start(vl,id0);
  883. cmUiRC_t rc = cmUiCreateMenuBtnV(uiH,panelId,id,label,flags,label0,id0,vl);
  884. va_end(vl);
  885. return rc;
  886. }
  887. cmUiRC_t cmUiCreateMenuBtnJson(cmUiH_t uiH, unsigned panelId, unsigned id, const cmChar_t* lavel, unsigned flags, const cmJsonNode_t* root, const cmChar_t* memberLabel )
  888. {
  889. cmUiRC_t rc = kOkUiRC;
  890. // TODO:
  891. return rc;
  892. }
  893. cmUiRC_t cmUiCreateList(cmUiH_t uiH, unsigned panelId, unsigned id, const cmChar_t* label, unsigned flags, unsigned visibleRowCnt )
  894. {
  895. cmUi_t* p = _cmUiHandleToPtr(uiH);
  896. cmUiRC_t rc;
  897. cmUiCtl_t* c;
  898. cmUiPanel_t* pp;
  899. if((rc = _cmUiFindPanel(p,panelId,&pp,true)) != kOkUiRC )
  900. return rc;
  901. if( cmIsNotFlag(pp->flags,kNextWHUiFl) )
  902. cmUiSetNextWH( uiH, panelId, cmUiNextW(uiH,panelId), cmUiH(uiH,panelId) * visibleRowCnt );
  903. if((rc = _cmUiCreateCtl(p,panelId,kListUiCId,id,label,flags,&c)) == kOkUiRC )
  904. _cmUiSetIntAccessors(c);
  905. return rc;
  906. }
  907. cmUiRC_t cmUiCreateListV( cmUiH_t uiH, unsigned panelId, unsigned id, const cmChar_t* label, unsigned flags, unsigned visibleRowCnt, const cmChar_t* label0, unsigned id0, va_list vl )
  908. {
  909. cmUiRC_t rc = kOkUiRC;
  910. // TODO:
  911. return rc;
  912. }
  913. cmUiRC_t cmUiCreateListA( cmUiH_t uiH, unsigned panelId, unsigned id, const cmChar_t* label, unsigned flags, unsigned visibleRowCnt, const cmChar_t* label0, unsigned id0, ... )
  914. {
  915. va_list vl;
  916. va_start(vl,id0);
  917. cmUiRC_t rc = cmUiCreateListV(uiH,panelId,id,label,flags,visibleRowCnt,label0,id0,vl);
  918. va_end(vl);
  919. return rc;
  920. }
  921. cmUiRC_t cmUiCreateListJson( cmUiH_t uiH, unsigned panelId, unsigned id, const cmChar_t* label, unsigned flags, unsigned visibleRowCnt, const cmJsonNode_t* root, const cmChar_t* memberLabel )
  922. {
  923. cmUiRC_t rc = kOkUiRC;
  924. // TODO:
  925. return rc;
  926. }
  927. cmUiRC_t cmUiAppendListEle( cmUiH_t uiH, unsigned panelId, unsigned id, const cmChar_t* text, unsigned eleId )
  928. {
  929. cmUiRC_t rc = kOkUiRC;
  930. cmUi_t* p = _cmUiHandleToPtr(uiH);
  931. cmUiCtl_t* ctl = NULL;
  932. if((rc = _cmUiFindCtl(p,id,&ctl,true)) != kOkUiRC )
  933. return rc;
  934. if( ctl->cId != kListUiCId && ctl->cId != kMenuBtnUiCId )
  935. return cmErrMsg(&p->err,kInvalidCtlOpUiRC,"List elements may only be set on 'list' and 'menu button' controls.");
  936. if( cmArrayIsValid(ctl->idArrH) )
  937. cmArrayPush(ctl->idArrH,&eleId,1);
  938. return _cmUiSetDriverValueIntAndStr(p,ctl,kAppendUiFl,eleId,text);
  939. }
  940. cmUiRC_t cmUiDestroyCtl( cmUiH_t uiH, unsigned id )
  941. {
  942. cmUiRC_t rc = kOkUiRC;
  943. cmUi_t* p = _cmUiHandleToPtr(uiH);
  944. cmUiCtl_t* ctl = NULL;
  945. if((rc = _cmUiFindCtl(p,id,&ctl,true)) == kOkUiRC )
  946. {
  947. if( ctl->cId == kPanelUiCId )
  948. _cmUiDestroyPanel(p,ctl->usrId);
  949. else
  950. rc = _cmUiDestroyCtl(p,ctl);
  951. }
  952. return rc;
  953. }
  954. bool cmUiCtlExists( cmUiH_t uiH, unsigned panelId, unsigned id )
  955. {
  956. cmUi_t* p = _cmUiHandleToPtr(uiH);
  957. if( panelId == id )
  958. {
  959. cmUiPanel_t* pp=NULL;
  960. return _cmUiFindPanel(p, panelId, &pp, false ) == kOkUiRC;
  961. }
  962. cmUiCtl_t* ctl=NULL;
  963. return _cmUiFindCtl(p,id,&ctl,false) == kOkUiRC;
  964. }
  965. cmUiRC_t cmUiClearPanel( cmUiH_t uiH, unsigned panelId )
  966. {
  967. cmUiRC_t rc = kOkUiRC;
  968. cmUi_t* p = _cmUiHandleToPtr(uiH);
  969. cmUiPanel_t* pp = NULL;
  970. // get the panel recd ptr
  971. if((rc = _cmUiFindPanel(p,panelId,&pp,true)) != kOkUiRC )
  972. return rc;
  973. cmUiApp_t* ap = pp->appPtr;
  974. cmUiCtl_t* ctl = NULL;
  975. unsigned i = 0;
  976. unsigned n = cmArrayCount(ap->ctlArrH);
  977. cmUiRC_t rc0;
  978. // Destroy all controls that belong to this panel.
  979. for(i=0; i<n; ++i)
  980. if( _cmUiFindCtl(p,i,&ctl,false) == kOkUiRC && ctl != NULL && ctl->panelId == panelId && ctl->usrId != panelId)
  981. if((rc0 = _cmUiDestroyCtl(p,ctl)) != kOkUiRC )
  982. rc = rc0;
  983. return rc;
  984. }
  985. cmUiRC_t cmUiNextRect( cmUiH_t uiH, unsigned panelId, int x, int y, int w, int h )
  986. {
  987. cmUi_t* p = _cmUiHandleToPtr(uiH);
  988. cmUiPanel_t* pp;
  989. cmUiRC_t rc;
  990. if((rc = _cmUiFindPanel(p, panelId, &pp, true)) != kOkUiRC )
  991. return rc;
  992. pp->rect.x = x;
  993. pp->rect.y = y;
  994. pp->rect.w = w;
  995. pp->rect.h = h;
  996. pp->flags = cmSetFlag(pp->flags,kUseRectUiFl);
  997. return rc;
  998. }
  999. cmUiRC_t cmUiPrevRect( cmUiH_t uiH, unsigned panelId, int* xRef, int* yRef, int* wRef, int* hRef )
  1000. {
  1001. cmUi_t* p = _cmUiHandleToPtr(uiH);
  1002. cmUiPanel_t* pp;
  1003. cmUiRC_t rc;
  1004. if((rc = _cmUiFindPanel(p, panelId, &pp, true)) != kOkUiRC )
  1005. return rc;
  1006. if( xRef != NULL )
  1007. *xRef = pp->prevRect.x;
  1008. if( yRef != NULL )
  1009. *yRef = pp->prevRect.y;
  1010. if( wRef != NULL )
  1011. *wRef = pp->prevRect.w;
  1012. if( hRef != NULL )
  1013. *hRef = pp->prevRect.h;
  1014. return rc;
  1015. }
  1016. bool cmUiFillRows( cmUiH_t uiH, unsigned panelId )
  1017. {
  1018. cmUi_t* p = _cmUiHandleToPtr(uiH);
  1019. cmUiPanel_t* pp;
  1020. if( _cmUiFindPanel(p, panelId, &pp, true) != kOkUiRC )
  1021. return false;
  1022. return cmIsFlag(pp->flags,kFillRowsUiFl);
  1023. }
  1024. bool cmUiSetFillRows( cmUiH_t uiH, unsigned panelId, bool enableFl )
  1025. {
  1026. cmUi_t* p = _cmUiHandleToPtr(uiH);
  1027. cmUiPanel_t* pp;
  1028. if( _cmUiFindPanel(p, panelId, &pp, true) != kOkUiRC )
  1029. return false;
  1030. bool retFl = cmIsFlag(pp->flags,kFillRowsUiFl);
  1031. pp->flags = cmEnaFlag(pp->flags,kFillRowsUiFl,enableFl);
  1032. return retFl;
  1033. }
  1034. void cmUiPlaceRight( cmUiH_t uiH, unsigned panelId )
  1035. {
  1036. cmUi_t* p = _cmUiHandleToPtr(uiH);
  1037. cmUiPanel_t* pp;
  1038. if(_cmUiFindPanel(p, panelId, &pp, true) != kOkUiRC )
  1039. return;
  1040. pp->flags = cmClrFlag(pp->flags,kPlaceBelowUiFl);
  1041. pp->flags = cmSetFlag(pp->flags,kPlaceRightUiFl);
  1042. }
  1043. void cmUiPlaceBelow( cmUiH_t uiH, unsigned panelId )
  1044. {
  1045. cmUi_t* p = _cmUiHandleToPtr(uiH);
  1046. cmUiPanel_t* pp;
  1047. if(_cmUiFindPanel(p, panelId, &pp, true) != kOkUiRC )
  1048. return;
  1049. pp->flags = cmClrFlag(pp->flags,kPlaceRightUiFl);
  1050. pp->flags = cmSetFlag(pp->flags,kPlaceBelowUiFl);
  1051. }
  1052. void cmUiNewLine( cmUiH_t uiH, unsigned panelId )
  1053. {
  1054. cmUiSetBaseRow( uiH, panelId, cmUiPrevB(uiH,panelId) + cmUiNextVBorder(uiH,panelId) );
  1055. cmUiSetBaseCol( uiH, panelId, cmUiBaseCol(uiH,panelId));
  1056. }
  1057. int cmUiBaseCol( cmUiH_t uiH, unsigned panelId )
  1058. {
  1059. cmUi_t* p = _cmUiHandleToPtr(uiH);
  1060. cmUiPanel_t* pp;
  1061. if(_cmUiFindPanel(p, panelId, &pp, true) != kOkUiRC )
  1062. return -1;
  1063. return pp->baseCol;
  1064. }
  1065. int cmUiSetBaseCol( cmUiH_t uiH, unsigned panelId, int x )
  1066. {
  1067. cmUi_t* p = _cmUiHandleToPtr(uiH);
  1068. cmUiPanel_t* pp;
  1069. if( _cmUiFindPanel(p, panelId, &pp, true) != kOkUiRC )
  1070. return -1;
  1071. int bc = pp->baseCol;
  1072. pp->baseCol = x;
  1073. pp->flags = cmSetFlag(pp->flags,kPlaceBaseRowUiFl);
  1074. return bc;
  1075. }
  1076. int cmUiBaseRow( cmUiH_t uiH, unsigned panelId )
  1077. {
  1078. cmUi_t* p = _cmUiHandleToPtr(uiH);
  1079. cmUiPanel_t* pp;
  1080. if(_cmUiFindPanel(p, panelId, &pp, true) != kOkUiRC )
  1081. return -1;
  1082. return pp->baseRow;
  1083. }
  1084. int cmUiSetBaseRow( cmUiH_t uiH, unsigned panelId, int y )
  1085. {
  1086. cmUi_t* p = _cmUiHandleToPtr(uiH);
  1087. cmUiPanel_t* pp;
  1088. cmUiRC_t rc;
  1089. if((rc = _cmUiFindPanel(p, panelId, &pp, true)) != kOkUiRC )
  1090. return -1;
  1091. int br = pp->baseRow;
  1092. pp->baseRow = y;
  1093. return br;
  1094. }
  1095. int cmUiW( cmUiH_t uiH, unsigned panelId )
  1096. {
  1097. cmUi_t* p = _cmUiHandleToPtr(uiH);
  1098. cmUiPanel_t* pp;
  1099. if(_cmUiFindPanel(p, panelId, &pp, true) != kOkUiRC )
  1100. return -1;
  1101. return pp->dfltW;
  1102. }
  1103. int cmUiH( cmUiH_t uiH, unsigned panelId )
  1104. {
  1105. cmUi_t* p = _cmUiHandleToPtr(uiH);
  1106. cmUiPanel_t* pp;
  1107. if(_cmUiFindPanel(p, panelId, &pp, true) != kOkUiRC )
  1108. return -1;
  1109. return pp->dfltH;
  1110. }
  1111. int cmUiSetW( cmUiH_t uiH, unsigned panelId, int w )
  1112. {
  1113. cmUi_t* p = _cmUiHandleToPtr(uiH);
  1114. cmUiPanel_t* pp;
  1115. if(_cmUiFindPanel(p, panelId, &pp, true) != kOkUiRC )
  1116. return -1;
  1117. int rv = pp->dfltW;
  1118. pp->dfltW = w;
  1119. pp->nextW = w;
  1120. return rv;
  1121. }
  1122. int cmUiSetH( cmUiH_t uiH, unsigned panelId, int h )
  1123. {
  1124. cmUi_t* p = _cmUiHandleToPtr(uiH);
  1125. cmUiPanel_t* pp;
  1126. if(_cmUiFindPanel(p, panelId, &pp, true) != kOkUiRC )
  1127. return -1;
  1128. int rv = pp->dfltH;
  1129. pp->dfltH = h;
  1130. pp->nextW = h;
  1131. return rv;
  1132. }
  1133. void cmUiSetWH( cmUiH_t uiH, unsigned panelId, int w, int h )
  1134. {
  1135. cmUi_t* p = _cmUiHandleToPtr(uiH);
  1136. cmUiPanel_t* pp;
  1137. if(_cmUiFindPanel(p, panelId, &pp, true) != kOkUiRC )
  1138. return;
  1139. pp->dfltW = w;
  1140. pp->dfltH = h;
  1141. pp->nextW = w;
  1142. pp->nextH = h;
  1143. }
  1144. int cmUiNextW( cmUiH_t uiH, unsigned panelId )
  1145. {
  1146. cmUi_t* p = _cmUiHandleToPtr(uiH);
  1147. cmUiPanel_t* pp;
  1148. if(_cmUiFindPanel(p, panelId, &pp, true) != kOkUiRC )
  1149. return -1;
  1150. return pp->nextW;
  1151. }
  1152. int cmUiNextH( cmUiH_t uiH, unsigned panelId )
  1153. {
  1154. cmUi_t* p = _cmUiHandleToPtr(uiH);
  1155. cmUiPanel_t* pp;
  1156. if(_cmUiFindPanel(p, panelId, &pp, true) != kOkUiRC )
  1157. return -1;
  1158. return pp->nextH;
  1159. }
  1160. void cmUiSetNextW( cmUiH_t uiH, unsigned panelId, int w )
  1161. { return cmUiSetNextWH( uiH, panelId, w, cmUiNextH(uiH,panelId)); }
  1162. void cmUiSetNextH( cmUiH_t uiH, unsigned panelId, int h )
  1163. { return cmUiSetNextWH( uiH, panelId, cmUiNextW(uiH,panelId), h); }
  1164. void cmUiSetNextWH( cmUiH_t uiH, unsigned panelId, int w, int h )
  1165. {
  1166. cmUi_t* p = _cmUiHandleToPtr(uiH);
  1167. cmUiPanel_t* pp;
  1168. if(_cmUiFindPanel(p, panelId, &pp, true) != kOkUiRC )
  1169. return;
  1170. pp->nextW = w;
  1171. pp->nextH = h;
  1172. pp->flags = cmSetFlag(pp->flags,kNextWHUiFl);
  1173. }
  1174. int cmUiHBorder( cmUiH_t uiH, unsigned panelId )
  1175. {
  1176. cmUi_t* p = _cmUiHandleToPtr(uiH);
  1177. cmUiPanel_t* pp;
  1178. if(_cmUiFindPanel(p, panelId, &pp, true) != kOkUiRC )
  1179. return -1;
  1180. return pp->dfltHBorder;
  1181. }
  1182. int cmUiVBorder( cmUiH_t uiH, unsigned panelId )
  1183. {
  1184. cmUi_t* p = _cmUiHandleToPtr(uiH);
  1185. cmUiPanel_t* pp;
  1186. if(_cmUiFindPanel(p, panelId, &pp, true) != kOkUiRC )
  1187. return -1;
  1188. return pp->dfltVBorder;
  1189. }
  1190. int cmUiSetHBorder( cmUiH_t uiH, unsigned panelId, int w )
  1191. {
  1192. cmUi_t* p = _cmUiHandleToPtr(uiH);
  1193. cmUiPanel_t* pp;
  1194. if(_cmUiFindPanel(p, panelId, &pp, true) != kOkUiRC )
  1195. return -1;
  1196. int rv = pp->dfltHBorder;
  1197. pp->dfltHBorder = w;
  1198. return rv;
  1199. }
  1200. int cmUiSetVBorder( cmUiH_t uiH, unsigned panelId, int h )
  1201. {
  1202. cmUi_t* p = _cmUiHandleToPtr(uiH);
  1203. cmUiPanel_t* pp;
  1204. if(_cmUiFindPanel(p, panelId, &pp, true) != kOkUiRC )
  1205. return -1;
  1206. int rv = pp->dfltVBorder;
  1207. pp->dfltVBorder = h;
  1208. return rv;
  1209. }
  1210. int cmUiNextHBorder( cmUiH_t uiH, unsigned panelId )
  1211. {
  1212. cmUi_t* p = _cmUiHandleToPtr(uiH);
  1213. cmUiPanel_t* pp;
  1214. if(_cmUiFindPanel(p, panelId, &pp, true) != kOkUiRC )
  1215. return -1;
  1216. return pp->nextHBorder;
  1217. }
  1218. int cmUiNextVBorder( cmUiH_t uiH, unsigned panelId )
  1219. {
  1220. cmUi_t* p = _cmUiHandleToPtr(uiH);
  1221. cmUiPanel_t* pp;
  1222. if(_cmUiFindPanel(p, panelId, &pp, true) != kOkUiRC )
  1223. return -1;
  1224. return pp->nextVBorder;
  1225. }
  1226. int cmUiSetNextHBorder( cmUiH_t uiH, unsigned panelId, int w )
  1227. {
  1228. cmUi_t* p = _cmUiHandleToPtr(uiH);
  1229. cmUiPanel_t* pp;
  1230. if(_cmUiFindPanel(p, panelId, &pp, true) != kOkUiRC )
  1231. return -1;
  1232. int rv = pp->nextHBorder;
  1233. pp->nextHBorder = w;
  1234. return rv;
  1235. }
  1236. int cmUiSetNextVBorder( cmUiH_t uiH, unsigned panelId, int h )
  1237. {
  1238. cmUi_t* p = _cmUiHandleToPtr(uiH);
  1239. cmUiPanel_t* pp;
  1240. if(_cmUiFindPanel(p, panelId, &pp, true) != kOkUiRC )
  1241. return -1;
  1242. int rv = pp->nextVBorder;
  1243. pp->nextVBorder = h;
  1244. return rv;
  1245. }
  1246. int cmUiPrevL( cmUiH_t uiH, unsigned panelId )
  1247. {
  1248. cmUi_t* p = _cmUiHandleToPtr(uiH);
  1249. cmUiPanel_t* pp;
  1250. if(_cmUiFindPanel(p, panelId, &pp, true) != kOkUiRC )
  1251. return -1;
  1252. return pp->prevRect.x;
  1253. }
  1254. int cmUiPrevT( cmUiH_t uiH, unsigned panelId )
  1255. {
  1256. cmUi_t* p = _cmUiHandleToPtr(uiH);
  1257. cmUiPanel_t* pp;
  1258. if(_cmUiFindPanel(p, panelId, &pp, true) != kOkUiRC )
  1259. return -1;
  1260. return pp->prevRect.y;
  1261. }
  1262. int cmUiPrevR( cmUiH_t uiH, unsigned panelId )
  1263. {
  1264. cmUi_t* p = _cmUiHandleToPtr(uiH);
  1265. cmUiPanel_t* pp;
  1266. if(_cmUiFindPanel(p, panelId, &pp, true) != kOkUiRC )
  1267. return -1;
  1268. return pp->prevRect.x + pp->prevRect.w;
  1269. }
  1270. int cmUiPrevB( cmUiH_t uiH, unsigned panelId )
  1271. {
  1272. cmUi_t* p = _cmUiHandleToPtr(uiH);
  1273. cmUiPanel_t* pp;
  1274. if(_cmUiFindPanel(p, panelId, &pp, true) != kOkUiRC )
  1275. return -1;
  1276. return pp->prevRect.y + pp->prevRect.h;
  1277. }
  1278. int cmUiPrevW( cmUiH_t uiH, unsigned panelId )
  1279. {
  1280. cmUi_t* p = _cmUiHandleToPtr(uiH);
  1281. cmUiPanel_t* pp;
  1282. if(_cmUiFindPanel(p, panelId, &pp, true) != kOkUiRC )
  1283. return -1;
  1284. return pp->prevRect.w;
  1285. }
  1286. int cmUiPrevH( cmUiH_t uiH, unsigned panelId )
  1287. {
  1288. cmUi_t* p = _cmUiHandleToPtr(uiH);
  1289. cmUiPanel_t* pp;
  1290. if(_cmUiFindPanel(p, panelId, &pp, true) != kOkUiRC )
  1291. return -1;
  1292. return pp->prevRect.h;
  1293. }
  1294. cmUiRC_t cmUiSetInt( cmUiH_t uiH, unsigned id, int v )
  1295. {
  1296. cmUi_t* p = _cmUiHandleToPtr(uiH);
  1297. cmUiCtl_t* ctl;
  1298. cmUiRC_t rc;
  1299. if((rc = _cmUiFastFindCtl(p,id,&ctl,true)) != kOkUiRC )
  1300. return rc;
  1301. return _cmUiSetDriverValueInt(p,ctl,kValUiFl,v);
  1302. }
  1303. cmUiRC_t cmUiSetUInt( cmUiH_t uiH, unsigned id, unsigned v )
  1304. {
  1305. cmUi_t* p = _cmUiHandleToPtr(uiH);
  1306. cmUiCtl_t* ctl;
  1307. cmUiRC_t rc;
  1308. if((rc = _cmUiFastFindCtl(p,id,&ctl,true)) != kOkUiRC )
  1309. return rc;
  1310. return _cmUiSetDriverValueInt(p,ctl,kValUiFl,v);
  1311. }
  1312. cmUiRC_t cmUiSetDouble( cmUiH_t uiH, unsigned id, double v )
  1313. {
  1314. cmUi_t* p = _cmUiHandleToPtr(uiH);
  1315. cmUiCtl_t* ctl;
  1316. cmUiRC_t rc;
  1317. if((rc = _cmUiFastFindCtl(p,id,&ctl,true)) != kOkUiRC )
  1318. return rc;
  1319. return _cmUiSetDriverValueDouble(p,ctl,kValUiFl,v);
  1320. }
  1321. cmUiRC_t cmUiSetString( cmUiH_t uiH, unsigned id, const cmChar_t* v )
  1322. {
  1323. cmUi_t* p = _cmUiHandleToPtr(uiH);
  1324. cmUiCtl_t* ctl;
  1325. cmUiRC_t rc;
  1326. if((rc = _cmUiFastFindCtl(p,id,&ctl,true)) != kOkUiRC )
  1327. return rc;
  1328. return _cmUiSetDriverValueStr(p,ctl,kValUiFl,v);
  1329. }
  1330. int cmUiInt( cmUiH_t uiH, unsigned id )
  1331. {
  1332. cmUi_t* p = _cmUiHandleToPtr(uiH);
  1333. cmUiCtl_t* ctl;
  1334. cmUiRC_t rc;
  1335. if((rc = _cmUiFastFindCtl(p,id,&ctl,true)) != kOkUiRC )
  1336. return 0;
  1337. return ctl->getInt(ctl);
  1338. }
  1339. unsigned cmUiUInt( cmUiH_t uiH, unsigned id )
  1340. {
  1341. cmUi_t* p = _cmUiHandleToPtr(uiH);
  1342. cmUiCtl_t* ctl;
  1343. cmUiRC_t rc;
  1344. if((rc = _cmUiFastFindCtl(p,id,&ctl,true)) != kOkUiRC )
  1345. return 0;
  1346. return ctl->getInt(ctl);
  1347. }
  1348. double cmUiDouble( cmUiH_t uiH, unsigned id )
  1349. {
  1350. cmUi_t* p = _cmUiHandleToPtr(uiH);
  1351. cmUiCtl_t* ctl;
  1352. cmUiRC_t rc;
  1353. if((rc = _cmUiFastFindCtl(p,id,&ctl,true)) != kOkUiRC )
  1354. return 0;
  1355. return ctl->getDbl(ctl);
  1356. }
  1357. const cmChar_t* cmUiString( cmUiH_t uiH, unsigned id )
  1358. {
  1359. cmUi_t* p = _cmUiHandleToPtr(uiH);
  1360. cmUiCtl_t* ctl;
  1361. cmUiRC_t rc;
  1362. if((rc = _cmUiFastFindCtl(p,id,&ctl,true)) != kOkUiRC )
  1363. return 0;
  1364. return ctl->getStr(ctl);
  1365. }
  1366. cmUiRC_t cmUiLastRC( cmUiH_t uiH )
  1367. {
  1368. cmUi_t* p = _cmUiHandleToPtr(uiH);
  1369. return cmErrLastRC(&p->err);
  1370. }
  1371. cmUiRC_t cmUiSetRC( cmUiH_t uiH, cmUiRC_t rc )
  1372. {
  1373. cmUi_t* p = _cmUiHandleToPtr(uiH);
  1374. return cmErrSetRC(&p->err, rc);
  1375. }