1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2005 by Kevin Ferrare
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
28 * Initializes the yesno asker
29 * - yn : the yesno structure
30 * - main_message : the question the user has to answer
31 * - yes_message : message displayed if answer is 'yes'
32 * - no_message : message displayed if answer is 'no'
34 static void gui_yesno_init(struct gui_yesno
* yn
,
35 struct text_message
* main_message
,
36 struct text_message
* yes_message
,
37 struct text_message
* no_message
)
39 yn
->main_message
=main_message
;
40 yn
->result_message
[YESNO_YES
]=yes_message
;
41 yn
->result_message
[YESNO_NO
]=no_message
;
46 * Attach the yesno to a screen
47 * - yn : the yesno structure
48 * - display : the screen to attach
50 static void gui_yesno_set_display(struct gui_yesno
* yn
,
51 struct screen
* display
)
58 * - yn : the yesno structure
60 static void gui_yesno_draw(struct gui_yesno
* yn
)
62 struct screen
* display
=yn
->display
;
63 int nb_lines
, line_shift
=0;
65 gui_textarea_clear(display
);
66 nb_lines
=yn
->main_message
->nb_lines
;
68 if(nb_lines
+3<display
->nb_lines
)
70 nb_lines
=gui_textarea_put_message(display
, yn
->main_message
, line_shift
);
72 /* Space remaining for yes / no text ? */
73 if(nb_lines
+line_shift
+2<=display
->nb_lines
)
75 if(nb_lines
+line_shift
+3<=display
->nb_lines
)
77 display
->puts(0, nb_lines
+line_shift
, str(LANG_CONFIRM_WITH_PLAY_RECORDER
));
78 display
->puts(0, nb_lines
+line_shift
+1, str(LANG_CANCEL_WITH_ANY_RECORDER
));
80 gui_textarea_update(display
);
84 * Draws the yesno result
85 * - yn : the yesno structure
86 * - result : the result tha must be displayed :
90 static bool gui_yesno_draw_result(struct gui_yesno
* yn
, enum yesno_res result
)
92 struct text_message
* message
=yn
->result_message
[result
];
95 gui_textarea_put_message(yn
->display
, message
, 0);
99 enum yesno_res
gui_syncyesno_run(struct text_message
* main_message
,
100 struct text_message
* yes_message
,
101 struct text_message
* no_message
)
106 bool result_displayed
;
107 struct gui_yesno yn
[NB_SCREENS
];
110 gui_yesno_init(&(yn
[i
]), main_message
, yes_message
, no_message
);
111 gui_yesno_set_display(&(yn
[i
]), &(screens
[i
]));
112 gui_yesno_draw(&(yn
[i
]));
116 button
= get_action(CONTEXT_YESNOSCREEN
,TIMEOUT_BLOCK
);
119 case ACTION_YESNO_ACCEPT
:
123 case SYS_CHARGER_DISCONNECTED
:
124 /* ignore some SYS events that can happen */
127 if(default_event_handler(button
) == SYS_USB_CONNECTED
)
133 result_displayed
=gui_yesno_draw_result(&(yn
[i
]), result
);