--- /dev/null
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+*/
+
+//#include "config.h"
+#include <string.h>
+#include <stdio.h>
+#include "text.h"
+#include "io.h"
+#include "gfx.h"
+#include "fb_display.h"
+
+extern unsigned int alpha;
+
+void blit2FB(void *fbbuff,
+ uint32_t width, uint32_t height,
+ uint32_t xoffs, uint32_t yoffs,
+ uint32_t xp, uint32_t yp,
+ int cpp);
+
+void fb_display(unsigned char *rgbbuff, int x_size, int y_size, int x_pan, int y_pan, int x_offs, int y_offs, int clearflag, int alpha)
+{
+ void *fbbuff = NULL;
+ int bp = 0;
+ if(rgbbuff==NULL)
+ return;
+
+ /* correct panning */
+ if(x_pan > x_size - (int)var_screeninfo.xres) x_pan = 0;
+ if(y_pan > y_size - (int)var_screeninfo.yres) y_pan = 0;
+ /* correct offset */
+ if(x_offs + x_size > (int)var_screeninfo.xres) x_offs = 0;
+ if(y_offs + y_size > (int)var_screeninfo.yres) y_offs = 0;
+
+ /* blit buffer 2 fb */
+ fbbuff = convertRGB2FB(rgbbuff, x_size * y_size, var_screeninfo.bits_per_pixel, &bp, alpha);
+ if(fbbuff==NULL)
+ return;
+ /* ClearFB if image is smaller */
+ if(clearflag)
+ clearFB();
+ blit2FB(fbbuff, x_size, y_size, x_offs, y_offs, x_pan, y_pan, bp);
+ free(fbbuff);
+}
+
+void blit2FB(void *fbbuff,
+ uint32_t width, uint32_t height,
+ uint32_t xoffs, uint32_t yoffs,
+ uint32_t xp, uint32_t yp,
+ int cpp)
+{
+ int count, count2, xc, yc;
+
+ int ssx=startx+xoffs;
+ int ssy=starty+yoffs;
+
+ xc = (width > var_screeninfo.xres) ? var_screeninfo.xres : width;
+ yc = (height > var_screeninfo.yres) ? var_screeninfo.yres : height;
+
+ int xo = (ssx/*xoffs*/ * cpp)/sizeof(uint32_t);
+
+ switch(cpp){
+ case 4:
+ {
+ uint32_t * data = (uint32_t *) fbbuff;
+
+ uint32_t * d = (uint32_t *)lbb + xo + stride * ssy/*yoffs*/;
+ uint32_t * d2;
+
+ for (count = 0; count < yc; count++ ) {
+ uint32_t *pixpos = &data[(count + yp) * width];
+ d2 = (uint32_t *) d;
+ for (count2 = 0; count2 < xc; count2++ ) {
+ uint32_t pix = *(pixpos + xp);
+ if ((pix & 0xff000000) == 0xff000000)
+ *d2 = pix;
+ else {
+ uint8_t *in = (uint8_t *)(pixpos + xp);
+ uint8_t *out = (uint8_t *)d2;
+ int a = in[3]; /* TODO: big/little endian */
+ *out = (*out + ((*in - *out) * a) / 256);
+ in++; out++;
+ *out = (*out + ((*in - *out) * a) / 256);
+ in++; out++;
+ *out = (*out + ((*in - *out) * a) / 256);
+ }
+ d2++;
+ pixpos++;
+ }
+ d += stride;
+ }
+ }
+ break;
+ }
+}
+
+void clearFB()
+{
+ memset(lbb, 0, var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t));
+ memcpy(lfb, lbb, var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t));
+}
+
+void* convertRGB2FB(unsigned char *rgbbuff, unsigned long count, int bpp, int *cpp, int alpha)
+{
+ unsigned long i;
+ unsigned int *fbbuff = NULL;
+
+ switch(bpp)
+ {
+ case 24:
+ case 32:
+ *cpp = 4;
+ fbbuff = (unsigned int *) malloc(count * sizeof(unsigned int));
+ if(fbbuff==NULL)
+ {
+ printf("Error: malloc\n");
+ return NULL;
+ }
+ if(alpha) {
+ for(i = 0; i < count ; i++) {
+ fbbuff[i] = ((rgbbuff[i*4+3] << 24) & 0xFF000000) |
+ ((rgbbuff[i*4] << 16) & 0x00FF0000) |
+ ((rgbbuff[i*4+1] << 8) & 0x0000FF00) |
+ ((rgbbuff[i*4+2]) & 0x000000FF);
+ }
+ }
+ else
+ {
+ int transp;
+ for(i = 0; i < count ; i++) {
+ transp = 0;
+ if(rgbbuff[i*3] || rgbbuff[i*3+1] || rgbbuff[i*3+2])
+ transp = 0xFF;
+ fbbuff[i] = (transp << 24) |
+ ((rgbbuff[i*3] << 16) & 0xFF0000) |
+ ((rgbbuff[i*3+1] << 8) & 0xFF00) |
+ (rgbbuff[i*3+2] & 0xFF);
+ }
+ }
+ break;
+ default:
+ fprintf(stderr, "Unsupported video mode! You've got: %dbpp\n", bpp);
+ exit(1);
+ }
+ return (void *)fbbuff;
+}
--- /dev/null
+/*
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+*/
+
+#ifndef __pictureviewer_fbdisplay__
+#define __pictureviewer_fbdisplay__
+
+void* convertRGB2FB(unsigned char *rgbbuff, unsigned long count, int bpp, int *cpp, int alpha);
+void fb_display(unsigned char *rgbbuff, int x_size, int y_size, int x_pan, int y_pan, int x_offs, int y_offs, int clearflag, int alpha);
+void clearFB();
+
+#endif
#include "current.h"
+#include "gfx.h"
+#include "resize.h"
+#include "pngw.h"
+#include "fb_display.h"
+
+extern const char NOMEM[];
void RenderBox(int _sx, int _sy, int _ex, int _ey, int rad, int col)
{
pos+=stride;
}
}
+
+/******************************************************************************
+ * PaintIcon
+ ******************************************************************************/
+
+int paintIcon(const char *const fname, int xstart, int ystart, int xsize, int ysize, int *iw, int *ih)
+{
+FILE *tfh;
+int x1, y1, rv=-1, alpha=0, bpp=0;
+
+int imx,imy,dxo,dyo,dxp,dyp;
+unsigned char *buffer=NULL;
+
+ if((tfh=fopen(fname,"r"))!=NULL)
+ {
+ if(png_getsize(fname, &x1, &y1))
+ {
+ perror(__plugin__ " <invalid PNG-Format>\n");
+ fclose(tfh);
+ return -1;
+ }
+ // no resize
+ if (xsize == 0 || ysize ==0)
+ {
+ xsize = x1;
+ ysize = y1;
+ }
+ if((buffer=(unsigned char *) malloc(x1*y1*4))==NULL)
+ {
+ printf(NOMEM);
+ fclose(tfh);
+ return -1;
+ }
+
+ if(!(rv=png_load(fname, &buffer, &x1, &y1, &bpp)))
+ {
+ alpha=(bpp==4)?1:0;
+ scale_pic(&buffer,x1,y1,xstart,ystart,xsize,ysize,&imx,&imy,&dxp,&dyp,&dxo,&dyo,alpha);
+
+ fb_display(buffer, imx, imy, dxp, dyp, dxo, dyo, 0, alpha);
+ }
+ free(buffer);
+ fclose(tfh);
+ }
+ *iw=imx;
+ *ih=imy;
+ return (rv)?-1:0;
+}
+
+void scale_pic(unsigned char **buffer, int x1, int y1, int xstart, int ystart, int xsize, int ysize,
+ int *imx, int *imy, int *dxp, int *dyp, int *dxo, int *dyo, int alpha)
+{
+ float xfact=0, yfact=0;
+ int txsize=0, tysize=0;
+ int txstart =xstart, tystart= ystart;
+
+ if (xsize > (ex-xstart)) txsize= (ex-xstart);
+ else txsize= xsize;
+ if (ysize > (ey-ystart)) tysize= (ey-ystart);
+ else tysize=ysize;
+ xfact= 1000*txsize/x1;
+ xfact= xfact/1000;
+ yfact= 1000*tysize/y1;
+ yfact= yfact/1000;
+
+ if ( xfact <= yfact)
+ {
+ *imx=(int)x1*xfact;
+ *imy=(int)y1*xfact;
+ }
+ else
+ {
+ *imx=(int)x1*yfact;
+ *imy=(int)y1*yfact;
+ }
+ if ((x1 != *imx) || (y1 != *imy))
+ *buffer=color_average_resize(*buffer,x1,y1,*imx,*imy,alpha);
+
+ *dxp=0;
+ *dyp=0;
+ *dxo=txstart;
+ *dyo=tystart;
+}
#define __GFX_H__
void RenderBox(int sx, int sy, int ex, int ey, int mode, int color);
+int paintIcon(const char *const fname, int xstart, int ystart, int xsize, int ysize, int *iw, int *ih);
+void scale_pic(unsigned char **buffer, int x1, int y1, int xstart, int ystart, int xsize, int ysize,
+ int *imx, int *imy, int *dxp, int *dyp, int *dxo, int *dyo, int alpha);
#endif
--- /dev/null
+#ifndef __icons_h__
+#define __icons_h__
+
+#define ICON_BUTTON_RED "/share/tuxbox/neutrino/icons/rot.png"
+#define ICON_BUTTON_GREEN "/share/tuxbox/neutrino/icons/gruen.png"
+#define ICON_BUTTON_YELLOW "/share/tuxbox/neutrino/icons/gelb.png"
+#define ICON_BUTTON_BLUE "/share/tuxbox/neutrino/icons/blau.png"
+
+#define ICON_ERROR "/share/tuxbox/neutrino/icons/error.png"
+#define ICON_INFO "/share/tuxbox/neutrino/icons/information.png"
+
+#endif
#include <signal.h>
#include "current.h"
-
+#include "icons.h"
#include "text.h"
#include "io.h"
#include "gfx.h"
-#include "txtform.h"
+#include "txtform.h"
+#include "pngw.h"
+
-#define M_VERSION 1.27
+#define max(a,b) ( \
+ { __auto_type __a = (a); __auto_type __b = (b); \
+ __a > __b ? __a : __b; })
+
+#define M_VERSION 2.0
#define NCF_FILE "/var/tuxbox/config/neutrino.conf"
#define HDF_FILE "/tmp/.msgbox_hidden"
-//#define FONT "/usr/share/fonts/md_khmurabi_10.ttf"
#define FONT2 "/share/fonts/pakenham.ttf"
// if font is not in usual place, we look here:
-#define FONT "/share/fonts/neutrino.ttf"
+char FONT[128]="/share/fonts/neutrino.ttf";
-// CMCST, CMCS, CMCT, CMC, CMCIT, CMCI, CMHT, CMH
-// WHITE, BLUE0, TRANSP, CMS, ORANGE, GREEN, YELLOW, RED
+// CMCST, CMCS, CMCT, CMC, CMCIT, CMCI, CMHT, CMH
+// WHITE, BLUE0, TRANSP, CMS, ORANGE, GREEN, YELLOW, RED
+// COL_MENUCONTENT_PLUS_0 - 3, COL_SHADOW_PLUS_0
unsigned char bl[] = { 0x00, 0x00, 0xFF, 0x80, 0xFF, 0x80, 0x00, 0x80,
- 0xFF, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00};
+ 0xFF, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00};
unsigned char gn[] = { 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xC0, 0x00,
- 0xFF, 0x80, 0x00, 0x80, 0xC0, 0xFF, 0xFF, 0x00};
+ 0xFF, 0x80, 0x00, 0x80, 0xC0, 0xFF, 0xFF, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00};
unsigned char rd[] = { 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00,
- 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0xFF};
+ 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0xFF,
+ 0x00, 0x00, 0x00, 0x00, 0x00};
unsigned char tr[] = { 0xFF, 0xFF, 0xFF, 0xA0, 0xFF, 0xA0, 0xFF, 0xFF,
- 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
+ 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+ 0x00, 0x00, 0x00, 0x00, 0x00};
-uint32_t bgra[20];
+uint32_t bgra[22];
void TrimString(char *strg);
// OSD stuff
-static char menucoltxt[][25]={"Content_Selected_Text","Content_Selected","Content_Text","Content","Content_inactive_Text","Content_inactive","Head_Text","Head"};
+static char menucoltxt[][25]={
+ "Content_Selected_Text",
+ "Content_Selected",
+ "Content_Text",
+ "Content",
+ "Content_inactive_Text",
+ "Content_inactive",
+ "Head_Text",
+ "Head"
+};
static char spres[][5]={"","_crt","_lcd"};
-char *line_buffer=NULL, *title=NULL;
+char *line_buffer=NULL, *title=NULL, *icon=NULL;
int size=24, type=0, timeout=0, refresh=3, flash=0, selection=0, tbuttons=0, buttons=0, bpline=3, echo=0, absolute=0, mute=1, header=1, cyclic=1;
char *butmsg[16]={0};
-int rbutt[16],hide=0,radius=11;
+int rbutt[16],hide=0,radius=0, radius_small=0;
// Misc
const char NOMEM[]="MsgBox <Out of memory>\n";
}
}
}
-// printf("%s\n%s=%s -> %d\n",tstr,entry,cfptr,rv);
+ if((strncmp(entry, tstr, 10) == 0) && (strncmp(entry, "font_file=", 10) == 0))
+ {
+ sscanf(tstr, "font_file=%127s", FONT);
+ rv = 1;
+ }
+ //printf("%s\n%s=%s -> %d\n",tstr,entry,cfptr,rv);
}
fclose(nfh);
}
int show_txt(int buttonly)
{
FILE *tfh;
+char const *fname=NULL;
+int icon_w=0, icon_h=0, xsize=0, ysize=0;
int i,bx,by,x1,y1,rv=-1,run=1,line=0,action=1,cut,itmp,btns=buttons,lbtns=(buttons>bpline)?bpline:buttons,blines=1+((btns-1)/lbtns);
if(hide)
memcpy(lfb, hbb, var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t));
return 0;
}
+ if (strcmp(icon, "none")==0 || strcmp(icon, "0")==0)
+ fname = "";
+ else if (strcmp(icon, "error")==0 || strcmp(icon, "1")==0)
+ fname = ICON_ERROR;
+ else if (strcmp(icon, "info")==0 || strcmp(icon, "2")==0)
+ fname = ICON_INFO;
+ else
+ fname = icon;
+ png_getsize(fname, &icon_w, &icon_h);
+
+ // limit icon size
+ if(icon_w > 100 || icon_h > 60) {
+ icon_w = xsize = 100;
+ icon_h = ysize = 60;
+ }
- yo=20+((header)?FSIZE_MED*5/4:0);
- int moffs=yo*3/4+6;
+ int h_head = max(FSIZE_MED+(size/2), icon_h);
+ yo=((header)?h_head:0);
+
+ int moffs=yo-h_head/3-(size/2);
if(!buttonly)
{
memcpy(lbb, ibb, var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t));
if(btns)
{
buttxstart=psx+pxw/2-(((double)lbtns*(double)buttsize+(((lbtns>2)&&(lbtns&1))?((double)buttdx):0.0))/2.0);
- buttystart=psy+y1*dy+15;
+ buttystart=psy+y1*dy+20;
}
}
{
if(!buttonly)
{
- RenderBox(psx-20, psy-yo, psx+pxw+20, psy+pyw+myo+15, radius, CMH);
- RenderBox(psx-20+2, psy-yo+2, psx+pxw+20-2, psy+pyw+myo+15-2, radius, CMC);
+ int iw, ih, pxoffs = 0;
+ int slen = GetStringLen(sx, title, FSIZE_BIG)+20;
+ if (icon_w > 0 && (psx+pxw-20-slen <= psx-10+icon_w+10))
+ pxoffs = (icon_w)/2;
+ RenderBox(psx-20-pxoffs+6, psy-yo-h_head/3-6, psx+pxw+pxoffs+26, psy+pyw+myo+(h_head/3)+16, radius, COL_SHADOW_PLUS_0);
+ RenderBox(psx-20-pxoffs, psy-yo-h_head/3-10, psx+pxw+pxoffs+20, psy+pyw+myo+(h_head/3)+10, radius, CMC);
if(header)
{
- RenderBox(psx-20, psy-yo+2-FSIZE_BIG/2, psx+pxw+20, psy-yo+FSIZE_BIG*3/4, radius, CMH);
- RenderString(title, psx, psy-moffs+FSIZE_BIG/2, pxw, CENTER, FSIZE_BIG, CMHT);
+ int pyoffs=(icon_h < h_head)?1:0;
+ RenderBox(psx-20-pxoffs, psy-yo-h_head/3-10, psx+pxw+pxoffs+20, psy-yo+(h_head*2)/3-10, radius, CMH);
+ paintIcon(fname, psx-10-pxoffs, psy-yo-h_head/3+h_head/2-icon_h/2+pyoffs-10, xsize, ysize, &iw, &ih);
+ RenderString(title, psx+pxoffs, psy-moffs-10, pxw, CENTER, FSIZE_BIG, CMHT);
}
}
- if(buttonly || !(rv=fh_txt_load(TMP_FILE, psx, pxw, psy+20, dy, size, line, &cut)))
+ if(buttonly || !(rv=fh_txt_load(TMP_FILE, psx, pxw, psy+size, dy, size, line, &cut)))
{
if(type==1)
{
{
bx=i%lbtns;
by=i/lbtns;
- RenderBox(buttxstart+bx*(buttsize+buttdx/2), buttystart+by*(butty+buttdy/2), buttxstart+(bx+1)*buttsize+bx*(buttdx/2), buttystart+by*(butty+buttdy/2)+butty, radius, YELLOW);
- RenderBox(buttxstart+bx*(buttsize+buttdx/2)+2, buttystart+by*(butty+buttdy/2)+2, buttxstart+(bx+1)*buttsize+bx*(buttdx/2)-2, buttystart+by*(butty+buttdy/2)+butty-2, radius, ((by*bpline+bx)==(selection-1))?CMCS:CMC);
+ RenderBox(buttxstart+bx*(buttsize+buttdx/2)+4, buttystart+by*(butty+buttdy/2)+4, buttxstart+(bx+1)*buttsize+bx*(buttdx/2)+4, buttystart+by*(butty+buttdy/2)+butty+4, radius_small, COL_SHADOW_PLUS_0);
+ RenderBox(buttxstart+bx*(buttsize+buttdx/2), buttystart+by*(butty+buttdy/2), buttxstart+(bx+1)*buttsize+bx*(buttdx/2), buttystart+by*(butty+buttdy/2)+butty, radius_small, CMCS/*YELLOW*/);
+ RenderBox(buttxstart+bx*(buttsize+buttdx/2)+1, buttystart+by*(butty+buttdy/2)+1, buttxstart+(bx+1)*buttsize+bx*(buttdx/2)-1, buttystart+by*(butty+buttdy/2)+butty-1, radius_small, ((by*bpline+bx)==(selection-1))?CMCS:CMC);
RenderString(butmsg[i], buttxstart+bx*(buttsize+buttdx/2), buttystart+by*(butty+buttdy/2)+butty, buttsize, CENTER, 26, (i==(selection-1))?CMCST:CMCIT);
}
}
return (rv)?-1:0;
}
+int Transform_Icon(char *msg)
+{
+char *sptr=msg;
+
+ while(*sptr)
+ sptr++;
+ *sptr=0;
+ return strlen(msg);
+}
+
int Transform_Msg(char *msg)
{
int rv=0;
printf(" title=\"Window-Title\" : specify title of window\n");
printf(" size=nn : set fontsize\n");
printf(" timeout=nn : set autoclose-timeout\n");
+ printf(" icon=n : n=none(0), error(1), info(2) or /path/my.png (default: \"info\")\n");
printf(" refresh=n : n=1..3, see readme.txt\n");
printf(" select=\"Button1,..\" : Labels of up to 16 Buttons, see readme.txt\n");
- printf(" absolute=n : n=0/1 return relative/absolute button number (default is 0)\n");
- printf(" order=n : maximal buttons per line (default is 3)\n");
+ printf(" absolute=n : n=0/1 return relative/absolute button number (default: 0)\n");
+ printf(" order=n : maximal buttons per line (default: 3)\n");
printf(" default=n : n=1..buttons, initially selected button, see readme.txt\n");
- printf(" echo=n : n=0/1 print the button-label to console on return (default is 0)\n");
- printf(" hide=n : n=0..2, function of mute-button, see readme.txt (default is 1)\n");
- printf(" cyclic=n : n=0/1, cyclic screen refresh (default is 1)\n");
+ printf(" echo=n : n=0/1 print the button-label to console on return (default: 0)\n");
+ printf(" hide=n : n=0..2, function of mute-button, see readme.txt (default: 1)\n");
+ printf(" cyclic=n : n=0/1, cyclic screen refresh (default: 1)\n");
}
/******************************************************************************
}
else
{
- dloop=2;
+ if(strstr(aptr,"icon=")!=NULL)
+ {
+ icon=rptr;
+ dloop=Transform_Icon(icon)==0;
+ }
+ else
+ {
+ dloop=2;
+ }
}
}
}
}
}
- FSIZE_BIG=(FSIZE_MED*5)/4;
+ FSIZE_BIG=(float)FSIZE_MED*1.25;
FSIZE_SMALL=(FSIZE_MED*4)/5;
TABULATOR=2*FSIZE_MED;
size=FSIZE_MED;
}
}
}
+ if(!icon)
+ {
+ icon=strdup("info");
+ }
if(!title)
{
title=strdup("Information");
if((ey=Read_Neutrino_Cfg(line_buffer))<0)
ey=620;
-
for(ix=CMCST; ix<=CMH; ix++)
{
sprintf(rstr,"menu_%s_alpha",menucoltxt[ix]);
if((tv=Read_Neutrino_Cfg(rstr))>=0)
rd[ix]=(float)tv*2.55;
}
- for (ix = 0; ix <= RED; ix++)
- bgra[ix] = (tr[ix] << 24) | (rd[ix] << 16) | (gn[ix] << 8) | bl[ix];
+ int cix=CMC;
+ for(ix=COL_MENUCONTENT_PLUS_0; ix<=COL_MENUCONTENT_PLUS_3; ix++)
+ {
+ rd[ix]=rd[cix]+25;
+ gn[ix]=gn[cix]+25;
+ bl[ix]=bl[cix]+25;
+ tr[ix]=tr[cix];
+ cix=ix;
+ }
+
+ sprintf(rstr,"infobar_alpha");
+ if((tv=Read_Neutrino_Cfg(rstr))>=0)
+ tr[COL_SHADOW_PLUS_0]=255-(float)tv*2.55;
+
+ sprintf(rstr,"infobar_blue");
+ if((tv=Read_Neutrino_Cfg(rstr))>=0)
+ bl[COL_SHADOW_PLUS_0]=(float)tv*2.55*0.4;
+
+ sprintf(rstr,"infobar_green");
+ if((tv=Read_Neutrino_Cfg(rstr))>=0)
+ gn[COL_SHADOW_PLUS_0]=(float)tv*2.55*0.4;
+
+ sprintf(rstr,"infobar_red");
+ if((tv=Read_Neutrino_Cfg(rstr))>=0)
+ rd[COL_SHADOW_PLUS_0]=(float)tv*2.55*0.4;
+
+ for (ix = 0; ix <= COL_SHADOW_PLUS_0; ix++)
+ bgra[ix] = (tr[ix] << 24) | (rd[ix] << 16) | (gn[ix] << 8) | bl[ix];
if(Read_Neutrino_Cfg("rounded_corners")>0)
- radius=11;
+ {
+ radius = 11;
+ radius_small = 7;
+ }
else
- radius=0;
+ radius = radius_small = 0;
fb = open(FB_DEVICE, O_RDWR);
if(fb == -1)
return -1;
}
+ Read_Neutrino_Cfg("font_file=");
if((error = FTC_Manager_LookupFace(manager, FONT, &face)))
{
if((error = FTC_Manager_LookupFace(manager, FONT2, &face)))
}
return 0;
}
-
#define KEY_PLAY 0x0CF
//devs
-
int fb;
//framebuffer stuff
+enum {
+ FILL,
+ GRID
+};
+
+enum {
+ CMCST,
+ CMCS,
+ CMCT,
+ CMC,
+ CMCIT,
+ CMCI,
+ CMHT,
+ CMH,
+ WHITE,
+ BLUE1,
+ GTRANSP,
+ CMS,
+ ORANGE,
+ GREEN,
+ YELLOW,
+ RED,
+ COL_MENUCONTENT_PLUS_0,
+ COL_MENUCONTENT_PLUS_1,
+ COL_MENUCONTENT_PLUS_2,
+ COL_MENUCONTENT_PLUS_3,
+ COL_SHADOW_PLUS_0
+};
-enum {FILL, GRID};
-
-enum {CMCST, CMCS, CMCT, CMC, CMCIT, CMCI, CMHT, CMH, WHITE, BLUE1, GTRANSP, CMS, ORANGE, GREEN, YELLOW, RED};
#define TRANSP 0
extern int FSIZE_BIG;
--- /dev/null
+
+#include "pngw.h"
+
+int png_load_ext(const char *filename, unsigned char **buffer, int* xp, int* yp, int* bpp);
+int fh_png_getsize(const char *filename, int *x, int *y);
+
+extern "C"
+{
+
+int png_load(const char *filename, unsigned char **buffer, int* xp, int* yp, int* bpp)
+{
+ return png_load_ext(filename, buffer, xp, yp, bpp);
+}
+
+int png_getsize(const char *filename, int *x, int *y)
+{
+ return fh_png_getsize(filename, x, y);
+}
+
+}
+
--- /dev/null
+/*
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+*/
+
+#include <png.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include "pngw.h"
+
+#define FH_ERROR_OK 0
+#define FH_ERROR_FILE 1 /* read/access error */
+#define FH_ERROR_FORMAT 2 /* file format error */
+#define FH_ERROR_MALLOC 3 /* error during malloc */
+#define PNG_BYTES_TO_CHECK 4
+#define min(x,y) ((x) < (y) ? (x) : (y))
+
+int fh_png_load(const char *name, unsigned char **buffer, int* xp, int* yp);
+
+int fh_png_id(const char *name)
+{
+ int fd;
+ char id[4];
+ fd=open(name,O_RDONLY); if(fd==-1) return(0);
+ read(fd,id,4);
+ close(fd);
+ if(id[1]=='P' && id[2]=='N' && id[3]=='G') return(1);
+ return(0);
+}
+
+int fh_png_load(const char *name, unsigned char **buffer, int* xp, int* yp);
+
+int int_png_load(const char *name, unsigned char **buffer, int* xp, int* yp, int* bpp, bool alpha)
+{
+ static const png_color_16 my_background = {0, 0, 0, 0, 0};
+ png_structp png_ptr;
+ png_infop info_ptr;
+ png_uint_32 width, height;
+ unsigned int i;
+ int bit_depth, color_type, interlace_type, number_passes, pass, int_bpp;
+ png_byte * fbptr;
+ FILE * fh;
+ bool updateInfo_alreadyRead;
+
+ if(!(fh=fopen(name,"rb")))
+ return(FH_ERROR_FILE);
+ png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
+ if(png_ptr == NULL) {
+ fclose(fh);
+ return(FH_ERROR_FORMAT);
+ }
+ info_ptr = png_create_info_struct(png_ptr);
+ if(info_ptr == NULL)
+ {
+ png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL);
+ fclose(fh);
+ return(FH_ERROR_FORMAT);
+ }
+#if (PNG_LIBPNG_VER < 10500)
+ if (setjmp(png_ptr->jmpbuf))
+#else
+ if (setjmp(png_jmpbuf(png_ptr)))
+#endif
+ {
+ png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
+ fclose(fh);
+ return(FH_ERROR_FORMAT);
+ }
+ png_init_io(png_ptr,fh);
+ png_read_info(png_ptr, info_ptr);
+ png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, &interlace_type, NULL, NULL);
+ updateInfo_alreadyRead = false;
+ if (alpha) // 24bit or gray scale PNGs with alpha-channel
+ {
+ *bpp = png_get_channels(png_ptr, info_ptr);
+ if ((*bpp == 2) && (color_type == PNG_COLOR_TYPE_GRAY_ALPHA)) {
+ if (bit_depth < 8) {
+ /* Extract multiple pixels with bit depths of 1, 2, and 4
+ from a single byte into separate bytes
+ (useful for paletted and grayscale images). */
+ png_set_packing(png_ptr);
+ /* Expand grayscale images to the full 8 bits
+ from 1, 2, or 4 bits/pixel */
+#if PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MINOR <= 2 && PNG_LIBPNG_VER_RELEASE < 9
+ png_set_gray_1_2_4_to_8(png_ptr);
+#else
+ png_set_expand_gray_1_2_4_to_8(png_ptr);
+#endif
+ }
+ /* Expand the grayscale to 24-bit RGB if necessary. */
+ png_set_gray_to_rgb(png_ptr);
+ /* Update the users info structure */
+ png_read_update_info(png_ptr, info_ptr);
+ updateInfo_alreadyRead = true;
+ *bpp = png_get_channels(png_ptr, info_ptr);
+ if (*bpp != 4) {
+ /* No 4 channels found
+ load PNG without alpha channel */
+ png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
+ fclose(fh);
+ return fh_png_load(name, buffer, xp, yp);
+ }
+ }
+ else if ((*bpp != 4) || !(color_type & PNG_COLOR_MASK_ALPHA)) {
+ /* No 4 channels & not an alpha channel found
+ load PNG without alpha channel */
+ png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
+ fclose(fh);
+ return fh_png_load(name, buffer, xp, yp);
+ }
+ int_bpp = 4;
+
+ /* Expand paletted or RGB images with transparency
+ to full alpha channels so the data will
+ be available as RGBA quartets. */
+ if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
+ png_set_tRNS_to_alpha(png_ptr);
+ }else // All other PNGs
+ {
+ if (color_type == PNG_COLOR_TYPE_PALETTE)
+ {
+ png_set_palette_to_rgb(png_ptr);
+ png_set_background(png_ptr, (png_color_16*)&my_background, PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
+ /* other possibility for png_set_background: use png_get_bKGD */
+ }
+ if (color_type == PNG_COLOR_TYPE_GRAY ||
+ color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
+ {
+ png_set_gray_to_rgb(png_ptr);
+ png_set_background(png_ptr, (png_color_16*)&my_background, PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
+ }
+ /* this test does not trigger for 8bit-paletted PNGs with newer libpng (1.2.36 at least),
+ but the data delivered is with alpha channel anyway, so always strip alpha for now
+ */
+#if PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MINOR <= 2 && PNG_LIBPNG_VER_RELEASE < 36
+ if (color_type & PNG_COLOR_MASK_ALPHA)
+#endif
+ png_set_strip_alpha(png_ptr);
+ if (bit_depth < 8)
+ png_set_packing(png_ptr);
+ int_bpp = 3;
+ }
+ if (bit_depth == 16)
+ png_set_strip_16(png_ptr);
+ number_passes = png_set_interlace_handling(png_ptr);
+ /* Update the users info structure */
+ if (updateInfo_alreadyRead == 0)
+ png_read_update_info(png_ptr,info_ptr);
+ unsigned long rowbytes = png_get_rowbytes(png_ptr, info_ptr);
+ if (width * int_bpp != rowbytes)
+ {
+ printf("[pngw.cpp]: Error processing %s - please report (including image).\n", name);
+ printf(" width: %lu rowbytes: %lu\n", (unsigned long)width, (unsigned long)rowbytes);
+ fclose(fh);
+ return(FH_ERROR_FORMAT);
+ }
+ for (pass = 0; pass < number_passes; pass++)
+ {
+ fbptr = (png_byte *)(*buffer);
+ for (i = 0; i < height; i++, fbptr += width * int_bpp)
+ png_read_row(png_ptr, fbptr, NULL);
+ }
+ png_read_end(png_ptr, info_ptr);
+ png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
+ fclose(fh);
+ return(FH_ERROR_OK);
+}
+
+int png_load_ext(const char *name, unsigned char **buffer, int* xp, int* yp, int* bpp)
+{
+ return int_png_load(name, buffer, xp, yp, bpp, true);
+}
+
+int fh_png_load(const char *name, unsigned char **buffer, int* xp, int* yp)
+{
+ return int_png_load(name, buffer, xp, yp, NULL, false);
+}
+
+int fh_png_getsize(const char *name,int *x,int *y)
+{
+ png_structp png_ptr;
+ png_infop info_ptr;
+ png_uint_32 width, height;
+ int bit_depth, color_type, interlace_type;
+ FILE *fh;
+
+ if(!(fh=fopen(name,"rb"))) return(FH_ERROR_FILE);
+
+ png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,NULL,NULL,NULL);
+ if(png_ptr == NULL) {
+ fclose(fh);
+ return(FH_ERROR_FORMAT);
+ }
+ info_ptr = png_create_info_struct(png_ptr);
+ if(info_ptr == NULL)
+ {
+ png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL);
+ fclose(fh);
+ return(FH_ERROR_FORMAT);
+ }
+
+#if (PNG_LIBPNG_VER < 10500)
+ if (setjmp(png_ptr->jmpbuf))
+#else
+ if (setjmp(png_jmpbuf(png_ptr)))
+#endif
+ {
+ png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
+ fclose(fh);
+ return(FH_ERROR_FORMAT);
+ }
+
+ png_init_io(png_ptr,fh);
+ png_read_info(png_ptr, info_ptr);
+ png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,&interlace_type, NULL, NULL);
+ png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
+ *x=width;
+ *y=height;
+ fclose(fh);
+ return(FH_ERROR_OK);
+}
--- /dev/null
+/*
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+*/
+
+#ifndef __PNGW_H__
+#define __PNGW_H__
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+int png_load(const char *filename, unsigned char **buffer, int* xp, int* yp, int* bpp);
+int png_getsize(const char *filename, int *x, int *y);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // __PNGW_H__
Beenden den Bildschirmzustand wieder her, welcher vor dem Start der MessageBox aktuell war.
Dieser Parameter kann entfallen, in diesem Fall wird standardmäßig mit refresh=3 gearbeitet.
-Normalerweise wird die MessageBox auf dem Bildschirm seit der Version 2.60 jede Sekunde aufgefrischt.
+Normalerweise wird die MessageBox auf dem Bildschirm jede Sekunde aufgefrischt.
Sollte das bie bestimmten Anwendungen stören, kann dieser zyklische Refresh ausgeschaltet werden.
Dazu wird der Parameter
übergeben. Damit wird die Box nur noch ein Mal beim Aufruf und der Änderung des Inhaltes einer ange-
zeigten Datei dargestellt. Der Defaultwert für cyclic ist 1.
+Im Titelbereich wird standardmäßig ein Info-Icon im PNG-Format angezeigt. Es werden Icons bis zu
+einer Größe von 100 x 60 angezeigt. Größere werden skaliert. Die Anzeige von eigenen Icons wird mit
+icon=/Pfad_zum_Icon/mein_Icon.png angegeben.
+
+icon=
+
+Mit icon="none" oder icon=0 wird kein Icon angezeigt. Weitere sind "error" oder 1, "info" oder 2.
+
+
Formatierung des übergebenen Textes
-----------------------------------
Um die Darstellung des Textes ansprechender gestalten zu können, werden bestimmte Formatsteuer-
--- /dev/null
+/*
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+
+unsigned char * color_average_resize(unsigned char * orgin, int ox, int oy, int dx, int dy, int alpha)
+{
+ unsigned char *cr,*p,*q;
+ int i,j,k,l,ya,yb;
+ int sq,r,g,b,a;
+ cr = (unsigned char*) malloc(dx * dy * ((alpha) ? 4 : 3));
+ if(cr==NULL)
+ {
+ printf("Error: malloc\n");
+ return(orgin);
+ }
+ p=cr;
+
+ int xa_v[dx];
+ for(i=0;i<dx;i++)
+ xa_v[i] = i*ox/dx;
+ int xb_v[dx+1];
+ for(i=0;i<dx;i++)
+ {
+ xb_v[i]= (i+1)*ox/dx;
+ if(xb_v[i]>=ox)
+ xb_v[i]=ox-1;
+ }
+
+ if (alpha)
+ {
+ for(j=0;j<dy;j++)
+ {
+ ya= j*oy/dy;
+ yb= (j+1)*oy/dy; if(yb>=oy) yb=oy-1;
+ for(i=0;i<dx;i++,p+=4)
+ {
+ for(l=ya,r=0,g=0,b=0,a=0,sq=0;l<=yb;l++)
+ {
+ q=orgin+((l*ox+xa_v[i])*4);
+ for(k=xa_v[i];k<=xb_v[i];k++,q+=4,sq++)
+ {
+ r+=q[0]; g+=q[1]; b+=q[2]; a+=q[3];
+ }
+ }
+ int sq_tmp = sq ? sq : 1;//avoid division by zero
+ p[0]= (uint8_t)(r/sq_tmp);
+ p[1]= (uint8_t)(g/sq_tmp);
+ p[2]= (uint8_t)(b/sq_tmp);
+ p[3]= (uint8_t)(a/sq_tmp);
+ }
+ }
+ }else
+ {
+ for(j=0;j<dy;j++)
+ {
+ ya= j*oy/dy;
+ yb= (j+1)*oy/dy; if(yb>=oy) yb=oy-1;
+ for(i=0;i<dx;i++,p+=3)
+ {
+ for(l=ya,r=0,g=0,b=0,sq=0;l<=yb;l++)
+ {
+ q=orgin+((l*ox+xa_v[i])*3);
+ for(k=xa_v[i];k<=xb_v[i];k++,q+=3,sq++)
+ {
+ r+=q[0]; g+=q[1]; b+=q[2];
+ }
+ }
+ int sq_tmp = sq ? sq : 1;//avoid division by zero
+ p[0]= (uint8_t)(r/sq_tmp);
+ p[1]= (uint8_t)(g/sq_tmp);
+ p[2]= (uint8_t)(b/sq_tmp);
+ }
+ }
+ }
+ free(orgin);
+ return(cr);
+}
--- /dev/null
+/*
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+*/
+
+#ifndef __RESIZE_H__
+#define __RESIZE_H__
+
+unsigned char * color_average_resize(unsigned char * orgin,int ox,int oy,int dx,int dy,int alpha);
+
+#endif
break;
case 's':
ys-=(dy/2);
- RenderBox(xs, ys-2-size/3+1, xs+xw, ys-2-size/3+2, FILL, CMS);
- RenderBox(xs, ys-2-size/3, xs+xw, ys-2-size/3+1, FILL, CMCIT);
+ RenderBox(xs, ys-2-size/3, xs+xw, ys-2-size/3+2, FILL, COL_MENUCONTENT_PLUS_3);
break;
}
}
if (comment == 1)
{
int xxs = xs;
- RenderBox(xs, ys-2-size/2+1, xs+xw, ys-2-size/2+2, FILL, CMS);
- RenderBox(xs, ys-2-size/2, xs+xw, ys-2-size/2+1, FILL, CMCIT);
+ RenderBox(xs, ys-2-size/2, xs+xw, ys-2-size/2+2, FILL, COL_MENUCONTENT_PLUS_3);
if(slen > 0 && slen < xw) {
xxs += (xw-slen-boffs)/2-5;
RenderBox(xxs, ys-2-size/2, xxs+slen+10+boffs, ys-2-size/2+2, FILL, CMC);
}
else if (comment == 2)
{
- RenderBox(xs+slen+boffs, ys-2-size/2+1, xs+xw, ys-2-size/2+2, FILL, CMS);
- RenderBox(xs+slen+boffs, ys-2-size/2, xs+xw, ys-2-size/2+1, FILL, CMCIT);
+ RenderBox(xs+slen+boffs, ys-2-size/2, xs+xw, ys-2-size/2+2, FILL, COL_MENUCONTENT_PLUS_3);
RenderString(t, xs, ys, xw, LEFT, size, color);
}
else if (comment == 3)
{
- RenderBox(xs, ys-2-size/2+1, xs+xw-slen-boffs, ys-2-size/2+2, FILL, CMS);
- RenderBox(xs, ys-2-size/2, xs+xw-slen-boffs, ys-2-size/2+1, FILL, CMCIT);
+ RenderBox(xs, ys-2-size/2, xs+xw-slen-boffs, ys-2-size/2+2, FILL, COL_MENUCONTENT_PLUS_3);
RenderString(t, xs, ys, xw, RIGHT, size, color);
}
else