Remove dead code.
[Rockbox.git] / apps / gui / option_select.c
blobd4fb225a5920099474f86693859b68bc0ba2a6e0
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
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 ****************************************************************************/
20 #include "option_select.h"
21 #include "sprintf.h"
22 #include "kernel.h"
23 #include "lang.h"
25 void option_select_init_items(struct option_select * opt,
26 const char * title,
27 int selected,
28 const struct opt_items * items,
29 int nb_items)
31 opt->title=title;
32 opt->min_value=0;
33 opt->max_value=nb_items;
34 opt->option=selected;
35 opt->items=items;
38 void option_select_next(struct option_select * opt)
40 if(opt->option + 1 >= opt->max_value)
42 if(opt->option==opt->max_value-1)
43 opt->option=opt->min_value;
44 else
45 opt->option=opt->max_value-1;
47 else
48 opt->option+=1;
51 void option_select_prev(struct option_select * opt)
53 if(opt->option - 1 < opt->min_value)
55 /* the dissimilarity to option_select_next() arises from the
56 * sleep timer problem (bug #5000 and #5001):
57 * there we have min=0, step = 5 but the value itself might
58 * not be a multiple of 5 -- as time elapsed;
59 * We need to be able to set timer to 0 (= Off) nevertheless. */
60 if(opt->option!=opt->min_value)
61 opt->option=opt->min_value;
62 else
63 opt->option=opt->max_value-1;
65 else
66 opt->option-=1;
69 const char * option_select_get_text(struct option_select * opt/*, char * buffer,
70 int buffersize*/)
72 return(P2STR(opt->items[opt->option].string));