1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) Daniel Stenberg (2002)
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
21 #include "rbunicode.h"
24 #include "screen_access.h"
31 #define MAX(a, b) (((a)>(b))?(a):(b))
34 #ifdef HAVE_LCD_BITMAP
36 #define MAXLINES (LCD_HEIGHT/6)
39 #else /* HAVE_LCD_CHARCELLS */
46 static void splash(struct screen
* screen
, const char *fmt
, va_list ap
)
48 char splash_buf
[MAXBUFFER
];
49 short widths
[MAXLINES
];
50 char *lines
[MAXLINES
];
53 char *lastbreak
= NULL
;
59 #ifdef HAVE_LCD_BITMAP
65 screen
->getstringsize(" ", &space_w
, &h
);
66 #else /* HAVE_LCD_CHARCELLS */
69 screen
->double_height (false);
73 vsnprintf(splash_buf
, sizeof(splash_buf
), fmt
, ap
);
76 /* break splash string into display lines, doing proper word wrap */
78 next
= strtok_r(splash_buf
, " ", &store
);
80 return; /* nothing to display */
85 #ifdef HAVE_LCD_BITMAP
86 screen
->getstringsize(next
, &w
, NULL
);
92 if (x
+ (next
- lastbreak
) * space_w
+ w
> screen
->width
)
93 { /* too wide, wrap */
95 #ifdef HAVE_LCD_BITMAP
99 if ((y
+ h
> screen
->height
) || (line
>= (MAXLINES
-1)))
100 break; /* screen full or out of lines */
103 lines
[++line
] = next
;
107 /* restore & calculate spacing */
109 x
+= (next
- lastbreak
) * space_w
;
113 lastbreak
= next
+ strlen(next
);
114 next
= strtok_r(NULL
, " ", &store
);
116 { /* no more words */
118 #ifdef HAVE_LCD_BITMAP
128 screen
->stop_scroll();
130 #ifdef HAVE_LCD_BITMAP
131 /* If we center the display, then just clear the box we need and put
132 a nice little frame and put the text in there! */
133 y
= (screen
->height
- y
) / 2; /* height => y start position */
134 x
= (screen
->width
- maxw
) / 2 - 2;
137 if (screen
->depth
> 1)
139 prevfg
= screen
->get_foreground();
140 screen
->set_drawmode(DRMODE_FG
);
141 screen
->set_foreground(
142 SCREEN_COLOR_TO_NATIVE(screen
, LCD_LIGHTGRAY
));
146 screen
->set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
148 screen
->fillrect(x
, y
-2, maxw
+4, screen
->height
-y
*2+4);
151 if (screen
->depth
> 1)
152 screen
->set_foreground(SCREEN_COLOR_TO_NATIVE(screen
, LCD_BLACK
));
155 screen
->set_drawmode(DRMODE_SOLID
);
157 screen
->drawrect(x
, y
-2, maxw
+4, screen
->height
-y
*2+4);
158 #else /* HAVE_LCD_CHARCELLS */
159 y
= 0; /* vertical centering on 2 lines would be silly */
161 screen
->clear_display();
164 /* print the message to screen */
166 for (i
= 0; i
<= line
; i
++)
168 x
= MAX((screen
->width
- widths
[i
]) / 2, 0);
170 #ifdef HAVE_LCD_BITMAP
171 screen
->putsxy(x
, y
, lines
[i
]);
173 screen
->puts(x
, y
, lines
[i
]);
178 #if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH > 1)
179 if (screen
->depth
> 1)
181 screen
->set_foreground(prevfg
);
182 screen
->set_drawmode(DRMODE_SOLID
);
188 void gui_splash(struct screen
* screen
, int ticks
,
189 const char *fmt
, ...)
193 splash(screen
, fmt
, ap
);
200 void gui_syncsplash(int ticks
, const char *fmt
, ...)
204 #if !defined(SIMULATOR) || CONFIG_CODEC == SWCODEC
206 /* fmt may be a so called virtual pointer. See settings.h. */
207 if((id
= P2ID((unsigned char *)fmt
)) >= 0)
208 /* If fmt specifies a voicefont ID, and voice menus are
209 enabled, then speak it. */
210 cond_talk_ids_fq(id
);
212 /* If fmt is a lang ID then get the corresponding string (which
213 still might contain % place holders). */
214 fmt
= P2STR((unsigned char *)fmt
);
217 splash(&(screens
[i
]), fmt
, ap
);