namespace {
-#if 0
-/* length units
- */
-
-int const num_units = LyXLength::UNIT_NONE;
-
-// I am not sure if "mu" should be possible to select (Lgb)
-char const * unit_name[num_units] = { "sp", "pt", "bp", "dd",
- "mm", "pc", "cc", "cm",
- "in", "ex", "em", "mu",
- "%", "c%", "p%", "l%" };
-
-
-/* The following static items form a simple scanner for
- * length strings, used by isValid[Glue]Length. See comments there.
- */
-double number[4] = { 0, 0, 0, 0 };
-LyXLength::UNIT unit[4] = { LyXLength::UNIT_NONE,
- LyXLength::UNIT_NONE,
- LyXLength::UNIT_NONE,
- LyXLength::UNIT_NONE };
-int number_index;
-int unit_index;
-
-LyXLength::UNIT unitFromString(string const & data)
-{
- int i = 0;
- while (i < num_units && data != unit_name[i])
- ++i;
- return static_cast<LyXLength::UNIT>(i);
-}
-
-#endif
double number[4] = { 0, 0, 0, 0 };
LyXLength::UNIT unit[4] = { LyXLength::UNIT_NONE,
LyXLength::UNIT_NONE,
{
// Height of a normal line in pixels (zoom factor considered)
int default_height = bv->text->defaultHeight(); // [pixels]
- int default_skip = 0;
int default_width = bv->workWidth();
- if (kind_ == DEFSKIP)
- default_skip = bv->buffer()->params.getDefSkip().inPixels(bv);
-
- // Height of a normal line in pixels (zoom factor considered)
- int height = default_height; // [pixels]
-
- // Zoom factor specified by user in percent
- double const zoom = lyxrc.zoom / 100.0; // [percent]
-
- // DPI setting for monitor: pixels/inch
- double const dpi = lyxrc.dpi; // screen resolution [pixels/inch]
-
- // We want the result in pixels
- double result;
- double value;
-
switch (kind_) {
case NONE:
return 0;
-
case DEFSKIP:
- return default_skip;
+ return bv->buffer()->params.getDefSkip().inPixels(bv);
// This is how the skips are normally defined by
// LateX. But there should be some way to change
// this per document.
- case SMALLSKIP: return height / 4;
- case MEDSKIP: return height / 2;
- case BIGSKIP: return height;
- case VFILL: return 3 * height;
+ case SMALLSKIP:
+ return default_height / 4;
+ case MEDSKIP:
+ return default_height / 2;
+ case BIGSKIP:
+ return default_height;
+
+ case VFILL:
// leave space for the vfill symbol
+ return 3 * default_height;
case LENGTH:
- // Pixel values are scaled so that the ratio
- // between lengths and font sizes on the screen
- // is the same as on paper.
-
- // we don't care about sign of value, we
- // display negative space with text too
- result = 0.0;
- value = len_.len().value();
- int val_sign = value < 0.0 ? -1 : 1;
-
- switch (len_.len().unit()) {
- case LyXLength::SP:
- // Scaled point: sp = 1/65536 pt
- result = zoom * dpi * value
- / (72.27 * 65536); // 4736286.7
- break;
- case LyXLength::PT:
- // Point: 1 pt = 1/72.27 inch
- result = zoom * dpi * value
- / 72.27; // 72.27
- break;
- case LyXLength::BP:
- // Big point: 1 bp = 1/72 inch
- result = zoom * dpi * value
- / 72; // 72
- break;
- case LyXLength::DD:
- // Didot: 1157dd = 1238 pt?
- result = zoom * dpi * value
- / (72.27 / (0.376 * 2.845)); // 67.559735
- break;
- case LyXLength::MM:
- // Millimeter: 1 mm = 1/25.4 inch
- result = zoom * dpi * value
- / 25.4; // 25.4
- break;
- case LyXLength::PC:
- // Pica: 1 pc = 12 pt
- result = zoom * dpi * value
- / (72.27 / 12); // 6.0225
- break;
- case LyXLength::CC:
- // Cicero: 1 cc = 12 dd
- result = zoom * dpi * value
- / (72.27 / (12 * 0.376 * 2.845)); // 5.6299779
- break;
- case LyXLength::CM:
- // Centimeter: 1 cm = 1/2.54 inch
- result = zoom * dpi * value
- / 2.54; // 2.54
- break;
- case LyXLength::IN:
- // Inch
- result = zoom * dpi * value;
- break;
- case LyXLength::EX:
- // Ex: The height of an "x"
- result = zoom * value * height / 2; // what to / width?
- break;
- case LyXLength::EM: // what to / width?
- // Em: The width of an "m"
- result = zoom * value * height / 2; // Why 2?
- break;
- case LyXLength::MU: // This is probably only allowed in
- // math mode
- result = zoom * value * height;
- break;
- case LyXLength::PW: // Always % of workarea
- case LyXLength::PE:
- case LyXLength::PP:
- case LyXLength::PL:
- result = value * default_width / 100;
- break;
- case LyXLength::UNIT_NONE:
- result = 0; // this cannot happen
- break;
- }
- return static_cast<int>(result * val_sign + 0.5);
+ return len_.len().inPixels(default_width, default_height);
}
- return 0; // never reached
}