X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fgraphics%2FGraphicsCacheItem.h;h=a018b3931d7f871c0778eaa830a821d1326a4d53;hb=4f0981e7bbbb8d9d00490856daa3d35e170845d7;hp=49aaa28de928f294b323fb98384beedbae5237d3;hpb=797d87b4513088a66b17c7ac653b84e36ea80458;p=lyx.git diff --git a/src/graphics/GraphicsCacheItem.h b/src/graphics/GraphicsCacheItem.h index 49aaa28de9..a018b3931d 100644 --- a/src/graphics/GraphicsCacheItem.h +++ b/src/graphics/GraphicsCacheItem.h @@ -1,29 +1,102 @@ // -*- C++ -*- -/* This file is part of - * ================================================= - * - * LyX, The Document Processor - * Copyright 1995 Matthias Ettrich. - * Copyright 1995-2000 The LyX Team. +/** + * \file GraphicsCacheItem.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. * - * This file Copyright 2000 Baruch Even - * ================================================= */ + * \author Baruch Even + * \author Angus Leeming + * + * Full author contact details are available in file CREDITS. + * + * The graphics cache is a container of graphics::CacheItems. + * Each graphics::CacheItem, defined here represents a separate image file. + * + * The routines here can be used to load the graphics file into memory at + * which point (status() == graphics::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. + * + * The graphics cache supports fully asynchronous: + * file conversion to a loadable format; + * file loading. + * + * Whether you get that, of course, depends on graphics::Converter and + * on the graphics::Image-derived image class. + */ #ifndef GRAPHICSCACHEITEM_H #define GRAPHICSCACHEITEM_H -#ifdef __GNUG__ -#pragma interface -#endif +#include "GraphicsTypes.h" + +#include "support/signals.h" + + +namespace lyx { + +namespace support { class FileName; } + +namespace graphics { + +class Image; -/// -class GraphicsCacheItem { +/// A graphics::Cache item holder. +class CacheItem { public: + /// + CacheItem(support::FileName const & file, support::FileName const & doc_file); + /// Needed for the pimpl + ~CacheItem(); + + /// + support::FileName const & filename() const; + + /// Try to load a display format. + bool tryDisplayFormat() const; + + /// It's in the cache. Now start the loading process. + void startLoading() const; + + /** Monitor any changes to the file. + * There is no point monitoring the file before startLoading() is + * invoked. + */ + void startMonitoring() const; + /// + bool monitoring() const; + /// perform a modification check asynchronously + void checkModifiedAsync() const; + + /** Get the image associated with filename(). + * 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. + */ + Image const * image() const; + + /// How far have we got in loading the image? + ImageStatus status() const; + + /** Connect and you'll be informed when the loading status of the image + * changes. + */ + typedef signal::slot_type slot_type; + /// + connection connect(slot_type const &) const; + private: - /// - GraphicsCacheItem() {} - /// - friend class GraphicsCache; + /// noncopyable + CacheItem(CacheItem const &); + void operator=(CacheItem const &); + + /// Use the Pimpl idiom to hide the internals. + class Impl; + /// The pointer never changes although *pimpl_'s contents may. + Impl * const pimpl_; }; -#endif +} // namespace graphics +} // namespace lyx + +#endif // GRAPHICSCACHEITEM_H