]> git.lyx.org Git - lyx.git/blob - src/graphics/GraphicsCacheItem_pimpl.h
prepare for 1.1.6pre2
[lyx.git] / src / graphics / GraphicsCacheItem_pimpl.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_PIMPL_H
13 #define GRAPHICSCACHEITEM_PIMPL_H
14
15 #include <config.h>
16
17 #ifdef __GNUG__
18 #pragma interface
19 #endif
20
21 #include "graphics/GraphicsCacheItem.h"
22
23 #include XPM_H_LOCATION
24 #include "LString.h"
25 #include "graphics/Renderer.h"
26 #include "support/syscall.h"
27
28 #include "sigc++/signal_system.h"
29 #ifdef SIGC_CXX_NAMESPACES
30 using SigC::Signal0;
31 #endif
32
33 class LyXImage;
34
35 /// A GraphicsCache item holder.
36 class GraphicsCacheItem_pimpl {
37 public:
38         /// d-tor, frees the image structures.
39         ~GraphicsCacheItem_pimpl();
40         
41         /// Get the height of the image. Returns -1 on error.
42         int getHeight() const; 
43         
44         /// Get the width of the image. Returns -1 on error.
45         int getWidth() const;
46
47         /// Return a pixmap that can be displayed on X server.
48         LyXImage * getImage() const; 
49
50         typedef GraphicsCacheItem::ImageStatus ImageStatus;
51         
52         /// Is the pixmap ready for display?
53         ImageStatus getImageStatus() const; 
54
55         /** Get a notification when the image conversion is done.
56             used by an internal callback mechanism. */
57         void imageConverted(int retval);
58
59 private:
60         /// Private c-tor so that only GraphicsCache can create an instance.
61         GraphicsCacheItem_pimpl();
62
63         /// Set the filename this item will be pointing too.
64         bool setFilename(string const & filename);
65
66         /// Create an XPM file version of the image.
67         bool renderXPM(string const & filename);
68
69         /// Load the image from XPM to memory Pixmap
70         void loadXPMImage();
71         
72         ///
73         friend class GraphicsCacheItem;
74
75         /// The file name of the XPM file.
76         string xpmfile;
77         /// The image height
78         int height_;
79         /// The image width
80         int width_;
81         /// Is the pixmap loaded?
82         ImageStatus imageStatus_;
83         /// The image pixmap
84         LyXImage * pixmap_;
85         /// The rendering object.
86         Renderer * renderer;
87
88         /// The system caller, runs the convertor.
89         Systemcalls syscall;
90
91         /// The reference count
92         int refCount;
93 };
94
95 #endif