2002-06-26 14:15:08 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
2003-08-23 00:17:00 +00:00
|
|
|
* \file GraphicsLoader.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.
|
2002-06-26 14:15:08 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* \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-06-26 14:15:08 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* The public face of the graphics cache.
|
2002-06-28 11:22:56 +00:00
|
|
|
*
|
2002-06-26 14:15:08 +00:00
|
|
|
* * The user supplies an image file and the display parameters.
|
|
|
|
* * He can change the file or the display parameters through a reset() method.
|
|
|
|
* * He must start the loading process explicitly with startLoading().
|
2002-07-17 17:55:21 +00:00
|
|
|
* * If he is connected through the connect() method, then he'll be informed
|
|
|
|
* when the loading status changes.
|
|
|
|
* * When (status() == Ready), he can use image() to access the loaded image
|
|
|
|
* and pass it to the Painter.
|
2002-06-26 14:15:08 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* What could be simpler?
|
2002-06-26 14:15:08 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GRAPHICSLOADER_H
|
|
|
|
#define GRAPHICSLOADER_H
|
|
|
|
|
|
|
|
#include "GraphicsTypes.h"
|
|
|
|
|
2004-09-26 14:19:47 +00:00
|
|
|
#include <boost/signal.hpp>
|
2002-06-26 14:15:08 +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 {
|
2002-06-26 14:15:08 +00:00
|
|
|
|
2002-06-28 11:22:56 +00:00
|
|
|
class Image;
|
|
|
|
class Params;
|
2002-06-26 14:15:08 +00:00
|
|
|
|
|
|
|
class Loader {
|
|
|
|
public:
|
|
|
|
/// Must use the reset methods to make this instance usable.
|
|
|
|
Loader();
|
|
|
|
/// The image is not transformed, just displayed as-is.
|
2008-06-13 07:34:55 +00:00
|
|
|
Loader(support::FileName const & file_with_path, bool display = true);
|
2002-06-26 14:15:08 +00:00
|
|
|
/// The image is transformed before display.
|
2006-11-26 21:30:39 +00:00
|
|
|
Loader(support::FileName const & file_with_path, Params const &);
|
2003-06-03 10:13:26 +00:00
|
|
|
///
|
|
|
|
Loader(Loader const &);
|
2007-11-21 23:47:47 +00:00
|
|
|
/// Needed for the pimpl
|
2002-06-26 16:57:59 +00:00
|
|
|
~Loader();
|
|
|
|
|
2003-06-05 22:45:51 +00:00
|
|
|
Loader & operator=(Loader const &);
|
|
|
|
|
2002-06-26 14:15:08 +00:00
|
|
|
/// The file can be changed, or the display params, or both.
|
2008-06-13 07:34:55 +00:00
|
|
|
void reset(support::FileName const & file_with_path, bool display = true) const;
|
2002-06-26 14:15:08 +00:00
|
|
|
///
|
2006-11-26 21:30:39 +00:00
|
|
|
void reset(support::FileName const & file_with_path, Params const &) const;
|
2002-06-26 14:15:08 +00:00
|
|
|
///
|
2002-07-17 16:56:42 +00:00
|
|
|
void reset(Params const &) const;
|
2002-06-26 14:15:08 +00:00
|
|
|
|
|
|
|
/// Returns the absolute path of the loaded (loading?) file.
|
2006-11-26 21:30:39 +00:00
|
|
|
support::FileName const & filename() const;
|
2002-06-26 14:15:08 +00:00
|
|
|
///
|
|
|
|
|
2003-02-25 19:09:00 +00:00
|
|
|
/** starting loading of the image is done by a urgency-based
|
|
|
|
* decision. Here we only call LoaderQueue::touch to request it.
|
2002-07-15 11:08:46 +00:00
|
|
|
*/
|
2003-02-26 11:41:23 +00:00
|
|
|
void startLoading() const;
|
2002-07-15 11:08:46 +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-05 19:21:29 +00:00
|
|
|
/// How far have we got in loading the image?
|
2002-06-26 14:15:08 +00:00
|
|
|
ImageStatus status() const;
|
|
|
|
|
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;
|
2002-06-26 14:15:08 +00:00
|
|
|
|
|
|
|
/** The loaded image with Pixmap set.
|
|
|
|
* If the Pixmap is not yet set (see status() for why...), returns 0.
|
|
|
|
*/
|
2002-06-28 11:22:56 +00:00
|
|
|
Image const * image() const;
|
2002-06-26 14:15:08 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
/// 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-06-26 14:15:08 +00:00
|
|
|
};
|
|
|
|
|
2003-07-04 08:23:23 +00:00
|
|
|
} // namespace graphics
|
|
|
|
} // namespace lyx
|
2002-06-26 14:15:08 +00:00
|
|
|
|
|
|
|
#endif // GRAPHICSLOADER_H
|