X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fgraphics%2FGraphicsImage.h;h=6722b87bc03f20637a8450dd7732b58ae5d5c69b;hb=bda45704005d6b328e18457a07d05e56883c2874;hp=7200a8ce341f0de70ffe7a67a36c3ecfcd414c08;hpb=4f0019dfd775bb701cb7e84a283717f7b210ff30;p=lyx.git diff --git a/src/graphics/GraphicsImage.h b/src/graphics/GraphicsImage.h index 7200a8ce34..6722b87bc0 100644 --- a/src/graphics/GraphicsImage.h +++ b/src/graphics/GraphicsImage.h @@ -24,186 +24,47 @@ #ifndef GRAPHICSIMAGE_H #define GRAPHICSIMAGE_H -#include "support/std_string.h" - -#include -#include -#include +namespace lyx { -#include -#include +namespace support { class FileName; } -namespace lyx { namespace graphics { class Params; class Image { public: - /** This is to be connected to a function that will return a new - * instance of a viable derived class. - */ - typedef boost::shared_ptr ImagePtr; - /// - static boost::function0 newImage; - - /// Return the list of loadable formats. - typedef std::vector FormatList; - /// - static boost::function0 loadableFormats; - /// virtual ~Image() {} /// Create a copy - Image * clone() const; + virtual Image * clone() const = 0; /// Get the image width - unsigned int getWidth() const; + virtual unsigned int width() const = 0; /// Get the image height - unsigned int getHeight() const; + virtual unsigned int height() const = 0; /// Is the image drawable ? - bool isDrawable() const; - - /** At the end of the loading process inform the outside world - * by emitting a signal. - */ - typedef boost::signal1 SignalType; - /// - SignalType finishedLoading; + virtual bool isDrawable() const = 0; /** Start loading the image file. * The caller should expect this process to be asynchronous and * so should connect to the "finished" signal above. */ - void load(string const & filename); + virtual bool load(support::FileName const & filename) = 0; /** Generate the pixmap. * Uses the params to decide on color, grayscale etc. * Returns true if the pixmap is created. */ - bool setPixmap(Params const & params); - - /// Clip the image using params. - void clip(Params const & params); - - /// Rotate the image using params. - void rotate(Params const & params); - - /// Scale the image using params. - void scale(Params const & params); - -protected: - /// Must define default c-tor explicitly as we define a copy c-tor. - Image() {} - /// Don't copy the signal finishedLoading - 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()) - */ - std::pair - getScaledDimensions(Params const & params) const; - -private: - /// Create a copy - virtual Image * clone_impl() const = 0; - /// Get the image width - virtual unsigned int getWidth_impl() const = 0; - - /// Get the image height - virtual unsigned int getHeight_impl() const = 0; - - /// is the image drawable ? - virtual bool isDrawable_impl() const = 0; - - /** Start loading the image file. - * The caller should expect this process to be asynchronous and - * so should connect to the "finished" signal above. - */ - virtual void load_impl(string const & filename) = 0; - - /** Generate the pixmap. - * Uses the params to decide on color, grayscale etc. - * Returns true if the pixmap is created. - */ - virtual bool setPixmap_impl(Params const & params) = 0; - - /// Clip the image using params. - virtual void clip_impl(Params const & params) = 0; - - /// Rotate the image using params. - virtual void rotate_impl(Params const & params) = 0; - - /// Scale the image using params. - virtual void scale_impl(Params const & params) = 0; + virtual bool setPixmap(Params const & params) = 0; }; - -inline -Image * Image::clone() const -{ - return clone_impl(); -} - - -inline -unsigned int Image::getWidth() const -{ - return getWidth_impl(); -} - - -inline -unsigned int Image::getHeight() const -{ - return getHeight_impl(); -} - - -inline -bool Image::isDrawable() const -{ - return isDrawable_impl(); -} - - -inline -void Image::load(string const & filename) -{ - return load_impl(filename); -} - - -inline -bool Image::setPixmap(Params const & params) -{ - return setPixmap_impl(params); -} - - -inline -void Image::clip(Params const & params) -{ - return clip_impl(params); -} - - -inline -void Image::rotate(Params const & params) -{ - return rotate_impl(params); -} - - -inline -void Image::scale(Params const & params) -{ - return scale_impl(params); -} +/// Only way to create a new Image. +/// Implemented in the frontend. +Image * newImage(); } // namespace graphics } // namespace lyx