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 * * If he is connected through the connect() method, then he'll be informed
15 * when the loading status changes.
16 * * When (status() == Ready), he can use image() to access the loaded image
17 * and pass it to the Painter.
19 * What could be simpler?
22 #ifndef GRAPHICSLOADER_H
23 #define GRAPHICSLOADER_H
29 #include "GraphicsTypes.h"
32 #include <boost/signals/signal0.hpp>
33 #include <boost/scoped_ptr.hpp>
45 /// Must use the reset methods to make this instance usable.
47 /// The image is not transformed, just displayed as-is.
48 Loader(string const & file_with_path, DisplayType = ColorDisplay);
49 /// The image is transformed before display.
50 Loader(string const & file_with_path, Params const &);
52 /// Define an empty d-tor out-of-line to keep boost::scoped_ptr happy.
55 /// The file can be changed, or the display params, or both.
56 void reset(string const & file_with_path,
57 DisplayType = ColorDisplay) const;
59 void reset(string const & file_with_path, Params const &) const;
61 void reset(Params const &) const;
63 /// Returns the absolute path of the loaded (loading?) file.
64 string const & filename() const;
66 bool empty() const { return filename().empty(); }
68 /// We are explicit about when we begin the loading process.
69 void startLoading() const;
71 /** starting loading of the image is conditional upon the
72 * inset being visible or not.
74 void startLoading(Inset const &, BufferView const &) const;
76 /** Monitor any changes to the file.
77 * There is no point monitoring the file before startLoading() is
80 void startMonitoring() const;
82 bool monitoring() const;
83 /** Returns the check sum of filename() so that, for example, you can
84 * ascertain whether to output a new PostScript version of the file
87 unsigned long checksum() const;
89 /// How far have we got in loading the image?
90 ImageStatus status() const;
92 /** Connect and you'll be informed when the loading status of the image
95 typedef boost::signal0<void>::slot_type slot_type;
97 boost::signals::connection connect(slot_type const &) const;
99 /** The loaded image with Pixmap set.
100 * If the Pixmap is not yet set (see status() for why...), returns 0.
102 Image const * image() const;
105 /// Use the Pimpl idiom to hide the internals.
107 /// The pointer never changes although *pimpl_'s contents may.
108 boost::scoped_ptr<Impl> const pimpl_;
113 #endif // GRAPHICSLOADER_H