mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-11 05:33:33 +00:00
607ad8d3a7
* lazy loading (don't try and load the image until a request to draw it is received). * asynchronous conversion to a loadable format. * asynchronous loading if the image loader supports it (it doesn't). * "simple" cropping, rotating and scaling (in that order) of the image on the LyX screen. * display in color, grayscale or monochrome. We also have a forked calls dialog, although it isn't very exciting yet because only the graphics cache makes use of the forked call controller. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3591 a592a061-630c-0410-9148-cb99ea01b6c8
101 lines
2.4 KiB
C++
101 lines
2.4 KiB
C++
// -*- C++ -*-
|
|
/**
|
|
* \file GraphicsCache.h
|
|
* Copyright 2002 the LyX Team
|
|
* Read the file COPYING
|
|
*
|
|
* \author Baruch Even <baruch.even@writeme.com>
|
|
* \author Angus Leeming <a.leeming@ic.ac.uk>
|
|
*
|
|
* grfx::GCache is the manager of the image cache.
|
|
* It is responsible for creating the grfx::GCacheItem's and maintaining them.
|
|
*
|
|
* grfx::GCache is a singleton class. It is possible to have only one
|
|
* instance of it at any moment.
|
|
*/
|
|
|
|
#ifndef GRAPHICSCACHE_H
|
|
#define GRAPHICSCACHE_H
|
|
|
|
#ifdef __GNUG__
|
|
#pragma interface
|
|
#endif
|
|
|
|
#include "GraphicsTypes.h"
|
|
#include <map>
|
|
#include "LString.h"
|
|
#include <boost/utility.hpp>
|
|
|
|
class InsetGraphics;
|
|
|
|
namespace grfx {
|
|
|
|
class GCacheItem;
|
|
|
|
class GCache : boost::noncopyable {
|
|
public:
|
|
|
|
/// This is a singleton class. Get the instance.
|
|
static GCache & get();
|
|
|
|
///
|
|
~GCache();
|
|
|
|
/// Add a file to the cache (or modify an existing image).
|
|
void update(InsetGraphics const &);
|
|
|
|
/** Remove the data associated with this inset.
|
|
* Called from the InsetGraphics d-tor.
|
|
*/
|
|
void remove(InsetGraphics const &);
|
|
|
|
/** No processing of the image will take place until this call is
|
|
* received.
|
|
*/
|
|
void startLoading(InsetGraphics const &);
|
|
|
|
/** If (changed_background == true), then the background color of the
|
|
* graphics inset has changed. Update all images.
|
|
* Else, the preferred display type has changed.
|
|
* Update the view of all insets whose display type is DEFAULT.
|
|
*/
|
|
void changeDisplay(bool changed_background = false);
|
|
|
|
/// Get the image referenced by a particular inset.
|
|
ImagePtr const image(InsetGraphics const &) const;
|
|
|
|
/// How far have we got in loading the image?
|
|
ImageStatus status(InsetGraphics const &) const;
|
|
|
|
private:
|
|
/** Make the c-tor private so we can control how many objects
|
|
* are instantiated.
|
|
*/
|
|
GCache();
|
|
|
|
/// The cache contains data of this type.
|
|
typedef boost::shared_ptr<GCacheItem> CacheItemType;
|
|
|
|
/** The cache contains one item per file, so use a map to find the
|
|
* cache item quickly by filename.
|
|
* Note that each cache item can have multiple views, potentially one
|
|
* per inset that references the original file.
|
|
*/
|
|
typedef std::map<string, CacheItemType> CacheType;
|
|
|
|
/// Search the cache by inset.
|
|
CacheType::const_iterator find(InsetGraphics const &) const;
|
|
///
|
|
CacheType::iterator find(InsetGraphics const &);
|
|
|
|
/** Store a pointer to the cache so that we can forward declare
|
|
* GCacheItem.
|
|
*/
|
|
CacheType * cache;
|
|
};
|
|
|
|
} // namespace grfx
|
|
|
|
|
|
#endif // GRAPHICSCACHE_H
|