2 /* This file is part of
3 * =================================================
5 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich.
7 * Copyright 1995-2000 The LyX Team.
9 * This file Copyright 2000 Baruch Even
10 * ================================================= */
12 #ifndef GRAPHICSCACHEITEM_H
13 #define GRAPHICSCACHEITEM_H
21 #include XPM_H_LOCATION
23 #include "graphics/Renderer.h"
24 #include "support/syscall.h"
26 #include "sigc++/signal_system.h"
27 #ifdef SIGC_CXX_NAMESPACES
31 /* (Baruch Even 2000-08-05)
32 * This has a major drawback: it is only designed for X servers, no easy
33 * porting to non X-server based platform is offered right now, this is done
34 * in order to get a first version out of the door.
36 * Later versions should consider how to do this with more platform
37 * independence, this will probably involve changing the Painter class too.
40 /* (Baruch Even 2000-08-05)
41 * This should be made reference counted, but for the sake of initial design
42 * I'll forego that and just make a first version that actually works, though
43 * it may fail or leak in real document, this is an initial design to try
44 * ideas on and be a testbed.
45 * It may just as well be scraped later on to create a better design based on
46 * the results of working with the current design.
49 /// A GraphicsCache item holder.
50 class GraphicsCacheItem {
52 /// d-tor, frees the image structures.
55 /// Get the height of the image. Returns -1 on error.
56 int getHeight() const { return height_; }
58 /// Get the width of the image. Returns -1 on error.
59 int getWidth() const { return width_; }
61 /// Return a pixmap that can be displayed on X server.
62 Pixmap getImage() const { return pixmap_; }
71 /// Is the pixmap ready for display?
72 ImageStatus getImageStatus() const { return imageStatus_; }
74 /// Get a notification when the image conversion is done.
75 /// used by an internal callback mechanism.
76 void imageConverted(int retval);
78 /// A signal objects can connect to in order to know when the image
80 Signal0<void> imageDone;
82 /// Private c-tor so that only GraphicsCache can create an instance.
85 /// Set the filename this item will be pointing too.
86 bool setFilename(string const & filename);
88 /// Create an XPM file version of the image.
89 bool renderXPM(string const & filename);
91 /// Load the image from XPM to memory Pixmap
95 friend class GraphicsCache;
97 /// The file name of the XPM file.
103 /// Is the pixmap loaded?
104 ImageStatus imageStatus_;
107 /// The rendering object.
110 /// The system caller, runs the convertor.