mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-11 13:46:43 +00:00
cc132995fa
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4846 a592a061-630c-0410-9148-cb99ea01b6c8
97 lines
2.1 KiB
C++
97 lines
2.1 KiB
C++
// -*- C++ -*-
|
|
/**
|
|
* \file PreviewedInset.h
|
|
* Copyright 2002 the LyX Team
|
|
* Read the file COPYING
|
|
*
|
|
* \author Angus Leeming <leeming@lyx.org>
|
|
*
|
|
* grfx::PreviewedInset is an abstract base class that can help insets to
|
|
* generate previews. The daughter class must instantiate three small
|
|
* methods. The Inset would own an instance of this daughter class.
|
|
*/
|
|
|
|
#ifndef PREVIEWEDINSET_H
|
|
#define PREVIEWEDINSET_H
|
|
|
|
#ifdef __GNUG__
|
|
#pragma interface
|
|
#endif
|
|
|
|
#include "LString.h"
|
|
#include <boost/weak_ptr.hpp>
|
|
#include <boost/signals/trackable.hpp>
|
|
#include <boost/signals/connection.hpp>
|
|
|
|
class Inset;
|
|
class BufferView;
|
|
|
|
namespace grfx {
|
|
|
|
class PreviewImage;
|
|
class PreviewLoader;
|
|
|
|
class PreviewedInset : public boost::signals::trackable {
|
|
public:
|
|
/// a wrapper for Previews::activated()
|
|
static bool activated();
|
|
|
|
///
|
|
PreviewedInset(Inset & inset) : inset_(inset), pimage_(0) {}
|
|
///
|
|
virtual ~PreviewedInset() {}
|
|
|
|
/** Find the PreviewLoader, add a LaTeX snippet to it and
|
|
* start the loading process.
|
|
*/
|
|
void generatePreview();
|
|
|
|
/** Add a LaTeX snippet to the PreviewLoader but do not start the
|
|
* loading process.
|
|
*/
|
|
void addPreview(PreviewLoader & ploader);
|
|
|
|
/// The preview has been generated and is ready to use.
|
|
bool previewReady() const;
|
|
|
|
/// If !previewReady() returns 0.
|
|
PreviewImage const * pimage() const { return pimage_; }
|
|
|
|
///
|
|
void setView(BufferView *);
|
|
|
|
protected:
|
|
/// Allow the daughter classes to cast up to the parent inset.
|
|
Inset * inset() const { return &inset_; }
|
|
///
|
|
BufferView * view() const { return view_.get(); }
|
|
|
|
private:
|
|
/** This method is connected to the grfx::PreviewLoader::imageReady
|
|
* signal.
|
|
*/
|
|
void imageReady(PreviewImage const &) const;
|
|
|
|
/// Does the owning inset want a preview?
|
|
virtual bool previewWanted() const = 0;
|
|
/// a wrapper to Inset::latex
|
|
virtual string const latexString() const = 0;
|
|
|
|
///
|
|
Inset & inset_;
|
|
///
|
|
string snippet_;
|
|
///
|
|
boost::weak_ptr<BufferView> view_;
|
|
|
|
/// We don't own this. Cached for efficiency reasons.
|
|
mutable PreviewImage const * pimage_;
|
|
///
|
|
boost::signals::connection connection_;
|
|
};
|
|
|
|
} // namespace grfx
|
|
|
|
|
|
#endif // PREVIEWEDINSET_H
|