summaryrefslogtreecommitdiff
path: root/apps/gui
diff options
context:
space:
mode:
Diffstat (limited to 'apps/gui')
-rw-r--r--apps/gui/gwps-common.c2
-rw-r--r--apps/gui/gwps.c4
-rw-r--r--apps/gui/gwps.h1
-rw-r--r--apps/gui/option_select.c102
-rw-r--r--apps/gui/option_select.h119
-rw-r--r--apps/gui/quickscreen.c179
-rw-r--r--apps/gui/quickscreen.h114
-rw-r--r--apps/gui/select.c78
-rw-r--r--apps/gui/select.h33
-rw-r--r--apps/gui/statusbar.h5
10 files changed, 541 insertions, 96 deletions
diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c
index 16f3a6f2cc..4eee5f7ba1 100644
--- a/apps/gui/gwps-common.c
+++ b/apps/gui/gwps-common.c
@@ -61,7 +61,7 @@ static void gui_wps_statusbar_draw(struct gui_wps *wps, bool force)
61{ 61{
62 bool draw = global_settings.statusbar; 62 bool draw = global_settings.statusbar;
63 if(wps->data->wps_sb_tag 63 if(wps->data->wps_sb_tag
64 && gui_wps->data->show_sb_on_wps) 64 && wps->data->show_sb_on_wps)
65 draw = true; 65 draw = true;
66 else if(wps->data->wps_sb_tag) 66 else if(wps->data->wps_sb_tag)
67 draw = false; 67 draw = false;
diff --git a/apps/gui/gwps.c b/apps/gui/gwps.c
index a93750770f..52340e6547 100644
--- a/apps/gui/gwps.c
+++ b/apps/gui/gwps.c
@@ -509,7 +509,7 @@ long gui_wps_show(void)
509#ifdef WPS_RC_QUICK 509#ifdef WPS_RC_QUICK
510 case WPS_RC_QUICK: 510 case WPS_RC_QUICK:
511#endif 511#endif
512 if (quick_screen(CONTEXT_WPS, WPS_QUICK)) 512 if (quick_screen_quick())
513 return SYS_USB_CONNECTED; 513 return SYS_USB_CONNECTED;
514 restore = true; 514 restore = true;
515 lastbutton = 0; 515 lastbutton = 0;
@@ -518,7 +518,7 @@ long gui_wps_show(void)
518 /* screen settings */ 518 /* screen settings */
519#ifdef BUTTON_F3 519#ifdef BUTTON_F3
520 case BUTTON_F3: 520 case BUTTON_F3:
521 if (quick_screen(CONTEXT_WPS, BUTTON_F3)) 521 if (quick_screen_f3())
522 return SYS_USB_CONNECTED; 522 return SYS_USB_CONNECTED;
523 restore = true; 523 restore = true;
524 break; 524 break;
diff --git a/apps/gui/gwps.h b/apps/gui/gwps.h
index dfae7c34e2..66199bcfc4 100644
--- a/apps/gui/gwps.h
+++ b/apps/gui/gwps.h
@@ -68,6 +68,7 @@
68#define WPS_RC_BROWSE (BUTTON_RC_MENU | BUTTON_REL) 68#define WPS_RC_BROWSE (BUTTON_RC_MENU | BUTTON_REL)
69#define WPS_RC_BROWSE_PRE BUTTON_RC_MENU 69#define WPS_RC_BROWSE_PRE BUTTON_RC_MENU
70#define WPS_RC_CONTEXT (BUTTON_RC_MENU | BUTTON_REPEAT) 70#define WPS_RC_CONTEXT (BUTTON_RC_MENU | BUTTON_REPEAT)
71#define WPS_RC_QUICK (BUTTON_RC_MODE | BUTTON_REPEAT)
71 72
72#elif CONFIG_KEYPAD == RECORDER_PAD 73#elif CONFIG_KEYPAD == RECORDER_PAD
73#define WPS_NEXT (BUTTON_RIGHT | BUTTON_REL) 74#define WPS_NEXT (BUTTON_RIGHT | BUTTON_REL)
diff --git a/apps/gui/option_select.c b/apps/gui/option_select.c
new file mode 100644
index 0000000000..0e169617c4
--- /dev/null
+++ b/apps/gui/option_select.c
@@ -0,0 +1,102 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2005 by Kevin Ferrare
11 *
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.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include "option_select.h"
21#include "sprintf.h"
22#include "kernel.h"
23#include "lang.h"
24
25void option_select_init_numeric(struct option_select * opt,
26 const char * title,
27 int init_value,
28 int min_value,
29 int max_value,
30 int step,
31 const char * unit,
32 option_formatter *formatter)
33{
34 opt->title=title;
35 opt->min_value=min_value;
36 opt->max_value=max_value+1;
37 opt->option=init_value;
38 opt->step=step;
39 opt->extra_string=unit;
40 opt->formatter=formatter;
41 opt->items=NULL;
42 opt->limit_loop=false;
43}
44
45void option_select_init_items(struct option_select * opt,
46 const char * title,
47 int selected,
48 const struct opt_items * items,
49 int nb_items)
50{
51 opt->title=title;
52 opt->min_value=0;
53 opt->max_value=nb_items;
54 opt->option=selected;
55 opt->step=1;
56 opt->formatter=NULL;
57 opt->items=items;
58 opt->limit_loop=false;
59}
60
61void option_select_next(struct option_select * opt)
62{
63 if(opt->option + opt->step >= opt->max_value)
64 {
65 if(!opt->limit_loop)
66 {
67 if(opt->option==opt->max_value-1)
68 opt->option=opt->min_value;
69 else
70 opt->option=opt->max_value-1;
71 }
72 }
73 else
74 opt->option+=opt->step;
75}
76
77void option_select_prev(struct option_select * opt)
78{
79 if(opt->option - opt->step < opt->min_value)
80 {
81 if(!opt->limit_loop)
82 {
83 if(opt->option==opt->min_value)
84 opt->option=opt->max_value-1;
85 else
86 opt->option=opt->min_value;
87 }
88 }
89 else
90 opt->option-=opt->step;
91}
92
93const char * option_select_get_text(struct option_select * opt, char * buffer)
94{
95 if(opt->items)
96 return(P2STR(opt->items[opt->option].string));
97 if(!opt->formatter)
98 snprintf(buffer, sizeof buffer,"%d %s", opt->option, opt->extra_string);
99 else
100 opt->formatter(buffer, sizeof buffer, opt->option, opt->extra_string);
101 return(buffer);
102}
diff --git a/apps/gui/option_select.h b/apps/gui/option_select.h
new file mode 100644
index 0000000000..c6a5e196f0
--- /dev/null
+++ b/apps/gui/option_select.h
@@ -0,0 +1,119 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2005 by Kevin Ferrare
11 *
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.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#ifndef _GUI_OPTION_SELECT_H_
21#define _GUI_OPTION_SELECT_H_
22#include "settings.h"
23
24typedef void option_formatter(char* dest, int dest_length,
25 int variable, const char* unit);
26
27struct option_select
28{
29 const char * title;
30 int min_value;
31 int max_value;
32 int step;
33 int option;
34 const char * extra_string;
35 /* In the case the option is a number */
36 option_formatter *formatter;
37 const struct opt_items * items;
38 bool limit_loop;
39};
40
41/*
42 * Initializes an option containing a numeric values
43 * - title : the title of the option
44 * - init_value : the initial value the number will be
45 * - min_value, max_value : bounds to the value
46 * - step : the ammount you want to add / withdraw to the initial number
47 * each time a key is pressed
48 * - unit : the unit in which the value is (ex "s", "bytes", ...)
49 * - formatter : a callback function that generates a string
50 * from the number it gets
51 */
52extern void option_select_init_numeric(struct option_select * opt,
53 const char * title,
54 int init_value,
55 int min_value,
56 int max_value,
57 int step,
58 const char * unit,
59 option_formatter *formatter);
60
61/*
62 * Initializes an option containing a list of choices
63 * - title : the title of the option
64 * - selected : the initially selected item
65 * - items : the list of items, defined in settings.h
66 * - nb_items : the number of items in the 'items' list
67 */
68extern void option_select_init_items(struct option_select * opt,
69 const char * title,
70 int selected,
71 const struct opt_items * items,
72 int nb_items);
73
74/*
75 * Gets the selected option
76 * - opt : the option struct
77 * - buffer : a buffer to eventually format the option
78 * Returns the selected option
79 */
80extern const char * option_select_get_text(struct option_select * opt, char * buffer);
81
82/*
83 * Selects the next value
84 * - opt : the option struct
85 */
86extern void option_select_next(struct option_select * opt);
87
88/*
89 * Selects the previous value
90 * - opt : the option struct
91 */
92extern void option_select_prev(struct option_select * opt);
93
94/*
95 * Returns the selected number
96 * - opt : the option struct
97 */
98#define option_select_get_selected(_opt) \
99 (_opt)->option
100
101/*
102 * Returns the title
103 * - opt : the option struct
104 */
105#define option_select_get_title(_opt) \
106 (_opt)->title
107
108/*
109 * Tells the option selector wether it should stop when reaching the min/max value
110 * or should continue (by going to max/min)
111 * - opt : the option struct
112 * - scroll :
113 * - true : stops when reaching min/max
114 * - false : continues to go to max/min when reaching min/max
115 */
116#define option_select_limit_loop(_opt, loop) \
117 (_opt)->limit_loop=loop
118
119#endif /* _GUI_OPTION_SELECT_H_ */
diff --git a/apps/gui/quickscreen.c b/apps/gui/quickscreen.c
new file mode 100644
index 0000000000..760c1bdb00
--- /dev/null
+++ b/apps/gui/quickscreen.c
@@ -0,0 +1,179 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2005 by Kevin Ferrare
11 *
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.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include "quickscreen.h"
21#ifdef HAS_QUICKSCREEN
22
23#include "icons.h"
24#include "textarea.h"
25#include "font.h"
26#include "kernel.h"
27#include "misc.h"
28#include "statusbar.h"
29
30void gui_quickscreen_init(struct gui_quickscreen * qs,
31 struct option_select *left_option,
32 struct option_select *bottom_option,
33 struct option_select *right_option,
34 char * left_right_title,
35 quickscreen_callback callback)
36{
37 qs->left_option=left_option;
38 qs->bottom_option=bottom_option;
39 qs->right_option=right_option;
40 qs->left_right_title=left_right_title;
41 qs->callback=callback;
42}
43
44void gui_quickscreen_draw(struct gui_quickscreen * qs, struct screen * display)
45{
46 int w,h;
47 char buffer[30];
48 const char * option;
49 const char * title;
50#ifdef HAS_BUTTONBAR
51 display->has_buttonbar=false;
52#endif
53 gui_textarea_clear(display);
54 display->getstringsize("M",&w,&h);
55 /* Displays the icons */
56 display->mono_bitmap(bitmap_icons_7x8[Icon_FastBackward],
57 display->width/2 - 16,
58 display->height/2 - 4, 7, 8);
59 display->mono_bitmap(bitmap_icons_7x8[Icon_DownArrow],
60 display->width/2 - 3,
61 display->height - h*3, 7, 8);
62 display->mono_bitmap(bitmap_icons_7x8[Icon_FastForward],
63 display->width/2 + 8,
64 display->height/2 - 4, 7, 8);
65 display->setfont(FONT_SYSFIXED);
66
67 /* Displays the left's text */
68 title=option_select_get_title(qs->left_option);
69 option=option_select_get_text(qs->left_option, buffer);
70 display->putsxy(0, display->height/2 - h*2, title);
71 display->putsxy(0, display->height/2 - h, qs->left_right_title);
72 display->putsxy(0, display->height/2, option);
73
74 /* Displays the bottom's text */
75 title=option_select_get_title(qs->bottom_option);
76 option=option_select_get_text(qs->bottom_option, buffer);
77 display->getstringsize(title, &w, &h);
78 display->putsxy((display->width-w)/2, display->height - h*2, title);
79 display->getstringsize(option, &w, &h);
80 display->putsxy((display->width-w)/2, display->height - h, option);
81
82 /* Displays the right's text */
83 title=option_select_get_title(qs->right_option);
84 option=option_select_get_text(qs->right_option, buffer);
85 display->getstringsize(title,&w,&h);
86 display->putsxy(display->width - w, display->height/2 - h*2, title);
87 display->getstringsize(qs->left_right_title,&w,&h);
88 display->putsxy(display->width - w, display->height/2 - h, qs->left_right_title);
89 display->getstringsize(option,&w,&h);
90 display->putsxy(display->width - w, display->height/2, option);
91
92 gui_textarea_update(display);
93 lcd_setfont(FONT_UI);
94}
95
96void gui_syncquickscreen_draw(struct gui_quickscreen * qs)
97{
98 int i;
99 FOR_NB_SCREENS(i)
100 gui_quickscreen_draw(qs, &screens[i]);
101}
102
103bool gui_quickscreen_do_button(struct gui_quickscreen * qs, int button)
104{
105 switch(button)
106 {
107 case QUICKSCREEN_LEFT :
108 case QUICKSCREEN_LEFT | BUTTON_REPEAT :
109#ifdef QUICKSCREEN_RC_LEFT
110 case QUICKSCREEN_RC_LEFT :
111 case QUICKSCREEN_RC_LEFT | BUTTON_REPEAT :
112#endif
113 option_select_next(qs->left_option);
114 return(true);
115
116 case QUICKSCREEN_BOTTOM :
117 case QUICKSCREEN_BOTTOM | BUTTON_REPEAT :
118#ifdef QUICKSCREEN_RC_BOTTOM
119 case QUICKSCREEN_RC_BOTTOM :
120 case QUICKSCREEN_RC_BOTTOM | BUTTON_REPEAT :
121#endif
122 option_select_next(qs->bottom_option);
123 return(true);
124
125 case QUICKSCREEN_RIGHT :
126 case QUICKSCREEN_RIGHT | BUTTON_REPEAT :
127#ifdef QUICKSCREEN_RC_RIGHT
128 case QUICKSCREEN_RC_RIGHT :
129 case QUICKSCREEN_RC_RIGHT | BUTTON_REPEAT :
130#endif
131 option_select_next(qs->right_option);
132 return(true);
133
134 case QUICKSCREEN_BOTTOM_INV :
135 case QUICKSCREEN_BOTTOM_INV | BUTTON_REPEAT :
136#ifdef QUICKSCREEN_RC_BOTTOM_INV
137 case QUICKSCREEN_RC_BOTTOM_INV :
138 case QUICKSCREEN_RC_BOTTOM_INV | BUTTON_REPEAT :
139#endif
140 option_select_prev(qs->bottom_option);
141 return(true);
142 }
143 return(false);
144}
145
146bool gui_syncquickscreen_run(struct gui_quickscreen * qs)
147{
148 int key;
149 gui_syncquickscreen_draw(qs);
150 while (true) {
151 key = button_get(true);
152 if(default_event_handler(key) == SYS_USB_CONNECTED)
153 return(true);
154 if(gui_quickscreen_do_button(qs, key))
155 {
156 if(qs->callback)
157 qs->callback(qs);
158 gui_syncquickscreen_draw(qs);
159 }
160 else if(key==QUICKSCREEN_QUIT
161#ifdef QUICKSCREEN_QUIT
162 || key==QUICKSCREEN_QUIT
163#endif
164#ifdef QUICKSCREEN_QUIT2
165 || key==QUICKSCREEN_QUIT2
166#endif
167#if QUICKSCREEN_RC_QUIT
168 || key==QUICKSCREEN_RC_QUIT
169#endif
170 )
171 {
172 return(false);
173 }
174 gui_syncstatusbar_draw(&statusbars, false);
175 }
176}
177
178#endif /* HAS_QUICKSCREEN */
179
diff --git a/apps/gui/quickscreen.h b/apps/gui/quickscreen.h
new file mode 100644
index 0000000000..09a0390d93
--- /dev/null
+++ b/apps/gui/quickscreen.h
@@ -0,0 +1,114 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2005 by Kevin Ferrare
11 *
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.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#include "button.h"
20#include "config.h"
21#if (CONFIG_KEYPAD == RECORDER_PAD) || (CONFIG_KEYPAD == IRIVER_H100_PAD) ||\
22 (CONFIG_KEYPAD == IRIVER_H300_PAD)
23
24#ifndef _GUI_QUICKSCREEN_H_
25#define _GUI_QUICKSCREEN_H_
26
27#define HAS_QUICKSCREEN
28
29#include "option_select.h"
30#include "screen_access.h"
31
32#define QUICKSCREEN_LEFT BUTTON_LEFT
33#define QUICKSCREEN_BOTTOM BUTTON_DOWN
34#define QUICKSCREEN_BOTTOM_INV BUTTON_UP
35#define QUICKSCREEN_RIGHT BUTTON_RIGHT
36
37#if CONFIG_KEYPAD == RECORDER_PAD
38#define QUICKSCREEN_QUIT BUTTON_F2
39#define QUICKSCREEN_QUIT2 BUTTON_F3
40#elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
41#define QUICKSCREEN_QUIT BUTTON_MODE
42#define QUICKSCREEN_QUIT2 BUTTON_OFF
43#define QUICKSCREEN_RC_QUIT BUTTON_RC_MODE
44#ifdef CONFIG_REMOTE_KEYPAD
45#define QUICKSCREEN_RC_LEFT BUTTON_RC_REW
46#define QUICKSCREEN_RC_BOTTOM BUTTON_RC_VOL_DOWN
47#define QUICKSCREEN_RC_BOTTOM_INV BUTTON_RC_VOL_UP
48#define QUICKSCREEN_RC_RIGHT BUTTON_RC_FF
49#endif
50
51#endif
52
53struct gui_quickscreen;
54/*
55 * Callback function called each time the quickscreen gets modified
56 * - qs : the quickscreen that did the modification
57 */
58typedef void (quickscreen_callback)(struct gui_quickscreen * qs);
59
60struct gui_quickscreen
61{
62 struct option_select *left_option;
63 struct option_select *bottom_option;
64 struct option_select *right_option;
65 char * left_right_title;
66 quickscreen_callback *callback;
67};
68
69/*
70 * Initializes a quickscreen
71 * - qs : the quickscreen
72 * - left_option, bottom_option, right_option : a list of choices
73 * for each option
74 * - left_right_title : the 2nd line of the title
75 * on the left and on the right
76 * - callback : a callback function called each time the quickscreen
77 * gets modified
78 */
79void gui_quickscreen_init(struct gui_quickscreen * qs,
80 struct option_select *left_option,
81 struct option_select *bottom_option,
82 struct option_select *right_option,
83 char * left_right_title,
84 quickscreen_callback *callback);
85/*
86 * Draws the quickscreen on a given screen
87 * - qs : the quickscreen
88 * - display : the screen to draw on
89 */
90void gui_quickscreen_draw(struct gui_quickscreen * qs, struct screen * display);
91
92/*
93 * Does the actions associated to the given button if any
94 * - qs : the quickscreen
95 * - button : the key we are going to analyse
96 * returns : true if the button corresponded to an action, false otherwise
97 */
98bool gui_quickscreen_do_button(struct gui_quickscreen * qs, int button);
99
100/*
101 * Draws the quickscreen on all available screens
102 * - qs : the quickscreen
103 */
104void gui_syncquickscreen_draw(struct gui_quickscreen * qs);
105
106/*
107 * Runs the quickscreen on all available screens
108 * - qs : the quickscreen
109 * returns : true if usb was connected, false otherwise
110 */
111bool gui_syncquickscreen_run(struct gui_quickscreen * qs);
112
113#endif /*_GUI_QUICK_SCREEN_H_*/
114#endif /* CONFIG_KEYPAD */
diff --git a/apps/gui/select.c b/apps/gui/select.c
index 5cde812a2f..b632177fd7 100644
--- a/apps/gui/select.c
+++ b/apps/gui/select.c
@@ -21,9 +21,9 @@
21 21
22#include "lang.h" 22#include "lang.h"
23#include "textarea.h" 23#include "textarea.h"
24#include "sprintf.h"
25#include "kernel.h"
26#include "screen_access.h" 24#include "screen_access.h"
25#include "kernel.h"
26
27 27
28void gui_select_init_numeric(struct gui_select * select, 28void gui_select_init_numeric(struct gui_select * select,
29 const char * title, 29 const char * title,
@@ -32,23 +32,12 @@ void gui_select_init_numeric(struct gui_select * select,
32 int max_value, 32 int max_value,
33 int step, 33 int step,
34 const char * unit, 34 const char * unit,
35 void (*formatter)(char* dest, 35 option_formatter *formatter)
36 int dest_length,
37 int variable,
38 const char* unit)
39 )
40{ 36{
41 select->canceled=false; 37 select->canceled=false;
42 select->validated=false; 38 select->validated=false;
43 select->title=title; 39 option_select_init_numeric(&select->options, title, init_value,
44 select->min_value=min_value; 40 min_value, max_value, step, unit, formatter);
45 select->max_value=max_value+1;
46 select->option=init_value;
47 select->step=step;
48 select->extra_string=unit;
49 select->formatter=formatter;
50 select->items=NULL;
51 select->limit_loop=false;
52} 41}
53 42
54void gui_select_init_items(struct gui_select * select, 43void gui_select_init_items(struct gui_select * select,
@@ -59,69 +48,22 @@ void gui_select_init_items(struct gui_select * select,
59{ 48{
60 select->canceled=false; 49 select->canceled=false;
61 select->validated=false; 50 select->validated=false;
62 select->title=title; 51 option_select_init_items(&select->options, title, selected, items, nb_items);
63 select->min_value=0;
64 select->max_value=nb_items;
65 select->option=selected;
66 select->step=1;
67 select->formatter=NULL;
68 select->items=items;
69 select->limit_loop=false;
70}
71
72void gui_select_next(struct gui_select * select)
73{
74 if(select->option + select->step >= select->max_value)
75 {
76 if(!select->limit_loop)
77 {
78 if(select->option==select->max_value-1)
79 select->option=select->min_value;
80 else
81 select->option=select->max_value-1;
82 }
83 }
84 else
85 select->option+=select->step;
86}
87
88void gui_select_prev(struct gui_select * select)
89{
90 if(select->option - select->step < select->min_value)
91 {
92 if(!select->limit_loop)
93 {
94 if(select->option==select->min_value)
95 select->option=select->max_value-1;
96 else
97 select->option=select->min_value;
98 }
99 }
100 else
101 select->option-=select->step;
102} 52}
103 53
104void gui_select_draw(struct gui_select * select, struct screen * display) 54void gui_select_draw(struct gui_select * select, struct screen * display)
105{ 55{
56 char buffer[30];
57 const char * selected=option_select_get_text(&(select->options), buffer);
106#ifdef HAVE_LCD_BITMAP 58#ifdef HAVE_LCD_BITMAP
107 screen_set_xmargin(display, 0); 59 screen_set_xmargin(display, 0);
108#endif 60#endif
109 gui_textarea_clear(display); 61 gui_textarea_clear(display);
110 display->puts_scroll(0, 0, select->title); 62 display->puts_scroll(0, 0, option_select_get_title(&(select->options)));
111 63
112 if(gui_select_is_canceled(select)) 64 if(gui_select_is_canceled(select))
113 display->puts_scroll(0, 0, str(LANG_MENU_SETTING_CANCEL)); 65 display->puts_scroll(0, 0, str(LANG_MENU_SETTING_CANCEL));
114 if(select->items) 66 display->puts_scroll(0, 1, selected);
115 display->puts_scroll(0, 1, P2STR(select->items[select->option].string));
116 else
117 {
118 char buffer[30];
119 if(!select->formatter)
120 snprintf(buffer, sizeof buffer,"%d %s", select->option, select->extra_string);
121 else
122 select->formatter(buffer, sizeof buffer, select->option, select->extra_string);
123 display->puts_scroll(0, 1, buffer);
124 }
125 gui_textarea_update(display); 67 gui_textarea_update(display);
126} 68}
127 69
diff --git a/apps/gui/select.h b/apps/gui/select.h
index bc14af4a24..2799d80043 100644
--- a/apps/gui/select.h
+++ b/apps/gui/select.h
@@ -21,6 +21,7 @@
21#define _GUI_SELECT_H_ 21#define _GUI_SELECT_H_
22#include "screen_access.h" 22#include "screen_access.h"
23#include "settings.h" 23#include "settings.h"
24#include "option_select.h"
24 25
25#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \ 26#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
26 (CONFIG_KEYPAD == IRIVER_H300_PAD) 27 (CONFIG_KEYPAD == IRIVER_H300_PAD)
@@ -83,19 +84,7 @@ struct gui_select
83{ 84{
84 bool canceled; 85 bool canceled;
85 bool validated; 86 bool validated;
86 const char * title; 87 struct option_select options;
87 int min_value;
88 int max_value;
89 int step;
90 int option;
91 const char * extra_string;
92 /* In the case the option is a number */
93 void (*formatter)(char* dest,
94 int dest_length,
95 int variable,
96 const char* unit);
97 const struct opt_items * items;
98 bool limit_loop;
99}; 88};
100 89
101/* 90/*
@@ -116,10 +105,7 @@ extern void gui_select_init_numeric(struct gui_select * select,
116 int max_value, 105 int max_value,
117 int step, 106 int step,
118 const char * unit, 107 const char * unit,
119 void (*formatter)(char* dest, 108 option_formatter *formatter);
120 int dest_length,
121 int variable,
122 const char* unit));
123 109
124 110
125/* 111/*
@@ -140,13 +126,15 @@ extern void gui_select_init_items(struct gui_select * select,
140 * Selects the next value 126 * Selects the next value
141 * - select : the select struct 127 * - select : the select struct
142 */ 128 */
143extern void gui_select_next(struct gui_select * select); 129#define gui_select_next(select) \
130 option_select_next(&(select->options))
144 131
145/* 132/*
146 * Selects the previous value 133 * Selects the previous value
147 * - select : the select struct 134 * - select : the select struct
148 */ 135 */
149extern void gui_select_prev(struct gui_select * select); 136#define gui_select_prev(select) \
137 option_select_prev(&(select->options))
150 138
151/* 139/*
152 * Draws the select on the given screen 140 * Draws the select on the given screen
@@ -159,9 +147,8 @@ extern void gui_select_draw(struct gui_select * select, struct screen * display)
159 * Returns the selected value 147 * Returns the selected value
160 * - select : the select struct 148 * - select : the select struct
161 */ 149 */
162#define gui_select_get_selected(select) \ 150#define gui_select_get_selected(_sel_) \
163 (select)->option 151 option_select_get_selected(&((_sel_)->options))
164
165/* 152/*
166 * Cancels the select 153 * Cancels the select
167 * - select : the select struct 154 * - select : the select struct
@@ -199,7 +186,7 @@ extern void gui_select_draw(struct gui_select * select, struct screen * display)
199 * - false : continues to go to max/min when reaching min/max 186 * - false : continues to go to max/min when reaching min/max
200 */ 187 */
201#define gui_select_limit_loop(select, loop) \ 188#define gui_select_limit_loop(select, loop) \
202 (select)->limit_loop=loop 189 option_select_limit_loop(&((select)->options), loop)
203 190
204/* 191/*
205 * Draws the select on all the screens 192 * Draws the select on all the screens
diff --git a/apps/gui/statusbar.h b/apps/gui/statusbar.h
index e7fe92eaf9..816205e2b4 100644
--- a/apps/gui/statusbar.h
+++ b/apps/gui/statusbar.h
@@ -85,8 +85,9 @@ extern void gui_statusbar_init(struct gui_statusbar * bar);
85 * - bar : the statusbar structure 85 * - bar : the statusbar structure
86 * - display : the screen to attach 86 * - display : the screen to attach
87 */ 87 */
88#define gui_statusbar_set_screen(gui_statusbar, screen) \ 88#define gui_statusbar_set_screen(gui_statusbar, _display) \
89 (gui_statusbar)->display = screen 89 (gui_statusbar)->display = (_display);
90
90 91
91/* 92/*
92 * Draws the status bar on the attached screen 93 * Draws the status bar on the attached screen