From 1e781eab6c7177df33e016d01dbd78ae25b36e2f Mon Sep 17 00:00:00 2001 From: Linus Nielsen Feltzing Date: Tue, 4 Nov 2003 13:17:29 +0000 Subject: Generic F-key buttonbar functionality git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4013 a1c6a512-1295-4272-9138-f99709370657 --- apps/status.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'apps/status.c') 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 @@ #endif #ifdef HAVE_LCD_BITMAP #include "icons.h" +#include "font.h" #endif #include "powermgmt.h" @@ -227,3 +228,47 @@ void status_draw(bool force_redraw) } +#ifdef HAVE_LCD_BITMAP +static void draw_buttonbar_btn(int num, char* caption) +{ + int xpos, ypos, button_width, text_width; + int fw, fh; + + lcd_setfont(FONT_SYSFIXED); + lcd_getstringsize("M", &fw, &fh); + + button_width = LCD_WIDTH/3; + xpos = num * button_width; + ypos = LCD_HEIGHT - fh; + + if(caption) + { + /* center the text */ + text_width = fw * strlen(caption); + lcd_putsxy(xpos + (button_width - text_width)/2, ypos, caption); + } + + lcd_invertrect(xpos, ypos, button_width - 1, fh); +} + +static char stored_caption1[8]; +static char stored_caption2[8]; +static char stored_caption3[8]; + +void set_buttonbar(char* caption1, char *caption2, char *caption3) +{ + strncpy(stored_caption1, caption1, 7); + stored_caption1[7] = 0; + strncpy(stored_caption2, caption2, 7); + stored_caption2[7] = 0; + strncpy(stored_caption3, caption3, 7); + stored_caption3[7] = 0; +} + +void draw_buttonbar(void) +{ + draw_buttonbar_btn(0, stored_caption1); + draw_buttonbar_btn(1, stored_caption2); + draw_buttonbar_btn(2, stored_caption3); +} +#endif -- cgit v1.2.3