From 11d208ca855b94e9ae3da8adf0964d1621e42522 Mon Sep 17 00:00:00 2001 From: Markus Braun Date: Tue, 20 Aug 2002 20:32:08 +0000 Subject: calculate the string width for numerical volume display and time display in status bar. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1828 a1c6a512-1295-4272-9138-f99709370657 --- apps/recorder/icons.c | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'apps/recorder/icons.c') diff --git a/apps/recorder/icons.c b/apps/recorder/icons.c index e094a12400..bac719e0f1 100644 --- a/apps/recorder/icons.c +++ b/apps/recorder/icons.c @@ -209,6 +209,10 @@ void statusbar_icon_volume(int percent) int volume; int step=0; char buffer[4]; + unsigned int width, height; +#if defined(LOADABLE_FONTS) + unsigned char *font; +#endif static long switch_tick; static int last_volume; @@ -231,8 +235,19 @@ void statusbar_icon_volume(int percent) /* display volume lever numerical? */ if (TIME_BEFORE(current_tick,switch_tick)) { snprintf(buffer, sizeof(buffer), "%2d", percent); - lcd_putsxy(ICON_VOLUME_X_POS + ICON_VOLUME_WIDTH / 2 - - 6*strlen(buffer)/2, STATUSBAR_Y_POS, buffer, 0); +#if defined(LCD_PROPFONTS) + lcd_getstringsize(buffer, 0, &width, &height); + width += strlen(buffer) - 1; +#elif defined(LOADABLE_FONTS) + font = lcd_getcurrentldfont(); + lcd_getstringsize(buffer, font, &width, &height); +#else + width = 6*strlen(buffer); + height = 8; +#endif + if (height <= STATUSBAR_HEIGHT) + lcd_putsxy(ICON_VOLUME_X_POS + ICON_VOLUME_WIDTH / 2 - + width/2, STATUSBAR_Y_POS, buffer, 0); } else { /* display volume bar */ volume = volume * 14 / 100; @@ -290,6 +305,10 @@ void statusbar_time(void) { int hour,minute; unsigned char buffer[6]; + unsigned int width, height; +#if defined(LOADABLE_FONTS) + unsigned char *font; +#endif hour = rtc_read(0x03); minute = rtc_read(0x02); @@ -299,6 +318,17 @@ void statusbar_time(void) hour & 0x0f, (minute & 0xf0) >> 4, minute & 0x0f); - lcd_putsxy(TIME_X_POS, STATUSBAR_Y_POS, buffer, 0); +#if defined(LCD_PROPFONTS) + lcd_getstringsize(buffer, 0, &width, &height); + width += strlen(buffer) - 1; +#elif defined(LOADABLE_FONTS) + font = lcd_getcurrentldfont(); + lcd_getstringsize(buffer, font, &width, &height); +#else + width = 6*strlen(buffer); + height = 8; +#endif + if (height <= STATUSBAR_HEIGHT) + lcd_putsxy(TIME_X_END - width, STATUSBAR_Y_POS, buffer, 0); } #endif -- cgit