2000-07-31 12:30:10 +00:00
|
|
|
// -*- C++ -*-
|
2002-09-05 11:31:30 +00:00
|
|
|
/**
|
2002-02-27 09:59:52 +00:00
|
|
|
* \file GraphicsCacheItem.h
|
2002-09-05 15:14:23 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2000-07-31 12:30:10 +00:00
|
|
|
*
|
2002-12-01 22:59:25 +00:00
|
|
|
* \author Baruch Even
|
|
|
|
* \author Angus Leeming
|
2002-09-05 11:31:30 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-02-27 09:59:52 +00:00
|
|
|
*
|
2007-11-21 23:31:12 +00:00
|
|
|
* The graphics cache is a container of graphics::CacheItems.
|
|
|
|
* Each graphics::CacheItem, defined here represents a separate image file.
|
2002-06-28 11:22:56 +00:00
|
|
|
*
|
|
|
|
* The routines here can be used to load the graphics file into memory at
|
2007-11-21 23:31:12 +00:00
|
|
|
* which point (status() == graphics::Loaded).
|
2002-06-28 11:22:56 +00:00
|
|
|
* The user is then free to access image() in order to copy it and to then
|
|
|
|
* transform the copy (rotate, scale, clip) and to generate the pixmap.
|
2002-02-27 09:59:52 +00:00
|
|
|
*
|
|
|
|
* The graphics cache supports fully asynchronous:
|
|
|
|
* file conversion to a loadable format;
|
|
|
|
* file loading.
|
|
|
|
*
|
2007-11-21 23:31:12 +00:00
|
|
|
* Whether you get that, of course, depends on graphics::Converter and
|
|
|
|
* on the graphics::Image-derived image class.
|
2002-02-27 09:59:52 +00:00
|
|
|
*/
|
2000-07-31 12:30:10 +00:00
|
|
|
|
|
|
|
#ifndef GRAPHICSCACHEITEM_H
|
|
|
|
#define GRAPHICSCACHEITEM_H
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
#include "GraphicsTypes.h"
|
2002-05-22 01:16:37 +00:00
|
|
|
|
2004-09-26 14:19:47 +00:00
|
|
|
#include <boost/signal.hpp>
|
2000-08-10 13:15:05 +00:00
|
|
|
|
2003-09-07 21:25:37 +00:00
|
|
|
|
2003-07-04 08:23:23 +00:00
|
|
|
namespace lyx {
|
2006-11-26 21:30:39 +00:00
|
|
|
|
|
|
|
namespace support { class FileName; }
|
|
|
|
|
2003-07-04 08:23:23 +00:00
|
|
|
namespace graphics {
|
2000-08-08 09:18:39 +00:00
|
|
|
|
2002-06-28 11:22:56 +00:00
|
|
|
class Image;
|
|
|
|
class Converter;
|
|
|
|
|
2007-11-21 23:31:12 +00:00
|
|
|
/// A graphics::Cache item holder.
|
|
|
|
class CacheItem {
|
2000-07-31 12:30:10 +00:00
|
|
|
public:
|
2000-08-14 15:31:16 +00:00
|
|
|
///
|
2006-11-26 21:30:39 +00:00
|
|
|
CacheItem(support::FileName const & file);
|
2007-11-21 23:47:47 +00:00
|
|
|
/// Needed for the pimpl
|
2002-06-28 11:22:56 +00:00
|
|
|
~CacheItem();
|
|
|
|
|
|
|
|
///
|
2006-11-26 21:30:39 +00:00
|
|
|
support::FileName const & filename() const;
|
2002-02-27 09:59:52 +00:00
|
|
|
|
|
|
|
/// It's in the cache. Now start the loading process.
|
2002-07-17 16:56:42 +00:00
|
|
|
void startLoading() const;
|
2002-02-27 09:59:52 +00:00
|
|
|
|
2002-07-18 14:01:42 +00:00
|
|
|
/** Monitor any changes to the file.
|
|
|
|
* There is no point monitoring the file before startLoading() is
|
|
|
|
* invoked.
|
|
|
|
*/
|
|
|
|
void startMonitoring() const;
|
|
|
|
///
|
|
|
|
bool monitoring() const;
|
2007-11-30 09:23:44 +00:00
|
|
|
/** Returns the check checksum of filename() so that, for example, you can
|
2002-07-18 14:01:42 +00:00
|
|
|
* ascertain whether to output a new PostScript version of the file
|
|
|
|
* for a LaTeX run.
|
|
|
|
*/
|
|
|
|
unsigned long checksum() const;
|
|
|
|
|
2002-07-17 17:16:15 +00:00
|
|
|
/** Get the image associated with filename().
|
2002-06-28 11:22:56 +00:00
|
|
|
* If the image is not yet loaded, returns 0.
|
|
|
|
* This routine returns a pointer to const; if you want to modify it,
|
|
|
|
* create a copy and modify that.
|
2002-02-27 09:59:52 +00:00
|
|
|
*/
|
2002-06-28 11:22:56 +00:00
|
|
|
Image const * image() const;
|
2002-02-27 09:59:52 +00:00
|
|
|
|
2002-06-25 15:59:10 +00:00
|
|
|
/// How far have we got in loading the image?
|
2002-06-28 11:22:56 +00:00
|
|
|
ImageStatus status() const;
|
2002-02-27 09:59:52 +00:00
|
|
|
|
2002-07-17 16:56:42 +00:00
|
|
|
/** Connect and you'll be informed when the loading status of the image
|
|
|
|
* changes.
|
|
|
|
*/
|
2004-09-26 14:19:47 +00:00
|
|
|
typedef boost::signal<void()> sig_type;
|
|
|
|
typedef sig_type::slot_type slot_type;
|
2002-07-17 16:56:42 +00:00
|
|
|
///
|
|
|
|
boost::signals::connection connect(slot_type const &) const;
|
2000-08-08 09:18:39 +00:00
|
|
|
|
2000-07-31 12:30:10 +00:00
|
|
|
private:
|
2007-11-21 23:31:12 +00:00
|
|
|
/// noncopyable
|
|
|
|
CacheItem(CacheItem const &);
|
|
|
|
void operator=(CacheItem const &);
|
|
|
|
|
2002-06-28 11:22:56 +00:00
|
|
|
/// Use the Pimpl idiom to hide the internals.
|
|
|
|
class Impl;
|
|
|
|
/// The pointer never changes although *pimpl_'s contents may.
|
2007-11-21 23:47:47 +00:00
|
|
|
Impl * const pimpl_;
|
2002-02-27 09:59:52 +00:00
|
|
|
};
|
|
|
|
|
2003-07-04 08:23:23 +00:00
|
|
|
} // namespace graphics
|
|
|
|
} // namespace lyx
|
2002-02-27 09:59:52 +00:00
|
|
|
|
|
|
|
#endif // GRAPHICSCACHEITEM_H
|