2002-06-26 14:15:08 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
|
|
|
* \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
|
|
|
*
|
2002-12-01 22:59:25 +00:00
|
|
|
* \author Angus Leeming
|
2002-09-05 11:31:30 +00:00
|
|
|
*
|
2002-09-05 14:10:50 +00:00
|
|
|
* Full author contact details are available in file CREDITS
|
2002-06-26 14:15:08 +00:00
|
|
|
*
|
2002-06-28 11:22:56 +00:00
|
|
|
* The public face of the graphics cache.
|
|
|
|
*
|
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
|
|
|
*
|
|
|
|
* What could be simpler?
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GRAPHICSLOADER_H
|
|
|
|
#define GRAPHICSLOADER_H
|
|
|
|
|
|
|
|
#include "GraphicsTypes.h"
|
|
|
|
#include "LString.h"
|
|
|
|
|
|
|
|
#include <boost/signals/signal0.hpp>
|
2002-06-26 16:57:59 +00:00
|
|
|
#include <boost/scoped_ptr.hpp>
|
2002-06-26 14:15:08 +00:00
|
|
|
|
2002-07-15 11:08:46 +00:00
|
|
|
class Inset;
|
|
|
|
class BufferView;
|
|
|
|
|
2002-06-26 14:15:08 +00:00
|
|
|
namespace grfx {
|
|
|
|
|
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.
|
|
|
|
Loader(string const & file_with_path, DisplayType = ColorDisplay);
|
|
|
|
/// The image is transformed before display.
|
2002-06-28 11:22:56 +00:00
|
|
|
Loader(string const & file_with_path, Params const &);
|
2002-06-26 14:15:08 +00:00
|
|
|
|
2002-06-26 16:57:59 +00:00
|
|
|
/// Define an empty d-tor out-of-line to keep boost::scoped_ptr happy.
|
|
|
|
~Loader();
|
|
|
|
|
2002-06-26 14:15:08 +00:00
|
|
|
/// The file can be changed, or the display params, or both.
|
2002-07-17 16:56:42 +00:00
|
|
|
void reset(string const & file_with_path,
|
|
|
|
DisplayType = ColorDisplay) const;
|
2002-06-26 14:15:08 +00:00
|
|
|
///
|
2002-07-17 16:56:42 +00:00
|
|
|
void reset(string 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.
|
|
|
|
string const & filename() const;
|
|
|
|
///
|
|
|
|
bool empty() const { return filename().empty(); }
|
|
|
|
|
|
|
|
/// We are explicit about when we begin the loading process.
|
2002-07-17 16:56:42 +00:00
|
|
|
void startLoading() 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-25 19:09:00 +00:00
|
|
|
void startLoading(Inset const &) 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;
|
|
|
|
/** Returns the check sum of filename() so that, for example, you can
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
typedef boost::signal0<void>::slot_type slot_type;
|
|
|
|
///
|
|
|
|
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.
|
2002-06-26 16:57:59 +00:00
|
|
|
boost::scoped_ptr<Impl> const pimpl_;
|
2002-06-26 14:15:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace grfx
|
|
|
|
|
|
|
|
#endif // GRAPHICSLOADER_H
|