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 ****************************************************************************/
20 #include "option_select.h"
25 void option_select_init_items(struct option_select
* opt
,
28 const struct opt_items
* items
,
33 opt
->max_value
=nb_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
;
45 opt
->option
=opt
->max_value
-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
;
63 opt
->option
=opt
->max_value
-1;
69 const char * option_select_get_text(struct option_select
* opt
/*, char * buffer,
72 return(P2STR(opt
->items
[opt
->option
].string
));