Esempio n. 1
0
static void PoV_DoVanish(struct nldlg *d) {
    double x,y,dv,tilt,dir;
    double t;
    int err = false;
    double vp;
    char buf[80];
    unichar_t ubuf[80];
extern char *coord_sep;

    x = GetQuietReal(d->gw,CID_XValue,&err);
    y = GetQuietReal(d->gw,CID_YValue,&err);
    /*z = GetQuietReal(d->gw,CID_ZValue,&err);*/
    dv = GetQuietReal(d->gw,CID_DValue,&err);
    tilt = GetQuietReal(d->gw,CID_Tilt,&err)*3.1415926535897932/180;
    dir = GetQuietReal(d->gw,CID_GazeDirection,&err)*3.1415926535897932/180;
    if ( err )
return;
    if ( GGadgetGetFirstListSelectedItem( GWidgetGetControl(d->gw,CID_XType))!=3 )
	x = 0;
    if ( GGadgetGetFirstListSelectedItem( GWidgetGetControl(d->gw,CID_YType))!=3 )
	y = 0;
    t = tan(tilt);
    if ( t<.000001 && t>-.000001 )
	sprintf(buf,"inf%sinf", coord_sep);
    else {
	vp = dv/t;
	x -= sin(dir)*vp;
	y += cos(dir)*vp;
	sprintf(buf,"%g%s%g", x, coord_sep, y );
    }
    uc_strcpy(ubuf,buf);
    GGadgetSetTitle( GWidgetGetControl(d->gw,CID_Vanish), ubuf );
}
Esempio n. 2
0
static int L2L_OK(GGadget *g, GEvent *e) {

    if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) {
	L2LDlg *d = GDrawGetUserData(GGadgetGetWindow(g));
	int from, to, clear;
	int err=0;
	double errbound;

	from = GGadgetGetFirstListSelectedItem(GWidgetGetControl(d->gw,CID_FromLayer));
	to   = GGadgetGetFirstListSelectedItem(GWidgetGetControl(d->gw,CID_ToLayer));
	if ( d->l2l==l2l_copy ) {
	    clear = GGadgetIsChecked(GWidgetGetControl(d->gw,CID_ClearOld));
	    if ( d->cv )
		_DoCVCopy(d->cv,from,to,clear);
	    else
		_DoFVCopy(d->fv,from,to,clear);
	} else {
	    errbound = GetReal8(d->gw,CID_ErrorBound,_("Error Bound"),&err);
	    if ( err )
return( true );
	    if ( d->cv )
		_DoCVCompare(d->cv,from,to,errbound);
	    else
		_DoFVCompare(d->fv,from,to,errbound);
	}
	d->done = true;
    }
