1
0
Fork 0
forked from len0rd/rockbox

Generic F-key buttonbar functionality

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4013 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Linus Nielsen Feltzing 2003-11-04 13:17:29 +00:00
parent 6afd0a7a08
commit 1e781eab6c
3 changed files with 52 additions and 6 deletions

View file

@ -55,7 +55,7 @@ static void kbd_setupkeys(char* line[KEYBOARD_LINES], int page)
break;
}
}
#if 0
static void kbd_draw_statusbar_button(int num, char* caption, int y, int fw)
{
int x, x2, tw, cx;
@ -67,7 +67,7 @@ static void kbd_draw_statusbar_button(int num, char* caption, int y, int fw)
lcd_putsxy((x + (cx/2)) - (tw/2), y, caption);
lcd_invertrect(x, y - 1, (x2-x)-1, LCD_HEIGHT-y+1);
}
#endif
int kbd_input(char* text, int buflen)
{
bool done = false;
@ -168,10 +168,9 @@ int kbd_input(char* text, int buflen)
lcd_drawline(curpos, main_y, curpos, main_y + font_h);
/* draw the status bar */
kbd_draw_statusbar_button(0, "Shift", status_y1, font_w);
kbd_draw_statusbar_button(1, "OK", status_y1, font_w);
kbd_draw_statusbar_button(2, "Del", status_y1, font_w);
set_buttonbar("Shift", "OK", "Del");
draw_buttonbar();
/* highlight the key that has focus */
lcd_invertrect(font_w * x, font_h * y, font_w, font_h);
lcd_update();

View file

@ -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

View file

@ -34,6 +34,8 @@ void status_init(void);
void status_set_playmode(enum playmode mode);
#ifdef HAVE_LCD_BITMAP
bool statusbar(bool state);
void set_buttonbar(char* caption1, char* caption2, char* caption3);
void draw_buttonbar(void);
#endif
void status_draw(bool force_redraw);