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
This commit is contained in:
Angus Leeming 2003-12-04 16:53:53 +00:00
parent 8fa8cfb4a3
commit bc045d9320
4 changed files with 48 additions and 8 deletions

View File

@ -1,3 +1,10 @@
2003-12-04 Angus Leeming <leeming@lyx.org>
* 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 <poenitz@gmx.net>

View File

@ -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();

View File

@ -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
*/

View File

@ -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);
}