summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)
160 } 160 }
161} 161}
162 162
163static void vp_puts_center(struct viewport *vp, struct screen *display, int line,
164 char *str)
165{
166 int w, offset;
167
168 display->getstringsize(str, &w, NULL);
169 if (w > vp->width)
170 display->puts_scroll(0, line, str);
171 else
172 {
173 offset = (vp->width - w)/2;
174 display->putsxy(offset, line * font_get(vp->font)->height, str);
175 }
176}
177
163static void draw_timedate(struct viewport *vp, struct screen *display) 178static void draw_timedate(struct viewport *vp, struct screen *display)
164{ 179{
165 struct tm *tm = get_time(); 180 struct tm *tm = get_time();
166 int w, line; 181 int line;
167 char time[16], date[16]; 182 char time[16], date[16];
168 if (vp->height == 0) 183 if (vp->height == 0)
169 return; 184 return;
@@ -193,18 +208,11 @@ static void draw_timedate(struct viewport *vp, struct screen *display)
193 snprintf(time, 16, "%s", "--:--:--"); 208 snprintf(time, 16, "%s", "--:--:--");
194 snprintf(date, 16, "%s", str(LANG_UNKNOWN)); 209 snprintf(date, 16, "%s", str(LANG_UNKNOWN));
195 } 210 }
196 display->getstringsize(time, &w, NULL); 211
197 if (w > vp->width) 212 vp_puts_center(vp, display, line, time);
198 display->puts_scroll(0, line, time);
199 else
200 display->putsxy((vp->width - w)/2, line*font_get(vp->font)->height, time);
201 line++; 213 line++;
214 vp_puts_center(vp, display, line, date);
202 215
203 display->getstringsize(date, &w, NULL);
204 if (w > vp->width)
205 display->puts_scroll(0, line, date);
206 else
207 display->putsxy((vp->width - w)/2, line*font_get(vp->font)->height, date);
208 display->update_viewport(); 216 display->update_viewport();
209} 217}
210 218