+2003-10-12 Angus Leeming <leeming@lyx.org>
+
+ * renderbase.h (view, view_): removed.
+ * renderbase.C: removed.
+ * Makefile.am: remove render_base.C. The shortest lived file in history?
+
+ * renderbutton.C (draw):
+ * render_graphic.C (draw): don't cache the BufferView.
+
+ * insetabase.h (cache, view): removed.
+
+ * inset.h (generatePreview) removed.
+
+ * insetcallapsable.[Ch] (cache, view, view_): removed.
+
+ * insetcollapsable.C (draw): don't cache the BufferView.
+
+ * insetcommand.[Ch] (view): removed.
+
+ * insetexternal.[Ch] (cache, view, view_):
+ * insetgraphics.[Ch] (cache, view, view_):
+ * insetinclude.[Ch] (cache, view, view_): added. Cache the BufferView.
+
+ * insetlabel.C: small clean-up. Don't use the BufferView cache, view(),
+ when you have direct access to it. In fact, don't use the cache at all.
+
2003-10-10 Angus Leeming <leeming@lyx.org>
* insetinclude.C (metrics): use preview_->metrics.
* insetinclude.[Ch]: mods to PreviewImpl due to the changes to
PreviewedInset.
-
+
2003-10-09 Angus Leeming <leeming@lyx.org>
* insetinclude.C (metrics, draw, restartLoading): pass a buffer arg
ExternalTemplate.h \
ExternalTransforms.C \
ExternalTransforms.h \
- render_base.C \
render_base.h \
render_button.C \
render_button.h \
* defaults to empty.
*/
virtual void addPreview(lyx::graphics::PreviewLoader &) const {}
-
- /** Find the PreviewLoader, add a LaTeX snippet to it and
- * start the loading process.
- *
- * Most insets have no interest in this capability, so the method
- * defaults to empty.
- */
- virtual void generatePreview(Buffer const &) const {}
-
protected:
///
mutable int top_x;
/// draw inset and update (xo, yo)-cache
virtual void draw(PainterInfo & pi, int x, int y) const = 0;
- /// Methods to cache and retrieve a cached BufferView.
- virtual void cache(BufferView *) const {}
- ///
- virtual BufferView * view() const { return 0; }
/// request "external features"
virtual void validate(LaTeXFeatures &) const {}
/// Appends \c list with all labels found within this inset.
void InsetCollapsable::draw(PainterInfo & pi, int x, int y, bool inlined) const
{
- BOOST_ASSERT(pi.base.bv);
- cache(pi.base.bv);
-
Dimension dim_collapsed;
dimension_collapsed(dim_collapsed);
{
inset.addPreview(loader);
}
-
-
-void InsetCollapsable::cache(BufferView * bv) const
-{
- view_ = bv->owner()->view();
-}
-
-
-BufferView * InsetCollapsable::view() const
-{
- return view_.lock().get();
-}
#include "box.h"
#include "lyxfont.h"
-#include <boost/weak_ptr.hpp>
-
class Painter;
class LyXText;
class Paragraph;
void addPreview(lyx::graphics::PreviewLoader &) const;
protected:
- ///
- virtual void cache(BufferView *) const;
- ///
- virtual BufferView * view() const;
-
///
void dimension_collapsed(Dimension &) const;
///
bool in_update;
///
mutable bool first_after_edit;
- ///
- mutable boost::weak_ptr<BufferView> view_;
};
{}
-BufferView * InsetCommand::view() const
-{
- return button_.view();
-}
-
-
void InsetCommand::metrics(MetricsInfo & mi, Dimension & dim) const
{
if (!set_label_) {
void setOptions(std::string const & o) { p_.setOptions(o); }
///
void setParams(InsetCommandParams const &);
- ///
- virtual BufferView * view() const;
/// This should provide the text for the button
virtual std::string const getScreenLabel(Buffer const &) const = 0;
#include "latexrunparams.h"
#include "lyxlex.h"
#include "lyxrc.h"
+#include "metricsinfo.h"
#include "frontends/lyx_gui.h"
+#include "frontends/LyXView.h"
#include "support/lstrings.h"
#include "support/lyxlib.h"
}
+void InsetExternal::cache(BufferView * view) const
+{
+ BOOST_ASSERT(view);
+ view_ = view->owner()->view();
+}
+
+BufferView * InsetExternal::view() const
+{
+ return view_.lock().get();
+}
+
+
void InsetExternal::statusChanged() const
{
- BufferView * const bv = renderer_->view();
+ BufferView * const bv = view();
if (bv)
bv->updateInset(this);
}
void InsetExternal::draw(PainterInfo & pi, int x, int y) const
{
+ cache(pi.base.bv);
renderer_->draw(pi, x, y);
}
#include <boost/scoped_ptr.hpp>
#include <boost/signals/trackable.hpp>
+#include <boost/weak_ptr.hpp>
/** No two InsetExternalParams variables can have the same temporary file.
void setParams(InsetExternalParams const &, Buffer const &);
private:
+ void cache(BufferView *) const;
+ BufferView * view() const;
/** This method is connected to the graphics loader, so we are
* informed when the image has been loaded.
*/
InsetExternalParams params_;
/// The thing that actually draws the image on LyX's screen.
boost::scoped_ptr<RenderBase> renderer_;
+
+ /// Cached
+ mutable boost::weak_ptr<BufferView> view_;
};
#include "latexrunparams.h"
#include "lyxlex.h"
#include "lyxrc.h"
+#include "metricsinfo.h"
#include "frontends/Alert.h"
+#include "frontends/LyXView.h"
#include "support/filetools.h"
#include "support/lyxalgo.h" // lyx::count
}
+void InsetGraphics::cache(BufferView * view) const
+{
+ BOOST_ASSERT(view);
+ view_ = view->owner()->view();
+}
+
+BufferView * InsetGraphics::view() const
+{
+ return view_.lock().get();
+}
+
+
void InsetGraphics::statusChanged() const
{
- BufferView * bv = graphic_->view();
+ BufferView * bv = view();
if (bv)
bv->updateInset(this);
}
void InsetGraphics::draw(PainterInfo & pi, int x, int y) const
{
+ cache(pi.base.bv);
graphic_->draw(pi, x, y);
}
#include <boost/scoped_ptr.hpp>
#include <boost/signals/trackable.hpp>
+#include <boost/weak_ptr.hpp>
class Dialogs;
///
void metrics(MetricsInfo &, Dimension &) const;
///
- void draw(PainterInfo & pi, int x, int y) const;
- ///
EDITABLE editable() const;
///
void write(Buffer const &, std::ostream &) const;
/// Get the inset parameters, used by the GUIndependent dialog.
InsetGraphicsParams const & params() const;
+ ///
+ void draw(PainterInfo & pi, int x, int y) const;
private:
///
friend class InsetGraphicsMailer;
+ void cache(BufferView *) const;
+ BufferView * view() const;
+
/** This method is connected to the graphics loader, so we are
* informed when the image has been loaded.
*/
/// The thing that actually draws the image on LyX's screen.
boost::scoped_ptr<RenderGraphic> const graphic_;
+
+ /// Cached
+ mutable boost::weak_ptr<BufferView> view_;
};
#include "lyxlex.h"
#include "metricsinfo.h"
+#include "frontends/LyXView.h"
#include "frontends/Painter.h"
#include "graphics/PreviewImage.h"
}
+void InsetInclude::cache(BufferView * view) const
+{
+ BOOST_ASSERT(view);
+ view_ = view->owner()->view();
+}
+
BufferView * InsetInclude::view() const
{
- return button_.view();
+ return view_.lock().get();
}
#include "insetcommandparams.h"
#include "render_button.h"
#include <boost/scoped_ptr.hpp>
+#include <boost/weak_ptr.hpp>
class Buffer;
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
void draw(PainterInfo & pi, int x, int y) const;
- ///
- virtual BufferView * view() const;
/// get the parameters
InsetCommandParams const & params(void) const;
void addPreview(lyx::graphics::PreviewLoader &) const;
private:
+ void cache(BufferView *) const;
+ BufferView * view() const;
+
/// Slot receiving a signal that the preview is ready to display.
void statusChanged() const;
/** Slot receiving a signal that the external file has changed
*/
void fileChanged() const;
-
friend class InsetIncludeMailer;
/// set the parameters
boost::scoped_ptr<RenderMonitoredPreview> const preview_;
/// cache
+ mutable boost::weak_ptr<BufferView> view_;
mutable bool set_label_;
mutable RenderButton button_;
};
#include "BufferView.h"
#include "funcrequest.h"
+#include "frontends/LyXView.h"
+
#include "support/lstrings.h"
#include "support/std_ostream.h"
}
+std::auto_ptr<InsetBase> InsetLabel::clone() const
+{
+ return std::auto_ptr<InsetBase>(new InsetLabel(params()));
+}
+
+
void InsetLabel::getLabelList(Buffer const &, std::vector<string> & list) const
{
list.push_back(getContents());
}
+string const InsetLabel::getScreenLabel(Buffer const &) const
+{
+ return getContents();
+}
+
+
dispatch_result InsetLabel::localDispatch(FuncRequest const & cmd)
{
+ BOOST_ASSERT(cmd.view());
+ BufferView * const bv = cmd.view();
+
switch (cmd.action) {
case LFUN_INSET_EDIT:
- InsetCommandMailer("label", *this).showDialog(cmd.view());
+ InsetCommandMailer("label", *this).showDialog(bv);
return DISPATCHED;
break;
return UNDISPATCHED;
bool clean = true;
- if (view() && p.getContents() != params().getContents()) {
- clean = view()->ChangeRefsIfUnique(params().getContents(),
- p.getContents());
+ if (bv && p.getContents() != params().getContents()) {
+ clean = bv->ChangeRefsIfUnique(params().getContents(),
+ p.getContents());
}
setParams(p);
- cmd.view()->updateInset(this);
+ bv->updateInset(this);
return DISPATCHED;
}
#include "insetcommand.h"
+#include <boost/weak_ptr.hpp>
class InsetLabel : public InsetCommand {
public:
///
~InsetLabel();
///
- virtual std::auto_ptr<InsetBase> clone() const {
- return std::auto_ptr<InsetBase>(new InsetLabel(params()));
- }
+ std::auto_ptr<InsetBase> clone() const;
///
virtual dispatch_result localDispatch(FuncRequest const & cmd);
///
- std::string const getScreenLabel(Buffer const &) const { return getContents(); }
+ std::string const getScreenLabel(Buffer const &) const;
///
EDITABLE editable() const { return IS_EDITABLE; }
///
+++ /dev/null
-/**
- * \file render_base.C
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Angus Leeming
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "render_base.h"
-
-#include "BufferView.h"
-
-
-BufferView * RenderBase::view() const
-{
- return view_.lock().get();
-}
#include "dimension.h"
-#include <boost/weak_ptr.hpp>
-
-class BufferView;
class MetricsInfo;
class PainterInfo;
/// draw inset and update (xo, yo)-cache
virtual void draw(PainterInfo & pi, int x, int y) const = 0;
- /// An accessor function to the cached store.
- BufferView * view() const;
-
protected:
RenderBase() {}
RenderBase(RenderBase const &) {}
void operator=(RenderBase const &) {}
- /// These are cached variables (are not copied).
- mutable boost::weak_ptr<BufferView> view_;
+ /// Cached
mutable Dimension dim_;
};
#include "render_button.h"
-#include "BufferView.h"
#include "LColor.h"
#include "metricsinfo.h"
#include "frontends/font_metrics.h"
-#include "frontends/LyXView.h"
#include "frontends/Painter.h"
using std::string;
void RenderButton::draw(PainterInfo & pi, int x, int y) const
{
- BOOST_ASSERT(pi.base.bv);
- view_ = pi.base.bv->owner()->view();
-
// Draw it as a box with the LaTeX text
LyXFont font(LyXFont::ALL_SANE);
font.setColor(LColor::command);
#include "insets/inset.h"
-#include "BufferView.h"
#include "gettext.h"
#include "LColor.h"
#include "metricsinfo.h"
#include "frontends/font_metrics.h"
-#include "frontends/LyXView.h"
#include "frontends/Painter.h"
#include "graphics/GraphicsImage.h"
void RenderGraphic::draw(PainterInfo & pi, int x, int y) const
{
- BOOST_ASSERT(pi.base.bv);
- view_ = pi.base.bv->owner()->view();
-
if (params_.display != lyx::graphics::NoDisplay &&
loader_.status() == lyx::graphics::WaitingToLoad)
loader_.startLoading();
+2003-10-12 Angus Leeming <leeming@lyx.org>
+
+ * formulabase.[Ch] (cache): added.
+ (view): make protected.
+ (view_): store as a boost::weak_ptr.
+ (generatePreview): added this virtual function. Moved from inset.h.
+
+ * math_inset.[Ch] (view): removed.
+
2003-10-10 Angus Leeming <leeming@lyx.org>
* command_inset.h:trivial changes ButtonRenderer -> RenderButton.
void InsetFormula::draw(PainterInfo & pi, int x, int y) const
{
- BOOST_ASSERT(pi.base.bv);
- BufferView * bv = pi.base.bv;
- cache(bv);
+ cache(pi.base.bv);
// The previews are drawn only when we're not editing the inset.
bool const editing_inset = mathcursor && mathcursor->formula() == this;
// one pixel gap in front
preview_->draw(pi, x + 1, y);
} else {
- PainterInfo p(bv);
+ PainterInfo p(pi.base.bv);
p.base.style = LM_ST_TEXT;
p.base.font = pi.base.font;
p.base.font.setColor(LColor::math);
void InsetFormula::metrics(MetricsInfo & m, Dimension & dim) const
{
- BOOST_ASSERT(m.base.bv);
- view_ = m.base.bv;
-
bool const editing_inset = mathcursor && mathcursor->formula() == this;
bool const use_preview = !editing_inset && preview_->previewReady();
InsetFormulaBase::InsetFormulaBase()
- : view_(0), xo_(0), yo_(0)
+ : xo_(0), yo_(0)
{
// This is needed as long the math parser is not re-entrant
initMath();
+void InsetFormulaBase::cache(BufferView * view) const
+{
+ BOOST_ASSERT(view);
+ view_ = view->owner()->view();
+}
+
BufferView * InsetFormulaBase::view() const
{
- return view_;
+ return view_.lock().get();
}
#define INSET_FORMULABASE_H
#include "insets/updatableinset.h"
+#include <boost/weak_ptr.hpp>
class Buffer;
///
virtual MathAtom & par() = 0;
///
- // And shouldn't this really return a shared_ptr<BufferView> instead?
- BufferView * view() const;
-
///
virtual bool searchForward(BufferView *, std::string const &,
bool = true, bool = false);
dispatch_result lfunMouseMotion(FuncRequest const &);
protected:
- ///
- //mutable boost::weak_ptr<BufferView> view_;
- mutable BufferView * view_;
+ void cache(BufferView *) const;
+ BufferView * view() const;
protected:
+
+ /** Find the PreviewLoader, add a LaTeX snippet to it and
+ * start the loading process.
+ *
+ * Most insets have no interest in this capability, so the method
+ * defaults to empty.
+ */
+ virtual void generatePreview(Buffer const &) const {}
+
///
void handleFont(BufferView * bv, std::string const & arg, std::string const & font);
///
mutable int xo_;
///
mutable int yo_;
+private:
+ // Cache
+ mutable boost::weak_ptr<BufferView> view_;
};
// We don't really mess want around with mathed stuff outside mathed.
#include <config.h>
#include "math_inset.h"
+#include "math_data.h"
#include "math_mathmlstream.h"
-#include "math_cursor.h"
#include "debug.h"
-#include "formulabase.h"
-
-
using std::string;
using std::ostream;
using std::endl;
-BufferView * MathInset::view() const
-{
- return mathcursor ? mathcursor->formula()->view() : 0;
-}
-
-
MathInset::size_type MathInset::nargs() const
{
return 0;
virtual std::string fileInsetLabel() const;
/// usually the latex name
virtual std::string name() const;
-
-protected:
- /// a dirty hack
- BufferView * view() const;
};
std::ostream & operator<<(std::ostream &, MathAtom const &);