Not so soon, I guess, since that FIXME was from r6305.
[lyx.git] / src / graphics / GraphicsLoader.h
blob65218505b0254121794466ab036f6992530d4234
1 // -*- C++ -*-
2 /**
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"
29 #include <boost/signal.hpp>
31 namespace lyx {
33 namespace support { class FileName; }
35 namespace graphics {
37 class Image;
38 class Params;
40 class Loader {
41 public:
42 /// Must use the reset methods to make this instance usable.
43 Loader();
44 /// The image is not transformed, just displayed as-is.
45 Loader(support::FileName const & file_with_path, bool display = true);
46 /// The image is transformed before display.
47 Loader(support::FileName const & file_with_path, Params const &);
48 ///
49 Loader(Loader const &);
50 /// Needed for the pimpl
51 ~Loader();
53 Loader & operator=(Loader const &);
55 /// The file can be changed, or the display params, or both.
56 void reset(support::FileName const & file_with_path, bool display = true) const;
57 ///
58 void reset(support::FileName const & file_with_path, Params const &) const;
59 ///
60 void reset(Params const &) const;
62 /// Returns the absolute path of the loaded (loading?) file.
63 support::FileName const & filename() const;
64 ///
66 /** starting loading of the image is done by a urgency-based
67 * decision. Here we only call LoaderQueue::touch to request it.
69 void startLoading() const;
71 /** Tries to reload the image.
73 void reload() const;
75 /** Monitor any changes to the file.
76 * There is no point monitoring the file before startLoading() is
77 * invoked.
79 void startMonitoring() const;
80 ///
81 bool monitoring() const;
82 /** Returns the check checksum of filename() so that, for example, you can
83 * ascertain whether to output a new PostScript version of the file
84 * for a LaTeX run.
86 unsigned long checksum() const;
88 /// How far have we got in loading the image?
89 ImageStatus status() const;
91 /** Connect and you'll be informed when the loading status of the image
92 * changes.
94 typedef boost::signal<void()> sig_type;
95 typedef sig_type::slot_type slot_type;
96 ///
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;
104 private:
105 /// Use the Pimpl idiom to hide the internals.
106 class Impl;
107 /// The pointer never changes although *pimpl_'s contents may.
108 Impl * const pimpl_;
111 } // namespace graphics
112 } // namespace lyx
114 #endif // GRAPHICSLOADER_H