//************************************************************************************************ // cMenu() //************************************************************************************************ cMenu::cMenu(const char *pName) { m_pName = pName; m_ItemWidth = ITEM_TEXT_LEFT + GetStringLen(m_pName) + ITEM_TEXT_RIGHT; if (m_ItemWidth < MENU_MIN_WIDTH) m_ItemWidth = MENU_MIN_WIDTH; m_RetValue = eMVNone; }
//************************************************************************************************ // cMenuItem::cMenuItem() //************************************************************************************************ cMenuItem::cMenuItem(const char *pText) { m_pText = pText; m_ItemNr = -1; m_Selected = 0; m_ItemWidth = ITEM_TEXT_LEFT + GetStringLen(m_pText) + ITEM_TEXT_RIGHT; m_ItemHeight = ITEM_HEIGHT; m_Selectable = true; m_RetValue = eMVNone; }
void RenderString(int ovwidth,Pixel *dest,const char *string, int sx, int sy, int maxwidth, int layout, int color, int bgcolor) { if (strlen(string) == 0) return; int stringlen, ex, charwidth,i,j; #if ((defined(FREETYPE_MAJOR)) && (((FREETYPE_MAJOR == 2) && (((FREETYPE_MINOR == 1) && (FREETYPE_PATCH >= 9)) || (FREETYPE_MINOR > 1))) || (FREETYPE_MAJOR > 2))) desc.width = desc.height = ROW_HEIGHT; #else desc.font.pix_width = desc.font.pix_height = ROW_HEIGHT; #endif //set alignment stringlen = GetStringLen(string); if(layout != LEFT) { switch(layout) { case CENTER: if(stringlen < maxwidth) sx += (maxwidth - stringlen)/2; break; case RIGHT: if(stringlen < maxwidth) sx += maxwidth - stringlen; } } //render string ex = sx + maxwidth; // fill background for(i = 1; i < ROW_HEIGHT-2; i++) { int in = 0; switch (i) { case 1 : in = 2;break; case 2 : in = 1;break; case ROW_HEIGHT-4: in = 1;break; case ROW_HEIGHT-3: in = 2;break; } for(j = in; j < stringlen-in; j++) dest[sx + j + ovwidth*(sy + i- ROW_HEIGHT)] = bgcolor; } while(*string != '\0' && *string != '\n') { if((charwidth = RenderChar(dest,*string, sx+1, sy, ex, color,ovwidth)) == -1) return; // string > maxwidth sx += charwidth; string++; } }
void CEDPacket::WriteEDString(LPCTSTR psz, BOOL bUnicode) { int nLen; if ( bUnicode ) { nLen = GetStringLenUTF8( psz ); WriteShortLE( nLen ); WriteStringUTF8( psz, FALSE ); } else { nLen = GetStringLen( psz ); WriteShortLE( nLen ); WriteString( psz, FALSE ); } ASSERT( nLen <= 0xFFFF ); }
void CEDPacket::WriteEDString(LPCTSTR psz, DWORD ServerFlags) { int nLen; if ( ServerFlags & ED2K_SERVER_TCP_UNICODE ) { nLen = GetStringLenUTF8( psz ); WriteShortLE( nLen ); WriteStringUTF8( psz, FALSE ); } else { nLen = GetStringLen( psz ); WriteShortLE( nLen ); WriteString( psz, FALSE ); } ASSERT( nLen <= 0xFFFF ); }
int fh_txt_trans(const char *name, int xs, int xw, int ys, int dy, int cs, int line, int *cut, int *x, int *y, int plot) { char tstr[BUFSIZE],rstr[BUFSIZE],*tptr; int loop=1, j, slen, cnt=0; FILE *fh; int just, color=CMCT; if(!(fh=fopen(name,"rb"))) return(FH_ERROR_FILE); // first=(line==0); *x=0; *y=0; while((loop>0) && (fgets(tstr, sizeof(tstr), fh))) { j=0; just=LEFT; color=CMCT; tptr=tstr+strlen(tstr); while((tptr>=tstr) && (*tptr<=32)) { *tptr=0; --tptr; } tptr=tstr; while(*tptr) { rstr[j++]=*tptr; cnt++; if(*tptr == '~') { switch (*(tptr+1)) { case 'l': just=LEFT; break; case 'r': just=RIGHT; break; case 'c': just=CENTER; break; case 's': // vert. line RenderBox(xs, ys-cs/3, xs+xw, ys-cs/3+1, FILL, COL_MENUCONTENT_PLUS_3); RenderBox(xs, ys-cs/3+1, xs+xw, ys-cs/3+2, FILL, COL_MENUCONTENT_PLUS_1); break; } } tptr++; } if((loop>0) && (ys<(ey-dy))) { rstr[j]=0; if(plot) { if(loop>=line) { RenderString(rstr, xs, ys, xw, just, cs, color); /* if(strlen(rstr)) { first=0; } */ ys+=dy; } } else { if(strlen(rstr)) { slen=GetStringLen(xs,rstr)+10; if(slen>*x) { *x=slen; } } *y=*y+1; } } } if(plot) { *cut=(ys>=(ey-dy)); } fclose(fh); return(FH_ERROR_OK); }
int fh_php_trans(const char *name, int sx, int sy, int dy, int cs, int line, int highlite, int *cut, int *x, int *y, int plain, int plot) { char tstr[BUFSIZE],rstr[BUFSIZE],*tptr,*xptr,cc,br3flag=0; int loop=1, j, first, aline=0, fx=sx, fy=sy, slen, deg=0; FILE *fh; if(!(fh=fopen(name,"rb"))) return(FH_ERROR_FILE); first=(line==0); *x=0; *y=0; sy+=dy; while((loop>0) && (fgets(tstr, sizeof(tstr), fh))) { tptr=tstr+strlen(tstr); while((tptr>=tstr) && (*tptr<=32)) { *tptr=0; --tptr; } if(((tptr=strstr(tstr,"<br>"))!=NULL) || ((tptr=strstr(tstr,"<h3>"))!=NULL)) { tptr+=4; if((xptr=strstr(tstr,"</h3>"))!=NULL) { *xptr=0; br3flag=1; } if((*tptr=='=') || (strncmp(tptr,"<br>",4)==0)) { if(aline>=line) { first=1; } } else { if(aline++>=line) { j=0; while(*tptr) { if(plain || (*tptr != '&')) { rstr[j++]=*tptr; tptr++; } else { if((*(tptr+1)!='#') && (strstr(tptr,"uml;")!=(tptr+2)) && (strstr(tptr,"nbsp;")!=(tptr+1)) && (strstr(tptr,"gt;")!=(tptr+1)) && (strstr(tptr,"lt;")!=(tptr+1)) && (strstr(tptr,"quot;")!=(tptr+1)) && (strstr(tptr,"zlig;")!=(tptr+2))) { rstr[j++]=*tptr++; } else { tptr++; cc=' '; switch (*tptr) { case 'a': cc='ä'; break; case 'A': cc='Ä'; break; case 'o': cc='ö'; break; case 'O': cc='Ö'; break; case 'u': cc='ü'; break; case 'U': cc='Ü'; break; case 's': cc='ß'; break; case 'q': case 'Q': cc='"'; break; case 'l': case 'g': cc=0; break; case '#': if(sscanf(tptr+1,"%3d",°)==1) { cc=deg; } break; } if(cc) { rstr[j++]=cc; } if((tptr=strchr(tptr,';'))==NULL) { printf("Tuxwetter <Parser Error in PHP>\n"); fclose(fh); return -1; } else { ++tptr; } } } } if((loop>0) && (sy<(fy+420))) { rstr[j]=0; if(plot) { if(!br3flag) { RenderString(rstr, sx, sy, 619, LEFT, cs, (first && highlite)?GREEN:CMCT); } else { RenderString(rstr, sx, fx+250, 619, CENTER, FSIZE_BIG, CMCT); } if(strlen(rstr)) { first=0; } sy+=dy; } else { if(strlen(rstr)) { slen=GetStringLen(sx, rstr, FSIZE_MED); if(slen>*x) { *x=slen; } } *y=*y+1; } } } if(plot) { *cut=(sy>=(fy+420)); if(line) { RenderString("<<", fx, fy, sx, LEFT, FSIZE_MED, CMHT); } if(*cut) { RenderString(">>", fx, sy, sx, LEFT, FSIZE_MED, CMHT); } } } } } fclose(fh); return(FH_ERROR_OK); }
static void ShowInfo(MENU *m, int knew ) { int icon_w=0, icon_h=0, xsize=0, ysize=0; 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)?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=OFFSET_SMALL/*4*/, oldx=startx, oldy=starty, sbar=0, nosel; PLISTENTRY pl; moffs=iyw/(MAX_FUNCS+1)+OFFSET_SMALL; mh=iyw-moffs; dy=mh/(MAX_FUNCS+1); toffs=dy/2; my=moffs+toffs+dy; startx = sx + (((ex-sx) - ixw)/2); starty = sy + (((ey-sy) - iyw)/2); tind=index; //frame layout 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(0, 0, ixw, moffs, radius, CMH); for(loop=MAX_FUNCS*(index/MAX_FUNCS); loop<MAX_FUNCS*(index/MAX_FUNCS+1) && loop<m->num_entrys && !sbar; loop++) { pl=m->list[loop]; sbar |= ((pl->type!=TYP_COMMENT) && (pl->type!=TYP_INACTIVE)); } --loop; if(loop>index) { m->act_entry=index=loop; } if(sbw) { //sliderframe RenderBox(ixw-sbw, moffs, ixw, iyw, radius, COL_MENUCONTENT_PLUS_1); //slider scrollbar_len = (double)mh / (double)((m->num_entrys/MAX_FUNCS+1)*MAX_FUNCS); scrollbar_ofs = scrollbar_len*(double)((index/MAX_FUNCS)*MAX_FUNCS); scrollbar_cor = scrollbar_len*(double)MAX_FUNCS; 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:scale2res(48); int ioffs = xoffs+8; // + half standard icon if(m->icon[m->act_header]) { png_getsize(m->icon[m->act_header], &icon_w, &icon_h); // limit icon size if(icon_w > 150 || icon_h > 36) { icon_w = xsize = 150; icon_h = ysize = 36; } if (icon_w > 32) { offset = ioffs-16; } else offset = ioffs-icon_w/2; paintIcon(m->icon[m->act_header], offset, (moffs-icon_h)/2+1, xsize, ysize, &iw, &ih); } // Title text if (icon_w > 32) { hoffs = offset+iw+8; } lcstr=strdup(m->headertxt[m->act_header]); clean_string(m->headertxt[m->act_header],lcstr); RenderString(lcstr, hoffs, moffs-(moffs-FSIZE_BIG)/2+2, ixw-sbw-hoffs, (m->headermed[m->act_header]==1)?CENTER:LEFT, FSIZE_BIG, CMHT); free(lcstr); index /= MAX_FUNCS; dloop=0; ldy=dy; //Show table of commands for(loop = index*MAX_FUNCS; (loop < (index+1)*MAX_FUNCS) && (loop < m->num_entrys); ++loop) { int clh=2; // comment line height dy=ldy; pl=m->list[loop]; strcpy(dstr,pl->entry); if((tptr=strxchr(dstr,','))!=NULL) { if(pl->type != TYP_COMMENT) { *tptr=0; } } lcptr=tptr=dstr; while(*tptr) { if(*tptr==0x27) { memmove(tptr,tptr+1,strlen(tptr)); } ++tptr; } if(m->num_active && sbar && (loop==m->act_entry)) { RenderBox(0, my+soffs-dy, ixw-sbw, my+soffs, radius, CMCS); } nosel=(pl->type==TYP_COMMENT) || (pl->type==TYP_INACTIVE); if(!(pl->type==TYP_COMMENT && pl->underline==2)) { int font_type = MED; int font_size = FSIZE_MED; int coffs=0; // comment offset if (pl->type==TYP_COMMENT) { font_type = SMALL; font_size = FSIZE_SMALL; if (pl->underline==1) { coffs=clh; } } RenderString(dstr, scale2res(48), 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(">", scale2res(30), my+soffs-(dy-FSIZE_MED)/2+OFFSET_MIN, scale2res(65), LEFT, MED, (((loop%MAX_FUNCS) == (tind%MAX_FUNCS)) && (sbar) && (!nosel))?CMCST:CMCT); } if(pl->underline) { int cloffs=0,ccenter=0; if(pl->type==TYP_COMMENT) { if(strlen(dstr)==0) { cloffs=dy/2; if(pl->underline==2) { dy/=2; // FIXME: these substraction causes space at bottom of painted box cloffs+=dy/2; } } else { if(pl->underline==2) { cloffs=dy/2; ccenter=1; } } } else { if(pl->underline==2) { dy+=dy/2; // FIXME: these addition causes text outside painted box cloffs=-dy/4; } } RenderBox(xoffs, my+soffs-cloffs-clh, ixw-xoffs-sbw, my+soffs-cloffs, 0, COL_MENUCONTENT_PLUS_3); 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+3*OFFSET_SMALL, my+soffs, FILL, CMC); RenderString(dstr, xoffs, my+soffs-(dy-FSIZE_MED)/2, ixw-sbw, CENTER, MED, CMCIT); } } if((pl->type!=TYP_COMMENT) && ((pl->type!=TYP_INACTIVE) || (pl->showalways==2))) { icon_w = icon_h = 0; png_getsize(ICON_BUTTON_RED, &icon_w, &icon_h); direct[dloop++]=(pl->type!=TYP_INACTIVE)?loop:-1; switch(dloop) { case 1: paintIcon(ICON_BUTTON_RED, ioffs-icon_w/2, my+soffs-(dy+icon_h)/2, 0, 0, &iw, &ih); break; case 2: paintIcon(ICON_BUTTON_GREEN, ioffs-icon_w/2, my+soffs-(dy+icon_h)/2, 0, 0, &iw, &ih); break; case 3: paintIcon(ICON_BUTTON_YELLOW, ioffs-icon_w/2, my+soffs-(dy+icon_h)/2, 0, 0, &iw, &ih); break; case 4: paintIcon(ICON_BUTTON_BLUE, ioffs-icon_w/2, my+soffs-(dy+icon_h)/2, 0, 0, &iw, &ih); break; default: if(dloop<15) { sprintf(tstr,"%1d",(dloop-4)%10); 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; } } my += dy; } dy=ldy; for(; dloop<MAX_FUNCS; dloop++) { direct[dloop]=-1; } //copy backbuffer to framebuffer #ifdef MARTII blit(); #else memcpy(lfb, lbb, var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t)); #endif if(m->num_active && knew) { if(m->list[m->act_entry]->entry) { sprintf(trstr,"%s%s",(m->list[m->act_entry]->type<=TYP_MENUSOFF)?"> ":"",m->list[m->act_entry]->entry); if((lcptr=strxchr(trstr,','))!=NULL) { *lcptr=0; } } else { sprintf(trstr,"Kein Eintrag"); } if(vfd) { lcstr=strdup(trstr); clean_string(trstr,lcstr); sprintf(tstr,"%s -t\"%s\"",VFD,lcstr); system(tstr); free(lcstr); } } startx=oldx; starty=oldy; }
int show_txt(int buttonly) { FILE *tfh; 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); return 0; } yo=(header)?80:35; if(!buttonly) { memcpy(lbb, ibb, var_screeninfo.xres*var_screeninfo.yres); } if((tfh=fopen(TMP_FILE,"r"))!=NULL) { fclose(tfh); if(!buttonly) { if(type!=1) { btns=0; myo=0; } RenderString("X", 310, 270, 20, LEFT, BIG, TRANSP); pxw=GetStringLen(sx,title)+10; if(type==1) { RenderString("X", 310, 270, 20, LEFT, MED, TRANSP); myo=blines*(butty+buttdy); for(i=0; i<btns; i++) { itmp=GetStringLen(sx,butmsg[i])+10; if(itmp>buttx) { buttx=itmp; } } } buttsize=buttx; RenderString("X", 310, 270, 20, LEFT, size, TRANSP); if(fh_txt_getsize(TMP_FILE, &x1, &y1, &cut)) { printf("msgbox <invalid Text-Format>\n"); return -1; } x1+=10; dy=0.8*(double)size; if(pxw<x1) { pxw=x1; } if(pxw<(lbtns*buttx+lbtns*buttdx)) { pxw=(lbtns*buttx+lbtns*buttdx); } if(pxw>((ex-sx)-2*buttdx)) { pxw=ex-sx-2*buttdx; } psx=((ex-sx)/2-pxw/2); pyw=y1*dy/*-myo*/; if(pyw>((ey-sy)-yo-myo)) { pyw=((ey-sy)-yo-myo); } psy=/*sy+*/((ey-sy)/2-(pyw+myo-yo)/2); if(btns) { buttxstart=psx+pxw/2-(((double)lbtns*(double)buttsize+(((lbtns>2)&&(lbtns&1))?((double)buttdx):0.0))/2.0); // buttystart=psy+pyw/2-(((double)blines*(double)butty+(((blines>2)&&(blines&1))?((double)buttdy):0.0))/2.0); buttystart=psy+y1*dy; } } while(run) { //frame layout if(action) { if(!buttonly) { RenderBox(psx-20, psy-yo, psx+pxw+20, psy+pyw+myo, radius, CMH); RenderBox(psx-20+2, psy-yo+2, psx+pxw+20-2, psy+pyw+myo-2, radius, CMC); if(header) { RenderBox(psx-18, psy-yo+2, psx+pxw+18, psy-yo+44, radius, CMH); RenderString(title, psx, psy-yo+36, pxw, CENTER, BIG, CMHT); } } if(buttonly || !(rv=fh_txt_load(TMP_FILE, psx, pxw, psy, dy, size, line, &cut))) { if(type==1) { for(i=0; i<btns; i++) { 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); RenderString(butmsg[i], buttxstart+bx*(buttsize+buttdx/2), buttystart+by*(butty+buttdy/2)+butty-7, buttsize, CENTER, MED, (i==(selection-1))?CMCST:CMCIT); } // RenderBox((ex-sx)/2-buttx/2, psy+pyw+myo/2-butty/2, (ex-sx)/2+buttx/2, psy+pyw+myo/2+butty/2, FILL, CMCS); // RenderBox((ex-sx)/2-buttx/2, psy+pyw+myo/2-butty/2, (ex-sx)/2+buttx/2, psy+pyw+myo/2+butty/2, GRID, YELLOW); // RenderString("OK", (ex-sx)/2-buttx/2, psy+pyw+myo/2+butty/2-7, buttx, CENTER, MED, CMCST); } memcpy(lfb, lbb, var_screeninfo.xres*var_screeninfo.yres); } } run=0; } } return (rv)?-1:0; }
int show_txt(int buttonly) { FILE *tfh; char const *fname=NULL; int yo=scale2res(80), buttx=scale2res(80), butty=scale2res(30), buttdx=scale2res(20), buttdy=scale2res(10); 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) { #if HAVE_SPARK_HARDWARE || HAVE_DUCKBOX_HARDWARE memcpy(lbb, hbb, var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t)); blit(); #else memcpy(lfb, hbb, var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t)); #endif 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; } 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((tfh=fopen(TMP_FILE,"r"))!=NULL) { fclose(tfh); int fsizebut = scale2res(26); if(!buttonly) { if(type!=1) { btns=0; myo=0; } pxw=GetStringLen(sx,title,FSIZE_BIG)+OFFSET_MED; if(type==1) { myo=blines*(butty+buttdy); for(i=0; i<btns; i++) { itmp=GetStringLen(sx,butmsg[i],fsizebut)+OFFSET_MED; if(itmp>buttx) { buttx=itmp; } } } buttsize=buttx; if(fh_txt_getsize(TMP_FILE, &x1, &y1, size, &cut)) { printf(__plugin__ " <invalid Text-Format>\n"); return -1; } x1+=OFFSET_MED; dy=size; if(pxw<x1) { pxw=x1; } if(pxw<(lbtns*buttx+lbtns*buttdx)) { pxw=(lbtns*buttx+lbtns*buttdx); } if(pxw>((ex-sx)-2*buttdx)) { pxw=ex-sx-2*buttdx; } psx=((ex-sx)/2-pxw/2); pyw=y1*dy/*-myo*/; if(pyw>((ey-sy)-yo-myo)) { pyw=((ey-sy)-yo-myo); } psy=((ey-sy)/2-(pyw+myo-yo)/2); if(btns) { buttxstart=psx+pxw/2-(((double)lbtns*(double)buttsize+(((lbtns>2)&&(lbtns&1))?((double)buttdx):0.0))/2.0); buttystart=psy+y1*dy+2*OFFSET_MED; } } while(run) { //frame layout if(action) { if(!buttonly) { int iw, ih, pxoffs = 0; int slen = GetStringLen(sx, title, FSIZE_BIG)+2*OFFSET_MED; if (icon_w > 0 && (psx+pxw-2*OFFSET_MED-slen <= psx-OFFSET_MED+icon_w+OFFSET_MED)) pxoffs = (icon_w)/2; RenderBox(psx-2*OFFSET_MED-pxoffs+OFFSET_SMALL, psy-yo-h_head/3-OFFSET_SMALL, psx+pxw+pxoffs+2*OFFSET_MED+OFFSET_SMALL, psy+pyw+myo+(h_head/3)+OFFSET_MED+OFFSET_SMALL, radius, COL_SHADOW_PLUS_0); RenderBox(psx-2*OFFSET_MED-pxoffs, psy-yo-h_head/3-OFFSET_MED, psx+pxw+pxoffs+2*OFFSET_MED, psy+pyw+myo+(h_head/3)+OFFSET_MED, radius, CMC); if(header) { int pyoffs=(icon_h < h_head)?1:0; RenderBox(psx-2*OFFSET_MED-pxoffs, psy-yo-h_head/3-OFFSET_MED, psx+pxw+pxoffs+2*OFFSET_MED, psy-yo+(h_head*2)/3-OFFSET_MED, radius, CMH); paintIcon(fname, psx-OFFSET_MED-pxoffs, psy-yo-h_head/3+h_head/2-icon_h/2+pyoffs-OFFSET_MED, xsize, ysize, &iw, &ih); RenderString(title, psx+pxoffs, psy-moffs-OFFSET_MED, pxw, CENTER, FSIZE_BIG, CMHT); } } if(buttonly || !(rv=fh_txt_load(TMP_FILE, psx, pxw, psy+size, dy, size, line, &cut))) { if(type==1) { for(i=0; i<btns; i++) { bx=i%lbtns; by=i/lbtns; RenderBox(buttxstart+bx*(buttsize+buttdx/2)+OFFSET_SMALL/2, buttystart+by*(butty+buttdy/2)+OFFSET_SMALL/2, buttxstart+(bx+1)*buttsize+bx*(buttdx/2)+OFFSET_SMALL/2, buttystart+by*(butty+buttdy/2)+butty+OFFSET_SMALL/2, 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, fsizebut, (i==(selection-1))?CMCST:CMCIT); } } #if HAVE_SPARK_HARDWARE || HAVE_DUCKBOX_HARDWARE blit(); #else memcpy(lfb, lbb, var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t)); #endif } } run=0; } } return (rv)?-1:0; }
void BatchSetText(uint16 control_id,uchar *strings) { TX_16(control_id); TX_16(GetStringLen(strings)); SendStrings(strings); }
char *inputd(char *form, char *title, char *defstr, int keys, int frame, int mask, int bhelp, int cols, int tmo, int debounce) { int exs,eys,wxs,wxw,wys,wyw,i,j,xp,yp; char trnd[2]={0,0},tch; int act_key=-1, last_key=-1, b_key=-1, run=1, ipos=0; time_t t1,t2,tm1; char knum[12][2]={"1","2","3","4","5","6","7","8","9"," ","0"}; char kalp[12][5]={"+-*/","abcä","def","ghi","jkl","mnoö","pqrs","tuvü","wxyz","","_,.;"}; epos=-1; cpos=0; kpos=0; first=1; time(&tm1); if(cols>25) { cols=25; } if(cols<1) { cols=1; } format=form; estr=strdup(form); cnt=strlen(form); RenderString("X", 310, 250, 20, LEFT, BIG, CMC); i=GetStringLen(title)+10; j=((cnt>cols)?cols:cnt)*exsz; if(j>i) { i=j; } if(keys) { j=3*bxsz; if(j>i) { i=j; } } wxw=i+2*xbrd; i=(((cnt-1)/cols)+1)*eysz; if(keys) { i+=4*bysz; } wyw=((keys)?4:2)*ybrd+i; wxs=((ex-sx)-wxw)/2; wys=(((ey-sy)-wyw)+hsz)/2; exs=wxs+(wxw-((cnt>cols)?cols:cnt)*exsz)/2; eys=wys+ybrd; *estr=0; *rstr=0; j=0; for(i=0; i<strlen(format); i++) { tch=format[i]; if(IsInput(tch)) { if(epos==-1) { epos=i; } if(defstr && j<strlen(defstr)) { estr[i]=defstr[j++]; } else { estr[i]=' '; } } else { estr[i]=format[i]; } } estr[i]=0; RenderBox(wxs-2, wys-hsz-2, wxs+wxw+2, wys+wyw+2, radius, CMH); RenderBox(wxs, wys-hsz, wxs+wxw, wys+wyw, radius, CMC); RenderBox(wxs, wys-hsz, wxs+wxw, wys, radius, CMH); RenderString(title, wxs, wys-15, wxw, CENTER, BIG, CMHT); if(keys) { int bxs=wxs+(wxw-(3*bxsz))/2; int bys=((wys+wyw)-2*ybrd)-4*bysz; for(i=0; i<11; i++) { if(i!=9) { RenderBox(bxs+(i%3)*bxsz, bys+(i/3)*bysz, bxs+((i%3)+1)*bxsz, bys+((i/3)+1)*bysz, radius, COL_MENUCONTENT_PLUS_4); RenderBox(bxs+(i%3)*bxsz+2, bys+(i/3)*bysz+2, bxs+((i%3)+1)*bxsz-2, bys+((i/3)+1)*bysz-2, radius, CMC); RenderString(knum[i], bxs+(i%3)*bxsz, bys+(i/3)*bysz+bysz/2, bxsz, CENTER, MED, CMCIT); RenderString(kalp[i], bxs+(i%3)*bxsz, bys+(i/3)*bysz+bysz-8, bxsz, CENTER, SMALL, CMCIT); } } RenderCircle(bxs,wys+wyw-ybrd-8,'R'); RenderString("Groß/Klein",bxs+15,wys+wyw-ybrd+5,3*bxsz,LEFT,SMALL,CMCIT); RenderCircle(bxs+3*bxsz-GetStringLen("löschen")-15,wys+wyw-ybrd-8,'Y'); RenderString("löschen",bxs,wys+wyw-ybrd+5,3*bxsz,RIGHT,SMALL,CMCIT); } while(run) { for(i=0; i<cnt; i++) { xp=i%cols; yp=i/cols; if(frame && IsInput(format[i])) { RenderBox(exs+xp*exsz, eys+5+yp*eysz, exs+(xp+1)*exsz, eys+(yp+1)*eysz, radius, COL_MENUCONTENT_PLUS_4); } RenderBox(exs+xp*exsz+1, eys+5+yp*eysz+1, exs+(xp+1)*exsz-1, eys+(yp+1)*eysz-1, radius, (epos==i)?CMCS:CMC); *trnd=(mask && format[i]==NUM && IsNum(estr[i]))?'*':estr[i]; RenderString(trnd, exs+xp*exsz+2, eys+yp*eysz+tys, exsz-2, CENTER, MED, (epos==i)?CMCST:(IsInput(format[i]))?CMCT:CMCIT); } memcpy(lfb, lbb, var_screeninfo.xres*var_screeninfo.yres); time(&t1); i=-1; while(i==-1) { i=GetRCCode(); if(i!=-1) { tmo=0; if(i==b_key) { usleep(debounce*1000); while((i=GetRCCode())!=-1); } b_key=i; } time(&t2); if(tmo) { if((t2-tm1)>=tmo) { i=RC_HOME; } } if((((format[epos]!=NUM) && (format[epos]!=HEX)) || ((format[epos]==HEX)&&(strlen(hcod[cpos])>1))) && ((t2-t1)>ndelay) && last_key>=0) { act_key=i=-2; b_key=-3; NextPos(); } } act_key=i; switch(act_key) { case RC_0: SetCode(0); break; case RC_1: SetCode(1); break; case RC_2: SetCode(2); break; case RC_3: SetCode(3); break; case RC_4: SetCode(4); break; case RC_5: SetCode(5); break; case RC_6: SetCode(6); break; case RC_7: SetCode(7); break; case RC_8: SetCode(8); break; case RC_9: SetCode(9); break; case RC_RIGHT: NextPos(); act_key=-2; break; case RC_LEFT: PrevPos(); act_key=-2; break; case RC_PLUS: ipos=epos; while(IsInput(format[ipos+1]) && ((ipos+1)<cnt)) { ++ipos; } while(ipos>epos) { estr[ipos]=estr[ipos-1]; --ipos; } estr[epos]=' '; act_key=-1; break; case RC_MINUS: ipos=epos+1; while(IsInput(format[ipos]) && (ipos<cnt)) { estr[ipos-1]=estr[ipos]; ++ipos; } estr[ipos-1]=' '; act_key=-1; break; case RC_OK: run=0; break; case RC_MUTE: memset(lfb, TRANSP, 720*576); usleep(500000L); while(GetRCCode()!=-1) { usleep(100000L); } while(GetRCCode()!=RC_MUTE) { usleep(500000L); } while((act_key=GetRCCode())!=-1) { usleep(100000L); } break; case RC_UP: if(epos>=cols) { epos-=cols; if(!IsInput(format[epos])) { NextPos(); } } else { epos=cnt-1; if(!IsInput(format[epos])) { PrevPos(); } } act_key=-2; break; case RC_DOWN: if(epos<=(cnt-cols)) { epos+=cols; if(!IsInput(format[epos])) { NextPos(); } } else { epos=0; if(!IsInput(format[epos])) { NextPos(); } } act_key=-2; break; case RC_HOME: free(estr); estr=NULL; *rstr=0; run=0; break; case RC_RED: if(IsAlpha(estr[epos])) { estr[epos]^=0x20; } act_key=-2; break; case RC_YELLOW: epos=-1; for(i=0; i<strlen(format); i++) { if(IsInput(format[i])) { if(epos==-1) { epos=i; } estr[i]=' '; } } act_key=-2; break; case RC_HELP: if(bhelp) { sprintf(estr,"?"); run=0; } break; default: act_key=-2; break; } last_key=act_key; } if(estr) { j=0; for(i=0; i<strlen(format); i++) { if(IsInput(format[i])) { rstr[j++]=estr[i]; } } rstr[j]=0; free(estr); } ReTransform_Msg(rstr); return tstr; }
/****************************************************************************** * RenderString ******************************************************************************/ int RenderString(char *string, int _sx, int _sy, int maxwidth, int layout, int size, int color) { int stringlen = 0, _ex = 0, charwidth = 0,found = 0; unsigned int i = 0; char rstr[BUFSIZE]={0}, *rptr=rstr, rc=' '; int varcolor=color; //set size snprintf(rstr,sizeof(rstr),"%s",string); desc.width = desc.height = size; TABULATOR=3*size; //set alignment stringlen = GetStringLen(_sx, rstr, size); if(layout != LEFT) { switch(layout) { case CENTER: if(stringlen < maxwidth) _sx += (maxwidth - stringlen)/2; break; case RIGHT: if(stringlen < maxwidth) _sx += maxwidth - stringlen; } } //reset kerning prev_glyphindex = 0; //render string _ex = _sx + maxwidth; while(*rptr != '\0') { if(*rptr=='~') { ++rptr; rc=*rptr; found=0; for(i=0; i< sizeof(sc)/sizeof(sc[0]) && !found; i++) { if(rc==sc[i]) { rc=tc[i]; found=1; } } if(found) { if((charwidth = RenderChar(rc, _sx, _sy, _ex, varcolor)) == -1) return _sx; /* string > maxwidth */ _sx += charwidth; } else { switch(*rptr) { case 'R': varcolor=RED; break; case 'G': varcolor=GREEN; break; case 'Y': varcolor=YELLOW; break; case 'B': varcolor=BLUE1; break; case 'S': varcolor=color; break; case 't': _sx=TABULATOR*((int)(_sx/TABULATOR)+1); break; case 'T': if(sscanf(rptr+1,"%4d",&i)==1) { rptr+=4; _sx=i; } break; } } } else { int uml = 0; switch(*rptr) /* skip Umlauts */ { case '\xc4': case '\xd6': case '\xdc': case '\xe4': case '\xf6': case '\xfc': case '\xdf': uml=1; break; } if (uml == 0) { // UTF8_to_Latin1 encoding if (((*rptr) & 0xf0) == 0xf0) /* skip (can't be encoded in Latin1) */ { rptr++; if ((*rptr) == 0) *rptr='\x3f'; // ? question mark rptr++; if ((*rptr) == 0) *rptr='\x3f'; rptr++; if ((*rptr) == 0) *rptr='\x3f'; } else if (((*rptr) & 0xe0) == 0xe0) /* skip (can't be encoded in Latin1) */ { rptr++; if ((*rptr) == 0) *rptr='\x3f'; rptr++; if ((*rptr) == 0) *rptr='\x3f'; } else if (((*rptr) & 0xc0) == 0xc0) { char c = (((*rptr) & 3) << 6); rptr++; if ((*rptr) == 0) *rptr='\x3f'; *rptr = (c | ((*rptr) & 0x3f)); } } if((charwidth = RenderChar(*rptr, _sx, _sy, _ex, varcolor)) == -1) return _sx; /* string > maxwidth */ _sx += charwidth; } rptr++; } return stringlen; }