#include "Floating.h"
#include "FloatList.h"
#include "funcrequest.h"
+#include "FuncStatus.h"
#include "gettext.h"
#include "LaTeXFeatures.h"
#include "LColor.h"
#include "pariterator.h"
#include "support/lstrings.h"
-#include "support/tostr.h"
+#include "support/convert.h"
#include <sstream>
namespace {
-// this should not be hardcoded, but be part of the definition
-// of the float (JMarc)
-string const caplayout("Caption");
-
string floatname(string const & type, BufferParams const & bp)
{
FloatList const & floats = bp.getLyXTextClass().floats();
setLabelFont(font);
params_.type = type;
setInsetName(type);
- LyXTextClass const & tclass = bp.getLyXTextClass();
- if (tclass.hasLayout(caplayout))
- paragraphs().begin()->layout(tclass[caplayout]);
}
}
-void InsetFloat::priv_dispatch(LCursor & cur, FuncRequest & cmd)
+void InsetFloat::doDispatch(LCursor & cur, FuncRequest & cmd)
{
switch (cmd.action) {
params_.sideways = params.sideways;
wide(params_.wide, cur.buffer().params());
sideways(params_.sideways, cur.buffer().params());
- cur.bv().update();
break;
}
InsetFloatMailer(*this).showDialog(&cur.bv());
break;
}
- InsetCollapsable::priv_dispatch(cur, cmd);
+ InsetCollapsable::doDispatch(cur, cmd);
break;
}
default:
- InsetCollapsable::priv_dispatch(cur, cmd);
+ InsetCollapsable::doDispatch(cur, cmd);
break;
}
}
+bool InsetFloat::getStatus(LCursor & cur, FuncRequest const & cmd,
+ FuncStatus & flag) const
+{
+ switch (cmd.action) {
+
+ case LFUN_INSET_MODIFY:
+ case LFUN_INSET_DIALOG_UPDATE:
+ flag.enabled(true);
+ return true;
+
+ default:
+ return InsetCollapsable::getStatus(cur, cmd, flag);
+ }
+}
+
+
void InsetFloatParams::write(ostream & os) const
{
os << "Float " << type << '\n';
}
-bool InsetFloat::insetAllowed(InsetOld::Code code) const
+bool InsetFloat::insetAllowed(InsetBase::Code code) const
{
- return code != InsetOld::FLOAT_CODE
- && code != InsetOld::FOOT_CODE
- && code != InsetOld::MARGIN_CODE;
+ return code != InsetBase::FLOAT_CODE
+ && code != InsetBase::FOOT_CODE
+ && code != InsetBase::MARGIN_CODE;
}
// Find a caption layout in one of the (child inset's) pars
for (; pit != end; ++pit) {
- if (pit->layout()->name() == caplayout) {
- string const name = floatname(params_.type, buf.params());
+ if (pit->layout()->labeltype == LABEL_SENSITIVE) {
+ string const type = params_.type;
string const str =
- tostr(toclist[name].size() + 1)
+ convert<string>(toclist[type].size() + 1)
+ ". " + pit->asString(buf, false);
lyx::toc::TocItem const item(pit->id(), 0 , str);
- toclist[name].push_back(item);
+ toclist[type].push_back(item);
}
}
}