3 * \file GraphicsLoader.h
4 * Copyright 2002 the LyX Team
5 * Read the file COPYING
7 * \author Angus Leeming <leeming@lyx.org>
9 * The public face of the graphics cache.
11 * * The user supplies an image file and the display parameters.
12 * * He can change the file or the display parameters through a reset() method.
13 * * He must start the loading process explicitly with startLoading().
14 * * He receives a statusChanged signal when the loading status changes.
15 * * When (status() == Ready), he uses image() to access the loaded image
16 * and passes it to the Painter.
18 * What could be simpler?
21 #ifndef GRAPHICSLOADER_H
22 #define GRAPHICSLOADER_H
28 #include "GraphicsTypes.h"
31 #include <boost/signals/signal0.hpp>
32 #include <boost/scoped_ptr.hpp>
41 /// Must use the reset methods to make this instance usable.
43 /// The image is not transformed, just displayed as-is.
44 Loader(string const & file_with_path, DisplayType = ColorDisplay);
45 /// The image is transformed before display.
46 Loader(string const & file_with_path, Params const &);
48 /// Define an empty d-tor out-of-line to keep boost::scoped_ptr happy.
51 /// The file can be changed, or the display params, or both.
52 void reset(string const & file_with_path, DisplayType = ColorDisplay);
54 void reset(string const & file_with_path, Params const &);
56 void reset(Params const &);
58 /// Returns the absolute path of the loaded (loading?) file.
59 string const & filename() const;
61 bool empty() const { return filename().empty(); }
63 /// We are explicit about when we begin the loading process.
66 /// How far have we got in loading the image?
67 ImageStatus status() const;
69 /// This signal is emitted when the image loading status changes.
70 boost::signal0<void> statusChanged;
72 /** The loaded image with Pixmap set.
73 * If the Pixmap is not yet set (see status() for why...), returns 0.
75 Image const * image() const;
78 /// Use the Pimpl idiom to hide the internals.
80 /// The pointer never changes although *pimpl_'s contents may.
81 boost::scoped_ptr<Impl> const pimpl_;
86 #endif // GRAPHICSLOADER_H