]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/xformsImage.C
Introduce LFUN_PRINT.
[lyx.git] / src / frontends / xforms / xformsImage.C
index d32f08270bbfd8437311f0a61da1df1d21ed37e9..bdb98f49cdfdc7537edc578bf38c9cfcd2bcaa15 100644 (file)
@@ -5,19 +5,23 @@
  *
  * \author Angus Leeming
  *
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
  */
 
 #include <config.h>
 
-
 #include "xformsImage.h"
-#include "graphics/GraphicsParams.h"
 #include "Color.h"
-#include "format.h"
+
 #include "debug.h"
-#include "support/LAssert.h"
+#include "format.h"
+#include "LColor.h"
+
+#include "graphics/GraphicsParams.h"
+
+#include "support/lstrings.h"
 #include "support/lyxfunctional.h"  // compare_memfun
+#include "support/lyxlib.h"
 
 #include "lyx_forms.h"
 
 
 #include <boost/tuple/tuple.hpp>
 
+
+using lyx::support::float_equal;
+using lyx::support::prefixIs;
+using lyx::support::rtrim;
+
 using std::find_if;
+using std::string;
+
 
 namespace {
 
@@ -42,7 +53,8 @@ unsigned int packedcolor(LColor::color c);
 } // namespace anon
 
 
-namespace grfx {
+namespace lyx {
+namespace graphics {
 
 /// Access to this class is through this static method.
 Image::ImagePtr xformsImage::newImage()
@@ -141,13 +153,21 @@ xformsImage::~xformsImage()
 }
 
 
-Image * xformsImage::clone() const
+Pixmap xformsImage::getPixmap() const
+{
+       if (!pixmap_status_ == PIXMAP_SUCCESS)
+               return 0;
+       return pixmap_;
+}
+
+
+Image * xformsImage::clone_impl() const
 {
        return new xformsImage(*this);
 }
 
 
-unsigned int xformsImage::getWidth() const
+unsigned int xformsImage::getWidth_impl() const
 {
        if (!image_)
                return 0;
@@ -156,7 +176,7 @@ unsigned int xformsImage::getWidth() const
 }
 
 
-unsigned int xformsImage::getHeight() const
+unsigned int xformsImage::getHeight_impl() const
 {
        if (!image_)
                return 0;
@@ -164,21 +184,13 @@ unsigned int xformsImage::getHeight() const
 }
 
 
-bool xformsImage::isDrawable() const
+bool xformsImage::isDrawable_impl() const
 {
        return pixmap_;
 }
 
 
-Pixmap xformsImage::getPixmap() const
-{
-       if (!pixmap_status_ == PIXMAP_SUCCESS)
-               return 0;
-       return pixmap_;
-}
-
-
-void xformsImage::load(string const & filename)
+void xformsImage::load_impl(string const & filename)
 {
        if (image_) {
                lyxerr[Debug::GRAPHICS]
@@ -206,7 +218,7 @@ void xformsImage::load(string const & filename)
 }
 
 
-bool xformsImage::setPixmap(Params const & params)
+bool xformsImage::setPixmap_impl(Params const & params)
 {
        if (!image_ || params.display == NoDisplay)
                return false;
@@ -253,7 +265,7 @@ bool xformsImage::setPixmap(Params const & params)
 }
 
 
-void xformsImage::clip(Params const & params)
+void xformsImage::clip_impl(Params const & params)
 {
        if (!image_)
                return;
@@ -291,12 +303,12 @@ void xformsImage::clip(Params const & params)
 }
 
 
-void xformsImage::rotate(Params const & params)
+void xformsImage::rotate_impl(Params const & params)
 {
        if (!image_)
                return ;
 
-       if (lyx::float_equal(params.angle, 0.0, 0.1))
+       if (float_equal(params.angle, 0.0, 0.1))
                // No rotation is necessary.
                return;
 
@@ -306,7 +318,7 @@ void xformsImage::rotate(Params const & params)
        // Work around xforms bug when params.angle == 270
        // the 'InternalError: bad special angle' error.
        // This bug fix is not needed in xforms 1.0 and greater.
-       if (lyx::float_equal(params.angle, 270.0, 0.1)) {
+       if (float_equal(params.angle, 270.0, 0.1)) {
                flimage_rotate(image_,  900, FLIMAGE_SUBPIXEL);
                flimage_rotate(image_, 1800, FLIMAGE_SUBPIXEL);
        } else {
@@ -317,7 +329,7 @@ void xformsImage::rotate(Params const & params)
 }
 
 
-void xformsImage::scale(Params const & params)
+void xformsImage::scale_impl(Params const & params)
 {
        if (!image_)
                return;
@@ -361,7 +373,8 @@ void xformsImage::errorCB(string const & error_message)
        finishedLoading(false);
 }
 
-} // namespace grfx
+} // namespace graphics
+} // namespace lyx
 
 
 namespace {
@@ -370,7 +383,7 @@ extern "C" {
 
 int status_report(FL_IMAGE * ob, const char *s)
 {
-       lyx::Assert(ob && ob->u_vdata);
+       BOOST_ASSERT(ob && ob->u_vdata);
 
        string const str = s ? rtrim(s) : string();
        if (str.empty())
@@ -379,8 +392,8 @@ int status_report(FL_IMAGE * ob, const char *s)
        lyxerr[Debug::GRAPHICS]
                << "xforms image loader. Status: " << str << std::endl;
 
-       grfx::xformsImage * ptr =
-               static_cast<grfx::xformsImage *>(ob->u_vdata);
+       lyx::graphics::xformsImage * ptr =
+               static_cast<lyx::graphics::xformsImage *>(ob->u_vdata);
        ptr->statusCB(str);
 
        return 0;
@@ -389,7 +402,7 @@ int status_report(FL_IMAGE * ob, const char *s)
 
 static void error_report(FL_IMAGE * ob, const char *s)
 {
-       lyx::Assert(ob && ob->u_vdata);
+       BOOST_ASSERT(ob && ob->u_vdata);
 
        string const str = s ? rtrim(s) : string();
        if (str.empty())
@@ -398,8 +411,8 @@ static void error_report(FL_IMAGE * ob, const char *s)
        lyxerr[Debug::GRAPHICS]
                << "xforms image loader. Error: " << str << std::endl;
 
-       grfx::xformsImage * ptr =
-               static_cast<grfx::xformsImage *>(ob->u_vdata);
+       lyx::graphics::xformsImage * ptr =
+               static_cast<lyx::graphics::xformsImage *>(ob->u_vdata);
        ptr->errorCB(str);
 }
 
@@ -457,7 +470,7 @@ unsigned int packedcolor(LColor::color col)
        bool const success = getRGBColor(col, r, g, b);
        if (!success)
                // Set to black on failure
-               return FL_PACK(255,255,255);
+               return FL_PACK(255, 255, 255);
 
        return FL_PACK(r, g, b);
 }