]> git.lyx.org Git - features.git/commitdiff
cosmetics
authorAndré Pönitz <poenitz@gmx.net>
Fri, 23 Nov 2007 22:15:17 +0000 (22:15 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Fri, 23 Nov 2007 22:15:17 +0000 (22:15 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21749 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiExternal.cpp
src/frontends/qt4/GuiGraphics.cpp
src/frontends/qt4/GuiImage.cpp
src/frontends/qt4/GuiImage.h
src/graphics/GraphicsImage.cpp
src/graphics/GraphicsImage.h
src/graphics/PreviewImage.cpp
src/insets/RenderGraphic.cpp

index 10d4f35670cd90dca0ee267c82b75df472551ffc..b053b064e03768bf77a18d5455fc40dbd6809dd7 100644 (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();
                }
        }
 
index 2170c7f35fac7a9fbc74ce61cde183b0abfaf7a1..a263d8f07c26413d945bb3c7c6d56f0e0f7a031f 100644 (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();
                }
        }
 
index c5c870a62198870cf00be5278b333997600feefe..446bdcad223cbf8357cb79dfb2a14c01b0e15d85 100644 (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);
 }
 
index e88af055e4f26a2684a9d76e12a464ebf4e6516d..675053619fc98a832198d3f2ec3b8bfb79961b37 100644 (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; }
        /**
index b1abf942db7d9e9c65d8b7fa354dc3968c313610..f4ccf9edc4d5141ea1f22767f14375edeaca1e6f 100644 (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
index 6b25f6505250005080f77f37f240a57aac3e9f14..08dfd40391ac9d18ef432c9088628a84f0eaee9a 100644 (file)
 #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;
 };
 
 
index 02af7c470a7239c2297afbf34907a626aae901ca..47b30a4d339e1e43f7f78f6f0078c6cc8e3ba3bb 100644 (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;
 }
 
 
index 74e31819896d852e598eb5adeac67b9afe95733c..60ca378ba5aa40d17333952446220e4592eadd83 100644 (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;