summaryrefslogtreecommitdiff
path: root/apps/plugins/lib/display_text.c
diff options
context:
space:
mode:
authorTeruaki Kawashima <teru@rockbox.org>2010-02-22 07:17:15 +0000
committerTeruaki Kawashima <teru@rockbox.org>2010-02-22 07:17:15 +0000
commit56d29e89778f30e87a20bb1e67fd6854fe19684c (patch)
tree588064022421b1094aebdc6f627a1a0f5ed4d4df /apps/plugins/lib/display_text.c
parent04067fd7a0570692b0a25f578aaeeb5ab1cbff46 (diff)
downloadrockbox-56d29e89778f30e87a20bb1e67fd6854fe19684c.zip
rockbox-56d29e89778f30e87a20bb1e67fd6854fe19684c.tar.gz
rockbox-56d29e89778f30e87a20bb1e67fd6854fe19684c.tar.bz2
rockbox-56d29e89778f30e87a20bb1e67fd6854fe19684c.tar.xz
some changes to use of display_text.
* add parameter, wait_key to display_text(). - set this true to wait button press after all words is displayed. * use ARRAYLEN macro instead of #define WORDS * add macro to indicate end of style array. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24846 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/lib/display_text.c')
-rw-r--r--apps/plugins/lib/display_text.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/apps/plugins/lib/display_text.c b/apps/plugins/lib/display_text.c
index c696610..5d13fc6 100644
--- a/apps/plugins/lib/display_text.c
+++ b/apps/plugins/lib/display_text.c
@@ -28,8 +28,20 @@
#define MARGIN 5
#endif
-bool display_text(short words, char** text, struct style_text* style,
- struct viewport* vp_text)
+static bool wait_key_press(void)
+{
+ int button;
+ do {
+ button = rb->button_get(true);
+ if ( rb->default_event_handler( button ) == SYS_USB_CONNECTED )
+ return true;
+ } while( ( button == BUTTON_NONE )
+ || ( button & (BUTTON_REL|BUTTON_REPEAT) ) );
+ return false;
+}
+
+bool display_text(unsigned short words, char** text, struct style_text* style,
+ struct viewport* vp_text, bool wait_key)
{
#ifdef HAVE_LCD_BITMAP
int prev_drawmode;
@@ -41,7 +53,6 @@ bool display_text(short words, char** text, struct style_text* style,
unsigned short x , y;
unsigned short vp_width = LCD_WIDTH;
unsigned short vp_height = LCD_HEIGHT;
- int button;
unsigned short i = 0, style_index = 0;
if (vp_text != NULL) {
vp_width = vp_text->width;
@@ -76,12 +87,8 @@ bool display_text(short words, char** text, struct style_text* style,
if (y + height > vp_height - MARGIN) {
y = MARGIN;
rb->screens[SCREEN_MAIN]->update_viewport();
- do {
- button = rb->button_get(true);
- if ( rb->default_event_handler( button ) == SYS_USB_CONNECTED )
- return true;
- } while( ( button == BUTTON_NONE )
- || ( button & (BUTTON_REL|BUTTON_REPEAT) ) );
+ if (wait_key_press())
+ return true;
rb->screens[SCREEN_MAIN]->clear_viewport();
}
/* no text formatting available */
@@ -134,5 +141,10 @@ bool display_text(short words, char** text, struct style_text* style,
#ifdef HAVE_LCD_BITMAP
rb->lcd_set_drawmode(prev_drawmode);
#endif
+ if (wait_key)
+ {
+ if (wait_key_press())
+ return true;
+ }
return false;
}