|
@@ -1702,7 +1702,8 @@ cmDspClass_t* cmMeterClassCons( cmDspCtx_t* ctx )
|
1702
|
1702
|
enum
|
1703
|
1703
|
{
|
1704
|
1704
|
kInLbId,
|
1705
|
|
- kAlignLbId
|
|
1705
|
+ kAlignLbId,
|
|
1706
|
+ kTextLbId
|
1706
|
1707
|
};
|
1707
|
1708
|
|
1708
|
1709
|
cmDspClass_t _cmLabelDC;
|
|
@@ -1710,27 +1711,68 @@ cmDspClass_t _cmLabelDC;
|
1710
|
1711
|
typedef struct
|
1711
|
1712
|
{
|
1712
|
1713
|
cmDspInst_t inst;
|
|
1714
|
+ cmChar_t* label;
|
1713
|
1715
|
} cmDspLabel_t;
|
1714
|
1716
|
|
1715
|
1717
|
cmDspInst_t* _cmDspLabelAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsigned storeSymId, unsigned instSymId, unsigned id, unsigned va_cnt, va_list vl )
|
1716
|
1718
|
{
|
1717
|
|
- cmDspVarArg_t args[] =
|
|
1719
|
+ const unsigned argCnt = 3;
|
|
1720
|
+ cmDspVarArg_t args[argCnt+1];
|
|
1721
|
+ cmChar_t* label = NULL;
|
|
1722
|
+ unsigned align = kLeftAlignDuiId;
|
|
1723
|
+ va_list vl1;
|
|
1724
|
+
|
|
1725
|
+ va_copy(vl1,vl);
|
|
1726
|
+
|
|
1727
|
+ if( va_cnt < 1 )
|
1718
|
1728
|
{
|
1719
|
|
- { "in", kInLbId, 0, 0, kInDsvFl | kStrzDsvFl | kReqArgDsvFl, "LabelText" },
|
1720
|
|
- { "align",kAlignLbId, 0, 0, kInDsvFl | kUIntDsvFl | kOptArgDsvFl, "Alignment 0=right 1=left 2=center" },
|
1721
|
|
- { NULL, 0, 0, 0, 0 }
|
1722
|
|
- };
|
|
1729
|
+ va_end(vl1);
|
|
1730
|
+ cmDspClassErr(ctx,classPtr,kVarArgParseFailDspRC,"The 'label' constructor argument list must contain at least one argument.");
|
|
1731
|
+ return NULL;
|
|
1732
|
+ }
|
|
1733
|
+
|
|
1734
|
+ // get the default label
|
|
1735
|
+ const char* clabel = va_arg(vl,const char*);
|
|
1736
|
+ if( clabel != NULL && strlen(clabel) > 0 )
|
|
1737
|
+ {
|
|
1738
|
+ label = cmLhAllocStr(ctx->lhH,clabel);
|
|
1739
|
+ printf("%s\n",label);
|
|
1740
|
+ }
|
|
1741
|
+
|
|
1742
|
+ // if an alignment id was provided
|
|
1743
|
+ if( va_cnt > 1 )
|
|
1744
|
+ align = va_arg(vl,double);
|
|
1745
|
+
|
|
1746
|
+ // setup the arg. config. array.
|
|
1747
|
+ cmDspArgSetup(ctx,args+0,"in", cmInvalidId, kInLbId, 0,0, kInDsvFl | kTypeDsvMask, "Input to set label" );
|
|
1748
|
+ cmDspArgSetup(ctx,args+1,"align",cmInvalidId, kAlignLbId, 0,0, kInDsvFl | kUIntDsvFl, "Justification: 0=right 1=center 2=left" );
|
|
1749
|
+ cmDspArgSetup(ctx,args+2,"text", cmInvalidId, kTextLbId, 0,0, kInDsvFl | kStrzDsvFl, "Label text");
|
|
1750
|
+ cmDspArgSetupNull(args + argCnt);
|
1723
|
1751
|
|
1724
|
|
- cmDspLabel_t* p = cmDspInstAlloc(cmDspLabel_t,ctx,classPtr,args,instSymId,id,storeSymId,va_cnt,vl);
|
|
1752
|
+ // create the instance
|
|
1753
|
+ cmDspLabel_t* p = cmDspInstAlloc(cmDspLabel_t,ctx,classPtr,args,instSymId,id,storeSymId,0,vl1);
|
1725
|
1754
|
|
1726
|
|
- cmDspSetDefaultDouble(ctx, &p->inst, kAlignLbId, 0.0, kLeftAlignDuiId);
|
|
1755
|
+ p->label = label;
|
1727
|
1756
|
|
|
1757
|
+ // set the default variable values
|
|
1758
|
+ cmDspSetDefaultDouble(ctx, &p->inst, kAlignLbId, 0.0, align);
|
|
1759
|
+ cmDspSetDefaultStrcz( ctx, &p->inst, kTextLbId, NULL, label==NULL ? "" : label );
|
|
1760
|
+
|
1728
|
1761
|
// create the UI control
|
1729
|
|
- cmDspUiLabelCreate(ctx,&p->inst,kInLbId,kAlignLbId);
|
|
1762
|
+ cmDspUiLabelCreate(ctx,&p->inst,kTextLbId,kAlignLbId);
|
1730
|
1763
|
|
|
1764
|
+ va_end(vl1);
|
|
1765
|
+
|
1731
|
1766
|
return &p->inst;
|
1732
|
1767
|
}
|
1733
|
1768
|
|
|
1769
|
+cmDspRC_t _cmDspLabelFree(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
|
|
1770
|
+{
|
|
1771
|
+ cmDspLabel_t* p = (cmDspLabel_t*)inst;
|
|
1772
|
+ cmLhFree(ctx->lhH,p->label);
|
|
1773
|
+ return kOkDspRC;
|
|
1774
|
+}
|
|
1775
|
+
|
1734
|
1776
|
cmDspRC_t _cmDspLabelReset(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
|
1735
|
1777
|
{
|
1736
|
1778
|
cmDspApplyAllDefaults(ctx,inst);
|
|
@@ -1739,6 +1781,21 @@ cmDspRC_t _cmDspLabelReset(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t*
|
1739
|
1781
|
|
1740
|
1782
|
cmDspRC_t _cmDspLabelRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
|
1741
|
1783
|
{
|
|
1784
|
+ const unsigned bN = 128;
|
|
1785
|
+ cmChar_t b[ bN+1 ];
|
|
1786
|
+
|
|
1787
|
+ // if this event is arriving on the 'in' port ...
|
|
1788
|
+ if( evt->dstVarId == kInLbId )
|
|
1789
|
+ {
|
|
1790
|
+ cmDspLabel_t* p = (cmDspLabel_t*)inst;
|
|
1791
|
+ // ... then convert it to a string
|
|
1792
|
+ cmDsvToString( evt->valuePtr, p->label, b, bN );
|
|
1793
|
+
|
|
1794
|
+ // and set the 'label' variable
|
|
1795
|
+ return cmDspSetStrcz(ctx, inst, kTextLbId, b );
|
|
1796
|
+ }
|
|
1797
|
+
|
|
1798
|
+
|
1742
|
1799
|
return cmDspSetEvent(ctx,inst,evt);
|
1743
|
1800
|
}
|
1744
|
1801
|
|
|
@@ -1747,7 +1804,7 @@ cmDspClass_t* cmLabelClassCons( cmDspCtx_t* ctx )
|
1747
|
1804
|
cmDspClassSetup(&_cmLabelDC,ctx,"Label",
|
1748
|
1805
|
NULL,
|
1749
|
1806
|
_cmDspLabelAlloc,
|
1750
|
|
- NULL,
|
|
1807
|
+ _cmDspLabelFree,
|
1751
|
1808
|
_cmDspLabelReset,
|
1752
|
1809
|
NULL,
|
1753
|
1810
|
_cmDspLabelRecv,
|