cosmetics

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21749 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2007-11-23 22:15:17 +00:00
parent f0230e1d9a
commit c610af7ccd
8 changed files with 47 additions and 54 deletions

View File

@ -822,8 +822,8 @@ string const GuiExternal::readBB(string const & file)
graphics::Image const * image = gc.item(abs_file)->image();
if (image) {
width = image->getWidth();
height = image->getHeight();
width = image->width();
height = image->height();
}
}

View File

@ -710,22 +710,22 @@ void GuiGraphics::applyView()
void GuiGraphics::getBB()
{
string const fn = fromqstr(filename->text());
if (!fn.empty()) {
string const bb = readBB(fn);
if (!bb.empty()) {
lbX->setText(toqstr(token(bb, ' ', 0)));
lbY->setText(toqstr(token(bb, ' ', 1)));
rtX->setText(toqstr(token(bb, ' ', 2)));
rtY->setText(toqstr(token(bb, ' ', 3)));
// the default units for the bb values when reading
// it from the file
lbXunit->setCurrentIndex(0);
lbYunit->setCurrentIndex(0);
rtXunit->setCurrentIndex(0);
rtYunit->setCurrentIndex(0);
}
bbChanged = false;
}
if (fn.empty())
return;
string const bb = readBB(fn);
bbChanged = false;
if (bb.empty())
return;
lbX->setText(toqstr(token(bb, ' ', 0)));
lbY->setText(toqstr(token(bb, ' ', 1)));
rtX->setText(toqstr(token(bb, ' ', 2)));
rtY->setText(toqstr(token(bb, ' ', 3)));
// the default units for the bb values when reading
// it from the file
lbXunit->setCurrentIndex(0);
lbYunit->setCurrentIndex(0);
rtXunit->setCurrentIndex(0);
rtYunit->setCurrentIndex(0);
}
@ -795,8 +795,8 @@ string const GuiGraphics::readBB(string const & file)
graphics::Image const * image = gc.item(abs_file)->image();
if (image) {
width = image->getWidth();
height = image->getHeight();
width = image->width();
height = image->height();
}
}

View File

@ -125,13 +125,13 @@ Image * GuiImage::clone() const
}
unsigned int GuiImage::getWidth() const
unsigned int GuiImage::width() const
{
return transformed_.width();
}
unsigned int GuiImage::getHeight() const
unsigned int GuiImage::height() const
{
return transformed_.height();
}
@ -252,15 +252,13 @@ void GuiImage::scale(Params const & params)
if (transformed_.isNull())
return;
unsigned int width;
unsigned int height;
boost::tie(width, height) = getScaledDimensions(params);
Dimension dim = scaledDimension(params);
if (width == getWidth() && height == getHeight())
if (dim.width() == width() && dim.height() == height())
return;
QMatrix m;
m.scale(double(width) / getWidth(), double(height) / getHeight());
m.scale(double(dim.width()) / width(), double(dim.height()) / height());
transformed_ = transformed_.transformed(m);
}

View File

@ -40,9 +40,9 @@ private:
/// Create a copy
virtual Image * clone() const;
/// Get the image width
virtual unsigned int getWidth() const;
virtual unsigned int width() const;
/// Get the image height
virtual unsigned int getHeight() const;
virtual unsigned int height() const;
// FIXME Is the image drawable ?
virtual bool isDrawable() const { return true; }
/**

View File

@ -28,26 +28,22 @@ boost::function<Image *()> Image::newImage;
boost::function<Image::FormatList()> Image::loadableFormats;
std::pair<unsigned int, unsigned int>
Image::getScaledDimensions(Params const & params) const
Dimension Image::scaledDimension(Params const & params) const
{
// scale only when value > 0
unsigned int width;
unsigned int height;
unsigned int w = width();
unsigned int h = height();
if (params.scale) {
width = (getWidth() * params.scale) / 100;
height = (getHeight() * params.scale) / 100;
} else {
width = getWidth();
height = getHeight();
w = (w * params.scale) / 100;
h = (h * params.scale) / 100;
}
LYXERR(Debug::GRAPHICS, "graphics::Image::getScaledDimensions()"
<< "\n\tparams.scale : " << params.scale
<< "\n\twidth : " << width
<< "\n\theight : " << height);
<< "\n\twidth : " << w
<< "\n\theight : " << h);
return std::make_pair(width, height);
return Dimension(w, h, 0);
}
} // namespace graphics

View File

@ -24,11 +24,12 @@
#ifndef GRAPHICSIMAGE_H
#define GRAPHICSIMAGE_H
#include "Dimension.h"
#include <boost/function.hpp>
#include <boost/signal.hpp>
#include <vector>
#include <utility>
namespace lyx {
@ -57,10 +58,10 @@ public:
virtual Image * clone() const = 0;
/// Get the image width
virtual unsigned int getWidth() const = 0;
virtual unsigned int width() const = 0;
/// Get the image height
virtual unsigned int getHeight() const = 0;
virtual unsigned int height() const = 0;
/// Is the image drawable ?
virtual bool isDrawable() const = 0;
@ -100,11 +101,10 @@ protected:
Image(Image const &) {}
/** Uses the params to ascertain the dimensions of the scaled image.
* Returned as make_pair(width, height).
* If something goes wrong, returns make_pair(getWidth(), getHeight())
* Returned as Dimension(width, height, 0 descend).
* If something goes wrong, returns make_pair(getWidth(), getHeight(), 0)
*/
std::pair<unsigned int, unsigned int>
getScaledDimensions(Params const & params) const;
Dimension scaledDimension(Params const & params) const;
};

View File

@ -80,7 +80,7 @@ int PreviewImage::ascent() const
if (!image)
return 0;
return int(pimpl_->ascent_frac_ * double(image->getHeight()));
return int(pimpl_->ascent_frac_ * double(image->height()));
}
@ -91,14 +91,14 @@ int PreviewImage::descent() const
return 0;
// Avoids rounding errors.
return image->getHeight() - ascent();
return image->height() - ascent();
}
int PreviewImage::width() const
{
Image const * const image = pimpl_->iloader_.image();
return image ? image->getWidth() : 0;
return image ? image->width() : 0;
}

View File

@ -132,12 +132,11 @@ void RenderGraphic::metrics(MetricsInfo & mi, Dimension & dim) const
{
bool image_ready = displayGraphic(params_) && readyToDisplay(loader_);
dim.asc = image_ready ? loader_.image()->getHeight() : 50;
dim.asc = image_ready ? loader_.image()->height() : 50;
dim.des = 0;
if (image_ready) {
dim.wid = loader_.image()->getWidth() +
2 * Inset::TEXT_TO_INSET_OFFSET;
dim.wid = loader_.image()->width() + 2 * Inset::TEXT_TO_INSET_OFFSET;
} else {
int font_width = 0;