コード例 #1
0
ファイル: project_ui.c プロジェクト: armando-2011/grace
static void do_format_toggle(OptionStructure *opt, int value, void *data)
{
    ProjectUI *ui = (ProjectUI *) data;
    int orientation;
    double px, py;
    int page_units;
    char buf[32];
    
    if (value == PAGE_FORMAT_CUSTOM) {
        WidgetSetSensitive(ui->page_x->form, TRUE);
        WidgetSetSensitive(ui->page_y->form, TRUE);
        WidgetSetSensitive(ui->page_orient->menu, FALSE);
        return;
    } else {
        WidgetSetSensitive(ui->page_x->form, FALSE);
        WidgetSetSensitive(ui->page_y->form, FALSE);
        WidgetSetSensitive(ui->page_orient->menu, TRUE);
    }
    
    switch (value) {
    case PAGE_FORMAT_USLETTER:
        px = 612.0;
        py = 792.0;
        break;
    case PAGE_FORMAT_A4:
        px = 595.0;
        py = 842.0;
        break;
    default:
        return;
    }

    
    page_units = GetOptionChoice(ui->page_size_unit);
    orientation = GetOptionChoice(ui->page_orient);
    
    switch (page_units) {
    case PAGE_UNITS_IN:
        px /= 72.0;
        py /= 72.0;
        break;
    case PAGE_UNITS_CM:
        px /= 72.0/CM_PER_INCH;
        py /= 72.0/CM_PER_INCH;
        break;
    }
    
    if ((orientation == PAGE_ORIENT_LANDSCAPE && px > py) ||
        (orientation == PAGE_ORIENT_PORTRAIT  && px < py) ) {
        sprintf (buf, "%.2f", px);
        TextSetString(ui->page_x, buf);
        sprintf (buf, "%.2f", py);
        TextSetString(ui->page_y, buf);
    } else {
        sprintf (buf, "%.2f", py);
        TextSetString(ui->page_x, buf);
        sprintf (buf, "%.2f", px);
        TextSetString(ui->page_y, buf);
    }
}
コード例 #2
0
ファイル: dobject_ui.c プロジェクト: mariusal/grace
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 = SpinChoiceGetValue(ui->v_x);
        }
        if (!caller || caller == ui->v_y) {
            odata->vector.y  = SpinChoiceGetValue(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 = SpinChoiceGetValue(ui->a_length);
        }
        if (!caller || caller == ui->a_dL_ff) {
            odata->arrow.dL_ff  = SpinChoiceGetValue(ui->a_dL_ff);
        }
        if (!caller || caller == ui->a_lL_ff) {
            odata->arrow.lL_ff  = SpinChoiceGetValue(ui->a_lL_ff);
        }
    }
}
コード例 #3
0
ファイル: drv_ui.c プロジェクト: armando-2011/grace
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;
}
コード例 #4
0
ファイル: region_ui.c プロジェクト: mariusal/grace
int set_region_data(RegionUI *ui, Quark *q, void *caller)
{
    int retval = RETURN_SUCCESS;
    
    if (ui && q) {
        if (!caller || caller == ui->type) {
            region_set_type(q, GetOptionChoice(ui->type));
        }
        if (!caller || caller == ui->color) {
            region_set_color(q, GetOptionChoice(ui->color));
        }
    }
    
    return retval;
}
コード例 #5
0
ファイル: axis_ui.c プロジェクト: mariusal/grace
int set_axis_data(AxisUI *ui, Quark *q, void *caller)
{
    if (ui && q && quark_fid_get(q) == QFlavorAxis) {
        if (!caller || caller == ui->position) {
            axis_set_position(q, GetOptionChoice(ui->position));
        }
        if (!caller || caller == ui->offset) {
            axis_set_offset(q, SpinChoiceGetValue(ui->offset));
        }

        if (!caller || caller == ui->draw_bar) {
            axis_enable_bar(q, ToggleButtonGetState(ui->draw_bar));
        }
        if (!caller || caller == ui->draw_ticks) {
            axis_enable_ticks(q, ToggleButtonGetState(ui->draw_ticks));
        }
        if (!caller || caller == ui->draw_labels) {
            axis_enable_labels(q, ToggleButtonGetState(ui->draw_labels));
        }

        return RETURN_SUCCESS;
    } else {
        return RETURN_FAILURE;
    }
}
コード例 #6
0
ファイル: drv_ui.c プロジェクト: armando-2011/grace
static int set_pnm_setup_proc(void *data)
{
    PNM_UI_data *ui = (PNM_UI_data *) data;
    PNM_data *pnm = ui->pnm;
    
    pnm->format = GetOptionChoice(ui->format);
    pnm->rawbits = GetToggleButtonState(ui->rawbits);
    
    return RETURN_SUCCESS;
}
コード例 #7
0
ファイル: drv_ui.c プロジェクト: armando-2011/grace
static int set_hpdf_setup_proc(void *data)
{
    HPDF_UI_data *ui = (HPDF_UI_data *) data;
    HPDF_data *hpdf = ui->hpdf;

    hpdf->colorspace  = GetOptionChoice(ui->colorspace);
    hpdf->compression = GetToggleButtonState(ui->compression);
    
    return RETURN_SUCCESS;
}
コード例 #8
0
ファイル: dobject_ui.c プロジェクト: mariusal/grace
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 = SpinChoiceGetValue(ui->offsetx);
        }
        if (!caller || caller == ui->offsety) {
            o->offset.y = SpinChoiceGetValue(ui->offsety);
        }
        if (!caller || caller == ui->angle) {
            o->angle = GetAngleChoice(ui->angle);
        }
        if (!caller || caller == ui->linew) {
            o->line.width = SpinChoiceGetValue(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;
    }
}
コード例 #9
0
ファイル: drv_ui.c プロジェクト: armando-2011/grace
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;
}
コード例 #10
0
ファイル: drv_ui.c プロジェクト: armando-2011/grace
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;
}
コード例 #11
0
ファイル: dobject_ui.c プロジェクト: mariusal/grace
static void set_arc_odata(ArcUI *ui, DOArcData *odata, void *caller)
{
    if (ui && odata && WidgetIsManaged(ui->top)) {
        if (!caller || caller == ui->width) {
            odata->width  = SpinChoiceGetValue(ui->width);
        }
        if (!caller || caller == ui->height) {
            odata->height = SpinChoiceGetValue(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 = ToggleButtonGetState(ui->draw_closure);
        }
    }
}
コード例 #12
0
ファイル: setwin.c プロジェクト: astrotycoon/grace
static int leval_aac_cb(void *data)
{
    int i, nscols, type;
    double start, stop;
    int npts;
    char *formula[MAX_SET_COLS];
    Quark *pset, *gr;
    GVar *t;
    Leval_ui *ui = (Leval_ui *) data;
    Grace *grace;
    
    gr = ui->gr;
    type = GetOptionChoice(ui->set_type);
    nscols = settype_cols(type);

    if (xv_evalexpr(ui->start, &start) != RETURN_SUCCESS) {
        errmsg("Start item undefined");
        return RETURN_FAILURE;
    }

    if (xv_evalexpr(ui->stop, &stop) != RETURN_SUCCESS) {
        errmsg("Stop item undefined");
        return RETURN_FAILURE;
    }

    if (xv_evalexpri(ui->npts, &npts) != RETURN_SUCCESS) {
        errmsg("Number of points undefined");
        return RETURN_FAILURE;
    }

    TableCommitEdit(ui->mw, FALSE);
    for (i = 0; i < nscols; i++) {
        formula[i] = TableGetCell(ui->mw, i, 0);
    }
    
    
    pset = gapp_set_new(gr);
    set_set_type(pset, type);

    grace = grace_from_quark(pset);
    
    t = graal_get_var(grace_get_graal(grace), "$t", TRUE);
    if (t == NULL) {
        errmsg("Internal error");
        return RETURN_FAILURE;
    }
#if 0    
    if (t->length != 0) {
        xfree(t->data);
        t->length = 0;
    }
    t->data = allocate_mesh(start, stop, npts);
    if (t->data == NULL) {
        return RETURN_FAILURE;
    }
    t->length = npts;
    
    if (set_set_length(pset, npts) != RETURN_SUCCESS) {
        quark_free(pset);
        XCFREE(t->data);
        t->length = 0;
        return RETURN_FAILURE;
    }
#endif    
    for (i = 0; i < nscols; i++) {
        char buf[32], *expr;
        int res;
        
        /* preparing the expression */
        sprintf(buf, "%s = ", dataset_col_name(grace, i));
        expr = copy_string(NULL, buf);
        expr = concat_strings(expr, formula[i]);
        
        /* evaluate the expression */
        res = graal_parse_line(grace_get_graal(grace), expr, NULL);
        
        xfree(expr);
        
        if (res != RETURN_SUCCESS) {
            quark_free(pset);
            
            return RETURN_FAILURE;
        }
    }

#if 0
    XCFREE(t->data);
    t->length = 0;
#endif
    
    update_set_lists(gr);
    
    return RETURN_SUCCESS;
}
コード例 #13
0
ファイル: setwin.c プロジェクト: astrotycoon/grace
static int datasetop_aac_cb(void *data)
{
    int n, i;
    int startno, endno;
    dataSetOpType optype;
    Quark *ss, **selssd;
       
    n = GetStorageChoices(datasetopui.sel, &selssd);
    if (n < 1) {
        errmsg("No SSD selected");
        return RETURN_FAILURE;
    } else {
        optype = GetOptionChoice(datasetopui.optype_item);
 
        switch (optype) {
        case DATASETOP_REVERSE:
            for (i = 0; i < n; i++) {
                ss = selssd[i];
                ssd_reverse(ss);
            }
            break;
        case DATASETOP_TRANSPOSE:
            for (i = 0; i < n; i++) {
                ss = selssd[i];
                if (ssd_transpose(ss) != RETURN_SUCCESS) {
                    errmsg("Transpose failed");
                    break;
                }
            }
            break;
        case DATASETOP_COALESCE:
            if (n > 1) {
                Quark *ss0 = selssd[0];
                for (i = 1; i < n; i++) {
                    ss = selssd[i];
                    if (ssd_coalesce(ss0, ss) != RETURN_SUCCESS) {
                        errmsg("Coalescing failed");
                        break;
                    }
                }
            }
            break;
#if 0
        case DATASETOP_SORT:
            stype = GetOptionChoice(datasetopui.up_down_item);

            for (i = 0; i < n; i++) {
                ss = selssd[i];
                ssd_sort(ss, stype);
            }
            break;
        case DATASETOP_JOIN:
            ssd_join(selssd, n);
            break;
        case DATASETOP_SPLIT:
            xv_evalexpri(datasetopui.length_item, &lpart);
            for (i = 0; i < n; i++) {
                ss = selssd[i];
                ssd_split(ss, lpart);
            }
            break;
#endif
        case DATASETOP_DROP:
            xv_evalexpri(datasetopui.start_item, &startno);
            xv_evalexpri(datasetopui.stop_item, &endno);
            for (i = 0; i < n; i++) {
                ss = selssd[i];
                ssd_delete_rows(ss, startno, endno);
            }
            break;
        default:
            xfree(selssd);
            return RETURN_FAILURE;
        }
        
        snapshot_and_update(gapp->gp, TRUE);
        
        xfree(selssd);

        return RETURN_SUCCESS;
    }
}
コード例 #14
0
ファイル: axis_ui.c プロジェクト: mariusal/grace
int set_axisgrid_data(AGridUI *ui, Quark *q, void *caller)
{
    tickmarks *t = axisgrid_get_data(q);

    if (t && ui) {
        AMem *amem = quark_get_amem(q);
        int i;
        
        if (!caller || caller == ui->type) {
            t->type = GetOptionChoice(ui->type);
        }

        if (!caller || caller == ui->tmajor) {
            if (xv_evalexpr(ui->tmajor, &t->tmajor) != RETURN_SUCCESS) {
                errmsg("Specify major tick spacing");
                return RETURN_FAILURE;
            }
        }
        if (!caller || caller == ui->nminor) {
            t->nminor = (int) SpinChoiceGetValue(ui->nminor);
        }
        if (!caller || caller == ui->tlform) {
            Format *format = GetFormatChoice(ui->tlform);
            AMem *amem = quark_get_amem(q);
            amem_free(amem, t->tl_format.fstring);
            t->tl_format = *format;
            t->tl_format.fstring = amem_strdup(amem, format->fstring);
            format_free(format);
        }
        if (!caller || caller == ui->tlfont) {
            t->tl_tprops.font = GetOptionChoice(ui->tlfont);
        }
        if (!caller || caller == ui->tlcolor) {
            t->tl_tprops.color = GetOptionChoice(ui->tlcolor);
        }
        if (!caller || caller == ui->barpen) {
            GetPenChoice(ui->barpen, &t->bar.pen);
        }
        if (!caller || caller == ui->barlinew) {
            t->bar.width = SpinChoiceGetValue(ui->barlinew);
        }
        if (!caller || caller == ui->barlines) {
            t->bar.style = GetOptionChoice(ui->barlines);
        }
        if (!caller || caller == ui->tlcharsize) {
            t->tl_tprops.charsize = SpinChoiceGetValue(ui->tlcharsize);
        }
        if (!caller || caller == ui->tlangle) {
            t->tl_tprops.angle = GetAngleChoice(ui->tlangle);
        }
        if (!caller || caller == ui->tlstagger) {
            t->tl_staggered = GetOptionChoice(ui->tlstagger);
        }
        if (!caller || caller == ui->tlstarttype) {
            t->tl_starttype = GetOptionChoice(ui->tlstarttype) == 0 ?
                TYPE_AUTO : TYPE_SPEC;
        }
        if (!caller || caller == ui->tlstart) {
            if (t->tl_starttype == TYPE_SPEC) {
                if (xv_evalexpr(ui->tlstart, &t->tl_start) != RETURN_SUCCESS) {
                errmsg("Specify tick label start");
                    return RETURN_FAILURE;
                }
            }
        }
        if (!caller || caller == ui->tlstoptype) {
            t->tl_stoptype = GetOptionChoice(ui->tlstoptype) == 0 ?
                TYPE_AUTO : TYPE_SPEC;
        }
        if (!caller || caller == ui->tlstop) {
            if (t->tl_stoptype == TYPE_SPEC) {
                if (xv_evalexpr(ui->tlstop, &t->tl_stop) != RETURN_SUCCESS) {
                    errmsg("Specify tick label stop");
                    return RETURN_FAILURE;
                }
            }
        }
        if (!caller || caller == ui->tlskip) {
            t->tl_skip = GetOptionChoice(ui->tlskip);
        }
        if (!caller || caller == ui->tlformula) {
            char *s = TextGetString(ui->tlformula);
            t->tl_formula = amem_strcpy(amem, t->tl_formula, s);
            xfree(s);
        }
        if (!caller || caller == ui->tlprestr) {
            char *s = TextGetString(ui->tlprestr);
            t->tl_prestr = amem_strcpy(amem, t->tl_prestr, s);
            xfree(s);
        }
        if (!caller || caller == ui->tlappstr) {
            char *s = TextGetString(ui->tlappstr);
            t->tl_appstr = amem_strcpy(amem, t->tl_appstr, s);
            xfree(s);
        }
        if (!caller || caller == ui->tlgap_para) {
            xv_evalexpr(ui->tlgap_para, &t->tl_gap.x);
        }
        if (!caller || caller == ui->tlgap_perp) {
            xv_evalexpr(ui->tlgap_perp, &t->tl_gap.y);
        }
        if (!caller || caller == ui->tround) {
            t->t_round = ToggleButtonGetState(ui->tround);
        }
        if (!caller || caller == ui->autonum) {
            t->t_autonum = GetOptionChoice(ui->autonum) + 2;
        }


        if (!caller || caller == ui->tgrid) {
            t->gprops.onoff = ToggleButtonGetState(ui->tgrid);
        }
        if (!caller || caller == ui->tgridpen) {
            GetPenChoice(ui->tgridpen, &t->gprops.line.pen);
        }
        if (!caller || caller == ui->tgridlinew) {
            t->gprops.line.width = SpinChoiceGetValue(ui->tgridlinew);
        }
        if (!caller || caller == ui->tgridlines) {
            t->gprops.line.style = GetOptionChoice(ui->tgridlines);
        }

        if (!caller || caller == ui->tmgrid) {
            t->mgprops.onoff = ToggleButtonGetState(ui->tmgrid);
        }
        if (!caller || caller == ui->tmgridpen) {
            GetPenChoice(ui->tmgridpen, &t->mgprops.line.pen);
        }
        if (!caller || caller == ui->tmgridlinew) {
            t->mgprops.line.width = SpinChoiceGetValue(ui->tmgridlinew);
        }
        if (!caller || caller == ui->tmgridlines) {
            t->mgprops.line.style = GetOptionChoice(ui->tmgridlines);
        }


        if (!caller || caller == ui->tinout) {
            t->props.inout = GetOptionChoice(ui->tinout);
        }
        if (!caller || caller == ui->tlen) {
            t->props.size = SpinChoiceGetValue(ui->tlen);
        }
        if (!caller || caller == ui->tpen) {
            GetPenChoice(ui->tpen, &t->props.line.pen);
        }
        if (!caller || caller == ui->tgridlinew) {
            t->props.line.width = SpinChoiceGetValue(ui->tlinew);
        }
        if (!caller || caller == ui->tgridlines) {
            t->props.line.style = GetOptionChoice(ui->tlines);
        }
        if (!caller || caller == ui->tminout) {
            t->mprops.inout = GetOptionChoice(ui->tminout);
        }
        if (!caller || caller == ui->tmlen) {
            t->mprops.size = SpinChoiceGetValue(ui->tmlen);
        }
        if (!caller || caller == ui->tmpen) {
            GetPenChoice(ui->tmpen, &t->mprops.line.pen);
        }
        if (!caller || caller == ui->tmgridlinew) {
            t->mprops.line.width = SpinChoiceGetValue(ui->tmlinew);
        }
        if (!caller || caller == ui->tmgridlines) {
            t->mprops.line.style = GetOptionChoice(ui->tmlines);
        }
        if (!caller ||
            caller == ui->specticks || caller == ui->nspec || caller == ui->specloc) {
            t->t_spec = GetOptionChoice(ui->specticks);
            /* only read special info if special ticks used */
            if (t->t_spec != TICKS_SPEC_NONE) {
                t->nticks = (int) SpinChoiceGetValue(ui->nspec);
                /* ensure that enough tick positions have been specified */
                for (i = 0; i < t->nticks; i++) {
                    if (xv_evalexpr(ui->specloc[i], &t->tloc[i].wtpos) ==
                                                        RETURN_SUCCESS) {
                        char *cp, *s;
                        cp = TextGetString(ui->speclabel[i]);
                        if (cp[0] == '\0') {
                            t->tloc[i].type = TICK_TYPE_MINOR;
                        } else {
                            t->tloc[i].type = TICK_TYPE_MAJOR;
                        }
                        if (t->t_spec == TICKS_SPEC_BOTH) {
                            s = cp;
                        } else {
                            s = NULL;
                        }
                        t->tloc[i].label =
                            amem_strcpy(amem, t->tloc[i].label, s);
                        xfree(cp);
                    }
                } 
            }
        }
        
        quark_dirtystate_set(q, TRUE);
        
        return RETURN_SUCCESS;
    } else {
        return RETURN_FAILURE;
    }
}
コード例 #15
0
ファイル: project_ui.c プロジェクト: armando-2011/grace
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;
}
コード例 #16
0
ファイル: project_ui.c プロジェクト: armando-2011/grace
void update_project_ui(ProjectUI *ui, Quark *q)
{
    Project *pr = project_get_data(q);
    if (pr) {
        int y, m, d, h, mm, sec;
        char date_string[64], wrap_year_string[64], buf[32];
        double factor;
        int format;

        SetSpinChoice(ui->prec, project_get_prec(q));
        TextSetString(ui->description, project_get_description(q));

        switch (GetOptionChoice(ui->page_size_unit)) {
        case PAGE_UNITS_IN:
            factor = 1.0/72.0;
            break;
        case PAGE_UNITS_CM:
            factor = CM_PER_INCH/72.0;
            break;
        default:
            factor = 1.0;
        }

        sprintf (buf, "%.2f", factor*pr->page_wpp); 
        TextSetString(ui->page_x, buf);
        sprintf (buf, "%.2f", factor*pr->page_hpp); 
        TextSetString(ui->page_y, buf);

        if ((pr->page_wpp == 612 && pr->page_hpp == 792) ||
            (pr->page_hpp == 612 && pr->page_wpp == 792)) {
            format = PAGE_FORMAT_USLETTER;
        } else
        if ((pr->page_wpp == 595 && pr->page_hpp == 842) ||
            (pr->page_hpp == 595 && pr->page_wpp == 842)) {
            format = PAGE_FORMAT_A4;
        } else {
            format = PAGE_FORMAT_CUSTOM;
        }
        if (format == PAGE_FORMAT_CUSTOM) {
            WidgetSetSensitive(ui->page_x->form, TRUE);
            WidgetSetSensitive(ui->page_y->form, TRUE);
            WidgetSetSensitive(ui->page_orient->menu, FALSE);
        } else {
            WidgetSetSensitive(ui->page_x->form, FALSE);
            WidgetSetSensitive(ui->page_y->form, FALSE);
            WidgetSetSensitive(ui->page_orient->menu, TRUE);
        }
        SetOptionChoice(ui->page_format, format);
        
        if (pr->page_wpp > pr->page_hpp) {
            SetOptionChoice(ui->page_orient, PAGE_ORIENT_LANDSCAPE);
        } else {
            SetOptionChoice(ui->page_orient, PAGE_ORIENT_PORTRAIT);
        }

        SetOptionChoice(ui->bg_color, pr->bgcolor);
        SetToggleButtonState(ui->bg_fill, pr->bgfill);

        SetSpinChoice(ui->fsize_scale, pr->fscale);
        SetSpinChoice(ui->lwidth_scale, pr->lscale);

	    jdate_to_datetime(q, 0.0, ROUND_SECOND, &y, &m, &d, &h, &mm, &sec);
        sprintf(date_string, "%d-%02d-%02d %02d:%02d:%02d",
            y, m, d, h, mm, sec);
        TextSetString(ui->refdate, date_string);
        SetToggleButtonState(ui->two_digits_years, pr->two_digits_years);
        sprintf(wrap_year_string, "%04d", pr->wrap_year);
        TextSetString(ui->wrap_year, wrap_year_string);
        WidgetSetSensitive(ui->wrap_year->form, pr->two_digits_years ? TRUE:FALSE);
    }
}
コード例 #17
0
ファイル: graph_ui.c プロジェクト: astrotycoon/grace
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;
    }
}