diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2008-05-11 13:39:22 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2008-05-11 13:39:22 +0000 |
commit | 10df05438e329c7271c8cc7c4e9cdf2adace52dd (patch) | |
tree | f6c4bce9793bba63802137f0425bc9a7cfaefec0 /apps | |
parent | fc25f3f61be62fdfe1d32f5bf1a52a2a148db6ab (diff) |
more textarea to viewport conversion... yes/no screen...
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17454 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/gui/bitmap/list.c | 1 | ||||
-rw-r--r-- | apps/gui/charcell/list.c | 1 | ||||
-rw-r--r-- | apps/gui/list.c | 1 | ||||
-rw-r--r-- | apps/gui/quickscreen.c | 1 | ||||
-rw-r--r-- | apps/gui/textarea.c | 13 | ||||
-rw-r--r-- | apps/gui/textarea.h | 10 | ||||
-rw-r--r-- | apps/gui/yesno.c | 96 | ||||
-rw-r--r-- | apps/gui/yesno.h | 8 | ||||
-rw-r--r-- | apps/root_menu.c | 1 | ||||
-rw-r--r-- | apps/tree.c | 1 |
10 files changed, 54 insertions, 79 deletions
diff --git a/apps/gui/bitmap/list.c b/apps/gui/bitmap/list.c index f643053ab5..ed257155bd 100644 --- a/apps/gui/bitmap/list.c +++ b/apps/gui/bitmap/list.c @@ -34,7 +34,6 @@ #include "list.h" #include "scrollbar.h" #include "statusbar.h" -#include "textarea.h" #include "lang.h" #include "sound.h" #include "misc.h" diff --git a/apps/gui/charcell/list.c b/apps/gui/charcell/list.c index bba688d698..72c2cb7bb9 100644 --- a/apps/gui/charcell/list.c +++ b/apps/gui/charcell/list.c @@ -33,7 +33,6 @@ #include "screen_access.h" #include "scrollbar.h" #include "statusbar.h" -#include "textarea.h" #include "lang.h" #include "sound.h" #include "misc.h" diff --git a/apps/gui/list.c b/apps/gui/list.c index 1e2b682e6e..7adb83eb97 100644 --- a/apps/gui/list.c +++ b/apps/gui/list.c @@ -32,7 +32,6 @@ #include "list.h" #include "scrollbar.h" #include "statusbar.h" -#include "textarea.h" #include "lang.h" #include "sound.h" #include "misc.h" diff --git a/apps/gui/quickscreen.c b/apps/gui/quickscreen.c index 82550be66a..09592093e7 100644 --- a/apps/gui/quickscreen.c +++ b/apps/gui/quickscreen.c @@ -22,7 +22,6 @@ #include "config.h" #include "system.h" #include "icons.h" -#include "textarea.h" #include "font.h" #include "kernel.h" #include "misc.h" diff --git a/apps/gui/textarea.c b/apps/gui/textarea.c index dcffd0e621..21028da375 100644 --- a/apps/gui/textarea.c +++ b/apps/gui/textarea.c @@ -46,19 +46,6 @@ void gui_textarea_update(struct screen * display) #endif } -int gui_textarea_put_message(struct screen * display, - const struct text_message * message, - int ystart) -{ - int i; - gui_textarea_clear(display); - for(i=0;i<message->nb_lines && i+ystart<display->nb_lines;i++) - display->puts_scroll(0, i+ystart, P2STR((unsigned char *)message-> - message_lines[i])); - gui_textarea_update(display); - return(i); -} - void gui_textarea_update_nblines(struct screen * display) { int height=display->height; diff --git a/apps/gui/textarea.h b/apps/gui/textarea.h index 3f16dd440c..5e770eac38 100644 --- a/apps/gui/textarea.h +++ b/apps/gui/textarea.h @@ -43,16 +43,6 @@ extern void gui_textarea_clear(struct screen * display); extern void gui_textarea_update(struct screen * display); /* - * Displays message lines on the given screen - * - display : the screen structure - * - message : the lines to display - * - ystart : the lineon which we start displaying - * returns : the number of lines effectively displayed - */ -extern int gui_textarea_put_message(struct screen * display, - const struct text_message * message, - int ystart); -/* * Compute the number of text lines the display can draw with the current font * Also updates the char height and width * - display : the screen structure diff --git a/apps/gui/yesno.c b/apps/gui/yesno.c index 51a1eabd60..65dd9651d2 100644 --- a/apps/gui/yesno.c +++ b/apps/gui/yesno.c @@ -24,36 +24,31 @@ #include "lang.h" #include "action.h" #include "talk.h" +#include "textarea.h" +#include "viewport.h" -/* - * Initializes the yesno asker - * - yn : the yesno structure - * - main_message : the question the user has to answer - * - yes_message : message displayed if answer is 'yes' - * - no_message : message displayed if answer is 'no' - */ -static void gui_yesno_init(struct gui_yesno * yn, - const struct text_message * main_message, - const struct text_message * yes_message, - const struct text_message * no_message) -{ - yn->main_message=main_message; - yn->result_message[YESNO_YES]=yes_message; - yn->result_message[YESNO_NO]=no_message; - yn->display=0; -} -/* - * Attach the yesno to a screen - * - yn : the yesno structure - * - display : the screen to attach - */ -static void gui_yesno_set_display(struct gui_yesno * yn, - struct screen * display) +struct gui_yesno { - yn->display=display; + const struct text_message * main_message; + const struct text_message * result_message[2]; + + struct viewport *vp; + struct screen * display; +}; +static int put_message(struct screen *display, + const struct text_message * message, + int start, int max_y) +{ + int i; + for(i=0; i<message->nb_lines && i+start<max_y; i++) + { + display->puts_scroll(0, i+start, + P2STR((unsigned char *)message->message_lines[i])); + } + return i; } - + /* * Draws the yesno * - yn : the yesno structure @@ -61,26 +56,33 @@ static void gui_yesno_set_display(struct gui_yesno * yn, static void gui_yesno_draw(struct gui_yesno * yn) { struct screen * display=yn->display; - int nb_lines, line_shift=0; + struct viewport *vp = yn->vp; + int nb_lines, vp_lines, line_shift=0; - gui_textarea_clear(display); - nb_lines=yn->main_message->nb_lines; + display->set_viewport(vp); + display->clear_viewport(); + display->stop_scroll(); + nb_lines = yn->main_message->nb_lines; + vp_lines = viewport_get_nb_lines(vp); - if(nb_lines+3<display->nb_lines) + if(nb_lines+3< vp_lines) line_shift=1; - nb_lines=gui_textarea_put_message(display, yn->main_message, line_shift); + + line_shift += put_message(display, yn->main_message, + line_shift, vp_lines); /* Space remaining for yes / no text ? */ - if(nb_lines+line_shift+2<=display->nb_lines) + if(line_shift+2 <= vp_lines) { - if(nb_lines+line_shift+3<=display->nb_lines) - nb_lines++; - display->puts(0, nb_lines+line_shift, str(LANG_CONFIRM_WITH_BUTTON)); + if(line_shift+3 <= vp_lines) + line_shift++; + display->puts(0, line_shift, str(LANG_CONFIRM_WITH_BUTTON)); #ifdef HAVE_LCD_BITMAP - display->puts(0, nb_lines+line_shift+1, str(LANG_CANCEL_WITH_ANY)); + display->puts(0, line_shift+1, str(LANG_CANCEL_WITH_ANY)); #endif } - gui_textarea_update(display); + display->update_viewport(); + display->set_viewport(NULL); } /* @@ -93,14 +95,19 @@ static void gui_yesno_draw(struct gui_yesno * yn) static bool gui_yesno_draw_result(struct gui_yesno * yn, enum yesno_res result) { const struct text_message * message=yn->result_message[result]; + struct viewport *vp = yn->vp; + struct screen * display=yn->display; if(message==NULL) return false; - gui_textarea_put_message(yn->display, message, 0); + display->set_viewport(vp); + display->clear_viewport(); + display->stop_scroll(); + put_message(yn->display, message, 0, viewport_get_nb_lines(vp)); + display->update_viewport(); + display->set_viewport(NULL); return(true); } -#include "debug.h" - enum yesno_res gui_syncyesno_run(const struct text_message * main_message, const struct text_message * yes_message, const struct text_message * no_message) @@ -110,11 +117,16 @@ enum yesno_res gui_syncyesno_run(const struct text_message * main_message, int result=-1; bool result_displayed; struct gui_yesno yn[NB_SCREENS]; + struct viewport vp[NB_SCREENS]; long talked_tick = 0; FOR_NB_SCREENS(i) { - gui_yesno_init(&(yn[i]), main_message, yes_message, no_message); - gui_yesno_set_display(&(yn[i]), &(screens[i])); + yn[i].main_message=main_message; + yn[i].result_message[YESNO_YES]=yes_message; + yn[i].result_message[YESNO_NO]=no_message; + yn[i].display=&screens[i]; + yn[i].vp = &vp[i]; + viewport_set_defaults(yn[i].vp, i); gui_yesno_draw(&(yn[i])); } while (result==-1) diff --git a/apps/gui/yesno.h b/apps/gui/yesno.h index b57ee89d48..50c4fbac5b 100644 --- a/apps/gui/yesno.h +++ b/apps/gui/yesno.h @@ -30,14 +30,6 @@ enum yesno_res YESNO_USB }; -struct gui_yesno -{ - const struct text_message * main_message; - const struct text_message * result_message[2]; - - struct screen * display; -}; - /* * Runs the yesno asker : * it will display the 'main_message' question, and wait for user keypress diff --git a/apps/root_menu.c b/apps/root_menu.c index cb9d7769eb..229341f71b 100644 --- a/apps/root_menu.c +++ b/apps/root_menu.c @@ -42,7 +42,6 @@ #include "statusbar.h" #include "splash.h" #include "buttonbar.h" -#include "textarea.h" #include "action.h" #include "yesno.h" diff --git a/apps/tree.c b/apps/tree.c index 97f152ff74..5771311847 100644 --- a/apps/tree.c +++ b/apps/tree.c @@ -76,7 +76,6 @@ #include "statusbar.h" #include "splash.h" #include "buttonbar.h" -#include "textarea.h" #include "action.h" #include "quickscreen.h" |