graphics::Image const * image = gc.item(abs_file)->image();
if (image) {
- width = image->getWidth();
- height = image->getHeight();
+ width = image->width();
+ height = image->height();
}
}
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);
}
graphics::Image const * image = gc.item(abs_file)->image();
if (image) {
- width = image->getWidth();
- height = image->getHeight();
+ width = image->width();
+ height = image->height();
}
}
}
-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();
}
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);
}
/// 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; }
/**
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
#ifndef GRAPHICSIMAGE_H
#define GRAPHICSIMAGE_H
+#include "Dimension.h"
+
#include <boost/function.hpp>
#include <boost/signal.hpp>
#include <vector>
-#include <utility>
namespace lyx {
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;
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;
};
if (!image)
return 0;
- return int(pimpl_->ascent_frac_ * double(image->getHeight()));
+ return int(pimpl_->ascent_frac_ * double(image->height()));
}
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;
}
{
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;