1
0
Fork 0
forked from len0rd/rockbox

Remove dead code.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13488 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Nils Wallménius 2007-05-24 19:03:26 +00:00
parent 77bdacc646
commit c2a77563c2
3 changed files with 11 additions and 78 deletions

View file

@ -22,26 +22,6 @@
#include "kernel.h"
#include "lang.h"
void option_select_init_numeric(struct option_select * opt,
const char * title,
int init_value,
int min_value,
int max_value,
int step,
const char * unit,
option_formatter *formatter)
{
opt->title=title;
opt->min_value=min_value;
opt->max_value=max_value+1;
opt->option=init_value;
opt->step=step;
opt->extra_string=unit;
opt->formatter=formatter;
opt->items=NULL;
opt->limit_loop=true;
}
void option_select_init_items(struct option_select * opt,
const char * title,
int selected,
@ -52,31 +32,25 @@ void option_select_init_items(struct option_select * opt,
opt->min_value=0;
opt->max_value=nb_items;
opt->option=selected;
opt->step=1;
opt->formatter=NULL;
opt->items=items;
opt->limit_loop=false;
}
void option_select_next(struct option_select * opt)
{
if(opt->option + opt->step >= opt->max_value)
if(opt->option + 1 >= opt->max_value)
{
if(!opt->limit_loop)
{
if(opt->option==opt->max_value-1)
opt->option=opt->min_value;
else
opt->option=opt->max_value-1;
}
}
else
opt->option+=opt->step;
opt->option+=1;
}
void option_select_prev(struct option_select * opt)
{
if(opt->option - opt->step < opt->min_value)
if(opt->option - 1 < opt->min_value)
{
/* the dissimilarity to option_select_next() arises from the
* sleep timer problem (bug #5000 and #5001):
@ -85,21 +59,15 @@ void option_select_prev(struct option_select * opt)
* We need to be able to set timer to 0 (= Off) nevertheless. */
if(opt->option!=opt->min_value)
opt->option=opt->min_value;
else if(!opt->limit_loop)
else
opt->option=opt->max_value-1;
}
else
opt->option-=opt->step;
opt->option-=1;
}
const char * option_select_get_text(struct option_select * opt, char * buffer,
int buffersize)
const char * option_select_get_text(struct option_select * opt/*, char * buffer,
int buffersize*/)
{
if(opt->items)
return(P2STR(opt->items[opt->option].string));
if(!opt->formatter)
snprintf(buffer, buffersize,"%d %s", opt->option, opt->extra_string);
else
opt->formatter(buffer, buffersize, opt->option, opt->extra_string);
return(buffer);
}

View file

@ -21,43 +21,15 @@
#define _GUI_OPTION_SELECT_H_
#include "settings.h"
typedef void option_formatter(char* dest, int dest_length,
int variable, const char* unit);
struct option_select
{
const char * title;
int min_value;
int max_value;
int step;
int option;
const char * extra_string;
/* In the case the option is a number */
option_formatter *formatter;
const struct opt_items * items;
bool limit_loop;
};
/*
* Initializes an option containing a numeric values
* - title : the title of the option
* - init_value : the initial value the number will be
* - min_value, max_value : bounds to the value
* - step : the ammount you want to add / withdraw to the initial number
* each time a key is pressed
* - unit : the unit in which the value is (ex "s", "bytes", ...)
* - formatter : a callback function that generates a string
* from the number it gets
*/
extern void option_select_init_numeric(struct option_select * opt,
const char * title,
int init_value,
int min_value,
int max_value,
int step,
const char * unit,
option_formatter *formatter);
/*
* Initializes an option containing a list of choices
* - title : the title of the option
@ -74,12 +46,9 @@ extern void option_select_init_items(struct option_select * opt,
/*
* Gets the selected option
* - opt : the option struct
* - buffer : a buffer to eventually format the option
* Returns the selected option
*/
extern const char * option_select_get_text(struct option_select * opt,
char * buffer,
int buffersize);
extern const char * option_select_get_text(struct option_select * opt);
/*
* Selects the next value

View file

@ -55,7 +55,6 @@ static void gui_quickscreen_draw(struct gui_quickscreen * qs, struct screen * di
#define PUTSXY_CENTER (display->height/2)
#define PUTSXY_BOTTOM (display->height)
char buffer[30];
const unsigned char *option;
const unsigned char *title;
int w, font_h;
@ -71,8 +70,7 @@ static void gui_quickscreen_draw(struct gui_quickscreen * qs, struct screen * di
display->getstringsize("A", NULL, &font_h);
/* Displays the first line of text */
option=(unsigned char *)option_select_get_text(qs->left_option, buffer,
sizeof buffer);
option=(unsigned char *)option_select_get_text(qs->left_option);
title=(unsigned char *)qs->left_option->title;
display->puts_scroll(2, PUTS_CENTER-4+!statusbar, title);
display->puts_scroll(2, PUTS_CENTER-3+!statusbar, option);
@ -80,8 +78,7 @@ static void gui_quickscreen_draw(struct gui_quickscreen * qs, struct screen * di
PUTSXY_CENTER-(font_h*3), 7, 8);
/* Displays the second line of text */
option=(unsigned char *)option_select_get_text(qs->right_option, buffer,
sizeof buffer);
option=(unsigned char *)option_select_get_text(qs->right_option);
title=(unsigned char *)qs->right_option->title;
display->getstringsize(title, &w, NULL);
if(w > display->width - 8)
@ -103,8 +100,7 @@ static void gui_quickscreen_draw(struct gui_quickscreen * qs, struct screen * di
display->putsxy(display->width -w-12, PUTSXY_CENTER, option);
/* Displays the third line of text */
option=(unsigned char *)option_select_get_text(qs->bottom_option, buffer,
sizeof buffer);
option=(unsigned char *)option_select_get_text(qs->bottom_option);
title=(unsigned char *)qs->bottom_option->title;
display->getstringsize(title, &w, NULL);