diff options
author | Johannes Schwarz <ubuntuxer@rockbox.org> | 2009-07-02 17:02:47 +0000 |
---|---|---|
committer | Johannes Schwarz <ubuntuxer@rockbox.org> | 2009-07-02 17:02:47 +0000 |
commit | bff790d692333fe8e43605682c4a980821e82b53 (patch) | |
tree | 1a8e45107901fcf215d92815f8cc528e54e4295f /apps/plugins/lib | |
parent | 278f1f69bb132ee4600f7706ff5783a625f9039c (diff) |
reduce size of the instance of struct style_text in lib/display.h (thanks to Teruaki Kawashima)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21614 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/lib')
-rw-r--r-- | apps/plugins/lib/display_text.c | 19 | ||||
-rw-r--r-- | apps/plugins/lib/display_text.h | 9 |
2 files changed, 17 insertions, 11 deletions
diff --git a/apps/plugins/lib/display_text.c b/apps/plugins/lib/display_text.c index 8ba31e2ff3..67c78ec242 100644 --- a/apps/plugins/lib/display_text.c +++ b/apps/plugins/lib/display_text.c @@ -35,14 +35,14 @@ bool display_text(short words, char** text, struct style_text* style, int prev_drawmode; #endif #ifdef HAVE_LCD_COLOR - unsigned standard_fgcolor; + int standard_fgcolor; #endif int space_w, width, height; unsigned short x , y; unsigned short vp_width = LCD_WIDTH; unsigned short vp_height = LCD_HEIGHT; int button; - short i=0; + unsigned short i = 0, style_index = 0; if (vp_text != NULL) { vp_width = vp_text->width; vp_height = vp_text->height; @@ -85,17 +85,17 @@ bool display_text(short words, char** text, struct style_text* style, || ( button & (BUTTON_REL|BUTTON_REPEAT) ) ); rb->screens[SCREEN_MAIN]->clear_viewport(); } - /* no text formations available */ - if (style==NULL) { + /* no text formatting available */ + if (style==NULL || style[style_index].index != i) { rb->lcd_putsxy(x, y, text[i]); } else { /* set align */ - if (style[i].flags&TEXT_CENTER) { + if (style[style_index].flags&TEXT_CENTER) { x = (vp_width-width)/2; } /* set font color */ #ifdef HAVE_LCD_COLOR - switch (style[i].flags&TEXT_COLOR_MASK) { + switch (style[style_index].flags&TEXT_COLOR_MASK) { case C_RED: rb->lcd_set_foreground(LCD_RGBPACK(255,0,0)); break; @@ -118,11 +118,16 @@ bool display_text(short words, char** text, struct style_text* style, } #endif rb->lcd_putsxy(x, y, text[i]); + /* underline the word */ #ifdef HAVE_LCD_BITMAP - if (style[i].flags&TEXT_UNDERLINE) { + if (style[style_index].flags&TEXT_UNDERLINE) { rb->lcd_hline(x, x+width, y+height-1); } #endif +#ifdef HAVE_LCD_COLOR + rb->lcd_set_foreground(standard_fgcolor); +#endif + style_index++; } x += width + space_w; } diff --git a/apps/plugins/lib/display_text.h b/apps/plugins/lib/display_text.h index 9f21d236ea..39b5f76a14 100644 --- a/apps/plugins/lib/display_text.h +++ b/apps/plugins/lib/display_text.h @@ -24,9 +24,9 @@ * basic usage: * #define WORDS (sizeof text / sizeof (char*)) * char *text[] = {"normal", "centering", "red,underline"}; - * struct style_text formation[WORDS]={ - * [1] = { TEXT_CENTER }, - * [2] = { C_RED|TEXT_UNDERLINE }, + * struct style_text formation[]={ + * { 1, TEXT_CENTER }, + * { 2, C_RED|TEXT_UNDERLINE }, * }; * if (display_text(WORDS, text, formation, NULL)) * return PLUGIN_USB_CONNECTED; @@ -38,10 +38,11 @@ enum ecolor { STANDARD, C_YELLOW, C_RED, C_BLUE, C_GREEN , C_ORANGE }; #define TEXT_UNDERLINE 0x0200 struct style_text { + unsigned short index; unsigned short flags; }; -/* style and vp_text is optional. +/* style and vp_text are optional. * return true if usb is connected. */ bool display_text(short words, char** text, struct style_text* style, struct viewport* vp_text); |