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 view of the graphics cache.
10 * * The user supplies an image file and the display parameters.
11 * * He can change the file or the display parameters through a reset() method.
12 * * He must start the loading process explicitly with startLoading().
13 * * He receives a statusChanged signal when the loading status changes.
14 * * When (status() == Ready), he uses image() to access the loaded image
15 * and passes it to the Painter.
17 * What could be simpler?
20 #ifndef GRAPHICSLOADER_H
21 #define GRAPHICSLOADER_H
27 #include "GraphicsTypes.h"
30 #include <boost/signals/signal0.hpp>
37 /** One image, one instance of grfx::Loader, although the image can be
42 /// Must use the reset methods to make this instance usable.
44 /// The image is not transformed, just displayed as-is.
45 Loader(string const & file_with_path, DisplayType = ColorDisplay);
46 /// The image is transformed before display.
47 Loader(string const & file_with_path, GParams const &);
49 /// The file can be changed, or the display params, or both.
50 void reset(string const & file_with_path, DisplayType = ColorDisplay);
52 void reset(string const & file_with_path, GParams const &);
54 void reset(GParams const &);
56 /// Returns the absolute path of the loaded (loading?) file.
57 string const & filename() const;
59 bool empty() const { return filename().empty(); }
61 /// We are explicit about when we begin the loading process.
64 /// How far have we got in loading the image?
65 ImageStatus status() const;
67 /// This signal is emitted when the image loading status changes.
68 boost::signal0<void> statusChanged;
70 /** The loaded image with Pixmap set.
71 * If the Pixmap is not yet set (see status() for why...), returns 0.
73 GImage const * image() const;
76 /// Use the Pimpl idiom to hide the internals.
78 /// The pointer never changes although *pimpl_'s contents may.
79 std::auto_ptr<Impl> const pimpl_;
84 #endif // GRAPHICSLOADER_H