]> git.lyx.org Git - lyx.git/blob - src/graphics/GraphicsCacheItem.h
6fc9ee4f1c6f1b56ad82090ac2f5e5d18bb8717b
[lyx.git] / src / graphics / GraphicsCacheItem.h
1 // -*- C++ -*-
2 /* This file is part of
3  * =================================================
4  * 
5  *          LyX, The Document Processor
6  *          Copyright 1995 Matthias Ettrich.
7  *          Copyright 1995-2001 The LyX Team.
8  *
9  *          This file Copyright 2000 Baruch Even
10  * ================================================= */
11
12 #ifndef GRAPHICSCACHEITEM_H
13 #define GRAPHICSCACHEITEM_H
14
15 #include <config.h>
16
17 #ifdef __GNUG__
18 #pragma interface
19 #endif
20
21 #include XPM_H_LOCATION
22 #include "LString.h"
23
24 #include <boost/utility.hpp>
25 #include <boost/smart_ptr.hpp>
26
27 #include <sigc++/signal_system.h>
28
29 class LyXImage;
30
31 /// A GraphicsCache item holder.
32 class GraphicsCacheItem : boost::noncopyable {
33 public:
34         /// c-tor
35         GraphicsCacheItem(string const & filename);
36         /// d-tor, frees the image structures.
37         ~GraphicsCacheItem();
38         
39         /// Return a pixmap that can be displayed on X server.
40         LyXImage * getImage() const; 
41         ///
42         enum ImageStatus {
43                 ///
44                 Loading = 1,
45                 ///
46                 ErrorConverting,
47                 ///
48                 ErrorReading,
49                 ///
50                 UnknownError,
51                 ///
52                 Loaded
53         };
54         
55         /// Is the pixmap ready for display?
56         ImageStatus getImageStatus() const; 
57
58         /** Get a notification when the image conversion is done.
59             used by an internal callback mechanism.
60         */
61         void imageConverted(int retval);
62
63 private:
64         bool convertImage(string const & filename);
65         void loadImage();
66
67         /** The filename we refer too.
68             This is used when removing ourselves from the cache.
69         */
70         string filename_;
71         /// The temporary file that we use
72         string tempfile;
73         /// The image status
74         ImageStatus imageStatus_;
75         /// The image (if it got loaded)
76         boost::scoped_ptr<LyXImage> image_;
77 };
78
79 #endif