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>
44 /// Must use the reset methods to make this instance usable.
46 /// The image is not transformed, just displayed as-is.
47 Loader(string const & file_with_path, DisplayType = ColorDisplay);
48 /// The image is transformed before display.
49 Loader(string const & file_with_path, Params const &);
51 /// Define an empty d-tor out-of-line to keep boost::scoped_ptr happy.
54 /// The file can be changed, or the display params, or both.
55 void reset(string const & file_with_path, DisplayType = ColorDisplay);
57 void reset(string const & file_with_path, Params const &);
59 void reset(Params const &);
61 /// Returns the absolute path of the loaded (loading?) file.
62 string const & filename() const;
64 bool empty() const { return filename().empty(); }
66 /// We are explicit about when we begin the loading process.
69 /** starting loading of the image is conditional upon the
70 * inset being visible or not.
72 void startLoading(Inset const &, BufferView const &);
74 /// How far have we got in loading the image?
75 ImageStatus status() const;
77 /// This signal is emitted when the image loading status changes.
78 boost::signal0<void> statusChanged;
80 /** The loaded image with Pixmap set.
81 * If the Pixmap is not yet set (see status() for why...), returns 0.
83 Image const * image() const;
86 /// Use the Pimpl idiom to hide the internals.
88 /// The pointer never changes although *pimpl_'s contents may.
89 boost::scoped_ptr<Impl> const pimpl_;
94 #endif // GRAPHICSLOADER_H