]> git.lyx.org Git - features.git/blob - src/graphics/PreviewImage.h
Smart loading of image files for previews and for the graphics inset.
[features.git] / src / graphics / PreviewImage.h
1 // -*- C++ -*-
2 /**
3  *  \file PreviewImage.h
4  *  Copyright 2002 the LyX Team
5  *  Read the file COPYING
6  *
7  * \author Angus Leeming <leeming@lyx.org>
8  */
9
10 #ifndef PREVIEWIMAGE_H
11 #define PREVIEWIMAGE_H
12
13 #ifdef __GNUG__
14 #pragma interface
15 #endif
16
17 #include "LString.h"
18 #include <boost/scoped_ptr.hpp>
19
20 class Inset;
21 class BufferView;
22
23 namespace grfx {
24
25 class PreviewLoader;
26 class Image;
27
28 class PreviewImage {
29 public:
30         /** ascent = height * ascent_frac
31          *  descent = height * (1 - ascent_frac)
32          */
33         PreviewImage(PreviewLoader & parent,
34                      string const & latex_snippet,
35                      string const & bitmap_file,
36                      double ascent_frac);
37         ///
38         ~PreviewImage();
39
40         ///
41         string const & snippet() const;
42         ///
43         int ascent() const;
44         ///
45         int descent() const;
46         ///
47         int width() const;
48
49         /** If the image is not yet loaded (WaitingToLoad), then this method
50          *  triggers that.
51          *  inset and bv are passed so we can choose to load only
52          *  those insets that are visible.
53          */
54         Image const * image(Inset const & inset, BufferView const & bv) const;
55
56 private:
57         /// Use the Pimpl idiom to hide the internals.
58         class Impl;
59         /// The pointer never changes although *pimpl_'s contents may.
60         boost::scoped_ptr<Impl> const pimpl_;
61 };
62
63 } // namespace grfx
64
65 #endif // PREVIEWIMAGE_H