3 * \file GraphicsLoader.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Angus Leeming
9 * Full author contact details are available in file CREDITS
11 * The public face of the graphics cache.
13 * * The user supplies an image file and the display parameters.
14 * * He can change the file or the display parameters through a reset() method.
15 * * He must start the loading process explicitly with startLoading().
16 * * If he is connected through the connect() method, then he'll be informed
17 * when the loading status changes.
18 * * When (status() == Ready), he can use image() to access the loaded image
19 * and pass it to the Painter.
21 * What could be simpler?
24 #ifndef GRAPHICSLOADER_H
25 #define GRAPHICSLOADER_H
27 #include "GraphicsTypes.h"
30 #include <boost/signals/signal0.hpp>
31 #include <boost/scoped_ptr.hpp>
43 /// Must use the reset methods to make this instance usable.
45 /// The image is not transformed, just displayed as-is.
46 Loader(string const & file_with_path, DisplayType = ColorDisplay);
47 /// The image is transformed before display.
48 Loader(string const & file_with_path, Params const &);
50 /// Define an empty d-tor out-of-line to keep boost::scoped_ptr happy.
53 /// The file can be changed, or the display params, or both.
54 void reset(string const & file_with_path,
55 DisplayType = ColorDisplay) const;
57 void reset(string const & file_with_path, Params const &) const;
59 void reset(Params const &) 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.
67 void startLoading() const;
69 /** starting loading of the image is done by a urgency-based
70 * decision. Here we only call LoaderQueue::touch to request it.
72 void startLoading(Inset const &) const;
74 /** Monitor any changes to the file.
75 * There is no point monitoring the file before startLoading() is
78 void startMonitoring() const;
80 bool monitoring() const;
81 /** Returns the check sum of filename() so that, for example, you can
82 * ascertain whether to output a new PostScript version of the file
85 unsigned long checksum() const;
87 /// How far have we got in loading the image?
88 ImageStatus status() const;
90 /** Connect and you'll be informed when the loading status of the image
93 typedef boost::signal0<void>::slot_type slot_type;
95 boost::signals::connection connect(slot_type const &) const;
97 /** The loaded image with Pixmap set.
98 * If the Pixmap is not yet set (see status() for why...), returns 0.
100 Image const * image() const;
103 /// Use the Pimpl idiom to hide the internals.
105 /// The pointer never changes although *pimpl_'s contents may.
106 boost::scoped_ptr<Impl> const pimpl_;
111 #endif // GRAPHICSLOADER_H