2000-07-31 12:30:10 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of
|
|
|
|
* =================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
* Copyright 1995 Matthias Ettrich.
|
|
|
|
* Copyright 1995-2000 The LyX Team.
|
|
|
|
*
|
|
|
|
* This file Copyright 2000 Baruch Even
|
|
|
|
* ================================================= */
|
|
|
|
|
|
|
|
#ifndef GRAPHICSCACHEITEM_H
|
|
|
|
#define GRAPHICSCACHEITEM_H
|
|
|
|
|
2000-08-08 09:18:39 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
2000-07-31 12:30:10 +00:00
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
2000-08-08 09:18:39 +00:00
|
|
|
#include XPM_H_LOCATION
|
|
|
|
#include "LString.h"
|
|
|
|
|
2001-02-22 16:53:59 +00:00
|
|
|
#include <boost/utility.hpp>
|
|
|
|
#include <boost/smart_ptr.hpp>
|
|
|
|
|
2001-03-15 18:21:56 +00:00
|
|
|
#include <sigc++/signal_system.h>
|
2000-08-10 13:15:05 +00:00
|
|
|
|
2000-10-12 10:46:06 +00:00
|
|
|
class LyXImage;
|
2000-08-08 09:18:39 +00:00
|
|
|
|
|
|
|
/// A GraphicsCache item holder.
|
2001-03-15 16:04:46 +00:00
|
|
|
class GraphicsCacheItem : public boost::noncopyable {
|
2000-07-31 12:30:10 +00:00
|
|
|
public:
|
2001-02-22 16:53:59 +00:00
|
|
|
/// c-tor
|
|
|
|
GraphicsCacheItem(string const & filename);
|
2000-08-08 09:18:39 +00:00
|
|
|
/// d-tor, frees the image structures.
|
|
|
|
~GraphicsCacheItem();
|
|
|
|
|
|
|
|
/// Return a pixmap that can be displayed on X server.
|
2000-10-12 10:46:06 +00:00
|
|
|
LyXImage * getImage() const;
|
2000-08-14 15:31:16 +00:00
|
|
|
///
|
2000-08-08 09:18:39 +00:00
|
|
|
enum ImageStatus {
|
2000-08-14 15:31:16 +00:00
|
|
|
///
|
2000-08-08 09:18:39 +00:00
|
|
|
Loading = 1,
|
2000-08-14 15:31:16 +00:00
|
|
|
///
|
2000-08-08 09:18:39 +00:00
|
|
|
ErrorConverting,
|
2000-08-14 15:31:16 +00:00
|
|
|
///
|
2000-08-08 09:18:39 +00:00
|
|
|
ErrorReading,
|
2000-08-14 15:31:16 +00:00
|
|
|
///
|
2000-10-12 10:46:06 +00:00
|
|
|
UnknownError,
|
|
|
|
///
|
2000-08-08 09:18:39 +00:00
|
|
|
Loaded
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Is the pixmap ready for display?
|
2000-08-10 13:15:05 +00:00
|
|
|
ImageStatus getImageStatus() const;
|
2000-08-08 09:18:39 +00:00
|
|
|
|
2000-08-14 15:31:16 +00:00
|
|
|
/** Get a notification when the image conversion is done.
|
|
|
|
used by an internal callback mechanism.
|
|
|
|
*/
|
2000-08-08 09:18:39 +00:00
|
|
|
void imageConverted(int retval);
|
|
|
|
|
2000-07-31 12:30:10 +00:00
|
|
|
private:
|
2001-04-02 19:56:48 +00:00
|
|
|
bool convertImage(string const & filename);
|
|
|
|
void loadImage();
|
2000-08-10 13:15:05 +00:00
|
|
|
|
2000-08-14 15:31:16 +00:00
|
|
|
/** The filename we refer too.
|
|
|
|
This is used when removing ourselves from the cache.
|
|
|
|
*/
|
2000-08-10 13:15:05 +00:00
|
|
|
string filename_;
|
2001-02-22 16:53:59 +00:00
|
|
|
/// The temporary file that we use
|
|
|
|
string tempfile;
|
|
|
|
/// The image status
|
|
|
|
ImageStatus imageStatus_;
|
|
|
|
/// The image (if it got loaded)
|
|
|
|
boost::scoped_ptr<LyXImage> image_;
|
2000-07-31 12:30:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|