diff options
author | Linus Nielsen Feltzing <linus@haxx.se> | 2003-11-04 13:17:29 +0000 |
---|---|---|
committer | Linus Nielsen Feltzing <linus@haxx.se> | 2003-11-04 13:17:29 +0000 |
commit | 1e781eab6c7177df33e016d01dbd78ae25b36e2f (patch) | |
tree | 9a230531ebb5e79f09d8ab82909f30b060c6fb13 /apps | |
parent | 6afd0a7a083fa470c62cc2189f30ae4c63c534f7 (diff) | |
download | rockbox-1e781eab6c7177df33e016d01dbd78ae25b36e2f.tar.gz rockbox-1e781eab6c7177df33e016d01dbd78ae25b36e2f.zip |
Generic F-key buttonbar functionality
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4013 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/recorder/keyboard.c | 11 | ||||
-rw-r--r-- | apps/status.c | 45 | ||||
-rw-r--r-- | apps/status.h | 2 |
3 files changed, 52 insertions, 6 deletions
diff --git a/apps/recorder/keyboard.c b/apps/recorder/keyboard.c index 9edf24694d..95b2cb3386 100644 --- a/apps/recorder/keyboard.c +++ b/apps/recorder/keyboard.c | |||
@@ -55,7 +55,7 @@ static void kbd_setupkeys(char* line[KEYBOARD_LINES], int page) | |||
55 | break; | 55 | break; |
56 | } | 56 | } |
57 | } | 57 | } |
58 | 58 | #if 0 | |
59 | static void kbd_draw_statusbar_button(int num, char* caption, int y, int fw) | 59 | static void kbd_draw_statusbar_button(int num, char* caption, int y, int fw) |
60 | { | 60 | { |
61 | int x, x2, tw, cx; | 61 | int x, x2, tw, cx; |
@@ -67,7 +67,7 @@ static void kbd_draw_statusbar_button(int num, char* caption, int y, int fw) | |||
67 | lcd_putsxy((x + (cx/2)) - (tw/2), y, caption); | 67 | lcd_putsxy((x + (cx/2)) - (tw/2), y, caption); |
68 | lcd_invertrect(x, y - 1, (x2-x)-1, LCD_HEIGHT-y+1); | 68 | lcd_invertrect(x, y - 1, (x2-x)-1, LCD_HEIGHT-y+1); |
69 | } | 69 | } |
70 | 70 | #endif | |
71 | int kbd_input(char* text, int buflen) | 71 | int kbd_input(char* text, int buflen) |
72 | { | 72 | { |
73 | bool done = false; | 73 | bool done = false; |
@@ -168,10 +168,9 @@ int kbd_input(char* text, int buflen) | |||
168 | lcd_drawline(curpos, main_y, curpos, main_y + font_h); | 168 | lcd_drawline(curpos, main_y, curpos, main_y + font_h); |
169 | 169 | ||
170 | /* draw the status bar */ | 170 | /* draw the status bar */ |
171 | kbd_draw_statusbar_button(0, "Shift", status_y1, font_w); | 171 | set_buttonbar("Shift", "OK", "Del"); |
172 | kbd_draw_statusbar_button(1, "OK", status_y1, font_w); | 172 | draw_buttonbar(); |
173 | kbd_draw_statusbar_button(2, "Del", status_y1, font_w); | 173 | |
174 | |||
175 | /* highlight the key that has focus */ | 174 | /* highlight the key that has focus */ |
176 | lcd_invertrect(font_w * x, font_h * y, font_w, font_h); | 175 | lcd_invertrect(font_w * x, font_h * y, font_w, font_h); |
177 | lcd_update(); | 176 | lcd_update(); |
diff --git a/apps/status.c b/apps/status.c index f0445c3901..a1e01106bc 100644 --- a/apps/status.c +++ b/apps/status.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #endif | 31 | #endif |
32 | #ifdef HAVE_LCD_BITMAP | 32 | #ifdef HAVE_LCD_BITMAP |
33 | #include "icons.h" | 33 | #include "icons.h" |
34 | #include "font.h" | ||
34 | #endif | 35 | #endif |
35 | #include "powermgmt.h" | 36 | #include "powermgmt.h" |
36 | 37 | ||
@@ -227,3 +228,47 @@ void status_draw(bool force_redraw) | |||
227 | 228 | ||
228 | } | 229 | } |
229 | 230 | ||
231 | #ifdef HAVE_LCD_BITMAP | ||
232 | static void draw_buttonbar_btn(int num, char* caption) | ||
233 | { | ||
234 | int xpos, ypos, button_width, text_width; | ||
235 | int fw, fh; | ||
236 | |||
237 | lcd_setfont(FONT_SYSFIXED); | ||
238 | lcd_getstringsize("M", &fw, &fh); | ||
239 | |||
240 | button_width = LCD_WIDTH/3; | ||
241 | xpos = num * button_width; | ||
242 | ypos = LCD_HEIGHT - fh; | ||
243 | |||
244 | if(caption) | ||
245 | { | ||
246 | /* center the text */ | ||
247 | text_width = fw * strlen(caption); | ||
248 | lcd_putsxy(xpos + (button_width - text_width)/2, ypos, caption); | ||
249 | } | ||
250 | |||
251 | lcd_invertrect(xpos, ypos, button_width - 1, fh); | ||
252 | } | ||
253 | |||
254 | static char stored_caption1[8]; | ||
255 | static char stored_caption2[8]; | ||
256 | static char stored_caption3[8]; | ||
257 | |||
258 | void set_buttonbar(char* caption1, char *caption2, char *caption3) | ||
259 | { | ||
260 | strncpy(stored_caption1, caption1, 7); | ||
261 | stored_caption1[7] = 0; | ||
262 | strncpy(stored_caption2, caption2, 7); | ||
263 | stored_caption2[7] = 0; | ||
264 | strncpy(stored_caption3, caption3, 7); | ||
265 | stored_caption3[7] = 0; | ||
266 | } | ||
267 | |||
268 | void draw_buttonbar(void) | ||
269 | { | ||
270 | draw_buttonbar_btn(0, stored_caption1); | ||
271 | draw_buttonbar_btn(1, stored_caption2); | ||
272 | draw_buttonbar_btn(2, stored_caption3); | ||
273 | } | ||
274 | #endif | ||
diff --git a/apps/status.h b/apps/status.h index 203c7a80d7..1331351523 100644 --- a/apps/status.h +++ b/apps/status.h | |||
@@ -34,6 +34,8 @@ void status_init(void); | |||
34 | void status_set_playmode(enum playmode mode); | 34 | void status_set_playmode(enum playmode mode); |
35 | #ifdef HAVE_LCD_BITMAP | 35 | #ifdef HAVE_LCD_BITMAP |
36 | bool statusbar(bool state); | 36 | bool statusbar(bool state); |
37 | void set_buttonbar(char* caption1, char* caption2, char* caption3); | ||
38 | void draw_buttonbar(void); | ||
37 | #endif | 39 | #endif |
38 | void status_draw(bool force_redraw); | 40 | void status_draw(bool force_redraw); |
39 | 41 | ||