#include "pngw.h"
-#define SH_VERSION 2.03
+#define SH_VERSION 2.10
static char CFG_FILE[128]="/var/tuxbox/config/shellexec.conf";
char url[256]="time.fu-berlin.de";
char *line_buffer=NULL;
char *trstr;
-int paging=1, mtmo=120, radius=0, radius_small=0;
-int ixw=600, iyw=680, xoffs=13, vfd=0;
+int paging=1, mtmo=120, vfd=0, radius=0, radius_small=0;
+int ixw, iyw, xoffs;
char INST_FILE[]="/tmp/rc.locked";
int instance=0;
int rclocked=0;
return NULL;
}
+int scale2res(int s)
+{
+ if (var_screeninfo.xres == 1920)
+ s += s/2;
+
+ return s;
+}
+
void TrimString(char *strg)
{
char *pt1=strg, *pt2=strg;
FSIZE_BIG=(FSIZE_MED*5)/4;
FSIZE_SMALL=(FSIZE_MED*4)/5;
TABULATOR=2*FSIZE_MED;
- ixw=(ixw>(ex-sx))?(ex-sx):((ixw<400)?400:ixw);
- iyw=(iyw>(ey-sy))?(ey-sy):((iyw<380)?380:iyw);
+ ixw=scale2res(ixw);
+ iyw=scale2res(iyw);
+ ixw=(ixw>(ex-sx))?(ex-sx):((ixw<scale2res(400))?scale2res(400):ixw);
+ iyw=(iyw>(ey-sy))?(ey-sy):((iyw<scale2res(380))?scale2res(380):iyw);
return rv;
}
int loop, dloop, ldy, stlen;
double scrollbar_len, scrollbar_ofs, scrollbar_cor;
int index=m->act_entry,tind=m->act_entry;
- int sbw=(m->num_entrys>MAX_FUNCS)?15:0; // scrollbar width
- int sbo=2; // inner scrollbar offset
+ int sbw=(m->num_entrys>MAX_FUNCS)?scale2res(15):0; // scrollbar width
+ int sbo=OFFSET_MIN; // inner scrollbar offset
char tstr[BUFSIZE]={0}, *tptr;
char dstr[BUFSIZE]={0}, *lcptr,*lcstr;
- int dy, my, moffs, mh, toffs, soffs=4, oldx=startx, oldy=starty, sbar=0, nosel;
+ int dy, my, moffs, mh, toffs, soffs=OFFSET_SMALL/*4*/, oldx=startx, oldy=starty, sbar=0, nosel;
PLISTENTRY pl;
- moffs=iyw/(MAX_FUNCS+1)+5;
+ moffs=iyw/(MAX_FUNCS+1)+OFFSET_SMALL;
mh=iyw-moffs;
dy=mh/(MAX_FUNCS+1);
toffs=dy/2;
tind=index;
//frame layout
- RenderBox(6, 6, ixw+6, iyw+6, radius, COL_SHADOW_PLUS_0);
+ RenderBox(OFFSET_SMALL/*6*/, OFFSET_SMALL, ixw+OFFSET_SMALL, iyw+OFFSET_SMALL, radius, COL_SHADOW_PLUS_0);
RenderBox(0, 0, ixw, iyw, radius, CMC);
// titlebar
RenderBox(ixw-sbw + sbo, moffs + scrollbar_ofs + sbo, ixw - sbo, moffs + scrollbar_ofs + scrollbar_cor - sbo, radius, COL_MENUCONTENT_PLUS_3);
}
int iw,ih;
- int offset, hoffs = (m->headermed[m->act_header]==1)?0:46;
+ int offset, hoffs = (m->headermed[m->act_header]==1)?0:50;
int ioffs = xoffs+8; // + half standard icon
if(m->icon[m->act_header])
{
coffs=clh;
}
}
- RenderString(dstr, 46, my+soffs-(dy-font_size)/2-coffs+2, ixw-sbw-65, LEFT, font_type, (((loop%MAX_FUNCS) == (tind%MAX_FUNCS)) && (sbar) && (!nosel))?CMCST:(nosel)?CMCIT:CMCT);
+ RenderString(dstr, 50, my+soffs-(dy-font_size)/2-coffs+2, ixw-sbw-scale2res(65), LEFT, font_type, (((loop%MAX_FUNCS) == (tind%MAX_FUNCS)) && (sbar) && (!nosel))?CMCST:(nosel)?CMCIT:CMCT);
}
if(pl->type==TYP_MENU)
{
- RenderString(">", 30, my+soffs-(dy-FSIZE_MED)/2+1, 65, LEFT, MED, (((loop%MAX_FUNCS) == (tind%MAX_FUNCS)) && (sbar) && (!nosel))?CMCST:CMCT);
+ RenderString(">", 30, my+soffs-(dy-FSIZE_MED)/2+1, scale2res(65), LEFT, MED, (((loop%MAX_FUNCS) == (tind%MAX_FUNCS)) && (sbar) && (!nosel))?CMCST:CMCT);
}
if(pl->underline)
{
if(ccenter)
{
stlen=GetStringLen(xoffs, dstr, MED);
- RenderBox(xoffs+(ixw-xoffs-sbw)/2-stlen/2, my+soffs-ldy, xoffs+(ixw-xoffs-sbw)/2+stlen/2+15, my+soffs, FILL, CMC);
+ RenderBox(xoffs+(ixw-xoffs-sbw)/2-stlen/2, my+soffs-ldy, xoffs+(ixw-xoffs-sbw)/2+stlen/2+3*OFFSET_SMALL/*15*/, my+soffs, FILL, CMC);
RenderString(dstr, xoffs, my+soffs-(dy-FSIZE_MED)/2, ixw-sbw, CENTER, MED, CMCIT);
}
}
if(dloop<15)
{
sprintf(tstr,"%1d",(dloop-4)%10);
- RenderString(tstr, xoffs, my+soffs-(dy-FSIZE_SMALL)/2+2, 15, CENTER, SMALL, ((loop%MAX_FUNCS) == (tind%MAX_FUNCS))?CMCST:((pl->type==TYP_INACTIVE)?CMCIT:CMCT));
+ RenderString(tstr, xoffs, my+soffs-(dy-FSIZE_SMALL)/2+2, 3*OFFSET_SMALL, CENTER, SMALL, ((loop%MAX_FUNCS) == (tind%MAX_FUNCS))?CMCST:((pl->type==TYP_INACTIVE)?CMCIT:CMCT));
}
break;
}
}
}
+ //init framebuffer before 1st scale2res
+ fb = open(FB_DEVICE, O_RDWR);
+ if(fb == -1)
+ {
+ perror(__plugin__ " <open framebuffer device>");
+ exit(1);
+ }
+ if(ioctl(fb, FBIOGET_FSCREENINFO, &fix_screeninfo) == -1)
+ {
+ perror(__plugin__ " <FBIOGET_FSCREENINFO>\n");
+ return -1;
+ }
+ if(ioctl(fb, FBIOGET_VSCREENINFO, &var_screeninfo) == -1)
+ {
+ perror(__plugin__ " <FBIOGET_VSCREENINFO>\n");
+ return -1;
+ }
+ if(!(lfb = (uint32_t*)mmap(0, fix_screeninfo.smem_len, PROT_WRITE|PROT_READ, MAP_SHARED, fb, 0)))
+ {
+ perror(__plugin__ " <mapping of Framebuffer>\n");
+ return -1;
+ }
+
+ // read config
+ ixw=scale2res(600), iyw=scale2res(680), xoffs=scale2res(13);
if((line_buffer=calloc(BUFSIZE+1, sizeof(char)))==NULL)
{
printf(NOMEM);
else
sprintf(trstr,"screen_StartX_%s_%d", spres[spr], resolution);
if((sx=Read_Neutrino_Cfg(trstr))<0)
- sx=100;
+ sx=scale2res(100);
if (resolution == -1)
sprintf(trstr,"screen_EndX_%s", spres[spr]);
else
sprintf(trstr,"screen_EndX_%s_%d", spres[spr], resolution);
if((ex=Read_Neutrino_Cfg(trstr))<0)
- ex=1180;
+ ex=scale2res(1180);
if (resolution == -1)
sprintf(trstr,"screen_StartY_%s", spres[spr]);
else
sprintf(trstr,"screen_StartY_%s_%d", spres[spr], resolution);
if((sy=Read_Neutrino_Cfg(trstr))<0)
- sy=100;
+ sy=scale2res(100);
if (resolution == -1)
sprintf(trstr,"screen_EndY_%s", spres[spr]);
else
sprintf(trstr,"screen_EndY_%s_%d", spres[spr], resolution);
if((ey=Read_Neutrino_Cfg(trstr))<0)
- ey=620;
+ ey=scale2res(620);
for(index=CMCST; index<=CMH; index++)
{
}
if(Read_Neutrino_Cfg("rounded_corners")>0) {
- radius = 11;
- radius_small = 7;
+ radius = scale2res(11);
+ radius_small = scale2res(5);
}
else
radius = radius_small = 0;
for (index = 0; index <= COL_SHADOW_PLUS_0; index++)
bgra[index] = (tr[index] << 24) | (rd[index] << 16) | (gn[index] << 8) | bl[index];
- fb = open(FB_DEVICE, O_RDWR);
- if(fb == -1)
- {
- perror(__plugin__ " <open framebuffer device>");
- exit(1);
- }
-
InitRC();
//InitVFD();
- //init framebuffer
- if(ioctl(fb, FBIOGET_FSCREENINFO, &fix_screeninfo) == -1)
- {
- perror(__plugin__ " <FBIOGET_FSCREENINFO>\n");
- return -1;
- }
- if(ioctl(fb, FBIOGET_VSCREENINFO, &var_screeninfo) == -1)
- {
- perror(__plugin__ " <FBIOGET_VSCREENINFO>\n");
- return -1;
- }
- if(!(lfb = (uint32_t*)mmap(0, fix_screeninfo.smem_len, PROT_WRITE|PROT_READ, MAP_SHARED, fb, 0)))
- {
- perror(__plugin__ " <mapping of Framebuffer>\n");
- return -1;
- }
-
//init fontlibrary
if((error = FT_Init_FreeType(&library)))
{
memset(lbb, TRANSP, var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t));
memcpy(lfb, lbb, var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t));
//blit();
- startx = sx + (((ex-sx) - (fix_screeninfo.line_length-200))/2);
- starty = sy + (((ey-sy) - (var_screeninfo.yres-150))/2);
+ startx = sx + (((ex-sx) - (fix_screeninfo.line_length-scale2res(200)))/2);
+ starty = sy + (((ey-sy) - (var_screeninfo.yres-scale2res(150)))/2);
+
+ /* scale to resolution */
+ FSIZE_BIG = scale2res(FSIZE_BIG);
+ FSIZE_MED = scale2res(FSIZE_MED);
+ FSIZE_SMALL = scale2res(FSIZE_SMALL);
+
+ TABULATOR = scale2res(TABULATOR);
+
+ OFFSET_MED = scale2res(OFFSET_MED);
+ OFFSET_SMALL = scale2res(OFFSET_SMALL);
+ OFFSET_MIN = scale2res(OFFSET_MIN);
+
+ /* Set up signal handlers. */
signal(SIGINT, quit_signal);
signal(SIGTERM, quit_signal);
signal(SIGQUIT, quit_signal);
int FSIZE_SMALL=20;
int TABULATOR=72;
+int OFFSET_MED=10;
+int OFFSET_SMALL=5;
+int OFFSET_MIN=2;
+
//extern void blit();
static char *sc = "aouAOUzd",
{
if(color != -1)
{
- if (_sx + 10 < _ex)
- RenderBox(_sx, _sy - 10, _sx + 10, _sy, GRID, color);
+ if (_sx + OFFSET_MED < _ex)
+ RenderBox(_sx, _sy - OFFSET_MED, _sx + OFFSET_MED, _sy, GRID, color);
else
return -1;
}
- return 10;
+ return OFFSET_MED;
}
if (currentchar == '\t')
{
/* simulate horizontal TAB */
- return 15;
+ return scale2res(15);
}
//load char
stringlen=desc.width+TABULATOR*((int)(stringlen/TABULATOR)+1);
else if(*string=='T' && sscanf(string+1,"%4d",&i)==1) {
string+=5;
- stringlen=i-_sx;
+ stringlen=scale2res(i)-_sx;
}
break;
default:
if(sscanf(rptr+1,"%4d",&i)==1)
{
rptr+=4;
- _sx=i;
+ _sx=scale2res(i);
}
else
{
void ShowMessage(char *mtitle, char *message, int wait)
{
extern int radius, radius_small;
- int ixw=420;
- int iyw=wait?327:300;
+ int ixw=scale2res(420);
+ int iyw=wait?scale2res(327):scale2res(300);
int lx=startx;
//int ly=starty;
char *tdptr;
//starty=sy;
//layout
- RenderBox(0+4, 178+4, ixw+4, iyw+4, radius, COL_SHADOW_PLUS_0);
- RenderBox(0, 178, ixw, iyw, radius, CMC);
- RenderBox(0, 178, ixw, 220, radius, CMH);
+ RenderBox(0+OFFSET_SMALL, scale2res(178)+OFFSET_SMALL, ixw+OFFSET_SMALL, iyw+OFFSET_SMALL, radius, COL_SHADOW_PLUS_0);
+ RenderBox(0, scale2res(178), ixw, iyw, radius, CMC);
+ RenderBox(0, scale2res(178), ixw, scale2res(220), radius, CMH);
//message
tdptr=strdup(mtitle);
remove_tabs(tdptr);
- RenderString(tdptr, 5, 215, ixw-10, CENTER, FSIZE_BIG, CMHT);
+ RenderString(tdptr, OFFSET_SMALL, scale2res(215), ixw-OFFSET_MED, CENTER, FSIZE_BIG, CMHT);
free(tdptr);
tdptr=strdup(message);
remove_tabs(tdptr);
- RenderString(tdptr, 5, 270, ixw-10, CENTER, FSIZE_MED, CMCT);
+ RenderString(tdptr, OFFSET_SMALL, scale2res(270), ixw-OFFSET_MED, CENTER, FSIZE_MED, CMCT);
free(tdptr);
if(wait)
- {
- RenderBox(ixw/2-35+4, 286+4, ixw/2+35+4, 310+4, radius_small, COL_SHADOW_PLUS_0);
- RenderBox(ixw/2-35, 286, ixw/2+35, 310, radius_small, CMCS);
- RenderString("OK", ixw/2-25, 312, 50, CENTER, FSIZE_MED, CMCT);
+ { int offs=2*OFFSET_MED+OFFSET_SMALL; // 35
+ RenderBox(ixw/2-offs+OFFSET_SMALL, scale2res(286)+OFFSET_SMALL, ixw/2+offs+OFFSET_SMALL, scale2res(310)+OFFSET_SMALL, radius_small, COL_SHADOW_PLUS_0);
+ RenderBox(ixw/2-offs, scale2res(286), ixw/2+offs, scale2res(310), radius_small, CMCS);
+ RenderString("OK", ixw/2-scale2res(25), scale2res(312), scale2res(50), CENTER, FSIZE_MED, CMCT);
}
memcpy(lfb, lbb, var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t));