Exemplo n.º 1
0
static void RH_SetupHint(ReviewHintData *hd) {
    char buffer[20]; unichar_t ubuf[20];
    static unichar_t nullstr[] = {'\0'};
    StemInfo *h;
    int pos,cnt;

    if ( hd->lastactive!=NULL )
	hd->lastactive->active = false;

    pos = cnt = 0;
    for ( h=hd->ishstem ? hd->cv->b.sc->hstem : hd->cv->b.sc->vstem; h!=NULL; h=h->next ) {
	++cnt;
	if ( h==hd->active ) pos=cnt;
    }
    sprintf( buffer,"%d/%d", pos, cnt );
    if ( cnt==3 ) {
	StemInfo *h2, *h3;
	h = hd->ishstem ? hd->cv->b.sc->hstem : hd->cv->b.sc->vstem;
	h2 = h->next; h3 = h2->next;
	if ( h->width == h2->width && h2->width==h3->width &&
		h2->start-h->start == h3->start-h2->start )
	    strcat( buffer, hd->ishstem ? " hstem3" : " vstem3" );
    }
    uc_strcpy(ubuf,buffer);
    GGadgetSetTitle(GWidgetGetControl(hd->gw,CID_Count),ubuf);
    
    if ( hd->active==NULL ) {
	GGadgetSetTitle(GWidgetGetControl(hd->gw,CID_Base),nullstr);
	GGadgetSetTitle(GWidgetGetControl(hd->gw,CID_Width),nullstr);
	GGadgetSetVisible(GWidgetGetControl(hd->gw,CID_Overlap),false);
    } else {
	hd->active->active = true;
	sprintf( buffer,"%g", (double) (!hd->active->ghost ? hd->active->start : hd->active->start+hd->active->width) );
	uc_strcpy(ubuf,buffer);
	GGadgetSetTitle(GWidgetGetControl(hd->gw,CID_Base),ubuf);
	GTextFieldShow(GWidgetGetControl(hd->gw,CID_Base),0);
	sprintf( buffer,"%g", (double) (!hd->active->ghost ? hd->active->width : -hd->active->width) );
	uc_strcpy(ubuf,buffer);
	GGadgetSetTitle(GWidgetGetControl(hd->gw,CID_Width),ubuf);
	GTextFieldShow(GWidgetGetControl(hd->gw,CID_Width),0);
	GGadgetSetVisible(GWidgetGetControl(hd->gw,CID_Overlap),hd->active->hasconflicts);
    }
    if ( hd->lastactive!=hd->active ) {
	hd->lastactive = hd->active;
	SCOutOfDateBackground(hd->cv->b.sc);
	SCUpdateAll(hd->cv->b.sc);	/* Changing the active Hint means we should redraw everything */
    }
    RH_SetNextPrev(hd);
}
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
static int BdfP_FinishTextField(struct bdf_dlg *bd) {
    if ( bd->active ) {
	char *text = GGadgetGetTitle8(bd->tf);
	char *pt, *end;
	int val;
	struct bdf_dlg_font *cur = bd->cur;
	BDFFont *bdf = cur->bdf;

	for ( pt=text; *pt; ++pt )
	    if ( *pt&0x80 ) {
		ff_post_error(_("Not ASCII"),_("All characters in the value must be in ASCII"));
		free(text);
return( false );
	    }
	val = strtol(text,&end,10);
	if ( NumericKey(bdf->props[cur->sel_prop].name) ) {
	    if ( *end!='\0' ) {
		ff_post_error(_("Bad Number"),_("Must be a number"));
		free(text);
return( false );
	    }
	}
	if ( (bdf->props[cur->sel_prop].type&~prt_property)==prt_string ||
		(bdf->props[cur->sel_prop].type&~prt_property)==prt_atom )
	    free(bdf->props[cur->sel_prop].u.str);
	if ( UnknownKey(bdf->props[cur->sel_prop].name) ) {
	    if ( *end!='\0' ) {
		bdf->props[cur->sel_prop].type = prt_string | prt_property;
		bdf->props[cur->sel_prop].u.str = copy(text);
	    } else {
		if ( bdf->props[cur->sel_prop].type != (prt_uint | prt_property ))
		    bdf->props[cur->sel_prop].type = prt_int | prt_property;
		bdf->props[cur->sel_prop].u.val = val;
	    }
	} else if ( NumericKey(bdf->props[cur->sel_prop].name) ) {
	    bdf->props[cur->sel_prop].type = KeyType(bdf->props[cur->sel_prop].name);
	    bdf->props[cur->sel_prop].u.val = val;
	} else {
	    bdf->props[cur->sel_prop].type = KeyType(bdf->props[cur->sel_prop].name);
	    bdf->props[cur->sel_prop].u.str = copy(text);
	}
	free(text);	    
	bd->active = false;
	GGadgetSetVisible(bd->tf,false);
    }
return( true );
}
Exemplo n.º 4
0
static void BdfP_Mouse(struct bdf_dlg *bd, GEvent *e) {
    int line = e->u.mouse.y/(bd->fh+1) + bd->cur->top_prop;

    if ( line<0 || line>bd->cur->bdf->prop_cnt )
return;			/* "New" happens when line==bd->cur->bdf->prop_cnt */
    if ( e->type == et_mousedown ) {
	if ( !BdfP_FinishTextField(bd) ) {
	    bd->press_pos = -1;
return;
	}
	if ( e->u.mouse.x>=4 && e->u.mouse.x<= bd->value_x ) {
	    bd->cur->sel_prop = line;
	    BdfP_PopupMenuProps(bd,e);
	    BdfP_EnableButtons(bd);
	} else if ( line>=bd->cur->bdf->prop_cnt )
return;
	else {
	    bd->press_pos = line;
	    bd->cur->sel_prop = -1;
	    GDrawRequestExpose(bd->v,NULL,false );
	}
    } else if ( e->type == et_mouseup ) {
	int pos = bd->press_pos;
	bd->press_pos = -1;
	if ( line>=bd->cur->bdf->prop_cnt || line!=pos )
return;
	if ( bd->active )		/* Should never happen */
return;
	bd->cur->sel_prop = line;
	if ( e->u.mouse.x > bd->value_x ) {
	    BDFFont *bdf = bd->cur->bdf;
	    GGadgetMove(bd->tf,bd->value_x+2,(line-bd->cur->top_prop)*(bd->fh+1));
	    if ( (bdf->props[line].type&~prt_property) == prt_int ||
		    (bdf->props[line].type&~prt_property) == prt_uint ) {
		char buffer[40];
		sprintf( buffer,"%d",bdf->props[line].u.val );
		GGadgetSetTitle8(bd->tf,buffer);
	    } else
		GGadgetSetTitle8(bd->tf,bdf->props[line].u.str );
	    GGadgetSetVisible(bd->tf,true);
	    bd->active = true;
	}
	GDrawRequestExpose(bd->v,NULL,false );
    }
}
Exemplo n.º 5
0
static int RH_TextChanged(GGadget *g, GEvent *e) {
    int wasconflict;
    if ( e->type==et_controlevent && e->u.control.subtype == et_textchanged ) {
	ReviewHintData *hd = GDrawGetUserData(GGadgetGetWindow(g));
	if ( hd->active!=NULL ) {
	    int cid = GGadgetGetCid(g);
	    int err=0;
	    real start = GetCalmReal8(hd->gw,CID_Base,_("Base:"),&err);
	    real width = GetCalmReal8(hd->gw,CID_Width,_("Size:"),&err);
	    if ( err )
return( true );
	    if ( GGadgetIsChecked(GWidgetGetControl(GGadgetGetWindow(g),CID_MovePoints)) ) {
		if ( width<0 )
		    RH_MovePoints(hd,hd->active,start+width,-width);
		else
		    RH_MovePoints(hd,hd->active,start,width);
	    }
	    if ( cid==CID_Base )
		hd->active->start = start;
	    else
		hd->active->width = width;
	    if ( width<0 ) {
		hd->active->ghost = true;
		hd->active->width = -width;
		hd->active->start = start+width;
	    } else
		hd->active->ghost = false;
	    wasconflict = hd->active->hasconflicts;
	    if ( hd->ishstem )
		hd->cv->b.sc->hconflicts = StemListAnyConflicts(hd->cv->b.sc->hstem);
	    else
		hd->cv->b.sc->vconflicts = StemListAnyConflicts(hd->cv->b.sc->vstem);
	    hd->cv->b.sc->manualhints = true;
	    hd->changed = true;
	    if ( wasconflict!=hd->active->hasconflicts ) {
		GGadgetSetVisible(GWidgetGetControl(hd->gw,CID_Overlap),hd->active->hasconflicts);
		if ( hd->active->hasconflicts )
		    GHVBoxFitWindow(GWidgetGetControl(hd->gw,CID_TopBox));
	    }
	    SCOutOfDateBackground(hd->cv->b.sc);
	    SCUpdateAll(hd->cv->b.sc);
	}
    }
return( true );
}
Exemplo n.º 6
0
static void BdfP_HideTextField(struct bdf_dlg *bd) {
    if ( bd->active ) {
	bd->active = false;
	GGadgetSetVisible(bd->tf,false);
    }
}
Exemplo n.º 7
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.º 8
0
static int Delta_OK(GGadget *g, GEvent *e) {
    if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) {
	QGData *qg = GDrawGetUserData(GGadgetGetWindow(g));
	int err=false;
	int dpi, depth;
	double within;
	char *sizes;

	within = GetReal8(qg->gw,CID_Within,_("Proximity"),&err);
	dpi = GetInt8(qg->gw,CID_DPI,_("DPI"),&err);
	if ( err )
return(true);
	if ( within<=0 || within>=.5 ) {
	    ff_post_error(_("Bad Number"),_("The \"Proximity\" field must be more than 0 and less than a half."));
return( true );
	}
	if ( dpi<10 || dpi>5000 ) {
	    ff_post_error(_("Unreasonable DPI"),_("The \"DPI\" field must be more than 10 and less than 5000."));
return( true );
	}
	depth = GGadgetIsChecked(GWidgetGetControl(qg->gw,CID_BW)) ? 1 : 8;
	sizes = GGadgetGetTitle8(GWidgetGetControl(qg->gw,CID_Sizes));

	GGadgetSetVisible(GWidgetGetControl(qg->gw,CID_Msg),true);
	GGadgetSetVisible(GWidgetGetControl(qg->gw,CID_Ok),false);
	GGadgetSetVisible(GWidgetGetControl(qg->gw,CID_Cancel),false);
	GDrawSetCursor(qg->gw,ct_watch);
	GDrawProcessPendingEvents(NULL);

	qg->within = within;
	qg->dpi = dpi;
	qg->pixelsizes = sizes;
	qg->depth = depth;
	TopFindQuestionablePoints(qg);

	GGadgetSetVisible(GWidgetGetControl(qg->gw,CID_Msg),false);
	GGadgetSetVisible(GWidgetGetControl(qg->gw,CID_Ok),true);
	GGadgetSetVisible(GWidgetGetControl(qg->gw,CID_Cancel),true);
	GDrawSetCursor(qg->gw,ct_pointer);
	GDrawProcessPendingEvents(NULL);

	if ( qg->error!=qg_ok ) {
	    switch ( qg->error ) {
	      case qg_notnumber:
		ff_post_error(_("Bad Number"),_("An entry in the \"Sizes\" field is not a number."));
	      break;
	      case qg_badnumber:
		ff_post_error(_("Bad Number"),_("An entry in the \"Sizes\" field is unreasonable."));
	      break;
	      case qg_badrange:
		ff_post_error(_("Bad Number"),_("An range in the \"Sizes\" field is incorrectly ordered."));
	      break;
	      case qg_nofont:
		ff_post_error(_("FreeType unavailable"),_("FreeType unavailable."));
	      break;
	      default:
		IError(_("Unexpected error"));
	      break;
	    }
	    free(sizes);
	    qg->cur = 0;
return( true );
	}

	free(delta_sizes);
	delta_within = within;
	delta_dpi    = dpi;
	delta_depth  = depth;
	delta_sizes  = sizes;

	if ( qg->cur==0 ) {
	    ff_post_error(_("Nothing found"),_("Nothng found."));
	    qg->done = true;
return( true );
	}

	if ( qg->cur >= qg->max )
	    qg->qg = realloc(qg->qg,(qg->max += 1) * sizeof(QuestionableGrid));
	memset(qg->qg+qg->cur,0,sizeof(QuestionableGrid));
	GDrawSetVisible(qg->gw,false);
	StartDeltaDisplay(qg);
	qg->done = true;
    }
return( true );
}