#include "support/convert.h"
#include "support/debug.h"
+#include "support/docstream.h"
#include "support/gettext.h"
#include "support/lstrings.h"
-#include "support/docstream.h"
#include "frontends/Application.h"
}
+docstring InsetFloat::toolTip(BufferView const & bv, int x, int y) const
+{
+ if (InsetCollapsable::toolTip(bv, x, y).empty())
+ return docstring();
+
+ docstring default_tip;
+ if (isOpen())
+ default_tip = _("Left-click to collapse the inset");
+ else
+ default_tip = _("Left-click to open the inset");
+ OutputParams rp(&buffer().params().encoding());
+ docstring caption_tip = getCaptionText(rp);
+ if (!isOpen() && !caption_tip.empty())
+ return caption_tip + '\n' + default_tip;
+ return default_tip;
+}
+
+
void InsetFloat::doDispatch(Cursor & cur, FuncRequest & cmd)
{
switch (cmd.action) {
case LFUN_INSET_MODIFY:
case LFUN_INSET_DIALOG_UPDATE:
- flag.enabled(true);
+ flag.setEnabled(true);
return true;
default:
void InsetFloat::updateLabels(ParIterator const & it)
{
- Counters & cnts = buffer().params().documentClass().counters();
+ Counters & cnts = buffer().masterBuffer()->params().documentClass().counters();
string const saveflt = cnts.current_float();
bool const savesubflt = cnts.isSubfloat();
- bool const subflt = it.innerInsetOfType(FLOAT_CODE);
+ bool const subflt = (it.innerInsetOfType(FLOAT_CODE)
+ || it.innerInsetOfType(WRAP_CODE));
// floats can only embed subfloats of their own kind
if (subflt)
params_.type = saveflt;
void InsetFloatParams::read(Lexer & lex)
{
- string token;
- lex >> token;
- if (token == "placement") {
+ lex.setContext("InsetFloatParams::read");
+ if (lex.checkFor("placement"))
lex >> placement;
- } else {
- // take countermeasures
- lex.pushToken(token);
- }
- lex >> token;
- if (token == "wide") {
- lex >> wide;
- } else {
- lyxerr << "InsetFloat::Read:: Missing wide!"
- << endl;
- // take countermeasures
- lex.pushToken(token);
- }
- lex >> token;
- if (token == "sideways") {
- lex >> sideways;
- } else {
- lyxerr << "InsetFloat::Read:: Missing sideways!"
- << endl;
- // take countermeasures
- lex.pushToken(token);
- }
+ lex >> "wide" >> wide;
+ lex >> "sideways" >> sideways;
}
}
+docstring InsetFloat::getCaptionText(OutputParams const & runparams) const
+{
+ if (paragraphs().empty())
+ return docstring();
+
+ ParagraphList::const_iterator pit = paragraphs().begin();
+ for (; pit != paragraphs().end(); ++pit) {
+ InsetList::const_iterator it = pit->insetList().begin();
+ for (; it != pit->insetList().end(); ++it) {
+ Inset & inset = *it->inset;
+ if (inset.lyxCode() == CAPTION_CODE) {
+ odocstringstream ods;
+ InsetCaption * ins =
+ static_cast<InsetCaption *>(it->inset);
+ ins->getCaptionText(ods, runparams);
+ return ods.str();
+ }
+ }
+ }
+ return docstring();
+}
+
+
void InsetFloat::string2params(string const & in, InsetFloatParams & params)
{
params = InsetFloatParams();
istringstream data(in);
Lexer lex;
lex.setStream(data);
-
- string name;
- lex >> name;
- if (!lex || name != "float") {
- LYXERR0("InsetFloat::string2params(" << in << ")\n"
- "Expected arg 1 to be \"float\"\n");
- }
-
- // This is part of the inset proper that is usually swallowed
- // by Text::readInset
- string id;
- lex >> id;
- if (!lex || id != "Float") {
- LYXERR0("InsetFloat::string2params(" << in << ")\n"
- "Expected arg 1 to be \"Float\"\n");
- }
-
- // We have to read the type here!
- lex >> params.type;
+ lex.setContext("InsetFloat::string2params");
+ lex >> "float" >> "Float";
+ lex >> params.type; // We have to read the type here!
params.read(lex);
}