2005-11-04 07:18:36 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2005 by Kevin Ferrare
|
|
|
|
*
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "select.h"
|
|
|
|
|
|
|
|
#include "lang.h"
|
|
|
|
#include "textarea.h"
|
|
|
|
#include "screen_access.h"
|
2005-11-22 03:38:07 +00:00
|
|
|
#include "kernel.h"
|
2006-08-15 12:27:07 +00:00
|
|
|
#include "action.h"
|
2005-11-22 03:38:07 +00:00
|
|
|
|
2005-11-04 07:18:36 +00:00
|
|
|
|
|
|
|
void gui_select_init_numeric(struct gui_select * select,
|
|
|
|
const char * title,
|
|
|
|
int init_value,
|
|
|
|
int min_value,
|
|
|
|
int max_value,
|
|
|
|
int step,
|
|
|
|
const char * unit,
|
2005-11-22 03:38:07 +00:00
|
|
|
option_formatter *formatter)
|
2005-11-04 07:18:36 +00:00
|
|
|
{
|
|
|
|
select->canceled=false;
|
|
|
|
select->validated=false;
|
2005-11-22 03:38:07 +00:00
|
|
|
option_select_init_numeric(&select->options, title, init_value,
|
|
|
|
min_value, max_value, step, unit, formatter);
|
2005-11-04 07:18:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void gui_select_init_items(struct gui_select * select,
|
|
|
|
const char * title,
|
|
|
|
int selected,
|
|
|
|
const struct opt_items * items,
|
|
|
|
int nb_items)
|
|
|
|
{
|
|
|
|
select->canceled=false;
|
|
|
|
select->validated=false;
|
2005-11-22 03:38:07 +00:00
|
|
|
option_select_init_items(&select->options, title, selected, items, nb_items);
|
2005-11-04 07:18:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void gui_select_draw(struct gui_select * select, struct screen * display)
|
|
|
|
{
|
2005-11-22 03:38:07 +00:00
|
|
|
char buffer[30];
|
2005-11-22 11:31:28 +00:00
|
|
|
const char * selected=option_select_get_text(&(select->options), buffer,
|
|
|
|
sizeof buffer);
|
2005-11-04 07:48:28 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2005-11-04 07:18:36 +00:00
|
|
|
screen_set_xmargin(display, 0);
|
2005-11-04 07:48:28 +00:00
|
|
|
#endif
|
2005-11-04 07:18:36 +00:00
|
|
|
gui_textarea_clear(display);
|
2005-12-05 23:37:14 +00:00
|
|
|
display->puts_scroll(0, 0, (unsigned char *)select->options.title);
|
2005-11-04 07:18:36 +00:00
|
|
|
|
2005-12-05 23:37:14 +00:00
|
|
|
if(select->canceled)
|
2005-11-04 07:18:36 +00:00
|
|
|
display->puts_scroll(0, 0, str(LANG_MENU_SETTING_CANCEL));
|
2005-12-05 23:37:14 +00:00
|
|
|
display->puts_scroll(0, 1, (unsigned char *)selected);
|
2005-11-04 07:18:36 +00:00
|
|
|
gui_textarea_update(display);
|
|
|
|
}
|
|
|
|
|
|
|
|
void gui_syncselect_draw(struct gui_select * select)
|
|
|
|
{
|
|
|
|
int i;
|
2005-11-09 22:47:15 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
2005-11-04 07:18:36 +00:00
|
|
|
gui_select_draw(select, &(screens[i]));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool gui_syncselect_do_button(struct gui_select * select, int button)
|
|
|
|
{
|
|
|
|
switch(button)
|
|
|
|
{
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_SETTINGS_INCREPEAT:
|
2005-12-05 23:37:14 +00:00
|
|
|
select->options.limit_loop = true;
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_SETTINGS_INC:
|
2005-12-05 23:37:14 +00:00
|
|
|
option_select_next(&select->options);
|
2005-11-06 14:04:56 +00:00
|
|
|
return(true);
|
|
|
|
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_SETTINGS_DECREPEAT:
|
2005-12-05 23:37:14 +00:00
|
|
|
select->options.limit_loop = true;
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_SETTINGS_DEC:
|
2005-12-05 23:37:14 +00:00
|
|
|
option_select_prev(&select->options);
|
2005-11-06 14:04:56 +00:00
|
|
|
return(true);
|
|
|
|
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_STD_OK:
|
|
|
|
case ACTION_STD_PREV: /*NOTE: this is in CONTEXT_SETTINGS ! */
|
2005-12-05 23:37:14 +00:00
|
|
|
select->validated=true;
|
2005-11-06 14:04:56 +00:00
|
|
|
return(false);
|
|
|
|
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_STD_CANCEL:
|
2005-12-05 23:37:14 +00:00
|
|
|
select->canceled = true;
|
2005-11-04 07:18:36 +00:00
|
|
|
gui_syncselect_draw(select);
|
|
|
|
sleep(HZ/2);
|
2006-08-15 12:27:07 +00:00
|
|
|
action_signalscreenchange();
|
2005-11-06 14:04:56 +00:00
|
|
|
return(false);
|
2005-11-04 07:18:36 +00:00
|
|
|
}
|
2005-11-06 14:04:56 +00:00
|
|
|
return(false);
|
2005-11-04 07:18:36 +00:00
|
|
|
}
|
|
|
|
|