2005-10-28 00:00:00 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
2005-10-30 01:24:35 +00:00
|
|
|
* Copyright (C) Daniel Stenberg (2002)
|
2005-10-28 00:00:00 +00:00
|
|
|
*
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
#include "stdarg.h"
|
|
|
|
#include "string.h"
|
|
|
|
#include "stdio.h"
|
|
|
|
#include "kernel.h"
|
|
|
|
#include "screen_access.h"
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
|
|
|
|
#define MAXLETTERS 128 /* 16*8 */
|
|
|
|
#define MAXLINES 10
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define MAXLETTERS 22 /* 11 * 2 */
|
|
|
|
#define MAXLINES 2
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2005-11-18 08:57:32 +00:00
|
|
|
static void splash(struct screen * screen,
|
|
|
|
bool center, const char *fmt, va_list ap)
|
2005-10-28 00:00:00 +00:00
|
|
|
{
|
|
|
|
char *next;
|
|
|
|
char *store=NULL;
|
2006-10-02 23:54:28 +00:00
|
|
|
int x = 0;
|
2006-10-03 15:02:49 +00:00
|
|
|
int w, h = 1;
|
2005-10-28 00:00:00 +00:00
|
|
|
unsigned char splash_buf[MAXLETTERS];
|
2006-10-02 23:54:28 +00:00
|
|
|
unsigned short widths[MAXLINES];
|
|
|
|
unsigned char *text = splash_buf;
|
|
|
|
int line = 0, i_line = 0;
|
2005-10-28 00:00:00 +00:00
|
|
|
bool first=true;
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
int maxw=0;
|
2006-10-02 23:54:28 +00:00
|
|
|
int space;
|
|
|
|
int y;
|
|
|
|
screen->getstringsize(" ", &space, &y);
|
2006-02-02 22:00:56 +00:00
|
|
|
#if LCD_DEPTH > 1
|
|
|
|
unsigned prevbg = LCD_DEFAULT_BG;
|
|
|
|
unsigned prevfg = LCD_DEFAULT_FG;
|
|
|
|
#endif
|
2006-10-02 23:54:28 +00:00
|
|
|
#else
|
|
|
|
screen->double_height (false); /* HAVE_LCD_CHARCELLS */
|
|
|
|
int space = 1;
|
|
|
|
int y = 0;
|
2005-10-28 00:00:00 +00:00
|
|
|
#endif
|
2005-11-20 01:02:14 +00:00
|
|
|
screen->stop_scroll();
|
2005-10-28 00:00:00 +00:00
|
|
|
vsnprintf( splash_buf, sizeof(splash_buf), fmt, ap );
|
2006-10-02 23:54:28 +00:00
|
|
|
va_end( ap );
|
|
|
|
|
|
|
|
/* measure sizes & concatenates tokenise words into lines. */
|
|
|
|
next = strtok_r(splash_buf, " ", &store);
|
|
|
|
while (next) {
|
2005-10-28 00:00:00 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2006-10-02 23:54:28 +00:00
|
|
|
screen->getstringsize(next, &w, &h);
|
2005-10-28 00:00:00 +00:00
|
|
|
#else
|
2006-10-02 23:54:28 +00:00
|
|
|
w = strlen(next);
|
|
|
|
h = 1; /* store height in characters */
|
2005-10-28 00:00:00 +00:00
|
|
|
#endif
|
2006-10-02 23:54:28 +00:00
|
|
|
if(!first) {
|
|
|
|
if(x + w > screen->width) { /* Too wide, wrap */
|
|
|
|
y += h;
|
|
|
|
line++;
|
|
|
|
x = 0;
|
|
|
|
if((y > (screen->height-h)) || (line > screen->nb_lines))
|
|
|
|
/* STOP */
|
|
|
|
break;
|
2005-10-28 00:00:00 +00:00
|
|
|
}
|
|
|
|
else
|
2006-10-02 23:54:28 +00:00
|
|
|
next[-1] = ' '; /* re-concatenate string */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
first = false;
|
2005-10-28 00:00:00 +00:00
|
|
|
|
2006-10-02 23:54:28 +00:00
|
|
|
x += w + space;
|
|
|
|
widths[line] = x - space; /* don't count the trailing space */
|
2005-10-28 00:00:00 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2006-10-02 23:54:28 +00:00
|
|
|
/* store the widest line */
|
|
|
|
if(widths[line]>maxw)
|
|
|
|
maxw = widths[line];
|
2005-10-28 00:00:00 +00:00
|
|
|
#endif
|
2006-10-02 23:54:28 +00:00
|
|
|
next = strtok_r(NULL, " ", &store);
|
|
|
|
}
|
2005-10-28 00:00:00 +00:00
|
|
|
|
2006-10-02 23:54:28 +00:00
|
|
|
if(center) {
|
2005-10-28 00:00:00 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2006-10-02 23:54:28 +00:00
|
|
|
/* Start displaying the message at position y. */
|
|
|
|
y = (screen->height - y)/2;
|
2005-10-28 00:00:00 +00:00
|
|
|
#else
|
|
|
|
y = 0; /* vertical center on 2 lines would be silly */
|
|
|
|
#endif
|
2006-10-02 23:54:28 +00:00
|
|
|
} else
|
|
|
|
y = 0;
|
2005-10-28 00:00:00 +00:00
|
|
|
|
|
|
|
/* If we center the display, then just clear the box we need and put
|
|
|
|
a nice little frame and put the text in there! */
|
2006-10-02 23:54:28 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2005-10-28 00:00:00 +00:00
|
|
|
if(center && (y > 2)) {
|
2006-10-02 23:54:28 +00:00
|
|
|
int xx = (screen->width - maxw)/2 - 2;
|
2005-10-28 00:00:00 +00:00
|
|
|
/* The new graphics routines handle clipping, so no need to check */
|
|
|
|
#if LCD_DEPTH > 1
|
2006-02-02 22:00:56 +00:00
|
|
|
if(screen->depth>1) {
|
|
|
|
prevbg = screen->get_background();
|
|
|
|
prevfg = screen->get_foreground();
|
2005-11-16 21:09:23 +00:00
|
|
|
screen->set_background(LCD_LIGHTGRAY);
|
2006-02-02 22:00:56 +00:00
|
|
|
screen->set_foreground(LCD_BLACK);
|
|
|
|
}
|
2005-10-28 00:00:00 +00:00
|
|
|
#endif
|
|
|
|
screen->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
|
|
|
|
screen->fillrect(xx, y-2, maxw+4, screen->height-y*2+4);
|
|
|
|
screen->set_drawmode(DRMODE_SOLID);
|
|
|
|
screen->drawrect(xx, y-2, maxw+4, screen->height-y*2+4);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
screen->clear_display();
|
2006-10-02 23:54:28 +00:00
|
|
|
|
|
|
|
/* print the message to screen */
|
|
|
|
while(line-- >= 0) {
|
|
|
|
if (center) {
|
|
|
|
x = (screen->width-widths[i_line++])/2;
|
|
|
|
if(x < 0)
|
|
|
|
x = 0;
|
|
|
|
} else
|
|
|
|
x = 0;
|
2005-10-28 00:00:00 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2006-10-02 23:54:28 +00:00
|
|
|
screen->putsxy(x, y, text);
|
2005-10-28 00:00:00 +00:00
|
|
|
#else
|
2006-10-02 23:54:28 +00:00
|
|
|
screen->puts(x, y, text);
|
2005-10-28 00:00:00 +00:00
|
|
|
#endif
|
2006-10-02 23:54:28 +00:00
|
|
|
text += strlen(text) + 1;
|
|
|
|
y +=h;
|
2005-10-28 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH > 1)
|
2006-02-02 22:00:56 +00:00
|
|
|
if(screen->depth > 1) {
|
|
|
|
screen->set_background(prevbg);
|
|
|
|
screen->set_foreground(prevfg);
|
|
|
|
}
|
2005-10-28 00:00:00 +00:00
|
|
|
#endif
|
|
|
|
#if defined(HAVE_LCD_BITMAP) || defined(SIMULATOR)
|
|
|
|
screen->update();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void gui_splash(struct screen * screen, int ticks,
|
2005-12-05 22:44:42 +00:00
|
|
|
bool center, const unsigned char *fmt, ...)
|
2005-10-28 00:00:00 +00:00
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
va_start( ap, fmt );
|
2005-11-18 08:57:32 +00:00
|
|
|
splash(screen, center, fmt, ap);
|
2005-10-28 00:00:00 +00:00
|
|
|
va_end( ap );
|
|
|
|
|
|
|
|
if(ticks)
|
|
|
|
sleep(ticks);
|
|
|
|
}
|
|
|
|
|
2005-12-05 22:44:42 +00:00
|
|
|
void gui_syncsplash(int ticks, bool center, const unsigned char *fmt, ...)
|
2005-10-28 00:00:00 +00:00
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
int i;
|
|
|
|
va_start( ap, fmt );
|
2005-11-09 22:47:15 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
2005-11-18 08:57:32 +00:00
|
|
|
splash(&(screens[i]), center, fmt, ap);
|
2005-10-28 00:00:00 +00:00
|
|
|
va_end( ap );
|
|
|
|
|
|
|
|
if(ticks)
|
|
|
|
sleep(ticks);
|
|
|
|
}
|