summaryrefslogtreecommitdiff
path: root/apps/gui
diff options
context:
space:
mode:
Diffstat (limited to 'apps/gui')
-rw-r--r--apps/gui/bitmap/list.c1
-rw-r--r--apps/gui/charcell/list.c1
-rw-r--r--apps/gui/list.c1
-rw-r--r--apps/gui/quickscreen.c1
-rw-r--r--apps/gui/textarea.c13
-rw-r--r--apps/gui/textarea.h10
-rw-r--r--apps/gui/yesno.c96
-rw-r--r--apps/gui/yesno.h8
8 files changed, 54 insertions, 77 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 @@
34#include "list.h" 34#include "list.h"
35#include "scrollbar.h" 35#include "scrollbar.h"
36#include "statusbar.h" 36#include "statusbar.h"
37#include "textarea.h"
38#include "lang.h" 37#include "lang.h"
39#include "sound.h" 38#include "sound.h"
40#include "misc.h" 39#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 @@
33#include "screen_access.h" 33#include "screen_access.h"
34#include "scrollbar.h" 34#include "scrollbar.h"
35#include "statusbar.h" 35#include "statusbar.h"
36#include "textarea.h"
37#include "lang.h" 36#include "lang.h"
38#include "sound.h" 37#include "sound.h"
39#include "misc.h" 38#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 @@
32#include "list.h" 32#include "list.h"
33#include "scrollbar.h" 33#include "scrollbar.h"
34#include "statusbar.h" 34#include "statusbar.h"
35#include "textarea.h"
36#include "lang.h" 35#include "lang.h"
37#include "sound.h" 36#include "sound.h"
38#include "misc.h" 37#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 @@
22#include "config.h" 22#include "config.h"
23#include "system.h" 23#include "system.h"
24#include "icons.h" 24#include "icons.h"
25#include "textarea.h"
26#include "font.h" 25#include "font.h"
27#include "kernel.h" 26#include "kernel.h"
28#include "misc.h" 27#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)
46#endif 46#endif
47} 47}
48 48
49int gui_textarea_put_message(struct screen * display,
50 const struct text_message * message,
51 int ystart)
52{
53 int i;
54 gui_textarea_clear(display);
55 for(i=0;i<message->nb_lines && i+ystart<display->nb_lines;i++)
56 display->puts_scroll(0, i+ystart, P2STR((unsigned char *)message->
57 message_lines[i]));
58 gui_textarea_update(display);
59 return(i);
60}
61
62void gui_textarea_update_nblines(struct screen * display) 49void gui_textarea_update_nblines(struct screen * display)
63{ 50{
64 int height=display->height; 51 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);
43extern void gui_textarea_update(struct screen * display); 43extern void gui_textarea_update(struct screen * display);
44 44
45/* 45/*
46 * Displays message lines on the given screen
47 * - display : the screen structure
48 * - message : the lines to display
49 * - ystart : the lineon which we start displaying
50 * returns : the number of lines effectively displayed
51 */
52extern int gui_textarea_put_message(struct screen * display,
53 const struct text_message * message,
54 int ystart);
55/*
56 * Compute the number of text lines the display can draw with the current font 46 * Compute the number of text lines the display can draw with the current font
57 * Also updates the char height and width 47 * Also updates the char height and width
58 * - display : the screen structure 48 * - 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 @@
24#include "lang.h" 24#include "lang.h"
25#include "action.h" 25#include "action.h"
26#include "talk.h" 26#include "talk.h"
27#include "textarea.h"
28#include "viewport.h"
27 29
28/*
29 * Initializes the yesno asker
30 * - yn : the yesno structure
31 * - main_message : the question the user has to answer
32 * - yes_message : message displayed if answer is 'yes'
33 * - no_message : message displayed if answer is 'no'
34 */
35static void gui_yesno_init(struct gui_yesno * yn,
36 const struct text_message * main_message,
37 const struct text_message * yes_message,
38 const struct text_message * no_message)
39{
40 yn->main_message=main_message;
41 yn->result_message[YESNO_YES]=yes_message;
42 yn->result_message[YESNO_NO]=no_message;
43 yn->display=0;
44}
45 30
46/* 31struct gui_yesno
47 * Attach the yesno to a screen
48 * - yn : the yesno structure
49 * - display : the screen to attach
50 */
51static void gui_yesno_set_display(struct gui_yesno * yn,
52 struct screen * display)
53{ 32{
54 yn->display=display; 33 const struct text_message * main_message;
34 const struct text_message * result_message[2];
35
36 struct viewport *vp;
37 struct screen * display;
38};
39static int put_message(struct screen *display,
40 const struct text_message * message,
41 int start, int max_y)
42{
43 int i;
44 for(i=0; i<message->nb_lines && i+start<max_y; i++)
45 {
46 display->puts_scroll(0, i+start,
47 P2STR((unsigned char *)message->message_lines[i]));
48 }
49 return i;
55} 50}
56 51
57/* 52/*
58 * Draws the yesno 53 * Draws the yesno
59 * - yn : the yesno structure 54 * - yn : the yesno structure
@@ -61,26 +56,33 @@ static void gui_yesno_set_display(struct gui_yesno * yn,
61static void gui_yesno_draw(struct gui_yesno * yn) 56static void gui_yesno_draw(struct gui_yesno * yn)
62{ 57{
63 struct screen * display=yn->display; 58 struct screen * display=yn->display;
64 int nb_lines, line_shift=0; 59 struct viewport *vp = yn->vp;
60 int nb_lines, vp_lines, line_shift=0;
65 61
66 gui_textarea_clear(display); 62 display->set_viewport(vp);
67 nb_lines=yn->main_message->nb_lines; 63 display->clear_viewport();
64 display->stop_scroll();
65 nb_lines = yn->main_message->nb_lines;
66 vp_lines = viewport_get_nb_lines(vp);
68 67
69 if(nb_lines+3<display->nb_lines) 68 if(nb_lines+3< vp_lines)
70 line_shift=1; 69 line_shift=1;
71 nb_lines=gui_textarea_put_message(display, yn->main_message, line_shift); 70
71 line_shift += put_message(display, yn->main_message,
72 line_shift, vp_lines);
72 73
73 /* Space remaining for yes / no text ? */ 74 /* Space remaining for yes / no text ? */
74 if(nb_lines+line_shift+2<=display->nb_lines) 75 if(line_shift+2 <= vp_lines)
75 { 76 {
76 if(nb_lines+line_shift+3<=display->nb_lines) 77 if(line_shift+3 <= vp_lines)
77 nb_lines++; 78 line_shift++;
78 display->puts(0, nb_lines+line_shift, str(LANG_CONFIRM_WITH_BUTTON)); 79 display->puts(0, line_shift, str(LANG_CONFIRM_WITH_BUTTON));
79#ifdef HAVE_LCD_BITMAP 80#ifdef HAVE_LCD_BITMAP
80 display->puts(0, nb_lines+line_shift+1, str(LANG_CANCEL_WITH_ANY)); 81 display->puts(0, line_shift+1, str(LANG_CANCEL_WITH_ANY));
81#endif 82#endif
82 } 83 }
83 gui_textarea_update(display); 84 display->update_viewport();
85 display->set_viewport(NULL);
84} 86}
85 87
86/* 88/*
@@ -93,14 +95,19 @@ static void gui_yesno_draw(struct gui_yesno * yn)
93static bool gui_yesno_draw_result(struct gui_yesno * yn, enum yesno_res result) 95static bool gui_yesno_draw_result(struct gui_yesno * yn, enum yesno_res result)
94{ 96{
95 const struct text_message * message=yn->result_message[result]; 97 const struct text_message * message=yn->result_message[result];
98 struct viewport *vp = yn->vp;
99 struct screen * display=yn->display;
96 if(message==NULL) 100 if(message==NULL)
97 return false; 101 return false;
98 gui_textarea_put_message(yn->display, message, 0); 102 display->set_viewport(vp);
103 display->clear_viewport();
104 display->stop_scroll();
105 put_message(yn->display, message, 0, viewport_get_nb_lines(vp));
106 display->update_viewport();
107 display->set_viewport(NULL);
99 return(true); 108 return(true);
100} 109}
101 110
102#include "debug.h"
103
104enum yesno_res gui_syncyesno_run(const struct text_message * main_message, 111enum yesno_res gui_syncyesno_run(const struct text_message * main_message,
105 const struct text_message * yes_message, 112 const struct text_message * yes_message,
106 const struct text_message * no_message) 113 const struct text_message * no_message)
@@ -110,11 +117,16 @@ enum yesno_res gui_syncyesno_run(const struct text_message * main_message,
110 int result=-1; 117 int result=-1;
111 bool result_displayed; 118 bool result_displayed;
112 struct gui_yesno yn[NB_SCREENS]; 119 struct gui_yesno yn[NB_SCREENS];
120 struct viewport vp[NB_SCREENS];
113 long talked_tick = 0; 121 long talked_tick = 0;
114 FOR_NB_SCREENS(i) 122 FOR_NB_SCREENS(i)
115 { 123 {
116 gui_yesno_init(&(yn[i]), main_message, yes_message, no_message); 124 yn[i].main_message=main_message;
117 gui_yesno_set_display(&(yn[i]), &(screens[i])); 125 yn[i].result_message[YESNO_YES]=yes_message;
126 yn[i].result_message[YESNO_NO]=no_message;
127 yn[i].display=&screens[i];
128 yn[i].vp = &vp[i];
129 viewport_set_defaults(yn[i].vp, i);
118 gui_yesno_draw(&(yn[i])); 130 gui_yesno_draw(&(yn[i]));
119 } 131 }
120 while (result==-1) 132 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
30 YESNO_USB 30 YESNO_USB
31}; 31};
32 32
33struct gui_yesno
34{
35 const struct text_message * main_message;
36 const struct text_message * result_message[2];
37
38 struct screen * display;
39};
40
41/* 33/*
42 * Runs the yesno asker : 34 * Runs the yesno asker :
43 * it will display the 'main_message' question, and wait for user keypress 35 * it will display the 'main_message' question, and wait for user keypress