static int AnchorD_CorrectionChanged(GGadget *g, GEvent *e) { AnchorDlg *a = GDrawGetUserData(GGadgetGetWindow(g)); if ( e->type==et_controlevent && e->u.control.subtype == et_textchanged ) { const unichar_t *ret = _GGadgetGetTitle(g); int is_y = GGadgetGetCid(g)==CID_YCor; unichar_t *end; int correction = u_strtol(ret,&end,10); while ( *end==' ' ) ++end; if ( *end!='\0' ) return( true ); if ( correction<-128 || correction>127 ) { ff_post_error( _("Out of Range"), _("Corrections must be between -128 and 127 (and should be smaller)") ); return( true ); } DeviceTableSet(is_y?&a->yadjust:&a->xadjust,a->pixelsize,correction); GDrawRequestExpose(a->gw,NULL,false); } return( true ); }
static int AnchorD_PositionChanged(GGadget *g, GEvent *e) { AnchorDlg *a = GDrawGetUserData(GGadgetGetWindow(g)); if ( e->type==et_controlevent && e->u.control.subtype == et_textchanged ) { const unichar_t *ret = _GGadgetGetTitle(g); int is_y = GGadgetGetCid(g)==CID_Y; unichar_t *end; int val = u_strtol(ret,&end,10); while ( *end==' ' ) ++end; if ( *end!='\0' ) return( true ); if ( (is_y && a->apos.y==val) || (!is_y && a->apos.x==val)) return( true ); if ( is_y ) a->apos.y = val; else a->apos.x = val; AnchorD_ClearCorrections(a); GDrawRequestExpose(a->gw,NULL,false); } return( true ); }
static int AnchorD_DisplaySizeChanged(GGadget *g, GEvent *e) { AnchorDlg *a = GDrawGetUserData(GGadgetGetWindow(g)); if ( e->type==et_controlevent && e->u.control.subtype == et_textchanged ) { const unichar_t *ret = _GGadgetGetTitle(GWidgetGetControl(a->gw,CID_DisplaySize)); unichar_t *end; int pixelsize = u_strtol(ret,&end,10); while ( *end==' ' ) ++end; if ( pixelsize>4 && pixelsize<400 && *end=='\0' ) { unichar_t ubuf[20]; char buffer[20]; ubuf[0] = '0'; ubuf[1] = '\0'; if ( a->xadjust.corrections!=NULL && pixelsize>=a->xadjust.first_pixel_size && pixelsize<=a->xadjust.last_pixel_size ) { sprintf( buffer, "%d", a->xadjust.corrections[ pixelsize-a->xadjust.first_pixel_size]); uc_strcpy(ubuf,buffer); } GGadgetSetTitle(GWidgetGetControl(a->gw,CID_XCor),ubuf); ubuf[0] = '0'; ubuf[1] = '\0'; if ( a->yadjust.corrections!=NULL && pixelsize>=a->yadjust.first_pixel_size && pixelsize<=a->yadjust.last_pixel_size ) { sprintf( buffer, "%d", a->yadjust.corrections[ pixelsize-a->yadjust.first_pixel_size]); uc_strcpy(ubuf,buffer); } GGadgetSetTitle(GWidgetGetControl(a->gw,CID_YCor),ubuf); a->xoff = pixelsize*a->xoff/a->pixelsize; a->pixelsize = aa_pixelsize = pixelsize; AnchorD_ChangeSize(a); GDrawRequestExpose(a->gw,NULL,false); } } return( true ); }
enum charset _GDraw_ParseMapping(unichar_t *setname) { unichar_t *pt; int val; if ( uc_strstrmatch(setname,"iso")!=NULL && uc_strstrmatch(setname,"10646")!=NULL ) return( em_unicode ); else if ( uc_strstrmatch(setname,"UnicodePlane")!=NULL ) { pt = u_strchr(setname,'-'); if ( pt==NULL ) return( em_uplane0+1 ); return( em_uplane0+u_strtol(pt+1,NULL,10) ); } else if ( uc_strstrmatch(setname,"unicode")!=NULL ) return( em_unicode ); #if 0 if ( uc_strstrmatch(setname,"ascii")!=NULL || ( uc_strstrmatch(setname,"iso")!=NULL && uc_strstrmatch(setname,"646")!=NULL )) { char *lang = getenv( "LANG" ); if ( lang==NULL || *lang=='\0' || (*lang=='e' && *lang=='n' )) return( em_iso8859_1 ); /* ascii can masquarade as iso8859-1 for english speakers (no accents needed) */ } #endif if ( uc_strstrmatch(setname,"iso")!=NULL && uc_strstrmatch(setname,"8859")!=NULL ) { pt = uc_strstrmatch(setname,"8859"); pt += 4; if ( *pt=='-' ) ++pt; if ( !isdigit(*pt) ) /* Bad */; else if ( !isdigit(pt[1]) ) return( em_iso8859_1+*pt-'1' ); else { val = (pt[0]-'0')*10 + pt[1]-'0'; switch ( val ) { case 10: case 11: return( em_iso8859_10+val-10 ); case 13: case 14: case 15: return( em_iso8859_13+val-13 ); } } } if ( uc_strstrmatch(setname,"latin1")!=NULL ) return( em_iso8859_1 ); else if ( uc_strstrmatch(setname,"latin2")!=NULL ) return( em_iso8859_2 ); else if ( uc_strstrmatch(setname,"latin3")!=NULL ) return( em_iso8859_3 ); else if ( uc_strstrmatch(setname,"latin4")!=NULL ) return( em_iso8859_4 ); else if ( uc_strstrmatch(setname,"latin5")!=NULL ) return( em_iso8859_9 ); else if ( uc_strstrmatch(setname,"latin6")!=NULL ) return( em_iso8859_10 ); else if ( uc_strstrmatch(setname,"latin7")!=NULL ) return( em_iso8859_13 ); else if ( uc_strstrmatch(setname,"latin8")!=NULL ) return( em_iso8859_14 ); else if ( uc_strstrmatch(setname,"latin0")!=NULL || uc_strstrmatch(setname,"latin9")!=NULL ) return( em_iso8859_15 ); if ( uc_strstrmatch(setname,"koi8")!=NULL ) return( em_koi8_r ); if ( uc_strstrmatch(setname,"cyrillic")!=NULL ) return( em_iso8859_5 ); /* This is grasping at straws */ else if ( uc_strstrmatch(setname,"greek")!=NULL ) return( em_iso8859_7 ); /* This is grasping at straws */ else if ( uc_strstrmatch(setname,"arabic")!=NULL ) return( em_iso8859_6 ); /* This is grasping at straws */ else if ( uc_strstrmatch(setname,"hebrew")!=NULL ) return( em_iso8859_8 ); /* This is grasping at straws */ else if ( uc_strstrmatch(setname,"thai")!=NULL || uc_strstrmatch(setname,"tis")!=NULL ) return( em_iso8859_11 ); if ( uc_strstrmatch(setname,"jis")!=NULL ) { if ( uc_strstrmatch(setname,"201")!=NULL ) return( em_jis201 ); if ( uc_strstrmatch(setname,"208")!=NULL ) return( em_jis208 ); if ( uc_strstrmatch(setname,"212")!=NULL ) return( em_jis212 ); if ( uc_strstrmatch(setname,"213")!=NULL ) /* I don't support 213 */ return( em_none ); return( em_jis208 ); } if ( uc_strstrmatch(setname,"ksc")!=NULL && uc_strstrmatch(setname,"5601")!=NULL ) return( em_ksc5601 ); /* Seem to be several versions of 5601, we want 94x94 */ if ( uc_strstrmatch(setname,"gb")!=NULL && uc_strstrmatch(setname,"2312")!=NULL ) return( em_gb2312 ); if ( uc_strstrmatch(setname,"big5")!=NULL ) return( em_big5 ); if ( uc_strstrmatch(setname,"mac")!=NULL ) return( em_mac ); if ( uc_strstrmatch(setname,"win")!=NULL ) return( em_win ); if ( IsUserMap(setname)) return( em_user ); /* !!! Encodings used for postscript japanese fonts, which I don't understand */ #if 0 if ( uc_strstrmatch(setname,"RJSJ")!=NULL ) return( em_sjis ); if ( uc_strstrmatch(setname,"EUC")!=NULL ) return( em_euc ); #endif return( em_none ); }
static void AnchorD_Expose(AnchorDlg *a,GWindow pixmap,GEvent *event) { GRect *area = &event->u.expose.rect; GRect clip, old1, old2; int expose_end = area->x+area->width; int factor = a->magfactor; int i,x,y; if ( expose_end<a->ctl_len ) return; GDrawPushClip(pixmap,area,&old1); if ( area->x<a->ctl_len+a->char_size*factor ) { GDrawDrawLine(pixmap,a->ctl_len,0,a->ctl_len,a->full_height,0x000000); KCD_DrawGlyph(pixmap,a->char_off*factor+a->ctl_len,a->baseline,a->bdfc,factor); DrawAnchorPoint(pixmap, a->char_off*factor+a->ctl_len + ((int) rint(a->apos.x*a->scale))*factor, a->baseline - ((int) rint(a->apos.y*a->scale))*factor, false); GDrawDrawLine(pixmap,a->ctl_len+a->char_size*factor,0,a->ctl_len+a->char_size*factor,a->full_height,0x000000); } if ( expose_end>a->ctl_len+a->char_size && area->y<a->sb_base ) { int xcor=0, ycor=0; unichar_t *end; const unichar_t *ret; ret = _GGadgetGetTitle(GWidgetGetControl(a->gw,CID_XCor)); xcor = u_strtol(ret,&end,10); while ( *end==' ' ) ++end; if ( *end!='\0' || xcor<-128 || xcor>127 ) xcor = 0; ret = _GGadgetGetTitle(GWidgetGetControl(a->gw,CID_YCor)); ycor = u_strtol(ret,&end,10); while ( *end==' ' ) ++end; if ( *end!='\0' || ycor<-128 || ycor>127 ) ycor = 0; clip = *area; if ( area->x<=a->ctl_len+a->char_size ) { clip.width -= a->ctl_len+a->char_size+1 - area->x; clip.x = a->ctl_len+a->char_size+1; } if ( area->y+area->height > a->sb_base ) clip.height = a->sb_base-area->y; GDrawPushClip(pixmap,&clip,&old2); for ( i=0; i<a->cnt; ++i ) { if ( a->apmatch[i].xstart - a->xoff > clip.x+clip.width ) break; if ( a->apmatch[i].xstart+a->apmatch[i].size*factor - a->xoff < clip.x ) continue; y = a->baseline; if ( i!=0 ) GDrawDrawLine(pixmap,a->apmatch[i].xstart-a->xoff,0, a->apmatch[i].xstart-a->xoff,a->sb_base,0x808080); if ( a->ap->type==at_cexit || a->ap->type==at_basechar || a->ap->type==at_baselig || a->ap->type==at_basemark ) { x = a->apmatch[i].xstart+a->char_off*factor - a->xoff; KCD_DrawGlyph(pixmap,x,y,a->bdfc,factor); x += ((int) rint((-a->apmatch[i].ap->me.x + a->apos.x)*a->scale) + xcor - DevTabFind(&a->apmatch[i].ap->xadjust,a->pixelsize))*factor; y += ((int) rint((a->apmatch[i].ap->me.y - a->apos.y)*a->scale) + -ycor + DevTabFind(&a->apmatch[i].ap->yadjust,a->pixelsize))*factor; KCD_DrawGlyph(pixmap,x,y,a->apmatch[i].bdfc,factor); } else { x = a->apmatch[i].xstart+a->apmatch[i].off*factor - a->xoff; KCD_DrawGlyph(pixmap,x,y,a->apmatch[i].bdfc,factor); x += ((int) rint((a->apmatch[i].ap->me.x - a->apos.x)*a->scale) + DevTabFind(&a->apmatch[i].ap->xadjust,a->pixelsize)-xcor)*factor; y += ((int) rint((-a->apmatch[i].ap->me.y + a->apos.y)*a->scale) + -DevTabFind(&a->apmatch[i].ap->yadjust,a->pixelsize)+ycor)*factor; KCD_DrawGlyph(pixmap,x,y,a->bdfc,factor); } } if ( i>0 ) GDrawDrawLine(pixmap,a->apmatch[i-1].xstart+a->apmatch[i-1].size*factor-a->xoff,0, a->apmatch[i-1].xstart+a->apmatch[i-1].size*factor-a->xoff,a->sb_base,0x808080); GDrawPopClip(pixmap,&old2); } GDrawPopClip(pixmap,&old1); }