Exemplo n.º 1
0
static void AnchorD_SelectGlyph(AnchorDlg *a, AnchorPoint *ap) {
    int i;
    int32 len;
    GTextInfo **ti = GGadgetGetList(GWidgetGetControl(a->gw,CID_Glyph),&len);

    for ( i=0; i<len; ++i )
	if ( ti[i]->userdata == ap )
    break;
    if ( i!=len )
	GGadgetSelectOneListItem(GWidgetGetControl(a->gw,CID_Glyph),i);
}
Exemplo n.º 2
0
static int Trans_TypeChange(GGadget *g, GEvent *e) {
    if ( e->type==et_controlevent && e->u.control.subtype == et_listselected ) {
	GWindow bw = GGadgetGetWindow(g);
	int offset = GGadgetGetCid(g)-CID_Type;
	int index = GGadgetGetFirstListSelectedItem(g);
	int mask = (intpt) transformtypes[index].userdata;
	int i;

	if ( mask & 0x400 ) {
	    real xoff = last_ruler_offset[0].x, yoff = last_ruler_offset[0].y;
	    char buf[24]; unichar_t ubuf[24];
	    if ( mask & 0x20 )
		index -= 4;	/* skew */
	    else
		index -= 7;	/* move or rotate */
	    GGadgetSelectOneListItem( g,index );
	    mask &= ~0x400;
	    if ( mask&1 ) {		/* Move */
		sprintf( buf, "%.1f", (double) xoff );
		uc_strcpy(ubuf,buf);
		GGadgetSetTitle(GWidgetGetControl(bw,CID_XMove+offset), ubuf );
		sprintf( buf, "%.1f", (double) yoff );
		uc_strcpy(ubuf,buf);
		GGadgetSetTitle(GWidgetGetControl(bw,CID_YMove+offset), ubuf );
	    } else {
		sprintf( buf, "%.0f", atan2(yoff,xoff)*180/3.1415926535897932 );
		uc_strcpy(ubuf,buf);
		GGadgetSetTitle(GWidgetGetControl(bw,((mask&0x2)?CID_Angle:CID_SkewAng)+offset), ubuf );
		GGadgetSetChecked(GWidgetGetControl(bw,CID_Clockwise+offset), false );
		GGadgetSetChecked(GWidgetGetControl(bw,CID_CounterClockwise+offset), true );
	    }
	}

	for ( i=CID_First; i<=CID_Last; ++i ) {
	    GGadget *sg;
	    sg = GWidgetGetControl(bw,i+offset);
	    GGadgetSetVisible(sg, ( ((intpt) GGadgetGetUserData(sg))&mask )?1:0);
	}
	if ( selcid[index]!=0 ) {
	    GGadget *tf = GWidgetGetControl(bw,selcid[index]+offset);
	    GWidgetIndicateFocusGadget(tf);
	    GTextFieldSelect(tf,0,-1);
	}
	GWidgetToDesiredSize(bw);
	GDrawRequestExpose(bw,NULL,false);
    }
return( true );
}
Exemplo n.º 3
0
void Wordlist_MoveByOffset( GGadget* g, int* idx, int offset )
{
    int cidx = *idx;
    if ( cidx!=-1 )
    {
	int32 len;
	GTextInfo **ti = GGadgetGetList(g,&len);
	/* We subtract 3 because: There are two lines saying "load * list" */
	/*  and then a line with a rule on it which we don't want access to */
	if ( cidx+offset >=0 && cidx+offset<len-3 )
	{
	    cidx += offset;
	    *idx = cidx;
	    GGadgetSelectOneListItem( g, cidx );
	    ti = NULL;
	}
	Wordlist_touch( g );
    }
}
Exemplo n.º 4
0
void WordlistLoadToGTextInfo( GGadget* g, int* idx  )
{
    int words_max = 1024*128;
    GTextInfo** words = WordlistLoadFileToGTextInfoBasic( words_max );
    if( !words )
    {
	GGadgetSetTitle8(g,"");
	return;
    }

    if( words[0] )
    {
	GGadgetSetList(g,words,true);
	GGadgetSetTitle8(g,(char *) (words[0]->text));
	*idx = 0;
	GGadgetSelectOneListItem( g, *idx );
	Wordlist_touch( g );
	return;
    }
    return;
}
Exemplo n.º 5
0
static void AnchorD_NextPrev(AnchorDlg *a,int incr) {
    GGadget *g = GWidgetGetControl(a->gw,CID_Glyph);
    int len;
    GTextInfo **ti = GGadgetGetList(g,&len);
    int sel = GGadgetGetFirstListSelectedItem(g);

    for ( sel += incr; sel>0 && sel<len; sel+=incr ) {
	if ( !( ti[sel]->userdata == Add_Mark ||
		ti[sel]->userdata == Add_Base ||
		ti[sel]->line ||
		ti[sel]->disabled ))
    break;
    }
    if ( sel==0 || sel>=len )
	GDrawBeep(NULL);
    else {
	char *name = u2utf8_copy(ti[sel]->text);
	SplineChar *sc = SFGetChar(a->sc->parent,-1,name);

	free(name);
	GGadgetSelectOneListItem(g,sel);
	AnchorD_ChangeGlyph(a,sc,ti[sel]->userdata);
    }
}
Exemplo n.º 6
0
void TransformDlgCreate(void *data,void (*transfunc)(void *,real *,int,BVTFunc *,enum fvtrans_flags),
	int (*getorigin)(void *,BasePoint *,int), enum transdlg_flags flags,
	enum cvtools cvt) {
    GRect pos;
    GWindow gw;
    GWindowAttrs wattrs;
    GGadgetCreateData gcd[12+TCnt*25], boxes[4], *subarray[TCnt*27], *array[2*(TCnt+8)+4], *buttons[13], *origarray[4];
    GTextInfo label[9+TCnt*24];
    static TransData td;
    int i, y, gci, subai, ai;
    int32 len;
    GGadget *orig;
    BasePoint junk;
    GTextInfo **ti;
    static int done = false;

    if ( !done ) {
	int i;
	for ( i=0; transformtypes[i].text!=NULL; ++i )
	    transformtypes[i].text = (unichar_t *) _((char *) transformtypes[i].text);
	for ( i=0; origin[i].text!=NULL; ++i )
	    origin[i].text = (unichar_t *) _((char *) origin[i].text);
	done = true;
    }

    td.userdata = data;
    td.transfunc = transfunc;
    td.getorigin = getorigin;
    td.done = false;

    if ( td.gw==NULL ) {
	memset(&wattrs,0,sizeof(wattrs));
	wattrs.mask = wam_events|wam_cursor|wam_utf8_wtitle|wam_undercursor|wam_isdlg|wam_restrict;
	wattrs.event_masks = ~(1<<et_charup);
	wattrs.restrict_input_to_me = 1;
	wattrs.undercursor = 1;
	wattrs.cursor = ct_pointer;
	wattrs.utf8_window_title = _("Transform");
	wattrs.is_dlg = true;
	pos.x = pos.y = 0;
	pos.width = GGadgetScale(GDrawPointsToPixels(NULL,TBlock_Width));
	pos.height = GDrawPointsToPixels(NULL,TBlock_Top+TCnt*TBlock_Height+110);
	td.gw = gw = GDrawCreateTopWindow(NULL,&pos,trans_e_h,&td,&wattrs);

	memset(&label,0,sizeof(label));
	memset(&gcd,0,sizeof(gcd));
	memset(&boxes,0,sizeof(boxes));

	label[0].text = (unichar_t *) _("Origin:");
	label[0].text_is_1byte = true;
	label[0].text_in_resource = true;
	gcd[0].gd.label = &label[0];
	gcd[0].gd.pos.x = 5; gcd[0].gd.pos.y = 4;
	gcd[0].gd.flags = (getorigin==NULL) ? gg_visible : (gg_visible | gg_enabled);
	gcd[0].creator = GLabelCreate;

	gcd[1].gd.pos.x = 5; gcd[1].gd.pos.y = 4;
	gcd[1].gd.flags = (getorigin==NULL) ? gg_visible : (gg_visible | gg_enabled);
	gcd[1].gd.label = &origin[1];
	gcd[1].gd.u.list = origin;
	gcd[1].gd.cid = CID_Origin;
	gcd[1].creator = GListButtonCreate;
	origin[1].selected = true;

	origarray[0] = &gcd[0]; origarray[1] = &gcd[1]; origarray[2] = GCD_Glue; origarray[3] = NULL;

	boxes[3].gd.flags = gg_enabled|gg_visible;
	boxes[3].gd.u.boxelements = origarray;
	boxes[3].creator = GHBoxCreate;

	array[0] = &boxes[3]; array[1] = NULL;

	gci = 2; subai = 0; ai = 2;
	for ( i=0; i<TCnt; ++i ) {
	    array[ai++] = MakeTransBlock(&td,i,gcd+gci,label+gci,subarray+subai);
	    array[ai++] = NULL;
	    gci += 23; subai += 27;
	}

	y = TBlock_Top+TCnt*TBlock_Height+4;

	    gcd[gci].gd.pos.x = 10; gcd[gci].gd.pos.y = y;
	    gcd[gci].gd.flags = (flags&tdf_enableback) ? (gg_visible | gg_enabled) : gg_visible;
	    label[gci].text = (unichar_t *) _("Transform _All Layers");
	    label[gci].text_is_1byte = true;
	    label[gci].text_in_resource = true;
	    gcd[gci].gd.label = &label[gci];
	    gcd[gci].gd.cid = CID_AllLayers;
	    gcd[gci++].creator = GCheckBoxCreate;
	    array[ai++] = &gcd[gci-1]; array[ai++] = NULL;
	    y += 16;

	    gcd[gci].gd.pos.x = 10; gcd[gci].gd.pos.y = y;
	    gcd[gci].gd.flags = (flags&tdf_enableback) ? (gg_visible | gg_enabled) : gg_visible;
	    label[gci].text = (unichar_t *) _("Transform _Guide Layer Too");
	    label[gci].text_is_1byte = true;
	    label[gci].text_in_resource = true;
	    gcd[gci].gd.label = &label[gci];
	    gcd[gci].gd.cid = CID_DoGrid;
	    gcd[gci++].creator = GCheckBoxCreate;
	    array[ai++] = &gcd[gci-1]; array[ai++] = NULL;
	    y += 16;

	    gcd[gci].gd.pos.x = 10; gcd[gci].gd.pos.y = y;
	    gcd[gci].gd.flags = (flags&tdf_enableback) ? (gg_visible | gg_enabled | gg_cb_on) : gg_visible;
	    label[gci].text = (unichar_t *) _("Transform _Width Too");
	    label[gci].text_is_1byte = true;
	    label[gci].text_in_resource = true;
	    gcd[gci].gd.label = &label[gci];
	    gcd[gci].gd.cid = CID_DoWidth;
	    gcd[gci++].creator = GCheckBoxCreate;
	    array[ai++] = &gcd[gci-1]; array[ai++] = NULL;
	    y += 16;

	    gcd[gci].gd.pos.x = 10; gcd[gci].gd.pos.y = y;
	    gcd[gci].gd.flags = gg_visible | (flags&tdf_enablekerns ? gg_enabled : 0) |
		    (flags&tdf_defaultkerns ? gg_cb_on : 0);
	    label[gci].text = (unichar_t *) _("Transform kerning _classes too");
	    label[gci].text_is_1byte = true;
	    label[gci].text_in_resource = true;
	    gcd[gci].gd.label = &label[gci];
	    gcd[gci].gd.cid = CID_DoKerns;
	    gcd[gci++].creator = GCheckBoxCreate;
	    array[ai++] = &gcd[gci-1]; array[ai++] = NULL;
	    y += 16;

	    gcd[gci].gd.pos.x = 10; gcd[gci].gd.pos.y = y;
	    gcd[gci].gd.flags = gg_visible |
		    (flags&tdf_enableback ? gg_enabled : 0) |
		    (flags&tdf_enablekerns ? gg_cb_on : 0);
	    label[gci].text = (unichar_t *) _("Transform simple positioning features & _kern pairs");
	    label[gci].text_is_1byte = true;
	    label[gci].text_in_resource = true;
	    gcd[gci].gd.label = &label[gci];
	    gcd[gci].gd.cid = CID_DoSimplePos;
	    gcd[gci++].creator = GCheckBoxCreate;
	    array[ai++] = &gcd[gci-1]; array[ai++] = NULL;
	    y += 16;

	    gcd[gci].gd.pos.x = 10; gcd[gci].gd.pos.y = y;
	    gcd[gci].gd.flags = gg_visible | gg_enabled;
	    label[gci].text = (unichar_t *) _("Round To _Int");
	    label[gci].text_is_1byte = true;
	    label[gci].text_in_resource = true;
	    gcd[gci].gd.label = &label[gci];
	    gcd[gci].gd.cid = CID_Round2Int;
	    gcd[gci++].creator = GCheckBoxCreate;
	    array[ai++] = &gcd[gci-1]; array[ai++] = NULL;
	    y += 24;

	array[ai++] = GCD_Glue; array[ai++] = NULL;

	gcd[gci].gd.pos.x = 30-3; gcd[gci].gd.pos.y = y;
	gcd[gci].gd.flags = gg_visible | gg_enabled | gg_but_default;
	label[gci].text = (unichar_t *) _("_OK");
	label[gci].text_is_1byte = true;
	label[gci].text_in_resource = true;
	gcd[gci].gd.mnemonic = 'O';
	gcd[gci].gd.label = &label[gci];
	gcd[gci].gd.handle_controlevent = Trans_OK;
	gcd[gci++].creator = GButtonCreate;
	buttons[0] = GCD_Glue; buttons[1] = &gcd[gci-1]; buttons[2] = GCD_Glue; buttons[3] = GCD_Glue;

	gcd[gci].gd.flags = gg_visible | gg_enabled;
	label[gci].text = (unichar_t *) _("_Apply");
	label[gci].text_is_1byte = true;
	label[gci].text_in_resource = true;
	gcd[gci].gd.label = &label[gci];
	gcd[gci].gd.handle_controlevent = Trans_OK;
	gcd[gci].gd.cid = CID_Apply;
	gcd[gci++].creator = GButtonCreate;
	buttons[4] = GCD_Glue; buttons[5] = &gcd[gci-1]; buttons[6] = GCD_Glue; buttons[7] = GCD_Glue;

	gcd[gci].gd.pos.x = -30; gcd[gci].gd.pos.y = gcd[gci-1].gd.pos.y+3;
	gcd[gci].gd.flags = gg_visible | gg_enabled | gg_but_cancel;
	label[gci].text = (unichar_t *) _("_Cancel");
	label[gci].text_is_1byte = true;
	label[gci].text_in_resource = true;
	gcd[gci].gd.label = &label[gci];
	gcd[gci].gd.mnemonic = 'C';
	gcd[gci].gd.handle_controlevent = Trans_Cancel;
	gcd[gci++].creator = GButtonCreate;
	buttons[8] = GCD_Glue; buttons[9] = &gcd[gci-1]; buttons[10] = GCD_Glue;
	buttons[11] = NULL;

	boxes[2].gd.flags = gg_enabled|gg_visible;
	boxes[2].gd.u.boxelements = buttons;
	boxes[2].creator = GHBoxCreate;

	array[ai++] = &boxes[2]; array[ai++] = NULL; array[ai++] = NULL;

	boxes[0].gd.pos.x = boxes[0].gd.pos.y = 2;
	boxes[0].gd.flags = gg_enabled|gg_visible;
	boxes[0].gd.u.boxelements = array;
	boxes[0].creator = GHVGroupCreate;

	GGadgetsCreate(gw,boxes);
	GHVBoxSetExpandableRow(boxes[0].ret,gb_expandglue);
	GHVBoxSetExpandableCol(boxes[2].ret,gb_expandgluesame);
	GHVBoxSetExpandableCol(boxes[3].ret,gb_expandglue);
	for ( i=0; i<TCnt; ++i ) {
	    GHVBoxSetPadding( GWidgetGetControl(gw,CID_ClockBox+i*TBlock_CIDOffset),0,0);
	    GHVBoxSetPadding( GWidgetGetControl(gw,CID_HVBox+i*TBlock_CIDOffset),0,0);
	    GHVBoxSetExpandableCol( GWidgetGetControl(gw,CID_HBox+i*TBlock_CIDOffset),gb_expandglue);
	}
	GGadgetSelectOneListItem( GWidgetGetControl(gw,CID_Type), 1);
	GWidgetToDesiredSize(gw);
    } else
	GDrawSetTransientFor(td.gw,(GWindow) -1);
    gw = td.gw;

    GGadgetSetEnabled( GWidgetGetControl(gw,CID_AllLayers), flags&tdf_enableback);
    GGadgetSetEnabled( GWidgetGetControl(gw,CID_DoGrid), flags&tdf_enableback);
    GGadgetSetEnabled( GWidgetGetControl(gw,CID_DoSimplePos), flags&tdf_enableback);
    GGadgetSetEnabled( GWidgetGetControl(gw,CID_DoKerns), flags&tdf_enablekerns);
    GGadgetSetVisible( GWidgetGetControl(gw,CID_Apply), flags&tdf_addapply);
    if ( !(flags&tdf_enableback) ) {
	GGadgetSetChecked( GWidgetGetControl(gw,CID_AllLayers), false );
	GGadgetSetChecked( GWidgetGetControl(gw,CID_DoGrid), false );
    }
    GGadgetSetChecked( GWidgetGetControl(gw,CID_DoKerns),
	    !(flags&tdf_enablekerns)?false:(flags&tdf_defaultkerns)?true:false );
    /* Yes, this is set differently from the previous, that's intended */
    GGadgetSetChecked( GWidgetGetControl(gw,CID_DoSimplePos),
	    !(flags&tdf_enableback)?false:(flags&tdf_enablekerns)?true:false );
    orig = GWidgetGetControl(gw,CID_Origin);
    GGadgetSetEnabled( orig, getorigin!=NULL );
    ti = GGadgetGetList(orig,&len);
    for ( i=0; i<len; ++i ) {
	ti[i]->disabled = !getorigin(data,&junk,i);
	if ( ti[i]->disabled && ti[i]->selected ) {
	    ti[i]->selected = false;
	    ti[0]->selected = true;
	    GGadgetSetTitle(orig,ti[0]->text);
	}
    }

    if ( cvt!=cvt_none ) {
	int index = cvt == cvt_scale  ? 4 :
		    cvt == cvt_flip   ? 5 :
		    cvt == cvt_rotate ? 2 :
		    cvt == cvt_skew   ? 6 :
			   /* 3d rot*/  7 ;
	GGadget *firstoption = GWidgetGetControl(td.gw,CID_Type);
	GEvent dummy;
	GGadgetSelectOneListItem( firstoption, index );
	memset(&dummy,0,sizeof(dummy));
	dummy.type = et_controlevent; dummy.u.control.subtype = et_listselected;
	Trans_TypeChange( firstoption, &dummy );
    }

    for ( i=0; i<TCnt; ++i ) {
	int index = GGadgetGetFirstListSelectedItem(GWidgetGetControl(td.gw,CID_Type+i*TBlock_CIDOffset));
	if ( selcid[index]!=0 ) {
	    GGadget *tf = GWidgetGetControl(td.gw,selcid[index]+i*TBlock_CIDOffset);
	    GWidgetIndicateFocusGadget(tf);
	    GTextFieldSelect(tf,0,-1);
    break;
	}
    }

    GWidgetHidePalettes();
    GDrawSetVisible(gw,true);
    while ( !td.done )
	GDrawProcessOneEvent(NULL);
    GDrawSetVisible(gw,false);
}
Exemplo n.º 7
0
static SplineChar *AddAnchor(AnchorDlg *a, SplineFont *sf, AnchorClass *ac,
	int ismarklike) {
    char *ret, *def;
    SplineChar *sc;
    int isliga = false, ismrk=false, maxlig=-1;
    AnchorPoint *ap;
    PST *pst;
    int i;

    def = copy(".notdef");
    for (;;) {
	ret = gwwv_ask_string(_("Provide a glyph name"),def,_("Please identify a glyph by name, and FontForge will add an anchor to that glyph."));
	free(def);
	if ( ret==NULL )
return( NULL );
	sc = SFGetChar(sf,-1,ret);
	def = ret;
	if ( sc==NULL )
	    ff_post_error(_("Non-existant glyph"), _("The glyph, %.80s, is not in the font"), ret );
	else {
	    isliga = ismrk = false;
	    for ( ap=sc->anchor ; ap!=NULL; ap=ap->next ) {
		if ( ap->type == at_baselig )
		    isliga = true;
		else if ( ap->type == at_basemark || ap->type == at_mark )
		    ismrk = true;
		if ( ap->anchor == ac ) {
		    if ( (ap->type == at_centry ||
			    (ap->type == at_mark && ac->type==act_mkmk) ||
			    ap->type == at_baselig ) && ismarklike==-1 )
			ismarklike = false;
		    else if ( (ap->type == at_cexit || (ap->type == at_basemark && ac->type==act_mkmk)) && ismarklike==-1 )
			ismarklike = true;
		    else if ( ap->type != at_baselig ||
			      ( ap->type == at_baselig && ismarklike>0 ))
			ff_post_error(_("Duplicate Anchor Class"), _("The glyph, %.80s, already contains an anchor in this class, %.80s."), ret, ac->name );
		    else if ( maxlig<ap->lig_index )
			maxlig = ap->lig_index;
	    break;
		}
	    }
	    if ( ap==NULL )
    break;
	}
    }

    ap = chunkalloc(sizeof(AnchorPoint));
    ap->anchor = ac;
    ap->me.x = ap->me.y = 0;
    ap->next = sc->anchor;
    sc->anchor = ap;
    SCCharChangedUpdate(sc,ly_none);

    if ( sc->width==0 ) ismrk = true;
    for ( pst=sc->possub; pst!=NULL; pst=pst->next ) {
	if ( pst->type == pst_ligature || pst->type == pst_lcaret ) {
	    isliga = true;
    break;
	}
    }

    if ( isliga || (ac->type==act_mklg && ismarklike==0 ) ) {
	ap->type = at_baselig;
	ap->lig_index = maxlig+1;
    } else if ( ismrk && ismarklike!=0 )
	ap->type = at_mark;
    else if ( ismarklike==0 && (ismrk || ac->type==act_mkmk) )
	ap->type = at_basemark;
    else if ( ac->type == act_curs ) {
	if ( ismarklike==true )
	    ap->type = at_centry;
	else
	    ap->type = at_cexit;
    } else if ( ismarklike==true )
	ap->type = at_mark;
    else
	ap->type = at_basechar;

    if ( a!=NULL ) {
	GTextInfo **ti = AnchorD_GlyphsInClass(a);
	GGadgetSetList(GWidgetGetControl(a->gw,CID_Glyph),ti,false);
	for ( i=0; ti[i]->text!=NULL || ti[i]->line; ++i ) {
	    if ( ti[i]->userdata == ap ) {
		GGadgetSelectOneListItem(GWidgetGetControl(a->gw,CID_Glyph),i);
	break;
	    }
	}
	AnchorD_ChangeGlyph(a,sc,ap);
    }
return( sc );
}