Remove unneeded include from screens.c
[kugel-rb.git] / apps / plugins / clock / clock_menu.c
blobed0027305b1ac80f932b4f34dc68769ba7d81617
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2003 Zakk Roberts
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #include "clock.h"
23 #include "clock_bitmaps.h"
24 #include "clock_settings.h"
25 #include "lib/playback_control.h"
27 /* Option structs (possible selections per each option) */
28 static const struct opt_items noyes_text[] = {
29 { "No", -1 },
30 { "Yes", -1 }
33 static const struct opt_items backlight_settings_text[] = {
34 { "Always Off", -1 },
35 { "Use Rockbox Setting", -1 },
36 { "Always On", -1 }
39 static const struct opt_items idle_poweroff_text[] = {
40 { "Disabled", -1 },
41 { "Enabled", -1 }
44 static const struct opt_items date_format_text[] = {
45 { "No date", -1 },
46 { "US (M-D-Y)", -1 },
47 { "European (D-M-Y)", -1 },
48 { "Japanese (Y-M-D)", -1 },
51 static const struct opt_items hour_format_text[] = {
52 { "24-Hour", -1 },
53 { "12-Hour", -1 }
56 /***************
57 * Select a mode, returs true when the mode has been selected
58 * (we go back to clock display then)
59 **************/
60 bool menu_mode_selector(void){
61 MENUITEM_STRINGLIST(menu,"Mode Selector",NULL, "Analog",
62 "Digital", "Binary");
63 if(rb->do_menu(&menu, &clock_settings.mode, NULL, false) >=0)
64 return(true);
65 return(false);
68 /**********************
69 * Analog settings menu
70 *********************/
71 void menu_analog_settings(void)
73 int selection=0, result=0;
75 MENUITEM_STRINGLIST(menu,"Analog Mode Settings",NULL,"Show Date",
76 "Show Second Hand","Show Border");
78 while(result>=0){
79 result=rb->do_menu(&menu, &selection, NULL, false);
80 switch(result){
81 case 0:
82 rb->set_option("Show Date", &clock_settings.analog.show_date,
83 BOOL, noyes_text, 2, NULL);
84 break;
85 case 1:
86 rb->set_option("Show Second Hand",
87 &clock_settings.analog.show_seconds,
88 BOOL, noyes_text, 2, NULL);
89 break;
90 case 2:
91 rb->set_option("Show Border",
92 &clock_settings.analog.show_border,
93 BOOL, noyes_text, 2, NULL);
94 break;
99 /***********************
100 * Digital settings menu
101 **********************/
102 void menu_digital_settings(void){
103 int selection=0, result=0;
105 MENUITEM_STRINGLIST(menu,"Digital Mode Settings",NULL,"Show Seconds",
106 "Blinking Colon");
108 while(result>=0){
109 result=rb->do_menu(&menu, &selection, NULL, false);
110 switch(result){
111 case 0:
112 rb->set_option("Show Seconds",
113 &clock_settings.digital.show_seconds,
114 BOOL, noyes_text, 2, NULL);
115 break;
116 case 1:
117 rb->set_option("Blinking Colon",
118 &clock_settings.digital.blinkcolon,
119 BOOL, noyes_text, 2, NULL);
120 break;
125 /***********************************************************
126 * Confirm resetting of settings, used in general_settings()
127 **********************************************************/
128 void confirm_reset(void){
129 int result=0;
131 rb->set_option("Reset all settings?", &result, INT, noyes_text, 2, NULL);
133 if(result == 1){ /* reset! */
134 clock_settings_reset(&clock_settings);
135 rb->splash(HZ, "Settings reset!");
137 else
138 rb->splash(HZ, "Settings NOT reset.");
141 /************************************
142 * General settings. Reset, save, etc
143 ***********************************/
144 void menu_general_settings(void){
145 int selection=0, result=0;
147 MENUITEM_STRINGLIST(menu,"General Settings",NULL,
148 "Hour Format","Date Format","Show Counter",
149 "Reset Settings","Save Settings Now",
150 "Save On Exit","Backlight Settings",
151 "Idle Poweroff (temporary)");
153 while(result>=0){
154 result=rb->do_menu(&menu, &selection, NULL, false);
155 switch(result){
156 case 0:
157 rb->set_option("Hour format",
158 &clock_settings.general.hour_format,
159 INT, hour_format_text, 2, NULL);
160 break;
161 case 1:
162 rb->set_option("Date format",
163 &clock_settings.general.date_format,
164 INT, date_format_text, 4, NULL);
165 break;
166 case 2:
167 rb->set_option("Show Counter", &clock_settings.general.show_counter,
168 BOOL, noyes_text, 2, NULL);
169 break;
170 case 3:
171 confirm_reset();
172 break;
174 case 4:
175 save_settings_wo_gui();
176 rb->splash(HZ, "Settings saved");
177 break;
179 case 5:
180 rb->set_option("Save On Exit",
181 &clock_settings.general.save_settings,
182 BOOL, noyes_text, 2, NULL);
184 /* if we no longer save on exit,
185 we better save now to remember that */
186 if(!clock_settings.general.save_settings)
187 save_settings_wo_gui();
188 break;
189 case 6:
190 rb->set_option("Backlight Settings",
191 &clock_settings.general.backlight,
192 INT, backlight_settings_text, 3, NULL);
193 apply_backlight_setting(clock_settings.general.backlight);
194 break;
196 case 7:
197 rb->set_option("Idle Poweroff (temporary)",
198 &clock_settings.general.idle_poweroff,
199 BOOL, idle_poweroff_text, 2, NULL);
200 break;
205 /***********
206 * Main menu
207 **********/
208 bool main_menu(void){
209 int selection=0;
210 bool done = false;
211 bool exit_clock=false;
213 MENUITEM_STRINGLIST(menu,"Clock Menu",NULL,"View Clock","Mode Selector",
214 "Mode Settings","General Settings","Playback Control",
215 "Quit");
217 while(!done){
218 switch(rb->do_menu(&menu, &selection, NULL, false)){
219 case 0:
220 done = true;
221 break;
223 case 1:
224 done=menu_mode_selector();
225 break;
227 case 2:
228 switch(clock_settings.mode){
229 case ANALOG: menu_analog_settings();break;
230 case DIGITAL: menu_digital_settings();break;
231 case BINARY: /* no settings */;break;
233 break;
235 case 3:
236 menu_general_settings();
237 break;
239 case 4:
240 playback_control(NULL);
241 break;
243 case 5:
244 exit_clock = true;
245 done = true;
246 break;
248 default:
249 done=true;
250 break;
253 return(exit_clock);