]> git.lyx.org Git - lyx.git/blob - src/graphics/GraphicsCacheItem_pimpl.h
ae819a75b24d9c17dd2b22b3347889e39ea933bf
[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 /* (Baruch Even 2000-08-05)
34  * This has a major drawback: it is only designed for X servers, no easy
35  * porting to non X-server based platform is offered right now, this is done
36  * in order to get a first version out of the door.
37  *
38  * Later versions should consider how to do this with more platform 
39  * independence, this will probably involve changing the Painter class too.
40  */
41
42 /// A GraphicsCache item holder.
43 class GraphicsCacheItem_pimpl {
44 public:
45         /// d-tor, frees the image structures.
46         ~GraphicsCacheItem_pimpl();
47         
48         /// Get the height of the image. Returns -1 on error.
49         int getHeight() const; 
50         
51         /// Get the width of the image. Returns -1 on error.
52         int getWidth() const;
53
54         /// Return a pixmap that can be displayed on X server.
55         Pixmap getImage() const; 
56
57         typedef GraphicsCacheItem::ImageStatus ImageStatus;
58         
59         /// Is the pixmap ready for display?
60         ImageStatus getImageStatus() const; 
61
62         /** Get a notification when the image conversion is done.
63             used by an internal callback mechanism. */
64         void imageConverted(int retval);
65
66 private:
67         /// Private c-tor so that only GraphicsCache can create an instance.
68         GraphicsCacheItem_pimpl();
69
70         /// Set the filename this item will be pointing too.
71         bool setFilename(string const & filename);
72
73         /// Create an XPM file version of the image.
74         bool renderXPM(string const & filename);
75
76         /// Load the image from XPM to memory Pixmap
77         void loadXPMImage();
78         
79         ///
80         friend class GraphicsCacheItem;
81
82         /// The file name of the XPM file.
83         string xpmfile;
84         /// The image height
85         int height_;
86         /// The image width
87         int width_;
88         /// Is the pixmap loaded?
89         ImageStatus imageStatus_;
90         /// The image pixmap
91         Pixmap pixmap_;
92         /// The rendering object.
93         Renderer * renderer;
94
95         /// The system caller, runs the convertor.
96         Systemcalls syscall;
97
98         /// The reference count
99         int refCount;
100 };
101
102 #endif