2000-07-31 12:30:10 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of
|
|
|
|
* =================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
* Copyright 1995 Matthias Ettrich.
|
2001-05-30 13:53:44 +00:00
|
|
|
* Copyright 1995-2001 The LyX Team.
|
2000-07-31 12:30:10 +00:00
|
|
|
*
|
|
|
|
* This file Copyright 2000 Baruch Even
|
|
|
|
* ================================================= */
|
|
|
|
|
|
|
|
#ifndef GRAPHICSCACHEITEM_H
|
|
|
|
#define GRAPHICSCACHEITEM_H
|
|
|
|
|
|
|
|
#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-04-17 14:11:26 +00:00
|
|
|
class GraphicsCacheItem : 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
|
|
|
///
|
2002-01-29 09:26:24 +00:00
|
|
|
Converting,
|
|
|
|
///
|
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.
|
|
|
|
*/
|
2001-07-17 00:38:04 +00:00
|
|
|
void imageConverted(bool success);
|
2000-08-08 09:18:39 +00:00
|
|
|
|
2000-07-31 12:30:10 +00:00
|
|
|
private:
|
2001-07-17 00:38:04 +00:00
|
|
|
/** Start image conversion process, checks first that it is necessary
|
|
|
|
* if necessary will start an (a)synchronous task and notify upon
|
|
|
|
* completion by calling imageConverted(bool) where true is for success
|
|
|
|
* and false is for a failure.
|
|
|
|
*
|
|
|
|
* Returns a bool to denote success or failure of starting the conversion
|
|
|
|
* task.
|
|
|
|
*/
|
2001-04-02 19:56:48 +00:00
|
|
|
bool convertImage(string const & filename);
|
2001-07-17 00:38:04 +00:00
|
|
|
|
|
|
|
/// Load the image into memory, this gets called from imageConverted(bool).
|
2001-04-02 19:56:48 +00:00
|
|
|
void loadImage();
|
2000-08-10 13:15:05 +00:00
|
|
|
|
2001-07-17 00:38:04 +00:00
|
|
|
/// Sets the status of the image, in the future will also notify listeners
|
|
|
|
/// that the status is updated.
|
|
|
|
void setStatus(ImageStatus new_status);
|
|
|
|
|
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
|