return( true );
}
Esempio n. 3
0
static int kpd_e_h(GWindow gw, GEvent *event) {
    if ( event->type==et_close ) {
	KPData *kpd = GDrawGetUserData(gw);
	kpd->done = true;
    } else if ( event->type == et_mousemove ) {
	kpdpopup(GDrawGetUserData(gw));
    } else if ( event->type == et_expose ) {
	KPData *kpd = GDrawGetUserData(gw);
	GRect size, sbsize;
	GDrawGetSize(kpd->v,&size);
	GGadgetGetSize(GWidgetGetControl(kpd->gw,CID_ScrollBar),&sbsize);
	GDrawSetLineWidth(gw,0);
	GDrawDrawLine(gw,size.x,size.y-1,sbsize.x+sbsize.width-1,size.y-1,0x000000);
	GDrawDrawLine(gw,size.x,size.y+size.height,sbsize.x+sbsize.width-1,size.y+size.height,0x000000);
	GDrawDrawLine(gw,size.x-1,size.y-1,size.x-1,size.y+size.height,0x000000);
    } else if ( event->type == et_char ) {
	if ( event->u.chr.keysym == GK_F1 || event->u.chr.keysym == GK_Help ) {
	    help("kernpairs.html");
return( true );
	}
	if ( event->u.chr.chars[0]!='\0' && event->u.chr.chars[1]=='\0' ) {
	    enum sortby sort = GGadgetGetFirstListSelectedItem(GWidgetGetControl(gw,CID_SortBy));
	    KPData *kpd = GDrawGetUserData(gw);
	    if ( sort!=sb_kern ) {
		KPScrollTo(kpd,event->u.chr.chars[0],sort);
return( true );
	    } else
		GDrawBeep(NULL);
	}
return( false );
    } else if ( event->type == et_resize && event->u.resize.sized ) {
	KP_Resize((KPData *) GDrawGetUserData(gw) );
    }
return( true );
}
static int DE_Delete(GGadget *g, GEvent *e) {
    GWindow gw;
    int *done;
    GGadget *list;
    int sel,i;
    Encoding *item;

    if ( e->type==et_controlevent &&
            (e->u.control.subtype == et_buttonactivate ||
             e->u.control.subtype == et_listdoubleclick )) {
        gw = GGadgetGetWindow(g);
        done = GDrawGetUserData(gw);
        list = GWidgetGetControl(gw,CID_Encodings);
        sel = GGadgetGetFirstListSelectedItem(list);
        i=0;
        for ( item=enclist; item!=NULL; item=item->next ) {
            if ( item->builtin )
                /* Do Nothing */;
            else if ( i==sel )
                break;
            else
                ++i;
        }
        if ( item!=NULL )
            DeleteEncoding(item);
        *done = true;
    }
    return( true );
}
Esempio n. 5
0
void Wordlist_touch( GGadget* g )
{
    // Force any extra chars to be setup and drawn
    GEvent e;
    e.type=et_controlevent;
    e.u.control.subtype = et_textchanged;
    e.u.control.u.tf_changed.from_pulldown = GGadgetGetFirstListSelectedItem(g);
    GGadgetDispatchEvent( g, &e );
}
Esempio n. 6
0
static int AnchorD_MagnificationChanged(GGadget *g, GEvent *e) {
    AnchorDlg *a = GDrawGetUserData(GGadgetGetWindow(g));
    if ( e->type==et_controlevent && e->u.control.subtype == et_listselected ) {
	int mag = GGadgetGetFirstListSelectedItem(GWidgetGetControl(a->gw,CID_Mag));

	if ( mag!=-1 && mag!=a->magfactor-1 ) {
	    a->xoff = (mag+1)*a->xoff/a->magfactor;
	    a->magfactor = mag+1;
	    AnchorD_ChangeMag(a);
	    GDrawRequestExpose(a->gw,NULL,false);
	}
    }
return( true );
}
Esempio n. 7
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 );
}
Esempio n. 8
0
static int KP_ChangeSort(GGadget *g, GEvent *e) {
    if ( e->type==et_controlevent && e->u.control.subtype == et_listselected ) {
	KPData *kpd = GDrawGetUserData(GGadgetGetWindow(g));
	KernPair *old = kpd->selected==-1 ? NULL : kpd->kerns[kpd->selected].kp;
	int i;

	KPSortEm(kpd,GGadgetGetFirstListSelectedItem(g));
	for ( i=0 ; i<kpd->kcnt; ++i )
	    if ( kpd->kerns[i].kp==old ) {
		kpd->selected = i;
		KP_ScrollTo(kpd,i);
	break;
	    }
	GDrawRequestExpose(kpd->v,NULL,false);
    }
return( true );
}
Esempio n. 9
0
static int BdfP_ChangeBDF(GGadget *g, GEvent *e) {
    if ( e->type==et_controlevent && e->u.control.subtype == et_listselected ) {
	struct bdf_dlg *bd = GDrawGetUserData(GGadgetGetWindow(g));
	int sel = GGadgetGetFirstListSelectedItem(g);
	if ( sel<0 || sel>=bd->fcnt )
return( true );
	if ( !BdfP_FinishTextField(bd)) {
	    sel = bd->cur-bd->fonts;
	    GGadgetSelectListItem(g,sel,true);
return( true );
	}
	bd->cur = &bd->fonts[sel];
	BdfP_RefigureScrollbar(bd);
	BdfP_EnableButtons(bd);
	GDrawRequestExpose(bd->v,NULL,false);
    }
return( true );
}
Esempio n. 10
0
static int GFD_FilterSelected(GGadget *g, GEvent *e) {
    if ( e->type==et_controlevent && e->u.control.subtype == et_listselected ) {
	struct gfc_data *d = GDrawGetUserData(GGadgetGetWindow(g));
	GTextInfo *ti = GGadgetGetListItemSelected(g);
	if ( ti->userdata==NULL )
	    /* They selected a line. Dull */;
	else if ( ti->userdata == (void *) -1 ) {
	    FilterDlg();
	    GGadgetSetList(g,StandardFilters(),true);
	} else {
	    unichar_t *temp = utf82u_copy(ti->userdata);
	    GFileChooserSetFilterText(d->gfc,temp);
	    free(temp);
	    temp = GFileChooserGetDir(d->gfc);
	    GFileChooserSetDir(d->gfc,temp);
	    free(temp);
	    default_font_filter_index = GGadgetGetFirstListSelectedItem(g);
	    SavePrefs(true);
	}
    }
return( true );
}
Esempio n. 11
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);
    }
}
Esempio n. 12
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);
}
Esempio n. 13
0
static int Trans_OK(GGadget *g, GEvent *e) {
    real transform[6], trans[6], t[6];
    bigreal angle, angle2;
    int i, index, err;
    int alllayers = false, round_2_int = false, dokerns = false, dokp=false;
    int dogrid = false, dowidth = false;
    BasePoint base;
    int origin, bvpos=0;
    BVTFunc bvts[TCnt+1];
    static int warned = false;
    int isapply = GGadgetGetCid(g) == CID_Apply;

    if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) {
	TransData *td = GDrawGetUserData(GGadgetGetWindow(g));

	transform[0] = transform[3] = 1.0;
	transform[1] = transform[2] = transform[4] = transform[5] = 0;
	base.x = base.y = 0;

	origin = GGadgetGetFirstListSelectedItem( GWidgetGetControl(td->gw,CID_Origin));
	if ( GWidgetGetControl(td->gw,CID_AllLayers)!=NULL )
	    alllayers = GGadgetIsChecked(GWidgetGetControl(td->gw,CID_AllLayers));
	if ( GWidgetGetControl(td->gw,CID_DoGrid)!=NULL )
	    dogrid = GGadgetIsChecked(GWidgetGetControl(td->gw,CID_DoGrid));
	if ( GWidgetGetControl(td->gw,CID_DoWidth)!=NULL )
	    dowidth = GGadgetIsChecked(GWidgetGetControl(td->gw,CID_DoWidth));
	else
	    dowidth = true;
	if ( GWidgetGetControl(td->gw,CID_DoSimplePos)!=NULL )
	    dokp = GGadgetIsChecked(GWidgetGetControl(td->gw,CID_DoSimplePos));
	if ( GWidgetGetControl(td->gw,CID_DoKerns)!=NULL )
	    dokerns = GGadgetIsChecked(GWidgetGetControl(td->gw,CID_DoKerns));
	round_2_int = GGadgetIsChecked(GWidgetGetControl(td->gw,CID_Round2Int));
	if ( isapply )
	    alllayers = dogrid = dokp = dokerns = false;
	if ( td->getorigin!=NULL ) {
	    (td->getorigin)(td->userdata,&base,origin );
	    transform[4] = -base.x;
	    transform[5] = -base.y;
	}
	for ( i=0; i<TCnt; ++i ) {
	    index =  GGadgetGetFirstListSelectedItem(
		    GWidgetGetControl(td->gw,CID_Type+i*TBlock_CIDOffset));
	    trans[0] = trans[3] = 1.0;
	    trans[1] = trans[2] = trans[4] = trans[5] = 0;
	    err = 0;
	    switch ( index ) {
	      case 0:		/* Do Nothing */
	      break;
	      case 1:		/* Move */
		trans[4] = GetReal8(td->gw,CID_XMove+i*TBlock_CIDOffset,_("X Movement"),&err);
		trans[5] = GetReal8(td->gw,CID_YMove+i*TBlock_CIDOffset,_("Y Movement"),&err);
		bvts[bvpos].x = trans[4]; bvts[bvpos].y = trans[5]; bvts[bvpos++].func = bvt_transmove;
	      break;
	      case 2:		/* Rotate */
		angle = GetReal8(td->gw,CID_Angle+i*TBlock_CIDOffset,_("Rotation Angle"),&err);
		if ( GGadgetIsChecked( GWidgetGetControl(td->gw,CID_Clockwise+i*TBlock_CIDOffset)) )
		    angle = -angle;
		if ( fmod(angle,90)!=0 )
		    bvts[0].func = bvt_none;		/* Bad trans=> No trans */
		else {
		    angle = fmod(angle,360);
		    if ( angle<0 ) angle+=360;
		    if ( angle==90 ) bvts[bvpos++].func = bvt_rotate90ccw;
		    else if ( angle==180 ) bvts[bvpos++].func = bvt_rotate180;
		    else if ( angle==270 ) bvts[bvpos++].func = bvt_rotate90cw;
		}
		angle *= 3.1415926535897932/180;
		trans[0] = trans[3] = cos(angle);
		trans[2] = -(trans[1] = sin(angle));
	      break;
	      case 3:		/* Scale Uniformly */
		trans[0] = trans[3] = GetReal8(td->gw,CID_Scale+i*TBlock_CIDOffset,_("Scale Factor"),&err)/100.0;
		bvts[0].func = bvt_none;		/* Bad trans=> No trans */
	      break;
	      case 4:		/* Scale */
		trans[0] = GetReal8(td->gw,CID_XScale+i*TBlock_CIDOffset,_("X Scale Factor"),&err)/100.0;
		trans[3] = GetReal8(td->gw,CID_YScale+i*TBlock_CIDOffset,_("Y Scale Factor"),&err)/100.0;
		bvts[0].func = bvt_none;		/* Bad trans=> No trans */
	      break;
	      case 5:		/* Flip */
		if ( GGadgetIsChecked( GWidgetGetControl(td->gw,CID_Horizontal+i*TBlock_CIDOffset)) ) {
		    trans[0] = -1;
		    bvts[bvpos++].func = bvt_fliph;
		} else {
		    trans[3] = -1;
		    bvts[bvpos++].func = bvt_flipv;
		}
	      break;
	      case 6:		/* Skew */
		angle = GetReal8(td->gw,CID_SkewAng+i*TBlock_CIDOffset,_("Skew Angle"),&err);
		if ( GGadgetIsChecked( GWidgetGetControl(td->gw,CID_CounterClockwise+i*TBlock_CIDOffset)) )
		    angle = -angle;
		angle *= 3.1415926535897932/180;
		trans[2] = tan(angle);
		skewselect(&bvts[bvpos],trans[2]); ++bvpos;
	      break;
	      case 7:		/* 3D rotate */
		angle =  GetReal8(td->gw,CID_XAxis+i*TBlock_CIDOffset,_("Rotation about X Axis"),&err) * 3.1415926535897932/180;
		angle2 = GetReal8(td->gw,CID_YAxis+i*TBlock_CIDOffset,_("Rotation about Y Axis"),&err) * 3.1415926535897932/180;
		trans[0] = cos(angle2);
		trans[3] = cos(angle );
		bvts[0].func = bvt_none;		/* Bad trans=> No trans */
	      break;
	      default:
		IError("Unexpected selection in Transform");
		err = 1;
	      break;
	    }
	    if ( err )
return(true);
#if 0
 printf( "(%g,%g,%g,%g,%g,%g)*(%g,%g,%g,%g,%g,%g) = ",
     trans[0], trans[1], trans[2], trans[3], trans[4], trans[5],
     transform[0], transform[1], transform[2], transform[3], transform[4], transform[5]);
#endif
	    t[0] = transform[0]*trans[0] +
			transform[1]*trans[2];
	    t[1] = transform[0]*trans[1] +
			transform[1]*trans[3];
	    t[2] = transform[2]*trans[0] +
			transform[3]*trans[2];
	    t[3] = transform[2]*trans[1] +
			transform[3]*trans[3];
	    t[4] = transform[4]*trans[0] +
			transform[5]*trans[2] +
			trans[4];
	    t[5] = transform[4]*trans[1] +
			transform[5]*trans[3] +
			trans[5];
	    memcpy(transform,t,sizeof(t));
#if 0
 printf( "(%g,%g,%g,%g,%g,%g)\n",
     transform[0], transform[1], transform[2], transform[3], transform[4], transform[5]);
#endif
	}
	bvts[bvpos++].func = bvt_none;		/* Done */
	for ( i=0; i<6; ++i )
	    if ( RealNear(transform[i],0)) transform[i] = 0;
	transform[4] += base.x;
	transform[5] += base.y;

	if (( transform[1]!=0 || transform[2]!=0 ) && !warned ) {
	    ff_post_notice(_("Warning"),_("After rotating or skewing a glyph you should probably apply Element->Add Extrema"));
	    warned = true;
	}
	(td->transfunc)(td->userdata,transform,origin,bvts,
		(alllayers?fvt_alllayers:0)|
		(dogrid?fvt_dogrid:0)|
		 (dowidth?0:fvt_dontmovewidth)|
		 (round_2_int?fvt_round_to_int:0)|
		 (dokp?fvt_scalepstpos:0)|
		 (dokerns?fvt_scalekernclasses:0)|
		 (isapply?fvt_justapply:0));
	td->done = !isapply;
	td->applied = isapply;
    }
