From bc045d9320859d700c50c9cd4498d147c60cfc30 Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Thu, 4 Dec 2003 16:53:53 +0000 Subject: [PATCH] Enable InsetExternal to be hit by the mouse once again. Some small additions to the ExternalTransforms stuff. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8193 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/ChangeLog | 7 +++++++ src/insets/ExternalTransforms.C | 33 +++++++++++++++++++++++++-------- src/insets/ExternalTransforms.h | 14 ++++++++++++++ src/insets/insetexternal.C | 2 ++ 4 files changed, 48 insertions(+), 8 deletions(-) diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index b7d20cd6d7..ca399e2b90 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,10 @@ +2003-12-04 Angus Leeming + + * insetexternal.C (draw): update the xo_, yo_ cache. + + * ExternalTransforms.[Ch] (ResizeData): add a usingScale member function. + (RotationDataType): new helper struct wrapping the + RotationData::OriginType enum. 2003-12-03 André Pönitz diff --git a/src/insets/ExternalTransforms.C b/src/insets/ExternalTransforms.C index 9d77c37d2e..05b66b7b05 100644 --- a/src/insets/ExternalTransforms.C +++ b/src/insets/ExternalTransforms.C @@ -45,8 +45,13 @@ void ExtraData::set(string const & id, string const & data) bool ResizeData::no_resize() const { - return float_equal(scale, 0.0, 0.05) && - width.zero() && height.zero(); + return !usingScale() && width.zero() && height.zero(); +} + + +bool ResizeData::usingScale() const +{ + return !float_equal(scale, 0.0, 0.05); } @@ -90,15 +95,27 @@ string const ResizeLatexCommand::front_impl() const return string(); std::ostringstream os; - if (!float_equal(data.scale, 0.0, 0.05)) { + if (data.usingScale()) { double const scl = data.scale / 100.0; os << "\\scalebox{" << scl << "}{" << scl << "}{"; } else { + string width = "!"; + string height = "!"; + if (data.keepAspectRatio) { + if (data.width.inPixels(10) > data.height.inPixels(10)) + width = data.width.asLatexString(); + else + height = data.height.asLatexString(); + } else { + if (!data.width.zero()) + width = data.width.asLatexString(); + if (!data.height.zero()) + height = data.height.asLatexString(); + } + os << "\\resizebox{" - << (data.width.zero() ? - "!" : data.width.asLatexString()) << "}{" - << (data.height.zero() ? - "!" : data.height.asLatexString()) << "}{"; + << width << "}{" + << height << "}{"; } return os.str(); } @@ -210,7 +227,7 @@ string const ResizeLatexOption::option_impl() const return string(); std::ostringstream os; - if (!float_equal(data.scale, 0.0, 0.05)) { + if (data.usingScale()) { if (!float_equal(data.scale, 100.0, 0.05)) os << "scale=" << data.scale / 100.0 << ','; return os.str(); diff --git a/src/insets/ExternalTransforms.h b/src/insets/ExternalTransforms.h index 9275759c58..f5ea527a7c 100644 --- a/src/insets/ExternalTransforms.h +++ b/src/insets/ExternalTransforms.h @@ -59,6 +59,8 @@ public: ResizeData() : scale(0), keepAspectRatio(false) {} bool no_resize() const; + bool usingScale() const; + float scale; LyXLength width; LyXLength height; @@ -100,6 +102,18 @@ private: }; +/** \c RotationDataType is a wrapper for RotationData::OriginType + * It can be forward-declared and passed as a function argument without + * having to expose this header file. + */ +class RotationDataType { + RotationData::OriginType val_; +public: + RotationDataType(RotationData::OriginType val) : val_(val) {} + operator RotationData::OriginType() const { return val_; } +}; + + /* * Transformers generating commands */ diff --git a/src/insets/insetexternal.C b/src/insets/insetexternal.C index b6239cc34b..7c7d888a2c 100644 --- a/src/insets/insetexternal.C +++ b/src/insets/insetexternal.C @@ -482,6 +482,8 @@ void InsetExternal::metrics(MetricsInfo & mi, Dimension & dim) const void InsetExternal::draw(PainterInfo & pi, int x, int y) const { + xo_ = x; + yo_ = y; renderer_->draw(pi, x, y); } -- 2.39.5