units.h revision c5ad14e3e964f997e716953743842f01274a2993
#ifndef __SP_UNIT_H__
#define __SP_UNIT_H__
/*
* SPUnit
*
* Ported from libgnomeprint
*
* Authors:
* Dirk Luetjens <dirk@luedi.oche.de>
* Yves Arrouye <Yves.Arrouye@marin.fdn.fr>
* Lauris Kaplinski <lauris@ximian.com>
*
* Copyright 1999-2001 Ximian, Inc. and authors
*
*/
#include <glib/gmessages.h>
#include "sp-metric.h"
/*
* Units and conversion methods used by libgnomeprint.
*
* You need those for certain config keys (like paper size), if you are
* interested in using these (look at gnome-print-config.h for discussion,
* why you may NOT be interested in paper size).
*
* Unit bases define set of mutually unrelated measuring systems (numbers,
* paper, screen and dimesionless user coordinates). Still, you can convert
* between those, specifying scaling factors explicitly.
*
* Paper (i.e. output) coordinates are taken as absolute real world units.
* It has some justification, because screen unit (pixel) size changes,
* if you change screen resolution, while you cannot change output on paper
* as easily (unless you have thermally contracting paper, of course).
*
*/
struct SPUnit;
struct SPDistance;
/*
* The base linear ("absolute") unit is 1/72th of an inch, i.e. the base unit of postscript.
*/
/*
* Unit bases
*/
enum SPUnitBase {
};
/*
* Units: indexes into sp_units.
*/
enum SPUnitId {
SP_UNIT_SCALE, // 1.0 == 100%
SP_UNIT_PT, // Postscript points: exactly 72 per inch
SP_UNIT_PC, // Pica; there are 12 points per pica
SP_UNIT_PX, // "Pixels" in the CSS sense; though Inkscape assumes a constant 90 per inch.
SP_UNIT_PERCENT, /* Note: In Inkscape this often means "relative to current value" (for
SP_UNIT_MM, // millimetres
SP_UNIT_CM, // centimetres
SP_UNIT_M, // metres
SP_UNIT_IN, // inches
SP_UNIT_FT, // foot
SP_UNIT_EM, // font-size of relevant font
SP_UNIT_EX, // x-height of relevant font
};
/*
* Notice, that for correct menus etc. you have to use
* ngettext method family yourself. For that reason we
* do not provide translations in unit names.
* I also do not know, whether to allow user-created units,
* because this would certainly confuse textdomain.
*/
struct SPUnit {
/* When using, you must call "gettext" on them so they're translated */
gchar const *abbr_plural;
};
/* When using, you must call "gettext" on them so they're translated */
inline SPUnit const &
{
/* inline because the compiler should optimize away the g_return_val_if_fail test in the
usual case that the argument value is known at compile-time, leaving just
"return sp_units[constant]". */
}
/** Used solely by units-test.cpp. */
bool sp_units_table_sane();
/* These are pure utility */
/* Return TRUE if conversion is possible, FALSE if unit bases differ */
/* Generic conversion between volatile units would be useless anyways */
/* Some more convenience */
double angle_to_compass(double angle);
double angle_from_compass(double angle);
#endif