return( true );
}
Esempio n. 14
0
int PointOfViewDlg(struct pov_data *pov, SplineFont *sf, int flags) {
    static struct pov_data def = { or_center, or_value, 0, 0, .1,
	    0, 3.1415926535897932/16, .2, 0 };
    double emsize = (sf->ascent + sf->descent);
    struct nldlg d;
    GRect pos;
    GWindowAttrs wattrs;
    GGadgetCreateData gcd[24], boxes[7], *varray[10][3], *harray1[3], *harray2[3],
	    *barray[9], *harray3[3], *harray4[3];
    GTextInfo label[24];
    int i,k,l;
    char xval[40], yval[40], zval[40], dval[40], tval[40], dirval[40];
    double x,y,z,dv,tilt,dir;
    int err;
    static int done = false;

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

    *pov = def;
    pov->x *= emsize; pov->y *= emsize; pov->z *= emsize; pov->d *= emsize;
    if ( !(flags&1) ) {
	if ( pov->xorigin == or_lastpress ) pov->xorigin = or_center;
	if ( pov->yorigin == or_lastpress ) pov->yorigin = or_center;
    }

    memset(&d,'\0',sizeof(d));

    memset(&wattrs,0,sizeof(wattrs));
    wattrs.mask = wam_events|wam_cursor|wam_utf8_wtitle|wam_undercursor|wam_restrict|wam_isdlg;
    wattrs.event_masks = ~(1<<et_charup);
    wattrs.restrict_input_to_me = 1;
    wattrs.is_dlg = 1;
    wattrs.undercursor = 1;
    wattrs.cursor = ct_pointer;
    wattrs.utf8_window_title = _("Point of View Projection");
    pos.x = pos.y = 0;
    pos.width = GGadgetScale(GDrawPointsToPixels(NULL,240));
    pos.height = GDrawPointsToPixels(NULL,216);
    d.gw = GDrawCreateTopWindow(NULL,&pos,nld_e_h,&d,&wattrs);

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

    k=l=0;
    label[k].text = (unichar_t *) _("View Point");
    label[k].text_is_1byte = true;
    gcd[k].gd.label = &label[k];
    gcd[k].gd.pos.x = 10; gcd[k].gd.pos.y = 8;
    gcd[k].gd.flags = gg_visible | gg_enabled;
    gcd[k++].creator = GLabelCreate;
    varray[l][0] = &gcd[k-1]; varray[l][1] = GCD_ColSpan; varray[l++][2] = NULL;

    label[k].text = (unichar_t *) _("_X");
    label[k].text_is_1byte = true;
    label[k].text_in_resource = true;
    gcd[k].gd.label = &label[k];
    gcd[k].gd.pos.x = 10; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y + 16;
    gcd[k].gd.flags = gg_visible | gg_enabled;
    gcd[k++].creator = GLabelCreate;
    harray1[0] = &gcd[k-1];

    for ( i=or_zero; i<or_undefined; ++i ) originx[i].selected = false;
    originx[pov->xorigin].selected = true;
    originx[or_lastpress].disabled = !(flags&1);
    gcd[k].gd.pos.x = 23; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y-4;
    gcd[k].gd.flags = gg_visible | gg_enabled;
    gcd[k].gd.label = &originx[pov->xorigin];
    gcd[k].gd.u.list = originx;
    gcd[k].gd.cid = CID_XType;
    gcd[k++].creator = GListButtonCreate;
    harray1[1] = &gcd[k-1]; harray1[2] = NULL;

    boxes[2].gd.flags = gg_enabled|gg_visible;
    boxes[2].gd.u.boxelements = harray1;
    boxes[2].creator = GHBoxCreate;
    varray[l][0] = &boxes[2];

    sprintf( xval, "%g", rint(pov->x));
    label[k].text = (unichar_t *) xval;
    label[k].text_is_1byte = true;
    gcd[k].gd.label = &label[k];
    gcd[k].gd.pos.x = 160; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y;  gcd[k].gd.pos.width = 60;
    gcd[k].gd.flags = gg_enabled|gg_visible;
    gcd[k].gd.handle_controlevent = PoV_Vanish;
    gcd[k].gd.cid = CID_XValue;
    gcd[k++].creator = GTextFieldCreate;
    varray[l][1] = &gcd[k-1]; varray[l++][2] = NULL;

    label[k].text = (unichar_t *) _("_Y");
    label[k].text_is_1byte = true;
    label[k].text_in_resource = true;
    gcd[k].gd.label = &label[k];
    gcd[k].gd.pos.x = gcd[k-3].gd.pos.x; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y + 28;
    gcd[k].gd.flags = gg_visible | gg_enabled;
    gcd[k++].creator = GLabelCreate;
    harray2[0] = &gcd[k-1];

    for ( i=or_zero; i<or_undefined; ++i ) originy[i].selected = false;
    originy[pov->yorigin].selected = true;
    originy[or_lastpress].disabled = !(flags&1);
    gcd[k].gd.pos.x = gcd[k-3].gd.pos.x; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y-4;
    gcd[k].gd.flags = gg_visible | gg_enabled;
    gcd[k].gd.label = &originy[pov->yorigin];
    gcd[k].gd.u.list = originy;
    gcd[k].gd.cid = CID_YType;
    gcd[k++].creator = GListButtonCreate;
    harray2[1] = &gcd[k-1]; harray2[2] = NULL;

    boxes[3].gd.flags = gg_enabled|gg_visible;
    boxes[3].gd.u.boxelements = harray2;
    boxes[3].creator = GHBoxCreate;
    varray[l][0] = &boxes[3];

    sprintf( yval, "%g", rint(pov->y));
    label[k].text = (unichar_t *) yval;
    label[k].text_is_1byte = true;
    gcd[k].gd.label = &label[k];
    gcd[k].gd.pos.x = gcd[k-3].gd.pos.x; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y;  gcd[k].gd.pos.width = gcd[k-3].gd.pos.width;
    gcd[k].gd.flags = gg_enabled|gg_visible;
    gcd[k].gd.cid = CID_YValue;
    gcd[k].gd.handle_controlevent = PoV_Vanish;
    gcd[k++].creator = GTextFieldCreate;
    varray[l][1] = &gcd[k-1]; varray[l++][2] = NULL;

    label[k].text = (unichar_t *) _("Distance to drawing plane:");
    label[k].text_is_1byte = true;
    gcd[k].gd.label = &label[k];
    gcd[k].gd.pos.x = 10; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y + 28;
    gcd[k].gd.flags = gg_visible | gg_enabled;
    gcd[k++].creator = GLabelCreate;
    varray[l][0] = &gcd[k-1];

    sprintf( zval, "%g", rint(pov->z));
    label[k].text = (unichar_t *) zval;
    label[k].text_is_1byte = true;
    gcd[k].gd.label = &label[k];
    gcd[k].gd.pos.x = 160; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y-4;  gcd[k].gd.pos.width = 60;
    gcd[k].gd.flags = gg_enabled|gg_visible;
    gcd[k].gd.handle_controlevent = PoV_Vanish;
    gcd[k].gd.cid = CID_ZValue;
    gcd[k++].creator = GTextFieldCreate;
    varray[l][1] = &gcd[k-1]; varray[l++][2] = NULL;

    label[k].text = (unichar_t *) _("Distance to projection plane:");
    label[k].text_is_1byte = true;
    gcd[k].gd.label = &label[k];
    gcd[k].gd.pos.x = gcd[k-2].gd.pos.x; gcd[k].gd.pos.y = gcd[k-2].gd.pos.y + 24;
    gcd[k].gd.flags = gg_visible | gg_enabled;
    gcd[k++].creator = GLabelCreate;
    varray[l][0] = &gcd[k-1];

    sprintf( dval, "%g", rint(pov->d));
    label[k].text = (unichar_t *) dval;
    label[k].text_is_1byte = true;
    gcd[k].gd.label = &label[k];
    gcd[k].gd.pos.x = 160; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y-4;  gcd[k].gd.pos.width = 60;
    gcd[k].gd.flags = gg_enabled|gg_visible;
    gcd[k].gd.handle_controlevent = PoV_Vanish;
    gcd[k].gd.cid = CID_DValue;
    gcd[k++].creator = GTextFieldCreate;
    varray[l][1] = &gcd[k-1]; varray[l++][2] = NULL;

    label[k].text = (unichar_t *) _("Drawing plane tilt:");
    label[k].text_is_1byte = true;
    gcd[k].gd.label = &label[k];
    gcd[k].gd.pos.x = gcd[k-2].gd.pos.x; gcd[k].gd.pos.y = gcd[k-2].gd.pos.y + 24;
    gcd[k].gd.flags = gg_visible | gg_enabled;
    gcd[k++].creator = GLabelCreate;
    varray[l][0] = &gcd[k-1];

    sprintf( tval, "%g", rint(pov->tilt*180/3.1415926535897932));
    label[k].text = (unichar_t *) tval;
    label[k].text_is_1byte = true;
    gcd[k].gd.label = &label[k];
    gcd[k].gd.pos.x = 160; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y-4;  gcd[k].gd.pos.width = 40;
    gcd[k].gd.flags = gg_enabled|gg_visible;
    gcd[k].gd.handle_controlevent = PoV_Vanish;
    gcd[k].gd.cid = CID_Tilt;
    gcd[k++].creator = GTextFieldCreate;
    harray3[0] = &gcd[k-1];

    label[k].text = (unichar_t *) U_("°");
    label[k].text_is_1byte = true;
    gcd[k].gd.label = &label[k];
    gcd[k].gd.pos.x = gcd[k-1].gd.pos.x+gcd[k-1].gd.pos.width+3; gcd[k].gd.pos.y = gcd[k-2].gd.pos.y;
    gcd[k].gd.flags = gg_visible | gg_enabled;
    gcd[k++].creator = GLabelCreate;
    harray3[1] = &gcd[k-1]; harray3[2] = NULL;

    boxes[4].gd.flags = gg_enabled|gg_visible;
    boxes[4].gd.u.boxelements = harray3;
    boxes[4].creator = GHBoxCreate;
    varray[l][1] = &boxes[4]; varray[l++][2] = NULL;

    label[k].text = (unichar_t *) _("Direction of gaze:");
    label[k].text_is_1byte = true;
    gcd[k].gd.label = &label[k];
    gcd[k].gd.pos.x = gcd[k-3].gd.pos.x; gcd[k].gd.pos.y = gcd[k-3].gd.pos.y + 24;
    gcd[k].gd.flags = gg_visible | gg_enabled;
    gcd[k++].creator = GLabelCreate;
    varray[l][0] = &gcd[k-1];

    sprintf( dirval, "%g", rint(pov->direction*180/3.1415926535897932));
    label[k].text = (unichar_t *) dirval;
    label[k].text_is_1byte = true;
    gcd[k].gd.label = &label[k];
    gcd[k].gd.pos.x = 160; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y-4;  gcd[k].gd.pos.width = 40;
    gcd[k].gd.flags = gg_enabled|gg_visible;
    gcd[k].gd.handle_controlevent = PoV_Vanish;
    gcd[k].gd.cid = CID_GazeDirection;
    gcd[k++].creator = GTextFieldCreate;
    harray4[0] = &gcd[k-1];

    label[k].text = (unichar_t *) U_("°");
    label[k].text_is_1byte = true;
    gcd[k].gd.label = &label[k];
    gcd[k].gd.pos.x = gcd[k-1].gd.pos.x+gcd[k-1].gd.pos.width+3; gcd[k].gd.pos.y = gcd[k-2].gd.pos.y;
    gcd[k].gd.flags = gg_visible | gg_enabled;
    gcd[k++].creator = GLabelCreate;
    harray4[1] = &gcd[k-1]; harray4[2] = NULL;

    boxes[5].gd.flags = gg_enabled|gg_visible;
    boxes[5].gd.u.boxelements = harray4;
    boxes[5].creator = GHBoxCreate;
    varray[l][1] = &boxes[5]; varray[l++][2] = NULL;

    label[k].text = (unichar_t *) _("Vanishing Point:");
    label[k].text_is_1byte = true;
    gcd[k].gd.label = &label[k];
    gcd[k].gd.pos.x = 10; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+18;
    gcd[k].gd.flags = gg_visible | gg_enabled | gg_utf8_popup;
    gcd[k].gd.popup_msg = (unichar_t *) _("This is the approximate location of the vanishing point.\nIt does not include the offset induced by \"Center of selection\"\nnor \"Last Press\".");
    gcd[k++].creator = GLabelCreate;
    varray[l][0] = &gcd[k-1];

    label[k].text = (unichar_t *) "123456.,123456.";
    label[k].text_is_1byte = true;
    gcd[k].gd.label = &label[k];
    gcd[k].gd.pos.x = 160; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y;
    gcd[k].gd.flags = gg_visible | gg_enabled | gg_utf8_popup;
    gcd[k].gd.popup_msg = (unichar_t *) _("This is the approximate location of the vanishing point.\nIt does not include the offset induced by \"Center of selection\"\nnor \"Last Press\".");
    gcd[k].gd.cid = CID_Vanish;
    gcd[k++].creator = GLabelCreate;
    varray[l][1] = &gcd[k-1]; varray[l++][2] = NULL;

    gcd[k].gd.pos.x = 30-3; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+18;
    gcd[k].gd.pos.width = -1; gcd[k].gd.pos.height = 0;
    gcd[k].gd.flags = gg_visible | gg_enabled | gg_but_default;
    label[k].text = (unichar_t *) _("_OK");
    label[k].text_is_1byte = true;
    label[k].text_in_resource = true;
    gcd[k].gd.label = &label[k];
    gcd[k].gd.cid = true;
    gcd[k++].creator = GButtonCreate;
    barray[0] = GCD_Glue; barray[1] = &gcd[k-1]; barray[2] = GCD_Glue;

    gcd[k].gd.pos.x = -30; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+3;
    gcd[k].gd.pos.width = -1; gcd[k].gd.pos.height = 0;
    gcd[k].gd.flags = gg_visible | gg_enabled | gg_but_cancel;
    label[k].text = (unichar_t *) _("_Cancel");
    label[k].text_is_1byte = true;
    label[k].text_in_resource = true;
    gcd[k].gd.label = &label[k];
    gcd[k].gd.cid = false;
    gcd[k++].creator = GButtonCreate;
    barray[3] = GCD_Glue; barray[4] = &gcd[k-1]; barray[5] = GCD_Glue; barray[6] = NULL;

    boxes[6].gd.flags = gg_enabled|gg_visible;
    boxes[6].gd.u.boxelements = barray;
    boxes[6].creator = GHBoxCreate;
    varray[l][0] = &boxes[6]; varray[l][1] = GCD_ColSpan; varray[l++][2] = NULL;
    varray[l][0] = 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 = varray[0];
    boxes[0].creator = GHVGroupCreate;

    GGadgetsCreate(d.gw,boxes);
    GHVBoxFitWindow(boxes[0].ret);
    PoV_DoVanish(&d);
    GDrawSetVisible(d.gw,true);
    while ( !d.done ) {
	GDrawProcessOneEvent(NULL);
	if ( d.done ) {
	    if ( !d.ok ) {
		GDrawDestroyWindow(d.gw);
return( -1 );
	    }
	    err = false;
	    x = GetReal8(d.gw,CID_XValue,_("_X"),&err);
	    y = GetReal8(d.gw,CID_YValue,_("_Y"),&err);
	    z = GetReal8(d.gw,CID_ZValue,_("Distance to drawing plane:"),&err);
	    dv = GetReal8(d.gw,CID_DValue,_("Distance to projection plane:"),&err);
	    tilt = GetReal8(d.gw,CID_Tilt,_("Drawing plane tilt:"),&err);
	    dir = GetReal8(d.gw,CID_GazeDirection,_("Direction of gaze:"),&err);
	    if ( err ) {
		d.done = d.ok = false;
    continue;
	    }
	    pov->x = x; pov->y = y; pov->z = z; pov->d = dv;
	    pov->tilt = tilt*3.1415926535897932/180;
	    pov->direction = dir*3.1415926535897932/180;
	    pov->xorigin = GGadgetGetFirstListSelectedItem( GWidgetGetControl(d.gw,CID_XType));
	    pov->yorigin = GGadgetGetFirstListSelectedItem( GWidgetGetControl(d.gw,CID_YType));
	}
    }

    GDrawDestroyWindow(d.gw);
    def = *pov;
    def.x /= emsize; def.y /= emsize; def.z /= emsize; def.d /= emsize;
return( 0 );		/* -1 => Canceled */
}
Esempio n. 15
0
static void QGDoSort(QGData *qg) {
    int pos, l, k, cnt, lstart;
    char buffer[200];

    pos = GGadgetGetFirstListSelectedItem(GWidgetGetControl(qg->gw,CID_Sort));
    qg->info_sort = (intpt) sorts[pos].userdata;

    pos = GGadgetGetFirstListSelectedItem(GWidgetGetControl(qg->gw,CID_GlyphSort));
    qg->glyph_sort = (intpt) glyphsorts[pos].userdata;

    kludge = qg;
    qsort(qg->qg,qg->cur,sizeof(QuestionableGrid),qg_sorter);

    qgnodeFree(&qg->list);
    memset(&qg->list,0,sizeof(struct qgnode));
    qg->list.open = true;
    qg->list.first = qg->qg;
    if ( qg->info_sort == is_glyph_size_pt || qg->info_sort == is_glyph_pt_size ) {
	SplineChar *sc = NULL;
	cnt = 0;
	for ( l=0; l<qg->cur; ++l ) {
	    if ( sc!=qg->qg[l].sc ) {
		++cnt;
		sc = qg->qg[l].sc;
	    }
	}
	qg->list.kid_cnt = cnt;
	qg->list.kids = calloc(cnt,sizeof(struct qgnode));
	cnt = 0;
	lstart = 0; sc=NULL;
	for ( l=0; l<qg->cur; ++l ) {
	    if ( sc!=qg->qg[l].sc && sc!=NULL ) {
		sprintf( buffer, "\"%.40s\" (%d)", sc->name, l-lstart );
		qg->list.kids[cnt].name = copy(buffer);
		qg->list.kids[cnt].parent = &qg->list;
		qg->list.kids[cnt].first = &qg->qg[lstart];
		qg->list.kids[cnt].qg_cnt = l-lstart;
		++cnt;
		lstart = l;
		sc = qg->qg[l].sc;
	    } else if ( sc!=qg->qg[l].sc )
		sc = qg->qg[l].sc;
	}
	if ( sc!=NULL ) {
	    sprintf( buffer, "\"%.40s\" (%d)", sc->name, l-lstart );
	    qg->list.kids[cnt].name = copy(buffer);
	    qg->list.kids[cnt].parent = &qg->list;
	    qg->list.kids[cnt].first = &qg->qg[lstart];
	    qg->list.kids[cnt].qg_cnt = l-lstart;
	}
    } else {
	int size = -1;
	cnt = 0;
	for ( l=0; l<qg->cur; ++l ) {
	    if ( size!=qg->qg[l].size ) {
		++cnt;
		size = qg->qg[l].size;
	    }
	}
	qg->list.kid_cnt = cnt;
	qg->list.kids = calloc(cnt,sizeof(struct qgnode));
	cnt = 0;
	lstart = 0; size=-1;
	for ( l=0; l<qg->cur; ++l ) {
	    if ( size!=qg->qg[l].size && size!=-1 ) {
		sprintf( buffer, _("Size: %d (%d)"), size, l-lstart );
		qg->list.kids[cnt].name = copy(buffer);
		qg->list.kids[cnt].parent = &qg->list;
		qg->list.kids[cnt].first = &qg->qg[lstart];
		qg->list.kids[cnt].qg_cnt = l-lstart;
		++cnt;
		lstart = l;
		size = qg->qg[l].size;
	    } else if ( size!=qg->qg[l].size )
		size = qg->qg[l].size;
	}
	if ( size!=-1 ) {
	    sprintf( buffer, _("Size: %d (%d)"), size, l-lstart );
	    qg->list.kids[cnt].name = copy(buffer);
	    qg->list.kids[cnt].parent = &qg->list;
	    qg->list.kids[cnt].first = &qg->qg[lstart];
	    qg->list.kids[cnt].qg_cnt = l-lstart;
	}
    }
    if ( qg->list.kid_cnt==1 )
	qg->list.kids[0].open = true;
    for ( k=0; k<qg->list.kid_cnt; ++k )
	QGSecondLevel(qg,&qg->list.kids[k]);
    QG_Remetric(qg);
}