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 "support/signals.h"
33 namespace support { class FileName; }
42 /// Must use the reset methods to make this instance usable.
43 Loader(support::FileName const & doc_file);
44 /// The image is not transformed, just displayed as-is.
45 Loader(support::FileName const & doc_file, support::FileName const & file_with_path, bool display = true);
46 /// The image is transformed before display.
47 Loader(support::FileName const & doc_file, support::FileName const & file_with_path, Params const &);
49 Loader(support::FileName const & doc_file, Loader const &);
51 Loader(Loader const & other);
52 /// Needed for the pimpl
55 Loader & operator=(Loader const &);
57 /// The file can be changed, or the display params, or both.
58 void reset(support::FileName const & file_with_path, bool display = true) const;
60 void reset(support::FileName const & file_with_path, Params const &) const;
62 void reset(Params const &) const;
64 /// Returns the absolute path of the loaded (loading?) file.
65 support::FileName const & filename() const;
68 /** starting loading of the image is done by a urgency-based
69 * decision. Here we only call LoaderQueue::touch to request it.
71 void startLoading() const;
73 /** Tries to reload the image.
77 /** Monitor any changes to the file.
78 * There is no point monitoring the file before startLoading() is
81 void startMonitoring() const;
83 bool monitoring() const;
85 void checkModifiedAsync() 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 signals2::signal<void()> sig;
94 typedef sig::slot_type slot;
96 signals2::connection connect(slot const &) const;
98 /** The loaded image with Pixmap set.
99 * If the Pixmap is not yet set (see status() for why...), returns 0.
101 Image const * image() const;
103 double displayPixelRatio() const;
104 void setDisplayPixelRatio(double scale);
107 /// Use the Pimpl idiom to hide the internals.
109 /// The pointer never changes although *pimpl_'s contents may.
113 } // namespace graphics
116 #endif // GRAPHICSLOADER_H