Small clean-up of the PreviewedInset interface.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7778 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2003-09-16 15:43:00 +00:00
parent 35abda384d
commit 27a9cc2098
7 changed files with 44 additions and 11 deletions

View File

@ -1,3 +1,9 @@
2003-09-16 Angus Leeming <leeming@lyx.org>
* PreviewedInset.[Ch] (c-tor) move out of line.
(d-tor): make private.
(inset): return a const reference rather than a non-const pointer.
2003-09-16 Angus Leeming <leeming@lyx.org>
* GraphicsImage.h: separate interface from implementation. Make all the

View File

@ -35,6 +35,11 @@ bool PreviewedInset::activated()
}
PreviewedInset::PreviewedInset(InsetOld & inset)
: inset_(inset), pimage_(0)
{}
BufferView * PreviewedInset::view() const
{
return inset_.view();
@ -121,7 +126,7 @@ void PreviewedInset::imageReady(PreviewImage const & pimage) const
pimage_ = &pimage;
if (view())
view()->updateInset(inset());
view()->updateInset(&inset());
}
} // namespace graphics

View File

@ -9,7 +9,7 @@
* Full author contact details are available in file CREDITS.
*
* lyx::graphics::PreviewedInset is an abstract base class that can help
* insets to generate previews. The daughter class must instantiate three small
* insets to generate previews. The daughter class must instantiate two small
* methods. The Inset would own an instance of this daughter class.
*/
@ -35,9 +35,7 @@ public:
static bool activated();
///
PreviewedInset(InsetOld & inset) : inset_(inset), pimage_(0) {}
///
virtual ~PreviewedInset() {}
PreviewedInset(InsetOld & inset);
/** Find the PreviewLoader, add a LaTeX snippet to it and
* start the loading process.
@ -58,11 +56,13 @@ public:
bool previewReady() const;
/// If !previewReady() returns 0.
PreviewImage const * pimage() const { return pimage_; }
PreviewImage const * pimage() const;
protected:
///
virtual ~PreviewedInset() {}
/// Allow the daughter classes to cast up to the parent inset.
InsetOld * inset() const { return &inset_; }
InsetOld const & inset() const;
///
BufferView * view() const;
@ -86,6 +86,20 @@ private:
boost::signals::connection connection_;
};
inline
PreviewImage const * PreviewedInset::pimage() const
{
return pimage_;
}
inline
InsetOld const & PreviewedInset::inset() const
{
return inset_;
}
} // namespace graphics
} // namespace lyx

View File

@ -1,3 +1,7 @@
2003-09-16 Angus Leeming <leeming@lyx.org>
* insetinclude.C (PreviewImpl::parent): return a const reference.
2003-09-16 Angus Leeming <leeming@lyx.org>
* insetcollapsable.[Ch]: make all member variables, except for 'inset', private.

View File

@ -74,8 +74,8 @@ public:
///
string const latexString() const;
///
InsetInclude & parent() const {
return *static_cast<InsetInclude*>(inset());
InsetInclude const & parent() const {
return dynamic_cast<InsetInclude const &>(inset());
}
///

View File

@ -1,3 +1,7 @@
2003-09-16 Angus Leeming <leeming@lyx.org>
* formula.C (PreviewImpl::parent): return a const reference.
2003-09-16 Angus Leeming <leeming@lyx.org>
* formula.C:

View File

@ -48,9 +48,9 @@ private:
///
string const latexString() const;
///
InsetFormula & parent() const
InsetFormula const & parent() const
{
return *static_cast<InsetFormula*>(inset());
return dynamic_cast<InsetFormula const &>(inset());
}
};