Team Ai
Datasetpublic

hschumann2/TempleOS-Source-Code

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes847downloads
MenuBttn.txt77 linesDownload Raw Back to DolDoc
1 2//This example shows bttns.  Bttns return a menu val3//unless you rig them to send macros.  Menu entries are4//about the same as bttns, but don't have a border.5 6I64 PopUpFreq()7{//See also PopUpRangeI64()8  I64 i;9  CDoc *doc=DocNew;10  DocPrint(doc,"$TX+CX,\"Set Freq\"$\n" //Centered text11        "$CM+LX,2,4$$BT,\"100 Hz\",LE=100$"12        "$CM+LX,18,0$$BT,\"200 Hz\",LE=200$"13        "$CM+LX,2,4$$BT,\"400 Hz\",LE=400$"14        "$CM+LX,18,0$$BT,\"800 Hz\",LE=800$\n");15  i=PopUpMenu(doc);16  if (i<0) i=0; // <SHIFT-ESC>17  DocDel(doc);18  return i;19}20 21#define MU_NOTHING      022#define MU_SET_FREQ     123#define MU_SND_ON       224#define MU_SND_OFF      325 26U0 MenuBttn()27{28  Bool done=FALSE;29  I64 i,j=0,freq=100;30  I64 old_flags=DocPut->flags;31//This allows keyboard navigation to skip nonselible entries.32  DocPut->flags|=DOCF_FORM;33  do {34    DocClear;35//Use <CTRL-l> to generate cursor movement expressions and check "Quote".36    "$CM+CX-RE,-4$Menu Demo\n\n";37    "$LM,8$"; //Set left margin38//These are bttns that return a val from a menu selection.39    if (!j)40      "\n$BT,\"Snd On\",LE=MU_SND_ON$\n\n\n";41    else42      "\n$BT,\"Snd Off\",LE=MU_SND_OFF$\n\n\n";43    "\n$BT,\"Set Freq\",LE=MU_SET_FREQ$\n\n\n"44          "\n$BT,\"Nothing\",LE=MU_NOTHING$\n\n\n"45          "\n$BT,\"Done\",LE=DOCM_CANCEL$\n\n\n";46    i=DocMenu(DocPut);47    DocBottom;48    switch (i) {49      case MU_NOTHING:50        break;51      case MU_SND_ON:52        j=freq;53        Snd(Freq2Ona(j));54        break;55      case MU_SND_OFF:56        j=0;57        Snd;58        break;59      case MU_SET_FREQ:60        freq=PopUpFreq;61        if (j) {62          j=freq;63          Snd(Freq2Ona(j));64        }65        break;66      default:67        done=TRUE;68    }69  } while (!done);70  DocPut->flags=DocPut->flags&~DOCF_FORM |71        old_flags & DOCF_FORM;72  DocClear;73  Snd;74}75 76MenuBttn;77