2000-07-31 12:30:10 +00:00
|
|
|
// -*- C++ -*-
|
2002-02-27 09:59:52 +00:00
|
|
|
/*
|
|
|
|
* \file GraphicsCacheItem.h
|
|
|
|
* Copyright 2002 the LyX Team
|
|
|
|
* Read the file COPYING
|
2000-07-31 12:30:10 +00:00
|
|
|
*
|
2002-02-27 09:59:52 +00:00
|
|
|
* \author Baruch Even <baruch.even@writeme.com>
|
|
|
|
* \author Angus Leeming <a.leeming@ic.ac.uk>
|
|
|
|
*
|
2002-06-28 11:22:56 +00:00
|
|
|
* The graphics cache is a container of grfx::CacheItems.
|
|
|
|
* Each grfx::CacheItem, definedhere represents a separate image file.
|
|
|
|
*
|
|
|
|
* The routines here can be used to load the graphics file into memory at
|
|
|
|
* which point (status() == grfx::Loaded).
|
|
|
|
* 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.
|
|
|
|
*
|
2002-06-28 11:22:56 +00:00
|
|
|
* Whether you get that, of course, depends on grfx::Converter and on the
|
|
|
|
* grfx::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
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
#include "GraphicsTypes.h"
|
2000-08-08 09:18:39 +00:00
|
|
|
#include "LString.h"
|
2002-05-22 01:16:37 +00:00
|
|
|
|
2001-02-22 16:53:59 +00:00
|
|
|
#include <boost/utility.hpp>
|
2002-06-28 11:22:56 +00:00
|
|
|
#include <boost/scoped_ptr.hpp>
|
2002-06-25 15:59:10 +00:00
|
|
|
#include <boost/signals/signal0.hpp>
|
2000-08-10 13:15:05 +00:00
|
|
|
|
2002-02-27 09:59:52 +00:00
|
|
|
class InsetGraphics;
|
|
|
|
|
|
|
|
namespace grfx {
|
2000-08-08 09:18:39 +00:00
|
|
|
|
2002-06-28 11:22:56 +00:00
|
|
|
class Image;
|
|
|
|
class Converter;
|
|
|
|
|
|
|
|
/// A grfx::Cache item holder.
|
|
|
|
class CacheItem : boost::noncopyable {
|
2000-07-31 12:30:10 +00:00
|
|
|
public:
|
2000-08-14 15:31:16 +00:00
|
|
|
///
|
2002-06-28 11:22:56 +00:00
|
|
|
CacheItem(string const & file);
|
|
|
|
|
|
|
|
/// Define an empty d-tor out-of-line to keep boost::scoped_ptr happy.
|
|
|
|
~CacheItem();
|
|
|
|
|
|
|
|
///
|
|
|
|
string const & filename() const;
|
2002-02-27 09:59:52 +00:00
|
|
|
|
|
|
|
/// It's in the cache. Now start the loading process.
|
2002-06-25 15:59:10 +00:00
|
|
|
void startLoading();
|
2002-02-27 09:59:52 +00:00
|
|
|
|
2002-06-25 15:59:10 +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-06-25 15:59:10 +00:00
|
|
|
/// This signal is emitted when the image loading status changes.
|
|
|
|
boost::signal0<void> statusChanged;
|
2000-08-08 09:18:39 +00:00
|
|
|
|
2000-07-31 12:30:10 +00:00
|
|
|
private:
|
2002-06-28 11:22:56 +00:00
|
|
|
/// Use the Pimpl idiom to hide the internals.
|
|
|
|
class Impl;
|
2002-02-27 09:59:52 +00:00
|
|
|
|
2002-06-28 11:22:56 +00:00
|
|
|
/// The pointer never changes although *pimpl_'s contents may.
|
|
|
|
boost::scoped_ptr<Impl> const pimpl_;
|
2002-02-27 09:59:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace grfx
|
|
|
|
|
|
|
|
#endif // GRAPHICSCACHEITEM_H
|