/* image base (x,y) and pass in the exposed rectangle */ void GDrawDrawImageMagnified(GWindow w, GImage *img, GRect *dest, int32 x, int32 y, int32 width, int32 height) { GRect temp; struct _GImage *base = img->list_len==0?img->u.image:img->u.images[0]; if ( base->width==width && base->height==height ) { /* Not magnified after all */ if ( dest==NULL ) GDrawDrawImage(w,img,NULL,x,y); else { int old; temp = *dest; temp.x += x; temp.y += y; if ( temp.x<x ) { temp.x = 0; temp.width-=x; } else { old = x; x = temp.x; temp.x -= old; temp.width -= old; } if ( temp.y<y ) { temp.y = 0; temp.height-=y; } else { old = y; y = temp.y; temp.y -= old; temp.height -= old; } if ( temp.x>=base->width || temp.y>=base->height || temp.width<=0 || temp.height<=0 ) return; if ( temp.x+temp.width>=base->width ) temp.width = base->width-temp.x; if ( temp.y+temp.height>=base->height ) temp.height = base->height-temp.y; GDrawDrawImage(w,img,&temp,x,y); } return; } if ( dest==NULL ) { temp.x = temp.y = 0; temp.width = width; temp.height = height; dest = &temp; } else if ( dest->x<0 || dest->y<0 || dest->x+dest->width > width || dest->y+dest->height > height ) { temp = *dest; if ( temp.x<0 ) { temp.width += temp.x; temp.x = 0; } if ( temp.y<0 ) { temp.height += temp.y; temp.y = 0; } if ( temp.x+temp.width>width ) temp.width = width-temp.x; if ( temp.y+temp.height>height ) temp.height = height-temp.y; dest = &temp; } (w->display->funcs->drawImageMag)(w,img,dest,x,y, width, height); }
static int wheel_e_h(GWindow gw, GEvent *event) { struct gcol_data *d = GDrawGetUserData(gw); GRect size; if ( event->type==et_expose ) { GRect circle; GDrawGetSize(d->wheelw,&size); if ( d->wheel==NULL || GImageGetHeight(d->wheel)!=size.height || GImageGetWidth(d->wheel)!=size.width ) { if ( d->wheel!=NULL ) GImageDestroy(d->wheel); d->wheel = ColorWheel(size.width,size.height); } GDrawDrawImage(gw,d->wheel,NULL,0,0); if ( d->col.hsv ) { double s = sin(d->col.h*3.1415926535897932/180.); double c = cos(d->col.h*3.1415926535897932/180.); int y = (int) rint(d->col.s*(size.height-1)*s/2.0) + size.height/2; int x = (int) rint(d->col.s*(size.width-1)*c/2.0) + size.width/2; circle.x = x-3; circle.y = y-3; circle.width = circle.height = 7; GDrawDrawElipse(gw,&circle,0x000000); } } else if ( event->type == et_mousedown || (event->type==et_mousemove && d->pressed) || event->type==et_mouseup ) { Color rgb; struct hslrgba temp; GDrawGetSize(d->wheelw,&size); if ( event->u.mouse.y>=0 && event->u.mouse.y<size.height && event->u.mouse.x>=0 && event->u.mouse.x<size.width ) { rgb = GImageGetPixelRGBA(d->wheel,event->u.mouse.x,event->u.mouse.y); temp.r = ((rgb>>16)&0xff)/255.; temp.g = ((rgb>>8)&0xff)/255.; temp.b = ((rgb )&0xff)/255.; gRGB2HSV((struct hslrgb *) &temp); d->col.h = temp.h; d->col.s = temp.s; GCol_ShowTexts(d); GDrawRequestExpose(d->colw,NULL,false); GDrawRequestExpose(d->wheelw,NULL,false); }
static int splash_e_h(GWindow gw, GEvent *event) { static int splash_cnt; GRect old; int i, y, x; static char *foolishness[] = { /* GT: These strings are for fun. If they are offensive or incomprehensible */ /* GT: simply translate them as something dull like: "FontForge" */ /* GT: This is a spoof of political slogans, designed to point out how foolish they are */ N_("A free press discriminates\nagainst the illiterate."), N_("A free press discriminates\nagainst the illiterate."), /* GT: This is a pun on the old latin drinking song "Gaudeamus igature!" */ N_("Gaudeamus Ligature!"), N_("Gaudeamus Ligature!"), /* GT: Spoof on the bible */ N_("In the beginning was the letter..."), /* GT: Some wit at MIT came up with this ("ontology recapitulates phylogony" is the original) */ N_("fontology recapitulates file-ogeny") }; switch ( event->type ) { case et_create: GDrawGrabSelection(gw,sn_user1); break; case et_expose: GDrawPushClip(gw,&event->u.expose.rect,&old); GDrawDrawImage(gw,&splashimage,NULL,0,0); GDrawSetFont(gw,splash_font); y = splashimage.u.image->height + as + fh/2; for ( i=1; i<linecnt; ++i ) { if ( is>=lines[i-1]+1 && is<lines[i] ) { x = 8+GDrawDrawText(gw,8,y,lines[i-1]+1,is-lines[i-1]-1,0x000000); GDrawSetFont(gw,splash_italic); GDrawDrawText(gw,x,y,is,lines[i]-is,0x000000); } else if ( ie>=lines[i-1]+1 && ie<lines[i] ) { x = 8+GDrawDrawText(gw,8,y,lines[i-1]+1,ie-lines[i-1]-1,0x000000); GDrawSetFont(gw,splash_font); GDrawDrawText(gw,x,y,ie,lines[i]-ie,0x000000); } else GDrawDrawText(gw,8,y,lines[i-1]+1,lines[i]-lines[i-1]-1,0x000000); y += fh; } GDrawPopClip(gw,&old); break; case et_map: splash_cnt = 0; break; case et_timer: if ( event->u.timer.timer==autosave_timer ) { DoAutoSaves(); } else if ( event->u.timer.timer==splasht ) { if ( ++splash_cnt==1 ) GDrawResize(gw,splashimage.u.image->width,splashimage.u.image->height-30); else if ( splash_cnt==2 ) GDrawResize(gw,splashimage.u.image->width,splashimage.u.image->height); else if ( splash_cnt>=7 ) { GGadgetEndPopup(); GDrawSetVisible(gw,false); GDrawCancelTimer(splasht); splasht = NULL; } } else { DoDelayedEvents(event); } break; case et_char: case et_mousedown: case et_close: GGadgetEndPopup(); GDrawSetVisible(gw,false); break; case et_mousemove: GGadgetPreparePopup8(gw,_(foolishness[rand()%(sizeof(foolishness)/sizeof(foolishness[0]))]) ); break; case et_selclear: /* If this happens, it means someone wants to send us a message with a*/ /* filename to open. So we need to ask for it, process it, and then */ /* take the selection back again */ if ( event->u.selclear.sel == sn_user1 ) { int len; char *arg; arg = GDrawRequestSelection(splashw,sn_user1,"STRING",&len); if ( arg==NULL ) return( true ); if ( strcmp(arg,"-new")==0 || strcmp(arg,"--new")==0 ) FontNew(); else if ( strcmp(arg,"-open")==0 || strcmp(arg,"--open")==0 ) _FVMenuOpen(NULL); else if ( strcmp(arg,"-quit")==0 || strcmp(arg,"--quit")==0 ) MenuExit(NULL,NULL,NULL); else ViewPostScriptFont(arg,0); free(arg); GDrawGrabSelection(splashw,sn_user1); } break; case et_destroy: IError("Who killed the splash screen?"); break; } return( true ); }
static void KP_ExposeKerns(KPData *kpd,GWindow pixmap,GRect *rect) { GRect old, subclip, subold, sel; struct _GImage base; GImage gi; int index1, index2; BDFChar *bdfc1, *bdfc2; int i, as, x, em = kpd->sf->ascent+kpd->sf->descent, yoff; int first, last; struct kerns *kern; char buffer[140]; first = rect->y/kpd->uh; last = (rect->y+rect->height+kpd->uh-1)/kpd->uh; for ( i=first; i<=last && i+kpd->off_top<kpd->kcnt; ++i ) { kern = &kpd->kerns[i+kpd->off_top]; index1 = kern->first->orig_pos; if ( kpd->bdf->glyphs[index1]==NULL ) BDFPieceMeal(kpd->bdf,index1); index2 = kern->second->orig_pos; if ( kpd->bdf->glyphs[index2]==NULL ) BDFPieceMeal(kpd->bdf,index2); } as = kpd->vpad + kpd->sf->ascent * kpd->bdf->pixelsize / em; memset(&gi,'\0',sizeof(gi)); memset(&base,'\0',sizeof(base)); gi.u.image = &base; base.image_type = it_index; base.clut = kpd->bdf->clut; GDrawSetDither(NULL, false); GDrawPushClip(pixmap,rect,&old); GDrawSetFont(pixmap,kpd->font); GDrawSetLineWidth(pixmap,0); GDrawFillRect(pixmap,rect,GDrawGetDefaultBackground(NULL)); subclip = *rect; for ( i=first; i<=last && i+kpd->off_top<kpd->kcnt; ++i ) { subclip.y = i*kpd->uh; subclip.height = kpd->uh; GDrawPushClip(pixmap,&subclip,&subold); kern = &kpd->kerns[i+kpd->off_top]; index1 = kern->first->orig_pos; index2 = kern->second->orig_pos; bdfc1 = kpd->bdf->glyphs[index1]; bdfc2 = kpd->bdf->glyphs[index2]; BaseFillFromBDFC(&base,bdfc1); base.trans = base.clut->trans_index = -1; /* the peculiar behavior concerning xmin/xmax is because the bitmaps */ /* don't contain the side-bearings, we have to add that spacing manually */ if ( !kern->r2l ) { GDrawDrawImage(pixmap,&gi,NULL, 10,subclip.y+as-bdfc1->ymax); x = 10 + (bdfc1->width-bdfc1->xmin) + bdfc2->xmin + (kern->newoff*kpd->bdf->pixelsize/em); } else { x = kpd->vwidth-10-(bdfc1->xmax-bdfc1->xmin); GDrawDrawImage(pixmap,&gi,NULL, x,subclip.y+as-bdfc1->ymax); x -= bdfc1->xmin + (bdfc2->width-bdfc2->xmin) + (kern->newoff*kpd->bdf->pixelsize/em); } BaseFillFromBDFC(&base,bdfc2); #ifndef _BrokenBitmapImages base.trans = base.clut->trans_index = 0; #endif yoff = (kern->newyoff*kpd->bdf->pixelsize/em); GDrawDrawImage(pixmap,&gi,NULL, x,subclip.y+as-bdfc2->ymax-yoff); GDrawDrawLine(pixmap,0,subclip.y+kpd->uh-1, subclip.x+subclip.width,subclip.y+kpd->uh-1,0x000000); if ( kern->kp!=NULL ) sprintf( buffer, "%d ", kern->newoff); else sprintf( buffer, "%d,%d ", kern->newoff, kern->newyoff ); if ( kern->ac!=NULL ) strncat(buffer,kern->ac->name,sizeof(buffer)-strlen(buffer)-1); GDrawDrawBiText8(pixmap,15,subclip.y+kpd->uh-kpd->fh+kpd->as,buffer,-1,NULL, kern->kp!=NULL && kern->newoff!=kern->kp->off ? 0xff0000 : 0x000000 ); if ( i+kpd->off_top==kpd->selected ) { sel.x = 0; sel.width = kpd->vwidth-1; sel.y = subclip.y; sel.height = kpd->uh-2; GDrawDrawRect(pixmap,&sel,0x000000); } GDrawPopClip(pixmap,&subold); } #ifndef _BrokenBitmapImages base.clut->trans_index = -1; #endif GDrawPopClip(pixmap,&old); GDrawSetDither(NULL, true); }