]> git.lyx.org Git - lyx.git/blob - src/graphics/GraphicsLoader.h
makeLaTeXFile has two variants that can be passed either a file name or an
[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  *  * He receives a statusChanged signal when the loading status changes.
15  *  * When (status() == Ready), he uses image() to access the loaded image
16  *    and passes it to the Painter.
17  *
18  *  What could be simpler?
19  */
20
21 #ifndef GRAPHICSLOADER_H
22 #define GRAPHICSLOADER_H
23
24 #ifdef __GNUG__
25 #pragma interface
26 #endif
27
28 #include "GraphicsTypes.h"
29 #include "LString.h"
30
31 #include <boost/signals/signal0.hpp>
32 #include <boost/scoped_ptr.hpp>
33
34 namespace grfx {
35
36 class Image;
37 class Params;
38
39 class Loader {
40 public:
41         /// Must use the reset methods to make this instance usable.
42         Loader();
43         /// The image is not transformed, just displayed as-is.
44         Loader(string const & file_with_path, DisplayType = ColorDisplay);
45         /// The image is transformed before display.
46         Loader(string const & file_with_path, Params const &);
47
48         /// Define an empty d-tor out-of-line to keep boost::scoped_ptr happy.
49         ~Loader();
50
51         /// The file can be changed, or the display params, or both.
52         void reset(string const & file_with_path, DisplayType = ColorDisplay);
53         ///
54         void reset(string const & file_with_path, Params const &);
55         ///
56         void reset(Params const &);
57
58         /// Returns the absolute path of the loaded (loading?) file.
59         string const & filename() const;
60         ///
61         bool empty() const { return filename().empty(); }
62
63         /// We are explicit about when we begin the loading process.
64         void startLoading();
65
66         /// How far have we got in loading the image?
67         ImageStatus status() const;
68
69         /// This signal is emitted when the image loading status changes.
70         boost::signal0<void> statusChanged;
71
72         /** The loaded image with Pixmap set.
73          *  If the Pixmap is not yet set (see status() for why...), returns 0.
74          */
75         Image const * image() const;
76
77 private:
78         /// Use the Pimpl idiom to hide the internals.
79         class Impl;
80         /// The pointer never changes although *pimpl_'s contents may.
81         boost::scoped_ptr<Impl> const pimpl_;
82 };
83
84 } // namespace grfx
85
86 #endif // GRAPHICSLOADER_H