]> git.lyx.org Git - lyx.git/blob - src/graphics/GraphicsLoader.h
Disable direct loading of PostScript files by the xforms image loader.
[lyx.git] / src / graphics / GraphicsLoader.h
1 // -*- C++ -*-
2 /**
3  *  \file GraphicsLoader.h
4  *  Copyright 2002 the LyX Team
5  *  Read the file COPYING
6  *
7  *  \author Angus Leeming <leeming@lyx.org>
8  *
9  *  The public face of the graphics cache.
10  *
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.
18  *
19  *  What could be simpler?
20  */
21
22 #ifndef GRAPHICSLOADER_H
23 #define GRAPHICSLOADER_H
24
25 #ifdef __GNUG__
26 #pragma interface
27 #endif
28
29 #include "GraphicsTypes.h"
30 #include "LString.h"
31
32 #include <boost/signals/signal0.hpp>
33 #include <boost/scoped_ptr.hpp>
34
35 class Inset;
36 class BufferView;
37
38 namespace grfx {
39
40 class Image;
41 class Params;
42
43 class Loader {
44 public:
45         /// Must use the reset methods to make this instance usable.
46         Loader();
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 &);
51
52         /// Define an empty d-tor out-of-line to keep boost::scoped_ptr happy.
53         ~Loader();
54
55         /// The file can be changed, or the display params, or both.
56         void reset(string const & file_with_path,
57                    DisplayType = ColorDisplay) const;
58         ///
59         void reset(string const & file_with_path, Params const &) const;
60         ///
61         void reset(Params const &) const;
62
63         /// Returns the absolute path of the loaded (loading?) file.
64         string const & filename() const;
65         ///
66         bool empty() const { return filename().empty(); }
67
68         /// We are explicit about when we begin the loading process.
69         void startLoading() const;
70
71         /** starting loading of the image is conditional upon the
72          *  inset being visible or not.
73          */
74         void startLoading(Inset const &, BufferView const &) const;
75
76         /// How far have we got in loading the image?
77         ImageStatus status() const;
78
79         /** Connect and you'll be informed when the loading status of the image
80          *  changes.
81          */
82         typedef boost::signal0<void>::slot_type slot_type;
83         ///
84         boost::signals::connection connect(slot_type const &) const;
85
86         /** The loaded image with Pixmap set.
87          *  If the Pixmap is not yet set (see status() for why...), returns 0.
88          */
89         Image const * image() const;
90
91 private:
92         /// Use the Pimpl idiom to hide the internals.
93         class Impl;
94         /// The pointer never changes although *pimpl_'s contents may.
95         boost::scoped_ptr<Impl> const pimpl_;
96 };
97
98 } // namespace grfx
99
100 #endif // GRAPHICSLOADER_H