menu_dialog_t *menu_dialog_new(const char *question, void (*yes_func)(), void (*no_func)()) { menu_dialog_t *dialog = new_dialog(question); dialog->selections[0] = menu_label("Yes"); dialog->selections[1] = menu_label("No"); dialog->selection_funcs[0] = yes_func; dialog->selection_funcs[1] = no_func; dialog->active_selections = 2; return dialog; }
menu_dialog_t *menu_dialog_new_message(const char *message) { menu_dialog_t *dialog = new_dialog(message); dialog->selections[0] = menu_label("Ok"); dialog->active_selections = 1; return dialog; }
void SelectFileScreen::LoadFavsMenu() { m_FavDirVec.clear(); selectFileUI->favsMenuButton->clear(); selectFileUI->favsMenuButton->add("Add to Favorites"); selectFileUI->favsMenuButton->add("Delete All Favorites", 0, NULL, (void*)0, FL_MENU_DIVIDER ); //==== Preferences ====// Fl_Preferences prefs( Fl_Preferences::USER, "NASA", "VSP"); //==== Load All Favorites From Preferences ====// char tag[256], str[256]; bool keep_looking = true; while ( keep_looking ) { keep_looking = false; sprintf( tag, "fav%d", (int)m_FavDirVec.size() ); if ( prefs.get( tag, str, "", 256 ) ) { keep_looking = true; m_FavDirVec.push_back( Stringc(str) ); Stringc menu_label(str); menu_label.insert_string_at( 0, "/" ); selectFileUI->favsMenuButton->add( menu_label ); } } }
// // // System setup menu // // void misc_setup(u08 force_menu) { #ifdef MENU_CODE u08 bl; u08 sound; u08 invert; u08 clock; // load backlight value in EEPROM bl = eeprom_read_byte((uint8_t *) EE_BACKLIGHT); // validate the sound value in EEPROM sound = eeprom_read_byte((uint8_t *) EE_SOUND); if(sound == 'N') sound = 1; else if(sound == 'F') sound = 0; else { force_menu = 1; sound = 1; } // validate the time value in EEPROM clock = eeprom_read_byte((uint8_t *) EE_SET_TIME); if(clock == 'N') clock = 1; else if(clock == 'F') clock = 0; else { force_menu = 1; clock = 0; } // validate the button color value in EEPROM invert = eeprom_read_byte((uint8_t *) EE_INVERT_BUT); if((invert != 0x00) && (invert != 0xFF)) { force_menu = 1; invert = 0xFF; } time_not_set = 1; if(force_menu == 0) goto use_params; MENU_INIT do { MENU_CONTROLS if((COLS < 160) || (ROWS < 80)) { menu_label (0,0, PS("Misc Setup")); menu_checkbox (1*CHAR_WIDTH-4, (CHAR_HEIGHT+CHAR_HEIGHT/2)*1, PS("Backlight"), bl, 1); menu_checkbox (1*CHAR_WIDTH-4, (CHAR_HEIGHT+CHAR_HEIGHT/2)*2, PS("Beeper"), sound, 2); menu_checkbox (1*CHAR_WIDTH-4, (CHAR_HEIGHT+CHAR_HEIGHT/2)*3, PS("Invert buttons"), invert, 3); #ifdef TIME_CLOCK menu_checkbox (1*CHAR_WIDTH-4, (CHAR_HEIGHT+CHAR_HEIGHT/2)*4, PS("Set clock"), clock, 4); #endif menu_exitbutton(); } else { menu_label (0,0, PS("Misc Setup Menu")); menu_checkbox (4*CHAR_WIDTH, CHAR_HEIGHT*2, PS("Backlight"), bl, 1); menu_checkbox (4*CHAR_WIDTH, CHAR_HEIGHT*4, PS("Beeper"), sound, 2); menu_checkbox (4*CHAR_WIDTH, CHAR_HEIGHT*6, PS("Invert buttons"), invert, 3); #ifdef TIME_CLOCK menu_checkbox (4*CHAR_WIDTH, CHAR_HEIGHT*8, PS("Set clock"), clock, 4); #endif menu_exitbutton(); } MENU_COMMANDS // menu button/control responses switch(menu_cmd()) { case 1: break; case 2: break; case 3: break; case 4: #ifdef TIME_CLOCK if(clock) { menu_call(set_time); time_not_set = 0; } #endif break; } } while(menu_cmd() != MENU_EXITCODE) ; // repeat until exit command wait_while_touched(); if(bl) bl = 0xFF; //!!! eeprom_write_byte((uint8_t *) EE_BACKLIGHT, bl); if(sound) eeprom_write_byte((uint8_t *) EE_SOUND, (uint8_t) 'N'); else eeprom_write_byte((uint8_t *) EE_SOUND, (uint8_t) 'F'); if(invert) eeprom_write_byte((uint8_t *) EE_INVERT_BUT, (uint8_t) 0xFF); else eeprom_write_byte((uint8_t *) EE_INVERT_BUT, (uint8_t) 0x00); if(clock) eeprom_write_byte((uint8_t *) EE_SET_TIME, (uint8_t) 'N'); else eeprom_write_byte((uint8_t *) EE_SET_TIME, (uint8_t) 'F'); use_params: lcd_backlight(bl); #ifdef TIME_CLOCK if(eeprom_read_byte((uint8_t *) EE_SET_TIME) == 'N') { if(time_not_set) set_time(); } #endif if(sound) beep_disabled = 0; else beep_disabled = 1; if(invert) invert_buttons = WHITE; else invert_buttons = 0x00; #endif }
u08 ve_update(void ) // do we need param? { COORD mds; u08 cmd; if (vePort == -1) { // LCD GUI MENU_CONTROLS menu_exitbutton(); mds = (CHAR_WIDTH*BUTTON_SIZE) + ButtonBorder + ButtonRowSpacing; //!!! ButtonBorder*2 #ifdef RES_128x64 menu_label (0,0,PS("Var Editor")); menu_buttonrow(5,XROWS-(CHAR_HEIGHT+6), PS("G \xAE\xAF #WR")); menu_button (5+mds*6,XROWS-CHAR_HEIGHT*4+2, PS("+"),'+'); menu_button (5+mds*7,XROWS-CHAR_HEIGHT*4+2, PS("-"),'-'); #else menu_label (0,0,PS("Variable Editor")); menu_buttonrow(5,XROWS-(CHAR_HEIGHT+6), PS("G \xAE\xAF # WR")); menu_button (5+mds*8,XROWS-CHAR_HEIGHT*4-6, PS("+"),'+'); menu_button (5+mds*9,XROWS-CHAR_HEIGHT*4-6, PS("-"),'-'); #endif varedit_slider(); if(MenuDraw) ve_setflag (veDO_REFRESH); // if MenuDraw (set by menu_init) then screen was cleared and controls just // redrawn, so redraw current variable MENU_COMMANDS cmd = menu_cmd(); } else // Serial Console { MenuCmd = 0; // make sure disabled cmd = 0; switch (vePort) { case 0 : if (rx_haschar()) {cmd = rx_getchar(); beep(20,1000); } break; case 1 : if (rx1_haschar()) {cmd = rx1_getchar(); beep(20,1000); } break; } if ((cmd>='a') && (cmd<='z')) cmd -=32; // shift to uppercase // handle numeric entry using local buffer if ((cmd>='0') && (cmd<='9') && (veBufIndex < VE_BUF_SIZE)) { veBuf[veBufIndex++] = cmd; printf("%c",cmd); // echo character cmd = 0; // prevent refresh (display of group / var) } // handle backspace if ((cmd ==8) && (veBufIndex>0)) { veBufIndex--; printf("%c",cmd); cmd = 0; // prevent refresh } if (cmd==13) { veStoreSerialBuffer=1; // leave cmd alone to force refresh } } // menu button/control responses switch(cmd) { case 1 : // slider ve_setflag(veUPDATE_FROM_SLIDER); // current var will set to slider value break; // on next call to ve_process() // select next group case 'G' : if(++veCurGroup>veGroupCount) veCurGroup=1; veCurVar = 1; veCurVal = MAXLONG; ve_setflag(veCOUNT_VARS); ve_process(); ve_clrflag(veCOUNT_VARS); break; // next group // select previous / next variable // special arrow characters 0xAE <- 0xAF -> case '<':; // greater than or ".' char (for Serial Console Support) case ',':; case 0xAE: if(veVarCount && (--veCurVar==0)) veCurVar=veVarCount; break; // prev variable case '>':; case '.':; case 0xAF: if(veVarCount && (++veCurVar>veVarCount)) veCurVar=1; break; // next variable case '=':; case '+': veDelta = ( 1); break; // flag for inc/dec of current variable case '_':; case '-': veDelta = (-1); break; case '#': ve_setflag(veCALL_INPUT_DIALOG); break; // flag case 'W': case 'R': ve_read_write(cmd,1); // do 'R'-Read or 'W'-Write of vars from/to EEPROM menu_init(); ve_setflag(veDO_REFRESH); break; case 'X': MenuCmd = MENU_EXITCODE; // Close Variable Editor (Remote Serial Console) printf (PS("Exit. Thank You for using Megadonkey Variable Editor\n")); break; } if(ve_flag(veDO_REFRESH) || (((cmd!=0)||menu_cmd()) && (menu_cmd() != MENU_EXITCODE))) { if(ve_flag(veDO_REFRESH)) { ve_setflag(veCOUNT_VARS); // do a variable count pass through list ve_process(); // really this could be done one time with static defs ve_clrflag(veCOUNT_VARS); // thinking toward dynamic list ve_clrflag(veDO_REFRESH); } if (vePort==-1) // output to LCD { // if 'G' command erase group label and variable label // if not just erase variable label set_color(color ^ WHITE); if(menu_cmd() == 'G') { filled_box(0,CHAR_HEIGHT*3/2,XCOLS-1, CHAR_HEIGHT*3/2+CHAR_HEIGHT-1); } #ifdef RES_128x64 filled_box(0,CHAR_HEIGHT*3, XCOLS-1,CHAR_HEIGHT*4-1); #else filled_box(0,CHAR_HEIGHT*4, XCOLS-1,CHAR_HEIGHT*5-1); #endif set_color(color ^ WHITE); ve_process(); // update display of current var & update slider vals mds = MenuDraw; // save MenuDraw state MenuDraw = 1; // force redraw of slider varedit_slider(); MenuDraw = mds; // restore MenuDraw state } else // Output to Serial Port { if (cmd != 0) ve_process(); // update display of current var : output to serial port } } if ((menu_cmd() == MENU_EXITCODE) && (vePort != -1)) { lcd_set_stdout(); // ASSUME LCD was connected to std out (maybe should have saved state) printf (PS("VE Exit")); } return (menu_cmd() != MENU_EXITCODE); // return TRUE unless close [X] }