]> git.lyx.org Git - lyx.git/blobdiff - src/graphics/GraphicsImage.C
* filetools.[Ch]: Make functions that start with a capital
[lyx.git] / src / graphics / GraphicsImage.C
index 6e7c8300aa3ea84cca7507debcf9b56c3e18f1eb..b1d7e60707e09c7e39ad530fa73640e149d05806 100644 (file)
@@ -1,59 +1,56 @@
-/*
+/**
  * \file GraphicsImage.C
- * Copyright 2002 the LyX Team
- * Read the file COPYING
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- * \author Baruch Even <baruch.even@writeme.com>
- * \author Angus Leeming <a.leeming@ic.ac.uk>
+ * \author Baruch Even
+ * \author Angus Leeming
+ * \author Herbert Voß
+ *
+ * Full author contact details are available in file CREDITS.
  */
 
 #include <config.h>
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
 #include "GraphicsImage.h"
 #include "GraphicsParams.h"
-#include <iostream>
+#include "debug.h"
+
 
-namespace grfx {
+namespace lyx {
+namespace graphics {
 
-// This will be connected to a function that will return whichever
-// whichever derived class we desire.
-SigC::Signal0<ImagePtr> GImage::newImage;
+// This is to be connected to a function that will return a new
+// instance of a viable derived class.
+boost::function<Image::ImagePtr()> Image::newImage;
 
 /// Return the list of loadable formats.
-SigC::Signal0<GImage::FormatList> GImage::loadableFormats;
+boost::function<Image::FormatList()> Image::loadableFormats;
+
 
 std::pair<unsigned int, unsigned int>
-GImage::getScaledDimensions(GParams const & params) const
+Image::getScaledDimensions(Params const & params) const
 {
-       if (params.scale == 0 && params.width == 0 && params.height == 0)
-               // No scaling
-               return std::make_pair(getWidth(), getHeight());
-
-       unsigned int width  = 0;
-       unsigned int height = 0;
-       if (params.scale != 0) {
-               width  = getWidth()  * params.scale / 100.0;
-               height = getHeight() * params.scale / 100.0;
+       // scale only when value > 0
+       unsigned int width;
+       unsigned int height;
+       if (params.scale) {
+               width  = (getWidth() * params.scale) / 100;
+               height = (getHeight() * params.scale) / 100;
        } else {
-               width  = params.width;
-               height = params.height;
-
-               if (width == 0) {
-                       width = height * getWidth() / getHeight();
-               } else if (height == 0) {
-                       height = width * getHeight() / getWidth();
-               }
+               width = getWidth();
+               height = getHeight();
        }
-       
-       if (width == 0 || height == 0)
-               // Something is wrong!
-               return std::make_pair(getWidth(), getHeight());
+
+       lyxerr[Debug::GRAPHICS]
+               << "GraphicsImage::getScaledDImensions()"
+               << "\n\tparams.scale       : " << params.scale
+               << "\n\twidth              : " << width
+               << "\n\theight             : " << height
+               << std::endl;
 
        return std::make_pair(width, height);
 }
-} // namespace grfx
 
+} // namespace graphics
+} // namespace lyx