From a1dfe6441d1fda2eedf492952d6180ebbf96482d Mon Sep 17 00:00:00 2001 From: Tomer Shalev Date: Tue, 6 Oct 2009 08:17:36 +0000 Subject: 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 --- apps/menus/time_menu.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'apps') 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(); } -- cgit v1.2.3