Logo Search packages:      
Sourcecode: inkscape version File versions  Download package

static void sp_style_read_ilength ( SPILength val,
gchar const *  str 
) [static]

Set SPILength object from string.

Todo:
fixme: Move this to standard place (Lauris)

Todo:
Allow the number of px per inch to vary (document preferences, X server or whatever). E.g. don't fill in computed here, do it at the same time as percentage units are done.

Definition at line 2849 of file style.cpp.

References SPILength::computed, SPILength::inherit, SPILength::set, SPILength::unit, and SPILength::value.

Referenced by sp_style_read_ilengthornormal(), and sp_style_read_plength().

{
    if (!strcmp(str, "inherit")) {
        val->set = TRUE;
        val->inherit = TRUE;
    } else {
        gdouble value;
        gchar *e;
        /** \todo fixme: Move this to standard place (Lauris) */
        value = g_ascii_strtod(str, &e);
        if ((gchar const *) e != str) {
            /** \todo
             * Allow the number of px per inch to vary (document preferences,
             * X server or whatever).  E.g. don't fill in computed here, do
             * it at the same time as percentage units are done.
             */
            if (!*e) {
                /* Userspace */
                val->unit = SP_CSS_UNIT_NONE;
                val->computed = value;
            } else if (!strcmp(e, "px")) {
                /* Userspace */
                val->unit = SP_CSS_UNIT_PX;
                val->computed = value;
            } else if (!strcmp(e, "pt")) {
                /* Userspace / DEVICESCALE */
                val->unit = SP_CSS_UNIT_PT;
                val->computed = value * PX_PER_PT;
            } else if (!strcmp(e, "pc")) {
                /* 1 pica = 12pt; FIXME: add it to SPUnit */
                val->unit = SP_CSS_UNIT_PC;
                val->computed = value * PX_PER_PT * 12;
            } else if (!strcmp(e, "mm")) {
                val->unit = SP_CSS_UNIT_MM;
                val->computed = value * PX_PER_MM;
            } else if (!strcmp(e, "cm")) {
                val->unit = SP_CSS_UNIT_CM;
                val->computed = value * PX_PER_CM;
            } else if (!strcmp(e, "in")) {
                val->unit = SP_CSS_UNIT_IN;
                val->computed = value * PX_PER_IN;
            } else if (!strcmp(e, "em")) {
                /* EM square */
                val->unit = SP_CSS_UNIT_EM;
                val->value = value;
            } else if (!strcmp(e, "ex")) {
                /* ex square */
                val->unit = SP_CSS_UNIT_EX;
                val->value = value;
            } else if (!strcmp(e, "%")) {
                /* Percentage */
                val->unit = SP_CSS_UNIT_PERCENT;
                val->value = value * 0.01;
            } else {
                /* Invalid */
                return;
            }
            val->set = TRUE;
            val->inherit = FALSE;
        }
    }
}


Generated by  Doxygen 1.6.0   Back to index