Team Ai
Datasetpublic

hschumann2/TempleOS-Source-Code

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes847downloads
PullDownMenu.txt91 linesDownload Raw Back to Demo
1 2//See Menus3 4#define M_OPTION1       15#define M_OPTION2       26 7U0 PullDownMenuDemo()8{9  I64 msg_code,arg1,arg2;10  CMenuEntry *tmpse;11 12  MenuPush(13        "File {"14        "  Open(,'O');"15        "  Save(,'S');"16        "  Exit(,CH_SHIFT_ESC);"17        "}"18        "Edit {"19        "  Cut(,,SC_DELETE|SCF_SHIFT);"20        "  Paste(,,SC_INS|SCF_SHIFT);"21        "}"22        "Misc {"23        "  Beep(,CH_SPACE);"24        "  Opt1(MSG_CMD,M_OPTION1);"25        "  Opt2(MSG_CMD,M_OPTION2);"26        "}"27        "Help {"28        "  Help(,,0x3B0000003B);"29        "  About(,,0x23B0000023B);"30        "}");31 32  "A pull-down menu will appear "33        "if you move the mouse to the top "34        "of the scrn.\n\n";35 36  do {37    msg_code=GetMsg(&arg1,&arg2,1<<MSG_KEY_DOWN+1<<MSG_CMD);38    "\nCmd:%d ARG1:%X ARG2:%X\n\n",msg_code,arg1,arg2;39 40    switch (msg_code) {41      case MSG_KEY_DOWN:42        switch (arg1) {//ASCII43          case CH_SPACE:44            Beep;45            break;46          case 0:47            switch (arg2.u8[0]) {//arg2=Scan code48              case SC_F1:49                if (arg2&SCF_SHIFT)50                  "About PullDown Demo\n";51                else52                  "Test the menu.\n";53                break;54              case SC_DELETE:55                if (arg2&SCF_SHIFT)56                  "Cut\n";57                break;58              case SC_INS:59                if (arg2&SCF_SHIFT)60                  "Paste\n";61                break;62            }63            break;64        }65        break;66 67      case MSG_CMD:68//I Recommend making your menu69      //drive by key strokes, but you can70      //use the MSG_CMD val.71        switch (arg1) {72          case M_OPTION1:73            "Option # 1\n";74            if (tmpse=MenuEntryFind(Fs->cur_menu,"Misc/Opt1"))75              tmpse->checked=!tmpse->checked;76            break;77          case M_OPTION2:78            "Option # 2\n";79            if (tmpse=MenuEntryFind(Fs->cur_menu,"Misc/Opt2"))80              tmpse->checked=!tmpse->checked;81            break;82        }83        break;84    }85 86  } while (msg_code!=MSG_KEY_DOWN||(arg1!=CH_SHIFT_ESC && arg1!=CH_ESC));87  MenuPop;88}89 90PullDownMenuDemo;91