3 * \file GraphicsImage.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
8 * \author Angus Leeming
10 * Full author contact details are available in file CREDITS.
12 * An abstract base class for the images themselves.
13 * Allows the user to retrieve the pixmap, once loaded and to issue commands
16 * The boost::functions newImage and loadableFormats are connected to the
17 * appropriate derived classes elsewhere, allowing the graphics cache to
18 * access them without knowing anything about their instantiation.
20 * The loading process can be asynchronous, but cropping, rotating and
21 * scaling block execution.
24 #ifndef GRAPHICSIMAGE_H
25 #define GRAPHICSIMAGE_H
27 #include "Dimension.h"
29 #include <boost/function.hpp>
30 #include <boost/signal.hpp>
36 namespace support { class FileName; }
44 /** This is to be connected to a function that will return a new
45 * instance of a viable derived class.
47 static boost::function<Image *()> newImage;
53 virtual Image * clone() const = 0;
55 /// Get the image width
56 virtual unsigned int width() const = 0;
58 /// Get the image height
59 virtual unsigned int height() const = 0;
61 /// Is the image drawable ?
62 virtual bool isDrawable() const = 0;
64 /** At the end of the loading process inform the outside world
65 * by emitting a signal
67 typedef boost::signal<void(bool)> SignalType;
69 SignalType finishedLoading;
71 /** Start loading the image file.
72 * The caller should expect this process to be asynchronous and
73 * so should connect to the "finished" signal above.
75 virtual bool load(support::FileName const & filename) = 0;
77 /** Generate the pixmap.
78 * Uses the params to decide on color, grayscale etc.
79 * Returns true if the pixmap is created.
81 virtual bool setPixmap(Params const & params) = 0;
84 /// Must define default c-tor explicitly as we define a copy c-tor.
86 /// Don't copy the signal finishedLoading
87 Image(Image const &) {}
89 /** Uses the params to ascertain the dimensions of the scaled image.
90 * Returned as Dimension(width, height, 0 descend).
91 * If something goes wrong, returns make_pair(getWidth(), getHeight(), 0)
93 Dimension scaledDimension(Params const & params) const;
97 } // namespace graphics
100 #endif // GRAPHICSIMAGE_H