if (style.pass_thru ||
(!insertInset(new InsetQuotes(c, bv_->buffer()->params))))
- Dispatch(LFUN_SELFINSERT, "\"");
+ bv_->owner()->getLyXFunc()->dispatch(LFUN_SELFINSERT, "\"");
}
+2002-01-17 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
+
+ * buffer.C (parseSingleLyXformat2Token): update because minipage
+ width is now a LyXLength
+
+ * lyxlength.C (inPixels): new method, extracted from VSpace::inPixels
+
+ * BufferView_pimpl.C (smartQuote): fix insertion of quote inset in
+ math insets
+
2002-01-17 Juergen Vigna <jug@sad.it>
* lyxfunc.C (dispatch): fixed PARAGRAPH_GOTO
}
InsetMinipage * mini = new InsetMinipage;
mini->pos(static_cast<InsetMinipage::Position>(par->params().pextraAlignment()));
- mini->pageWidth(par->params().pextraWidth());
+ mini->pageWidth(LyXLength(par->params().pextraWidth()));
if (!par->params().pextraWidthp().empty()) {
- lyxerr << "WP:" << mini->pageWidth() << endl;
- mini->pageWidth(tostr(par->params().pextraWidthp())+"%");
+ lyxerr << "WP:" << mini->pageWidth().asString() << endl;
+ mini->pageWidth(LyXLength((par->params().pextraWidthp())+"%"));
}
Paragraph * op = mini->firstParagraph();
mini->inset.paragraph(par);
InsetMinipage * mini = new InsetMinipage;
mini->pos(static_cast<InsetMinipage::Position>(minipar->params().pextraAlignment()));
- mini->pageWidth(minipar->params().pextraWidth());
+ mini->pageWidth(LyXLength(minipar->params().pextraWidth()));
if (!par->params().pextraWidthp().empty()) {
- lyxerr << "WP:" << mini->pageWidth() << endl;
- mini->pageWidth(tostr(par->params().pextraWidthp())+"%");
+ lyxerr << "WP:" << mini->pageWidth().asString() << endl;
+ mini->pageWidth(LyXLength((par->params().pextraWidthp())+"%"));
}
mini->inset.paragraph(minipar);
2002-01-17 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
+ * ControlMinipage.h: change MinipageParams::pageWidth to LyXLength
+
* ControlExternal.C (Browse): add a std:: qualifier
2002-01-16 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
///
MinipageParams(InsetMinipage const &);
///
- string pageWidth;
+ LyXLength pageWidth;
///
InsetMinipage::Position pos;
};
+2002-01-17 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
+
+ * FormMinipage.C (apply): change because MinipageParams::pageWidth
+ is now a real LyXLength
+
2002-01-17 John Levon <moz@compsoc.man.ac.uk>
* FormDocument.C: enable line spacing input properly
void FormMinipage::apply()
{
controller().params().pageWidth =
- getLengthFromWidgets(dialog_->input_width,
- dialog_->choice_width_units);
+ LyXLength(getLengthFromWidgets(dialog_->input_width,
+ dialog_->choice_width_units));
if (fl_get_button(dialog_->radio_top))
controller().params().pos = InsetMinipage::top;
+2002-01-17 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
+
+ * insettabular.C (getMaxWidthOfCell): use LyXLength::inPixels
+
+ * insetminipage.[Ch]: change width_ and height_ to be LyXLength
+ instead of string
+
2002-01-17 Juergen Vigna <jug@sad.it>
* insettabular.C (lockInsetInInset): same change as in insettext.
InsetMinipage::InsetMinipage()
: InsetCollapsable(), pos_(center),
- inner_pos_(inner_center)
+ inner_pos_(inner_center), width_(100, LyXLength::PW)
{
setLabel(_("minipage"));
LyXFont font(LyXFont::ALL_SANE);
setBackgroundColor(LColor::green);
inset.setFrameColor(0, LColor::blue);
setInsetName("Minipage");
- width_ = "100%"; // set default to 100% of column_width
}
os << getInsetName() << "\n"
<< "position " << pos_ << "\n"
<< "inner_position " << inner_pos_ << "\n"
- << "height \"" << height_ << "\"\n"
- << "width \"" << width_ << "\"\n";
+ << "height \"" << height_.asString() << "\"\n"
+ << "width \"" << width_.asString() << "\"\n";
InsetCollapsable::write(buf, os);
}
string const token = lex.getString();
if (token == "height") {
lex.next();
- height_ = lex.getString();
+ height_ = LyXLength(lex.getString());
} else {
lyxerr << "InsetMinipage::Read: Missing 'height'-tag!"
<< endl;
string const token = lex.getString();
if (token == "width") {
lex.next();
- width_ = lex.getString();
+ width_ = LyXLength(lex.getString());
} else {
lyxerr << "InsetMinipage::Read: Missing 'width'-tag!"
<< endl;
break;
}
os << "\\begin{minipage}[" << s_pos << "]{"
- << LyXLength(width_).asLatexString() << "}%\n";
+ << width_.asLatexString() << "}%\n";
int i = inset.latex(buf, os, fragile, fp);
}
-string const & InsetMinipage::pageHeight() const
+LyXLength const & InsetMinipage::pageHeight() const
{
return height_;
}
-void InsetMinipage::pageHeight(string const & ll)
+void InsetMinipage::pageHeight(LyXLength const & ll)
{
if (height_ != ll) {
height_ = ll;
}
-string const & InsetMinipage::pageWidth() const
+LyXLength const & InsetMinipage::pageWidth() const
{
return width_;
}
-void InsetMinipage::pageWidth(string const & ll)
+void InsetMinipage::pageWidth(LyXLength const & ll)
{
if (ll != width_) {
width_ = ll;
{
return -1;
}
- if (!width_.empty()) {
- LyXLength len(width_);
- switch(len.unit()) {
+ if (!width_.zero()) {
+ switch(width_.unit()) {
case LyXLength::PW: // Always % of workarea
case LyXLength::PE:
case LyXLength::PP:
case LyXLength::PL:
- return (InsetCollapsable::getMaxWidth(bv, inset) * (int)len.value()) / 100;
+ return (InsetCollapsable::getMaxWidth(bv, inset) * (int)width_.value()) / 100;
default:
{
- int ww1 = VSpace(width_).inPixels(bv);
+ int ww1 = width_.inPixels(bv);
int ww2 = InsetCollapsable::getMaxWidth(bv, inset);
if (ww2 > 0 && ww2 < ww1) {
return ww2;
#endif
#include "insetcollapsable.h"
-#include "vspace.h"
+#include "lyxlength.h"
#include <sigc++/signal_system.h>
/** The minipage inset
///
void innerPos(InnerPosition);
///
- string const & pageHeight() const;
+ LyXLength const & pageHeight() const;
///
- void pageHeight(string const &);
+ void pageHeight(LyXLength const &);
///
- string const & pageWidth() const;
+ LyXLength const & pageWidth() const;
///
- void pageWidth(string const &);
+ void pageWidth(LyXLength const &);
///
SigC::Signal0<void> hideDialog;
///
///
InnerPosition inner_pos_;
///
- string height_;
+ LyXLength height_;
///
- string width_;
+ LyXLength width_;
};
#endif
if (len.zero())
return -1;
-#ifdef WITH_WARNINGS
-#warning Remove use of VSpace as soon as LyXLength::inPixels exists (JMarc)
-#endif
- return VSpace(len).inPixels(bv);
+ return len.inPixels(bv);
}
#include "lyxlength.h"
#include "lengthcommon.h"
+#include "lyxrc.h"
+#include "BufferView.h"
+#include "lyxtext.h"
#include "Lsstream.h"
}
+int LyXLength::inPixels(BufferView const * bv) const
+{
+ // Height of a normal line in pixels (zoom factor considered)
+ int height = bv->text->defaultHeight(); // [pixels]
+ int default_width = bv->workWidth();
+
+ // 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]
+
+ // 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
+ double result = 0.0;
+ int val_sign = val_ < 0.0 ? -1 : 1;
+
+ switch (unit_) {
+ case LyXLength::SP:
+ // Scaled point: sp = 1/65536 pt
+ result = zoom * dpi * val_
+ / (72.27 * 65536); // 4736286.7
+ break;
+ case LyXLength::PT:
+ // Point: 1 pt = 1/72.27 inch
+ result = zoom * dpi * val_
+ / 72.27; // 72.27
+ break;
+ case LyXLength::BP:
+ // Big point: 1 bp = 1/72 inch
+ result = zoom * dpi * val_
+ / 72; // 72
+ break;
+ case LyXLength::DD:
+ // Didot: 1157dd = 1238 pt?
+ result = zoom * dpi * val_
+ / (72.27 / (0.376 * 2.845)); // 67.559735
+ break;
+ case LyXLength::MM:
+ // Millimeter: 1 mm = 1/25.4 inch
+ result = zoom * dpi * val_
+ / 25.4; // 25.4
+ break;
+ case LyXLength::PC:
+ // Pica: 1 pc = 12 pt
+ result = zoom * dpi * val_
+ / (72.27 / 12); // 6.0225
+ break;
+ case LyXLength::CC:
+ // Cicero: 1 cc = 12 dd
+ result = zoom * dpi * val_
+ / (72.27 / (12 * 0.376 * 2.845)); // 5.6299779
+ break;
+ case LyXLength::CM:
+ // Centimeter: 1 cm = 1/2.54 inch
+ result = zoom * dpi * val_
+ / 2.54; // 2.54
+ break;
+ case LyXLength::IN:
+ // Inch
+ result = zoom * dpi * val_;
+ break;
+ case LyXLength::EX:
+ // Ex: The height of an "x"
+ result = zoom * val_ * height / 2; // what to / width?
+ break;
+ case LyXLength::EM: // what to / width?
+ // Em: The width of an "m"
+ result = zoom * val_ * height / 2; // Why 2?
+ break;
+ case LyXLength::MU: // This is probably only allowed in
+ // math mode
+ result = zoom * val_ * height;
+ break;
+ case LyXLength::PW: // Always % of workarea
+ case LyXLength::PE:
+ case LyXLength::PP:
+ case LyXLength::PL:
+ result = val_ * default_width / 100;
+ break;
+ case LyXLength::UNIT_NONE:
+ result = 0; // this cannot happen
+ break;
+ }
+ return static_cast<int>(result * val_sign + 0.5);
+}
+
+
bool operator==(LyXLength const & l1, LyXLength const & l2)
{
return l1.value() == l2.value() && l1.unit() == l2.unit();
#include "LString.h"
+class BufferView;
+
//
/// LyXLength Class
//
string const asString() const;
///
string const asLatexString() const;
+ ///
+ int inPixels(BufferView const * bv) const;
/** If "data" is valid, the length represented by it is
stored into "result", if that is not 0. */
case VFILL: return 3 * height;
// leave space for the vfill symbol
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(bv);
}
return 0; // never reached
}