units.cpp revision de7fb4f0c90c78ab1eae3c5a6eda59a0366be610
#define __SP_PAPER_C__
/*
* SPUnit
*
* Ported from libgnomeprint
*
* Authors:
* Dirk Luetjens <dirk@luedi.oche.de>
* Yves Arrouye <Yves.Arrouye@marin.fdn.fr>
* Lauris Kaplinski <lauris@ximian.com>
* bulia byak <buliabyak@users.sf.net>
*
* Copyright 1999-2001 Ximian, Inc. and authors
*
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <glib.h> // g_assert()
#include "unit-constants.h"
#include "svg/svg-length.h"
/* todo: use some fancy unit program */
/* The order determines the order of the list returned by sp_unit_get_list.
* (It can also affect string lookups if there are any duplicates in the
* current locale... hopefully none.) If you re-order this list, then you must
* also re-order the SPUnitId enum values accordingly. Run `make check' (which
* calls sp_unit_table_sane) to ensure that the two are in sync.
*/
{SP_UNIT_SCALE, SP_UNIT_DIMENSIONLESS, 1.0, NONE, SVGLength::NONE, N_("Unit"), "", N_("Units"), ""},
{SP_UNIT_PT, SP_UNIT_ABSOLUTE, PX_PER_PT, SP_PT, SVGLength::PT, N_("Point"), N_("pt"), N_("Points"), N_("Pt")},
{SP_UNIT_PC, SP_UNIT_ABSOLUTE, PX_PER_PC, SP_PC, SVGLength::PC, N_("Pica"), N_("pc"), N_("Picas"), N_("Pc")},
{SP_UNIT_PX, SP_UNIT_DEVICE, PX_PER_PX, SP_PX, SVGLength::PX, N_("Pixel"), N_("px"), N_("Pixels"), N_("Px")},
/* You can add new elements from this point forward */
{SP_UNIT_PERCENT, SP_UNIT_DIMENSIONLESS, 0.01, NONE, SVGLength::PERCENT, N_("Percent"), N_("%"), N_("Percents"), N_("%")},
{SP_UNIT_MM, SP_UNIT_ABSOLUTE, PX_PER_MM, SP_MM, SVGLength::MM, N_("Millimeter"), N_("mm"), N_("Millimeters"), N_("mm")},
{SP_UNIT_CM, SP_UNIT_ABSOLUTE, PX_PER_CM, SP_CM, SVGLength::CM, N_("Centimeter"), N_("cm"), N_("Centimeters"), N_("cm")},
{SP_UNIT_M, SP_UNIT_ABSOLUTE, PX_PER_M, SP_M, SVGLength::NONE, N_("Meter"), N_("m"), N_("Meters"), N_("m")}, // no svg_unit
{SP_UNIT_IN, SP_UNIT_ABSOLUTE, PX_PER_IN, SP_IN, SVGLength::INCH, N_("Inch"), N_("in"), N_("Inches"), N_("in")},
{SP_UNIT_FT, SP_UNIT_ABSOLUTE, PX_PER_FT, SP_FT, SVGLength::FOOT, N_("Foot"), N_("ft"), N_("Feet"), N_("ft")},
/* Volatiles do not have default, so there are none here */
// TRANSLATORS: for info, see http://www.w3.org/TR/REC-CSS2/syndata.html#length-units
{SP_UNIT_EM, SP_UNIT_VOLATILE, 1.0, NONE, SVGLength::EM, N_("Em square"), N_("em"), N_("Em squares"), N_("em")},
// TRANSLATORS: for info, see http://www.w3.org/TR/REC-CSS2/syndata.html#length-units
{SP_UNIT_EX, SP_UNIT_VOLATILE, 1.0, NONE, SVGLength::EX, N_("Ex square"), N_("ex"), N_("Ex squares"), N_("ex")},
};
SPUnit const *
{
for (unsigned i = 0 ; i < sp_num_units ; i++) {
}
return NULL;
}
gchar const *
{
}
gchar const *
{
}
{
}
{
}
GSList *
{
for (unsigned i = sp_num_units ; i--; ) {
}
}
return units;
}
void
{
}
/* These are pure utility */
/* Return TRUE if conversion is possible */
{
return TRUE;
}
{
return TRUE;
}
return FALSE;
}
/** @param devicetransform for device units. */
/* TODO: Remove the ctmscale parameter given that we no longer have SP_UNIT_USERSPACE. */
{
return from_dist;
}
return ret;
}
{
}
case SP_UNIT_ABSOLUTE:
case SP_UNIT_DEVICE:
break;
default:
return from_dist;
}
default:
/* FALL-THROUGH */
case SP_UNIT_ABSOLUTE:
case SP_UNIT_DEVICE:
break;
}
return ret;
}
/* Some more convenience */
{
} else {
g_warning("Different unit bases: No exact unit conversion available");
}
}
{
} else {
g_warning("Different unit bases: No exact unit conversion available");
}
}
bool
{
for (unsigned i = 0; i < G_N_ELEMENTS(sp_units); ++i) {
return false;
}
}
return true;
}
/** Converts angle (in deg) to compass display */
double
angle_to_compass(double angle)
{
if (ret < 0)
return ret;
}
/** Converts angle (in deg) to compass display */
double
angle_from_compass(double angle)
{
if (ret > 180)
return ret;
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :