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"
27 #define MAX(a, b) (((a)>(b))?(a):(b))
30 #ifdef HAVE_LCD_BITMAP
32 #define MAXLINES (LCD_HEIGHT/6)
35 #else /* HAVE_LCD_CHARCELLS */
42 static void splash(struct screen
* screen
, const char *fmt
, va_list ap
)
44 char splash_buf
[MAXBUFFER
];
45 short widths
[MAXLINES
];
46 char *lines
[MAXLINES
];
49 char *lastbreak
= NULL
;
55 #ifdef HAVE_LCD_BITMAP
61 screen
->getstringsize(" ", &space_w
, &h
);
62 #else /* HAVE_LCD_CHARCELLS */
65 screen
->double_height (false);
69 vsnprintf(splash_buf
, sizeof(splash_buf
), fmt
, ap
);
72 /* break splash string into display lines, doing proper word wrap */
74 next
= strtok_r(splash_buf
, " ", &store
);
76 return; /* nothing to display */
81 #ifdef HAVE_LCD_BITMAP
82 screen
->getstringsize(next
, &w
, NULL
);
88 if (x
+ (next
- lastbreak
) * space_w
+ w
> screen
->width
)
89 { /* too wide, wrap */
91 #ifdef HAVE_LCD_BITMAP
95 if ((y
+ h
> screen
->height
) || (line
>= (MAXLINES
-1)))
96 break; /* screen full or out of lines */
103 /* restore & calculate spacing */
105 x
+= (next
- lastbreak
) * space_w
;
109 lastbreak
= next
+ strlen(next
);
110 next
= strtok_r(NULL
, " ", &store
);
112 { /* no more words */
114 #ifdef HAVE_LCD_BITMAP
124 screen
->stop_scroll();
126 #ifdef HAVE_LCD_BITMAP
127 /* If we center the display, then just clear the box we need and put
128 a nice little frame and put the text in there! */
129 y
= (screen
->height
- y
) / 2; /* height => y start position */
130 x
= (screen
->width
- maxw
) / 2 - 2;
133 if (screen
->depth
> 1)
135 prevfg
= screen
->get_foreground();
136 screen
->set_drawmode(DRMODE_FG
);
137 screen
->set_foreground(
138 SCREEN_COLOR_TO_NATIVE(screen
, LCD_LIGHTGRAY
));
142 screen
->set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
144 screen
->fillrect(x
, y
-2, maxw
+4, screen
->height
-y
*2+4);
147 if (screen
->depth
> 1)
148 screen
->set_foreground(SCREEN_COLOR_TO_NATIVE(screen
, LCD_BLACK
));
151 screen
->set_drawmode(DRMODE_SOLID
);
153 screen
->drawrect(x
, y
-2, maxw
+4, screen
->height
-y
*2+4);
154 #else /* HAVE_LCD_CHARCELLS */
155 y
= 0; /* vertical centering on 2 lines would be silly */
157 screen
->clear_display();
160 /* print the message to screen */
162 for (i
= 0; i
<= line
; i
++)
164 x
= MAX((screen
->width
- widths
[i
]) / 2, 0);
166 #ifdef HAVE_LCD_BITMAP
167 screen
->putsxy(x
, y
, lines
[i
]);
169 screen
->puts(x
, y
, lines
[i
]);
174 #if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH > 1)
175 if (screen
->depth
> 1)
177 screen
->set_foreground(prevfg
);
178 screen
->set_drawmode(DRMODE_SOLID
);
184 void gui_splash(struct screen
* screen
, int ticks
,
185 const unsigned char *fmt
, ...)
189 splash(screen
, fmt
, ap
);
196 void gui_syncsplash(int ticks
, const unsigned char *fmt
, ...)
202 splash(&(screens
[i
]), fmt
, ap
);