#include <config.h>
#include "insetcollapsable.h"
-#include "insettext.h"
+#include "buffer.h"
#include "BufferView.h"
#include "debug.h"
-#include "dimension.h"
-#include "gettext.h"
-#include "lyxfont.h"
+#include "LColor.h"
#include "lyxlex.h"
-#include "lyxtext.h"
-#include "WordLangTuple.h"
#include "funcrequest.h"
-#include "buffer.h"
#include "metricsinfo.h"
+#include "paragraph.h"
+#include "WordLangTuple.h"
#include "frontends/font_metrics.h"
#include "frontends/Painter.h"
#include "frontends/LyXView.h"
-#include "support/LAssert.h"
-#include "support/LOstream.h"
-using namespace lyx::support;
-using namespace lyx::graphics;
+using lyx::graphics::PreviewLoader;
-using std::vector;
-using std::ostream;
using std::endl;
+using std::string;
using std::max;
+using std::ostream;
InsetCollapsable::InsetCollapsable(BufferParams const & bp, bool collapsed)
- : UpdatableInset(), collapsed_(collapsed), inset(bp),
+ : UpdatableInset(), inset(bp), collapsed_(collapsed),
button_dim(0, 0, 0, 0), label("Label"),
#if 0
autocollapse(false),
InsetCollapsable::InsetCollapsable(InsetCollapsable const & in)
- : UpdatableInset(in), collapsed_(in.collapsed_),
- framecolor(in.framecolor), labelfont(in.labelfont), inset(in.inset),
- button_dim(0, 0, 0, 0), label(in.label),
+ : UpdatableInset(in), inset(in.inset), collapsed_(in.collapsed_),
+ labelfont_(in.labelfont_), button_dim(0, 0, 0, 0), label(in.label),
#if 0
autocollapse(in.autocollapse),
#endif
in_update(false), first_after_edit(false)
{
- inset.init(&(in.inset));
inset.setOwner(this);
}
void InsetCollapsable::dimension_collapsed(Dimension & dim) const
{
- font_metrics::buttonText(label, labelfont, dim.wid, dim.asc, dim.des);
+ font_metrics::buttonText(label, labelfont_, dim.wid, dim.asc, dim.des);
}
int InsetCollapsable::height_collapsed() const
{
Dimension dim;
- font_metrics::buttonText(label, labelfont, dim.wid, dim.asc, dim.des);
+ font_metrics::buttonText(label, labelfont_, dim.wid, dim.asc, dim.des);
return dim.asc + dim.des;
}
void InsetCollapsable::draw_collapsed(PainterInfo & pi, int x, int y) const
{
- pi.pain.buttonText(x, y, label, labelfont);
+ pi.pain.buttonText(x, y, label, labelfont_);
}
void InsetCollapsable::draw(PainterInfo & pi, int x, int y, bool inlined) const
{
- Assert(pi.base.bv);
- cache(pi.base.bv);
-
Dimension dim_collapsed;
dimension_collapsed(dim_collapsed);
}
bv->updateInset(this);
bv->buffer()->markDirty();
- lyxerr << "InsetCollapsable::lfunMouseRelease\n";
} else if (!collapsed_ && cmd.y > button_dim.y2) {
ret = inset.localDispatch(adjustCommand(cmd)) == DISPATCHED;
}
bool InsetCollapsable::hitButton(FuncRequest const & cmd) const
{
- return button_dim.contained(cmd.x, cmd.y);
+ return button_dim.contains(cmd.x, cmd.y);
}
-InsetOld::RESULT InsetCollapsable::localDispatch(FuncRequest const & cmd)
+dispatch_result InsetCollapsable::localDispatch(FuncRequest const & cmd)
{
//lyxerr << "InsetCollapsable::localDispatch: "
// << cmd.action << " '" << cmd.argument << "'\n";
bv->buffer()->markDirty();
inset.localDispatch(cmd);
} else {
- FuncRequest cmd1 = cmd;
if (!bv->lockInset(this))
return DISPATCHED;
if (cmd.y <= button_dim.y2) {
+ FuncRequest cmd1 = cmd;
cmd1.y = 0;
- } else {
- cmd1.y = ascent() + cmd.y - (height_collapsed() + inset.ascent());
- }
- inset.localDispatch(cmd);
+ inset.localDispatch(cmd1);
+ } else
+ inset.localDispatch(adjustCommand(cmd));
}
return DISPATCHED;
}
return DISPATCHED;
default:
- UpdatableInset::RESULT result = inset.localDispatch(cmd);
+ dispatch_result result = inset.localDispatch(cmd);
if (result >= FINISHED)
bv->unlockInset(this);
first_after_edit = false;
}
-void InsetCollapsable::getLabelList(std::vector<string> & list) const
+void InsetCollapsable::getLabelList(Buffer const & buffer,
+ std::vector<string> & list) const
{
- inset.getLabelList(list);
+ inset.getLabelList(buffer, list);
}
}
+void InsetCollapsable::setCollapsed(bool c) const
+{
+ collapsed_ = c;
+}
+
+
void InsetCollapsable::markErased()
{
inset.markErased();
{
inset.addPreview(loader);
}
-
-
-void InsetCollapsable::cache(BufferView * bv) const
-{
- view_ = bv->owner()->view();
-}
-
-
-BufferView * InsetCollapsable::view() const
-{
- return view_.lock().get();
-}