summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3d63c4b)
raw | patch | inline | side by side (parent: 3d63c4b)
author | cilix42 <cilix42@users.sourceforge.net> | |
Sun, 3 Feb 2008 14:56:48 +0000 (14:56 +0000) | ||
committer | cilix42 <cilix42@users.sourceforge.net> | |
Sun, 3 Feb 2008 14:56:48 +0000 (14:56 +0000) |
diff --git a/src/helper/units.cpp b/src/helper/units.cpp
index a78f5e623ef55c71f8d73349f77414f0fb36c2a1..3e632a0caf7530bfc86d857f39b04d7c7b669694 100644 (file)
--- a/src/helper/units.cpp
+++ b/src/helper/units.cpp
SPUnit const sp_units[] = {
{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_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")},
diff --git a/src/helper/units.h b/src/helper/units.h
index 3acb6582855f0da4cc6cb587f65768a9abeff3e1..8dc62fee642ce91b3f235694ebdfbcb1f015c679 100644 (file)
--- a/src/helper/units.h
+++ b/src/helper/units.h
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
users to edit a value), rather than the SVG/CSS use of percentages. */
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
sp_max_unit_id = SP_UNIT_EX // For bounds-checking in sp_unit_get_by_id.
diff --git a/src/sp-metric.h b/src/sp-metric.h
index 76db44710fdc507ffc1d60a28f7f6b6a611df53e..644c2c8eb1bf8fdaf4161a18e617d9590330c2f0 100644 (file)
--- a/src/sp-metric.h
+++ b/src/sp-metric.h
SP_MM,
SP_CM,
SP_IN,
+ SP_FT,
SP_PT,
+ SP_PC,
SP_PX,
SP_M
};
diff --git a/src/sp-metrics.cpp b/src/sp-metrics.cpp
index 5f05c9fad6b8ac9db3bb46541f776a9a4122792d..e3d8c3fe19bad2c66f9bd2b7d5ff77f16b0ef1a7 100644 (file)
--- a/src/sp-metrics.cpp
+++ b/src/sp-metrics.cpp
case SP_IN:
src = IN_PER_IN;
break;
+ case SP_FT:
+ src = FT_PER_IN;
+ break;
case SP_PT:
src = PT_PER_IN;
break;
+ case SP_PC:
+ src = PC_PER_IN;
+ break;
case SP_PX:
src = PX_PER_IN;
break;
case SP_IN:
dst = IN_PER_IN;
break;
+ case SP_FT:
+ dst = FT_PER_IN;
+ break;
case SP_PT:
dst = PT_PER_IN;
break;
+ case SP_PC:
+ dst = PC_PER_IN;
+ break;
case SP_PX:
dst = PX_PER_IN;
break;
diff --git a/src/svg/svg-length.cpp b/src/svg/svg-length.cpp
index f0b7f85f6dd52754aee5b1c34baf2c7a41f433a5..f909446675911d791382a4ca06d3150230760983 100644 (file)
--- a/src/svg/svg-length.cpp
+++ b/src/svg/svg-length.cpp
*unit = SVGLength::PC;
}
if (computed) {
- *computed = v * 12 * PX_PER_PT;
+ *computed = v * PX_PER_PC;
}
break;
case UVAL('m','m'):
@@ -377,6 +377,14 @@ static unsigned sp_svg_length_read_lff(gchar const *str, SVGLength::Unit *unit,
*computed = v * PX_PER_IN;
}
break;
+ case UVAL('f','t'):
+ if (unit) {
+ *unit = SVGLength::FOOT;
+ }
+ if (computed) {
+ *computed = v * PX_PER_FT;
+ }
+ break;
case UVAL('e','m'):
if (unit) {
*unit = SVGLength::EM;
diff --git a/src/svg/svg-length.h b/src/svg/svg-length.h
index 883657494e885ef3789533131493bc437f2f463e..d4e3334c660448a91ee370766ca07829634e2b22 100644 (file)
--- a/src/svg/svg-length.h
+++ b/src/svg/svg-length.h
MM,
CM,
INCH,
+ FOOT,
EM,
EX,
PERCENT
diff --git a/src/unit-constants.h b/src/unit-constants.h
index f74207cf7d054e14d307be8509eed900cfc4315d..c56c0a6e8c5e998e5f14aab98c78022becf0bc27 100644 (file)
--- a/src/unit-constants.h
+++ b/src/unit-constants.h
#define PT_PER_IN 72.0
#define PT_PER_PX DEVICESCALE
+#define PT_PER_PC 12.0
#define PX_PER_PT (1/DEVICESCALE)
+#define PX_PER_PC (PX_PER_PT * PT_PER_PC)
#define PX_PER_IN (PT_PER_IN / PT_PER_PX)
+#define PC_PER_IN (PT_PER_IN / PT_PER_PC)
#define M_PER_IN 0.0254
#define M_PER_PX (M_PER_IN / PX_PER_IN)
#define CM_PER_IN 2.54
#define IN_PER_PX (1 / PX_PER_IN)
#define IN_PER_CM (1 / CM_PER_IN)
#define IN_PER_MM (1 / MM_PER_IN)
+#define IN_PER_FT 12.0
+#define FT_PER_IN (1 / IN_PER_FT)
#define PT_PER_CM (PT_PER_IN / CM_PER_IN)
#define PX_PER_CM (PX_PER_IN / CM_PER_IN)
#define M_PER_PT (M_PER_IN / PT_PER_IN)
#define PT_PER_MM (PT_PER_IN / MM_PER_IN)
#define PX_PER_MM (PX_PER_IN / MM_PER_IN)
#define MM_PER_PX (MM_PER_IN / PX_PER_IN)
+#define PX_PER_FT (PX_PER_IN / FT_PER_IN)
#define PT_PER_PT 1.0
+#define PC_PER_PC 1.0
#define IN_PER_IN 1.0
#define PX_PER_PX 1.0
+#define FT_PER_FT 1.0
#endif /* !INKSCAPE_UNIT_CONSTANTS_H */
diff --git a/src/widgets/ruler.cpp b/src/widgets/ruler.cpp
index 597034faf92e8f480c395e6d0bb25243cc6092d8..b0037578d3c2375e7195955a145005d4f090cf57 100644 (file)
--- a/src/widgets/ruler.cpp
+++ b/src/widgets/ruler.cpp
{"millimeters", "mm", PX_PER_MM, { 1, 2, 5, 10, 25, 50, 100, 250, 500, 1000 }, { 1, 5, 10, 50, 100 }},
{"centimeters", "cm", PX_PER_CM, { 1, 2, 5, 10, 25, 50, 100, 250, 500, 1000 }, { 1, 5, 10, 50, 100 }},
{"inches", "in", PX_PER_IN, { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 }, { 1, 2, 4, 8, 16 }},
+ {"feet", "ft", PX_PER_FT, { 1, 2, 5, 10, 25, 50, 100, 250, 500, 1000 }, { 1, 5, 10, 50, 100 }},
{"points", "pt", PX_PER_PT, { 1, 2, 5, 10, 25, 50, 100, 250, 500, 1000 }, { 1, 5, 10, 50, 100 }},
+ {"picas", "pc", PX_PER_PC, { 1, 2, 5, 10, 25, 50, 100, 250, 500, 1000 }, { 1, 5, 10, 50, 100 }},
{"pixels", "px", PX_PER_PX, { 1, 2, 5, 10, 25, 50, 100, 250, 500, 1000 }, { 1, 5, 10, 50, 100 }},
- {"meters", "m", PX_PER_M, { 1, 2, 5, 10, 25, 50, 100, 250, 500, 1000 }, { 1, 5, 10, 50, 100 }},
+ {"meters", "m", PX_PER_M, { 1, 2, 5, 10, 25, 50, 100, 250, 500, 1000 }, { 1, 5, 10, 50, 100 }},
};
void
diff --git a/src/widgets/ruler.h b/src/widgets/ruler.h
index 8aa162940b34bb0f3de11fcdad2bdf75ced1d197..e2ea7c7fed4f56242edf4a36611eebd84de64740 100644 (file)
--- a/src/widgets/ruler.h
+++ b/src/widgets/ruler.h
#include <gtk/gtkruler.h>
#include "sp-metric.h"
-#include <iostream.h>
-#include <glib.h>
+#include <glib.h>
void sp_ruler_set_metric (GtkRuler * ruler, SPMetric metric);