diff options
author | Kevin Ferrare <kevin@rockbox.org> | 2007-08-04 03:01:46 +0000 |
---|---|---|
committer | Kevin Ferrare <kevin@rockbox.org> | 2007-08-04 03:01:46 +0000 |
commit | 93b2f9fd447b73fff736d71826880ef9ac64bd94 (patch) | |
tree | 1a4f54016c312738d66fb9dd2348ea0ef14f1255 /apps/plugins/clock/clock_menu.c | |
parent | ffbbc60f38ddc8aeadc9cea1102077e22ca84a1a (diff) | |
download | rockbox-93b2f9fd447b73fff736d71826880ef9ac64bd94.tar.gz rockbox-93b2f9fd447b73fff736d71826880ef9ac64bd94.zip |
Rewrote the clock plugin in a cleaner and more modular way so that it can scale on remote screens. Use left-right keys to change the type of clock displayed (analogic, digital, binary) and up/downto change the look of the clock
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14174 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/clock/clock_menu.c')
-rw-r--r-- | apps/plugins/clock/clock_menu.c | 246 |
1 files changed, 246 insertions, 0 deletions
diff --git a/apps/plugins/clock/clock_menu.c b/apps/plugins/clock/clock_menu.c new file mode 100644 index 0000000000..3310dbf929 --- /dev/null +++ b/apps/plugins/clock/clock_menu.c | |||
@@ -0,0 +1,246 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: jackpot.c 14034 2007-07-28 05:42:55Z kevin $ | ||
9 | * | ||
10 | * Copyright (C) 2003 Zakk Roberts | ||
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 "clock.h" | ||
21 | #include "clock_bitmaps.h" | ||
22 | #include "clock_settings.h" | ||
23 | |||
24 | /* Option structs (possible selections per each option) */ | ||
25 | static const struct opt_items noyes_text[] = { | ||
26 | { "No", -1 }, | ||
27 | { "Yes", -1 } | ||
28 | }; | ||
29 | |||
30 | static const struct opt_items backlight_settings_text[] = { | ||
31 | { "Always Off", -1 }, | ||
32 | { "Rockbox setting", -1 }, | ||
33 | { "Always On", -1 } | ||
34 | }; | ||
35 | |||
36 | static const struct opt_items idle_poweroff_text[] = { | ||
37 | { "Disabled", -1 }, | ||
38 | { "Enabled", -1 } | ||
39 | }; | ||
40 | |||
41 | static const struct opt_items date_format_text[] = { | ||
42 | { "No date", -1 }, | ||
43 | { "English format", -1 }, | ||
44 | { "European format", -1 }, | ||
45 | { "Japanese format", -1 }, | ||
46 | }; | ||
47 | |||
48 | static const struct opt_items hour_format_text[] = { | ||
49 | { "24-hour Format", -1 }, | ||
50 | { "12-hour Format", -1 } | ||
51 | }; | ||
52 | |||
53 | /*************** | ||
54 | * Select a mode, returs true when the mode has been selected | ||
55 | * (we go back to clock display then) | ||
56 | **************/ | ||
57 | bool menu_mode_selector(void){ | ||
58 | MENUITEM_STRINGLIST(menu,"Mode Selector",NULL, "Analog", | ||
59 | "Digital", "Binary"); | ||
60 | if(rb->do_menu(&menu, &clock_settings.mode) >=0) | ||
61 | return(true); | ||
62 | return(false); | ||
63 | } | ||
64 | |||
65 | /********************** | ||
66 | * Analog settings menu | ||
67 | *********************/ | ||
68 | void menu_analog_settings(void) | ||
69 | { | ||
70 | int selection=0, result=0; | ||
71 | |||
72 | MENUITEM_STRINGLIST(menu,"Analog Mode Settings",NULL,"Show Date", | ||
73 | "Show Second Hand","Show Border"); | ||
74 | |||
75 | while(result>=0){ | ||
76 | result=rb->do_menu(&menu, &selection); | ||
77 | switch(result){ | ||
78 | case 0: | ||
79 | rb->set_option("Show Date", &clock_settings.analog.show_date, | ||
80 | BOOL, noyes_text, 2, NULL); | ||
81 | break; | ||
82 | case 1: | ||
83 | rb->set_option("Show Second Hand", | ||
84 | &clock_settings.analog.show_seconds, | ||
85 | BOOL, noyes_text, 2, NULL); | ||
86 | break; | ||
87 | case 2: | ||
88 | rb->set_option("Show Border", | ||
89 | &clock_settings.analog.show_border, | ||
90 | BOOL, noyes_text, 2, NULL); | ||
91 | break; | ||
92 | } | ||
93 | } | ||
94 | } | ||
95 | |||
96 | /*********************** | ||
97 | * Digital settings menu | ||
98 | **********************/ | ||
99 | void menu_digital_settings(void){ | ||
100 | int selection=0, result=0; | ||
101 | |||
102 | MENUITEM_STRINGLIST(menu,"Digital Mode Settings",NULL,"Show Seconds", | ||
103 | "Blinking Colon"); | ||
104 | |||
105 | while(result>=0){ | ||
106 | result=rb->do_menu(&menu, &selection); | ||
107 | switch(result){ | ||
108 | case 0: | ||
109 | rb->set_option("Show Seconds", | ||
110 | &clock_settings.digital.show_seconds, | ||
111 | BOOL, noyes_text, 2, NULL); | ||
112 | break; | ||
113 | case 1: | ||
114 | rb->set_option("Blinking Colon", | ||
115 | &clock_settings.digital.blinkcolon, | ||
116 | BOOL, noyes_text, 2, NULL); | ||
117 | break; | ||
118 | } | ||
119 | } | ||
120 | } | ||
121 | |||
122 | /*********************************************************** | ||
123 | * Confirm resetting of settings, used in general_settings() | ||
124 | **********************************************************/ | ||
125 | void confirm_reset(void){ | ||
126 | int result=0; | ||
127 | |||
128 | rb->set_option("Reset all settings?", &result, INT, noyes_text, 2, NULL); | ||
129 | |||
130 | if(result == 1){ /* reset! */ | ||
131 | clock_settings_reset(&clock_settings); | ||
132 | rb->splash(HZ, "Settings reset!"); | ||
133 | } | ||
134 | else | ||
135 | rb->splash(HZ, "Settings NOT reset."); | ||
136 | } | ||
137 | |||
138 | /************************************ | ||
139 | * General settings. Reset, save, etc | ||
140 | ***********************************/ | ||
141 | void menu_general_settings(void){ | ||
142 | int selection=0, result=0; | ||
143 | |||
144 | MENUITEM_STRINGLIST(menu,"General Settings",NULL, | ||
145 | "Hour format","Date format","Show Counter", | ||
146 | "Reset Settings","Save Settings Now", | ||
147 | "Save On Exit","Backlight Settings", | ||
148 | "Idle Poweroff (temporary)"); | ||
149 | |||
150 | while(result>=0){ | ||
151 | result=rb->do_menu(&menu, &selection); | ||
152 | switch(result){ | ||
153 | case 0: | ||
154 | rb->set_option("Hour format", | ||
155 | &clock_settings.general.hour_format, | ||
156 | INT, hour_format_text, 2, NULL); | ||
157 | break; | ||
158 | case 1: | ||
159 | rb->set_option("Date format", | ||
160 | &clock_settings.general.date_format, | ||
161 | INT, date_format_text, 4, NULL); | ||
162 | break; | ||
163 | case 2: | ||
164 | rb->set_option("Show Counter", &clock_settings.general.show_counter, | ||
165 | BOOL, noyes_text, 2, NULL); | ||
166 | break; | ||
167 | case 3: | ||
168 | confirm_reset(); | ||
169 | break; | ||
170 | |||
171 | case 4: | ||
172 | save_settings_wo_gui(); | ||
173 | rb->splash(HZ, "Settings saved"); | ||
174 | break; | ||
175 | |||
176 | case 5: | ||
177 | rb->set_option("Save On Exit", | ||
178 | &clock_settings.general.save_settings, | ||
179 | BOOL, noyes_text, 2, NULL); | ||
180 | |||
181 | /* if we no longer save on exit, | ||
182 | we better save now to remember that */ | ||
183 | if(!clock_settings.general.save_settings) | ||
184 | save_settings_wo_gui(); | ||
185 | break; | ||
186 | case 6: | ||
187 | rb->set_option("Backlight Settings", | ||
188 | &clock_settings.general.backlight, | ||
189 | INT, backlight_settings_text, 3, NULL); | ||
190 | apply_backlight_setting(clock_settings.general.backlight); | ||
191 | break; | ||
192 | |||
193 | case 7: | ||
194 | rb->set_option("Idle Poweroff (temporary)", | ||
195 | &clock_settings.general.idle_poweroff, | ||
196 | BOOL, idle_poweroff_text, 2, NULL); | ||
197 | break; | ||
198 | } | ||
199 | } | ||
200 | } | ||
201 | |||
202 | /*********** | ||
203 | * Main menu | ||
204 | **********/ | ||
205 | bool main_menu(void){ | ||
206 | int selection=0; | ||
207 | bool done = false; | ||
208 | bool exit_clock=false; | ||
209 | |||
210 | MENUITEM_STRINGLIST(menu,"Clock Menu",NULL,"View Clock","Mode Selector", | ||
211 | "Mode Settings","General Settings","Quit"); | ||
212 | |||
213 | while(!done){ | ||
214 | switch(rb->do_menu(&menu, &selection)){ | ||
215 | case 0: | ||
216 | done = true; | ||
217 | break; | ||
218 | |||
219 | case 1: | ||
220 | done=menu_mode_selector(); | ||
221 | break; | ||
222 | |||
223 | case 2: | ||
224 | switch(clock_settings.mode){ | ||
225 | case ANALOG: menu_analog_settings();break; | ||
226 | case DIGITAL: menu_digital_settings();break; | ||
227 | case BINARY: /* no settings */;break; | ||
228 | } | ||
229 | break; | ||
230 | |||
231 | case 3: | ||
232 | menu_general_settings(); | ||
233 | break; | ||
234 | |||
235 | case 4: | ||
236 | exit_clock = true; | ||
237 | done = true; | ||
238 | break; | ||
239 | |||
240 | default: | ||
241 | done=true; | ||
242 | break; | ||
243 | } | ||
244 | } | ||
245 | return(exit_clock); | ||
246 | } | ||