summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomer Shalev <shalev.tomer@gmail.com>2009-10-06 08:17:36 +0000
committerTomer Shalev <shalev.tomer@gmail.com>2009-10-06 08:17:36 +0000
commita1dfe6441d1fda2eedf492952d6180ebbf96482d (patch)
tree14566a326f37d0047d7c18dc465f46e0a9c0ae96
parenta092b9ce923b3355868f0f7e99bf1d7cf2f83181 (diff)
downloadrockbox-a1dfe6441d1fda2eedf492952d6180ebbf96482d.tar.gz
rockbox-a1dfe6441d1fda2eedf492952d6180ebbf96482d.tar.bz2
rockbox-a1dfe6441d1fda2eedf492952d6180ebbf96482d.zip
Use helper function vp_puts_center() in time_menu.c
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22979 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/menus/time_menu.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/apps/menus/time_menu.c b/apps/menus/time_menu.c
index 457187cf41..e6cbb230da 100644
--- a/apps/menus/time_menu.c
+++ b/apps/menus/time_menu.c
@@ -160,10 +160,25 @@ static void talk_timedate(void)
}
}
+static void vp_puts_center(struct viewport *vp, struct screen *display, int line,
+ char *str)
+{
+ int w, offset;
+
+ display->getstringsize(str, &w, NULL);
+ if (w > vp->width)
+ display->puts_scroll(0, line, str);
+ else
+ {
+ offset = (vp->width - w)/2;
+ display->putsxy(offset, line * font_get(vp->font)->height, str);
+ }
+}
+
static void draw_timedate(struct viewport *vp, struct screen *display)
{
struct tm *tm = get_time();
- int w, line;
+ int line;
char time[16], date[16];
if (vp->height == 0)
return;
@@ -193,18 +208,11 @@ static void draw_timedate(struct viewport *vp, struct screen *display)
snprintf(time, 16, "%s", "--:--:--");
snprintf(date, 16, "%s", str(LANG_UNKNOWN));
}
- display->getstringsize(time, &w, NULL);
- if (w > vp->width)
- display->puts_scroll(0, line, time);
- else
- display->putsxy((vp->width - w)/2, line*font_get(vp->font)->height, time);
+
+ vp_puts_center(vp, display, line, time);
line++;
+ vp_puts_center(vp, display, line, date);
- display->getstringsize(date, &w, NULL);
- if (w > vp->width)
- display->puts_scroll(0, line, date);
- else
- display->putsxy((vp->width - w)/2, line*font_get(vp->font)->height, date);
display->update_viewport();
}