]> git.lyx.org Git - lyx.git/blob - src/graphics/GraphicsCacheItem.h
52d710cc08b502b1a964facccde2890ec4012195
[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-2000 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 "sigc++/signal_system.h"
25 #ifdef SIGC_CXX_NAMESPACES
26 using SigC::Signal0;
27 #endif
28
29
30 /* (Baruch Even 2000-08-05)
31  * This has a major drawback: it is only designed for X servers, no easy
32  * porting to non X-server based platform is offered right now, this is done
33  * in order to get a first version out of the door.
34  *
35  * Later versions should consider how to do this with more platform 
36  * independence, this will probably involve changing the Painter class too.
37  */
38
39 class GraphicsCacheItem_pimpl;
40 class LyXImage;
41
42 /// A GraphicsCache item holder.
43 class GraphicsCacheItem {
44 public:
45         /// d-tor, frees the image structures.
46         ~GraphicsCacheItem();
47         /// copy c-tor.
48         GraphicsCacheItem(GraphicsCacheItem const &);
49         /// Assignment operator.
50         GraphicsCacheItem & operator=(GraphicsCacheItem const &);
51         
52         /// Return a pixmap that can be displayed on X server.
53         LyXImage * getImage() const; 
54         ///
55         enum ImageStatus {
56                 ///
57                 Loading = 1,
58                 ///
59                 ErrorConverting,
60                 ///
61                 ErrorReading,
62                 ///
63                 UnknownError,
64                 ///
65                 Loaded
66         };
67         
68         /// Is the pixmap ready for display?
69         ImageStatus getImageStatus() const; 
70
71         /** Get a notification when the image conversion is done.
72             used by an internal callback mechanism.
73         */
74         void imageConverted(int retval);
75
76         /// Create another copy of the object.
77         GraphicsCacheItem * Clone() const;
78         
79 private:
80         /// Private c-tor so that only GraphicsCache can create an instance.
81         GraphicsCacheItem();
82
83         /// internal copy mechanism.
84         void copy(GraphicsCacheItem const &);
85         /// internal destroy mechanism.
86         void destroy();
87
88         /// Set the filename this item will be pointing too.
89         bool setFilename(string const & filename);
90
91         ///
92         friend class GraphicsCache;
93
94         ///
95         GraphicsCacheItem_pimpl * pimpl;
96
97         /** The filename we refer too.
98             This is used when removing ourselves from the cache.
99         */
100         string filename_;
101 };
102
103 #endif