static void set_line_odata(LineUI *ui, DOLineData *odata, void *caller) { if (ui && odata && WidgetIsManaged(ui->top)) { if (!caller || caller == ui->v_x) { odata->vector.x = GetSpinChoice(ui->v_x); } if (!caller || caller == ui->v_y) { odata->vector.y = GetSpinChoice(ui->v_y); } if (!caller || caller == ui->arrow_end) { odata->arrow_end = GetOptionChoice(ui->arrow_end); } if (!caller || caller == ui->a_type) { odata->arrow.type = GetOptionChoice(ui->a_type); } if (!caller || caller == ui->a_length) { odata->arrow.length = GetSpinChoice(ui->a_length); } if (!caller || caller == ui->a_dL_ff) { odata->arrow.dL_ff = GetSpinChoice(ui->a_dL_ff); } if (!caller || caller == ui->a_lL_ff) { odata->arrow.lL_ff = GetSpinChoice(ui->a_lL_ff); } } }
int set_object_data(ObjectUI *ui, Quark *q, void *caller) { DObject *o = object_get_data(q); if (o && ui) { if (!caller || caller == ui->x) { xv_evalexpr(ui->x, &o->ap.x); } if (!caller || caller == ui->y) { xv_evalexpr(ui->y, &o->ap.y); } if (!caller || caller == ui->offsetx) { o->offset.x = GetSpinChoice(ui->offsetx); } if (!caller || caller == ui->offsety) { o->offset.y = GetSpinChoice(ui->offsety); } if (!caller || caller == ui->angle) { o->angle = GetAngleChoice(ui->angle); } if (!caller || caller == ui->linew) { o->line.width = GetSpinChoice(ui->linew); } if (!caller || caller == ui->lines) { o->line.style = GetOptionChoice(ui->lines); } if (!caller || caller == ui->linepen) { GetPenChoice(ui->linepen, &o->line.pen); } if (!caller || caller == ui->fillpen) { GetPenChoice(ui->fillpen, &o->fillpen); } switch (o->type) { case DO_LINE: set_line_odata(ui->line_ui, (DOLineData *) o->odata, caller); break; case DO_BOX: set_box_odata(ui->box_ui, (DOBoxData *) o->odata, caller); break; case DO_ARC: set_arc_odata(ui->arc_ui, (DOArcData *) o->odata, caller); break; default: break; } quark_dirtystate_set(q, TRUE); return RETURN_SUCCESS; } else { return RETURN_FAILURE; } }
static void set_box_odata(BoxUI *ui, DOBoxData *odata, void *caller) { if (ui && odata && WidgetIsManaged(ui->top)) { if (!caller || caller == ui->width) { odata->width = GetSpinChoice(ui->width); } if (!caller || caller == ui->height) { odata->height = GetSpinChoice(ui->height); } } }
static int set_pdf_setup_proc(void *data) { PDF_UI_data *ui = (PDF_UI_data *) data; PDF_data *pdf = ui->pdf; pdf->compat = GetOptionChoice(ui->compat); pdf->colorspace = GetOptionChoice(ui->colorspace); pdf->compression = (int) GetSpinChoice(ui->compression); pdf->fpprec = (int) GetSpinChoice(ui->fpprec); return RETURN_SUCCESS; }
static int set_jpg_setup_proc(void *data) { JPG_UI_data *ui = (JPG_UI_data *) data; JPG_data *jpg = ui->jpg; jpg->grayscale = GetToggleButtonState(ui->grayscale); jpg->baseline = GetToggleButtonState(ui->baseline); jpg->optimize = GetToggleButtonState(ui->optimize); jpg->progressive = GetToggleButtonState(ui->progressive); jpg->quality = (int) GetSpinChoice (ui->quality); jpg->smoothing = (int) GetSpinChoice (ui->smoothing); jpg->dct = GetOptionChoice (ui->dct); return RETURN_SUCCESS; }
static int set_png_setup_proc(void *data) { PNG_UI_data *ui = (PNG_UI_data *) data; PNG_data *png = ui->png; png->interlaced = GetToggleButtonState(ui->interlaced); png->transparent = GetToggleButtonState(ui->transparent); png->compression = GetSpinChoice(ui->compression); return RETURN_SUCCESS; }
static int set_ps_setup_proc(void *data) { PS_UI_data *ui = (PS_UI_data *) data; PS_data *ps = ui->ps; ps->level2 = GetToggleButtonState(ui->level2); ps->docdata = GetOptionChoice(ui->docdata); ps->colorspace = GetOptionChoice(ui->colorspace); ps->fonts = GetOptionChoice(ui->fonts); if (ps->format == EPS_FORMAT) { ps->printable = GetToggleButtonState(ui->printable); } if (ps->format == PS_FORMAT) { ps->offset_x = (int) GetSpinChoice(ui->offset_x); ps->offset_y = (int) GetSpinChoice(ui->offset_y); ps->feed = GetOptionChoice(ui->feed); ps->hwres = GetToggleButtonState(ui->hwres); } return RETURN_SUCCESS; }
static void set_arc_odata(ArcUI *ui, DOArcData *odata, void *caller) { if (ui && odata && WidgetIsManaged(ui->top)) { if (!caller || caller == ui->width) { odata->width = GetSpinChoice(ui->width); } if (!caller || caller == ui->height) { odata->height = GetSpinChoice(ui->height); } if (!caller || caller == ui->angle1) { odata->angle1 = GetAngleChoice(ui->angle1); } if (!caller || caller == ui->angle2) { odata->angle2 = GetAngleChoice(ui->angle2); } if (!caller || caller == ui->closure_type) { odata->closure_type = GetOptionChoice(ui->closure_type); } if (!caller || caller == ui->draw_closure) { odata->draw_closure = GetToggleButtonState(ui->draw_closure); } } }
int set_project_data(ProjectUI *ui, Quark *q, void *caller) { Project *pr = project_get_data(q); int retval = RETURN_SUCCESS; if (ui && pr) { GraceApp *gapp = gapp_from_quark(q); double jul; if (!caller || caller == ui->prec) { project_set_prec(q, GetSpinChoice(ui->prec)); } if (!caller || caller == ui->description) { char *s = TextGetString(ui->description); project_set_description(q, s); xfree(s); } if (caller == ui->page_orient) { int wpp, hpp; int orientation = GetOptionChoice(ui->page_orient); project_get_page_dimensions(q, &wpp, &hpp); if ((orientation == PAGE_ORIENT_LANDSCAPE && wpp < hpp) || (orientation == PAGE_ORIENT_PORTRAIT && wpp > hpp)) { set_page_dimensions(gapp, hpp, wpp, TRUE); } } if (caller == ui->page_format) { int wpp, hpp; int orientation = GetOptionChoice(ui->page_orient); int format = GetOptionChoice(ui->page_format); GraceApp *gapp = gapp_from_quark(q); switch (format) { case PAGE_FORMAT_USLETTER: wpp = 792.0; hpp = 612.0; break; case PAGE_FORMAT_A4: wpp = 842.0; hpp = 595.0; break; default: return RETURN_SUCCESS; } if (orientation == PAGE_ORIENT_PORTRAIT) { iswap(&wpp, &hpp); } set_page_dimensions(gapp, wpp, hpp, TRUE); } if (!caller || caller == ui->page_x || caller == ui->page_y) { int page_units = GetOptionChoice(ui->page_size_unit); double factor, page_x, page_y; GraceApp *gapp = gapp_from_quark(q); if (xv_evalexpr(ui->page_x, &page_x) != RETURN_SUCCESS || xv_evalexpr(ui->page_y, &page_y) != RETURN_SUCCESS) { errmsg("Invalid page dimension(s)"); return RETURN_FAILURE; } switch (page_units) { case PAGE_UNITS_IN: factor = 72.0; break; case PAGE_UNITS_CM: factor = 72.0/CM_PER_INCH; break; default: factor = 1.0; break; } page_x *= factor; page_y *= factor; set_page_dimensions(gapp, (int) rint(page_x), (int) rint(page_y), TRUE); } if (!caller || caller == ui->bg_color) { pr->bgcolor = GetOptionChoice(ui->bg_color); } if (!caller || caller == ui->bg_fill) { pr->bgfill = GetToggleButtonState(ui->bg_fill); } if (!caller || caller == ui->fsize_scale) { pr->fscale = GetSpinChoice(ui->fsize_scale); } if (!caller || caller == ui->lwidth_scale) { pr->lscale = GetSpinChoice(ui->lwidth_scale); } if (!caller || caller == ui->refdate) { char *s = TextGetString(ui->refdate); if (parse_date_or_number(q, s, TRUE, get_date_hint(gapp), &jul) == RETURN_SUCCESS) { pr->ref_date = jul; } else { errmsg("Invalid date"); retval = RETURN_FAILURE; } xfree(s); } if (!caller || caller == ui->two_digits_years) { pr->two_digits_years = GetToggleButtonState(ui->two_digits_years); } if (!caller || caller == ui->wrap_year) { char *s = TextGetString(ui->wrap_year); pr->wrap_year = atoi(s); xfree(s); } quark_dirtystate_set(q, TRUE); } return retval; }
int graph_set_data(GraphUI *ui, Quark *q, void *caller) { if (quark_fid_get(q) == QFlavorGraph) { double axislim, znorm; world w; GLocator *locator; graph_get_world(q, &w); locator = graph_get_locator(q); if (!caller || caller == ui->graph_type) { graph_set_type(q, GetOptionChoice(ui->graph_type)); } if (!caller || caller == ui->stacked) { graph_set_stacked(q, GetToggleButtonState(ui->stacked)); } if (!caller || caller == ui->flip_xy) { graph_set_xyflip(q, GetToggleButtonState(ui->flip_xy)); } if (!caller || caller == ui->start_x) { if (xv_evalexpr(ui->start_x, &axislim) != RETURN_SUCCESS) { errmsg("Axis start/stop values undefined"); return RETURN_FAILURE; } w.xg1 = axislim; } if (!caller || caller == ui->stop_x) { if (xv_evalexpr(ui->stop_x, &axislim) != RETURN_SUCCESS) { errmsg("Axis start/stop values undefined"); return RETURN_FAILURE; } w.xg2 = axislim; } if (!caller || caller == ui->start_y) { if (xv_evalexpr(ui->start_y, &axislim) != RETURN_SUCCESS) { errmsg("Axis start/stop values undefined"); return RETURN_FAILURE; } w.yg1 = axislim; } if (!caller || caller == ui->stop_y) { if (xv_evalexpr(ui->stop_y, &axislim) != RETURN_SUCCESS) { errmsg("Axis start/stop values undefined"); return RETURN_FAILURE; } w.yg2 = axislim; } if (!caller || caller == ui->start_x || caller == ui->stop_x || caller == ui->start_y || caller == ui->stop_y) { graph_set_world(q, &w); } if (!caller || caller == ui->scale_x) { graph_set_xscale(q, GetOptionChoice(ui->scale_x)); } if (!caller || caller == ui->invert_x) { graph_set_xinvert(q, GetToggleButtonState(ui->invert_x)); } if (!caller || caller == ui->scale_y) { graph_set_yscale(q, GetOptionChoice(ui->scale_y)); } if (!caller || caller == ui->invert_y) { graph_set_yinvert(q, GetToggleButtonState(ui->invert_y)); } if (!caller || caller == ui->bargap) { graph_set_bargap(q, GetSpinChoice(ui->bargap)); } if (!caller || caller == ui->znorm) { xv_evalexpr(ui->znorm, &znorm); graph_set_znorm(q, znorm); } if (!caller || caller == ui->loc_type) { locator->type = GetOptionChoice(ui->loc_type); quark_dirtystate_set(q, TRUE); } if (!caller || caller == ui->loc_fx) { Format *format = GetFormatChoice(ui->loc_fx); AMem *amem = quark_get_amem(q); amem_free(amem, locator->fx.fstring); locator->fx = *format; locator->fx.fstring = amem_strdup(amem, format->fstring); format_free(format); quark_dirtystate_set(q, TRUE); } if (!caller || caller == ui->loc_fy) { Format *format = GetFormatChoice(ui->loc_fy); AMem *amem = quark_get_amem(q); amem_free(amem, locator->fy.fstring); locator->fy = *format; locator->fy.fstring = amem_strdup(amem, format->fstring); format_free(format); quark_dirtystate_set(q, TRUE); } if (!caller || caller == ui->fixedp) { locator->pointset = GetToggleButtonState(ui->fixedp); quark_dirtystate_set(q, TRUE); } if (!caller || caller == ui->locx) { xv_evalexpr(ui->locx, &locator->origin.x); quark_dirtystate_set(q, TRUE); } if (!caller || caller == ui->locy) { xv_evalexpr(ui->locy, &locator->origin.y); quark_dirtystate_set(q, TRUE); } return RETURN_SUCCESS; } else { return RETURN_FAILURE; } }