? archos-sim ? h300-sim ? yesno.patch Index: apps/gui/yesno.c =================================================================== RCS file: /cvsroot/rockbox/apps/gui/yesno.c,v retrieving revision 1.4 diff -u -r1.4 yesno.c --- apps/gui/yesno.c 21 Jan 2006 23:43:57 -0000 1.4 +++ apps/gui/yesno.c 7 Feb 2006 01:21:23 -0000 @@ -3,6 +3,10 @@ #include "kernel.h" #include "misc.h" #include "lang.h" + +#if defined(HAVE_LCD_BITMAP) +#define USING_NEW_STYLE_YESNO +#endif void gui_yesno_init(struct gui_yesno * yn, struct text_message * main_message, @@ -21,10 +25,15 @@ yn->display=display; } -void gui_yesno_draw(struct gui_yesno * yn) +void gui_yesno_draw(struct gui_yesno * yn, bool no_selected) { struct screen * display=yn->display; - int nb_lines, line_shift=0; + int nb_lines, line_shift=0; +#ifdef USING_NEW_STYLE_YESNO + int text_y, text_x_yes, text_x_no; + int yes_width = display->getstringsize(str(LANG_SET_BOOL_YES),0,0); + int no_width = display->getstringsize(str(LANG_SET_BOOL_NO),0,0); +#endif #ifdef HAS_LCD_BITMAP screen_set_xmargin(display, 0); #endif @@ -34,15 +43,29 @@ if(nb_lines+3nb_lines) line_shift=1; nb_lines=gui_textarea_put_message(display, yn->main_message, line_shift); - +#ifdef USING_NEW_STYLE_YESNO /* Space remaining for yes / no text ? */ if(nb_lines+line_shift+2<=display->nb_lines) - { - if(nb_lines+line_shift+3<=display->nb_lines) - nb_lines++; - display->puts(0, nb_lines+line_shift, str(LANG_CONFIRM_WITH_PLAY_RECORDER)); - display->puts(0, nb_lines+line_shift+1, str(LANG_CANCEL_WITH_ANY_RECORDER)); - } + nb_lines +=line_shift+2; + + text_y = display->char_height*nb_lines; + text_x_yes = (display->width/2)-yes_width-(display->char_width*2); + text_x_no = (display->width/2)+(display->char_width*2); + display->putsxy(text_x_yes,text_y,str(LANG_SET_BOOL_YES)); + display->putsxy(text_x_no,text_y,str(LANG_SET_BOOL_NO)); + + display->set_drawmode(DRMODE_COMPLEMENT); + display->fillrect((no_selected?text_x_no:text_x_yes)-3,text_y-3,(no_selected?no_width:yes_width)+6,display->char_height+6); + display->set_drawmode(DRMODE_SOLID); +#else /* use old style */ + if(nb_lines+line_shift+2<=display->nb_lines) + { + if(nb_lines+line_shift+3<=display->nb_lines) + nb_lines++; + display->puts(0, nb_lines+line_shift, str(LANG_CONFIRM_WITH_PLAY_RECORDER)); + display->puts(0, nb_lines+line_shift+1, str(LANG_CANCEL_WITH_ANY_RECORDER)); + } +#endif gui_textarea_update(display); } @@ -63,24 +86,51 @@ unsigned button; int result=-1; bool result_displayed; - struct gui_yesno yn[NB_SCREENS]; - FOR_NB_SCREENS(i) - { - gui_yesno_init(&(yn[i]), main_message, yes_message, no_message); - gui_yesno_set_display(&(yn[i]), &(screens[i])); - gui_yesno_draw(&(yn[i])); - } + struct gui_yesno yn[NB_SCREENS]; + int no_selected = 1; + while (result==-1) { + FOR_NB_SCREENS(i) + { + gui_yesno_init(&(yn[i]), main_message, yes_message, no_message); + gui_yesno_set_display(&(yn[i]), &(screens[i])); + gui_yesno_draw(&(yn[i]),no_selected); + } button = button_get(true); switch (button) - { + { + +#ifdef USING_NEW_STYLE_YESNO +#if (CONFIG_KEYPAD == IPOD_4G_PAD) + case BUTTON_SCROLL_FWD: + no_selected=1; + break; + case BUTTON_SCROLL_BACK: + no_selected=0; + break; +#else + case BUTTON_RIGHT: + no_selected=1; + break; + case BUTTON_LEFT: + no_selected=0; + break; +#endif case YESNO_OK: #ifdef YESNO_RC_OK case YESNO_RC_OK: -#endif - result=YESNO_YES; - break; +#endif + result=no_selected?YESNO_NO:YESNO_YES; +#else /* old style */ + case YESNO_OK: +#ifdef YESNO_RC_OK + case YESNO_RC_OK: +#endif + (void)no_selected; + result = YESNO_YES; +#endif /* new/old style? */ + break; default: if(default_event_handler(button) == SYS_USB_CONNECTED) @@ -88,7 +138,9 @@ if(!(button & BUTTON_REL)) result=YESNO_NO; } - } + } + + FOR_NB_SCREENS(i) result_displayed=gui_yesno_draw_result(&(yn[i]), result); if(result_displayed) Index: apps/gui/yesno.h =================================================================== RCS file: /cvsroot/rockbox/apps/gui/yesno.h,v retrieving revision 1.5 diff -u -r1.5 yesno.h --- apps/gui/yesno.h 5 Feb 2006 21:18:19 -0000 1.5 +++ apps/gui/yesno.h 7 Feb 2006 01:21:23 -0000 @@ -7,7 +7,8 @@ #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \ (CONFIG_KEYPAD == IRIVER_H300_PAD) #define YESNO_OK BUTTON_SELECT -#define YESNO_RC_OK BUTTON_RC_MENU +#define YESNO_RC_OK BUTTON_RC_MENU + #elif CONFIG_KEYPAD == RECORDER_PAD #define YESNO_OK BUTTON_PLAY @@ -18,19 +19,19 @@ #define YESNO_RC_OK BUTTON_RC_PLAY #elif CONFIG_KEYPAD == ONDIO_PAD -#define YESNO_OK BUTTON_RIGHT +#define YESNO_OK BUTTON_MENU #elif CONFIG_KEYPAD == GMINI100_PAD #define YESNO_OK BUTTON_PLAY #elif (CONFIG_KEYPAD == IPOD_3G_PAD) || (CONFIG_KEYPAD == IPOD_4G_PAD) -#define YESNO_OK BUTTON_RIGHT +#define YESNO_OK BUTTON_SELECT #elif (CONFIG_KEYPAD == IRIVER_IFP7XX_PAD) -#define YESNO_OK BUTTON_RIGHT +#define YESNO_OK BUTTON_SELECT #elif (CONFIG_KEYPAD == IAUDIO_X5_PAD) -#define YESNO_OK BUTTON_RIGHT +#define YESNO_OK BUTTON_PLAY #endif enum yesno_res @@ -70,9 +71,10 @@ /* * Draws the yesno - * - yn : the yesno structure + * - yn : the yesno structure + * - no_selected : will put the "cursor" around no if 1 */ -extern void gui_yesno_draw(struct gui_yesno * yn); +extern void gui_yesno_draw(struct gui_yesno * yn,bool no_selected); /* * Draws the yesno result