}
}
-
return 0;
}
+
Inset * createInset(Buffer & buf, FuncRequest const & cmd)
{
Inset * inset = createInsetHelper(buf, cmd);
return inset;
}
+
Inset * readInset(Lexer & lex, Buffer const & buf)
{
// consistency check
- if (lex.getString() != "\\begin_inset") {
- lyxerr << "Buffer::readInset: Consistency check failed."
- << endl;
- }
+ if (lex.getString() != "\\begin_inset")
+ LYXERR0("Buffer::readInset: Consistency check failed.");
auto_ptr<Inset> inset;
// test the different insets
- //FIXME It would be better if we did not have this branch and could
- //just do one massive switch for all insets. But at present, it's easier
- //to do it this way, and we can't do the massive switch until the conversion
- //mentioned below.
- //Note that if we do want to do a single switch, we need to remove
- //this "CommandInset" line---or replace it with a single "InsetType" line
- //that would be used in all insets.
+ // FIXME It would be better if we did not have this branch and could
+ // just do one massive switch for all insets. But at present, it's
+ // easier to do it this way, and we can't do the massive switch until
+ // the conversion mentioned below. Note that if we do want to do a
+ // single switch, we need to remove this "CommandInset" line---or
+ // replace it with a single "InsetType" line that would be used in all
+ // insets.
if (tmptok == "CommandInset") {
lex.next();
string const insetType = lex.getString();
#include "support/debug.h"
#include "support/Translator.h"
+#include "frontends/Application.h"
+
#include <sstream>
using namespace std;
typedef Translator<string, InsetBox::BoxType> BoxTranslator;
typedef Translator<docstring, InsetBox::BoxType> BoxTranslatorLoc;
-BoxTranslator const init_boxtranslator()
+BoxTranslator initBoxtranslator()
{
BoxTranslator translator("Boxed", InsetBox::Boxed);
translator.addPair("Frameless", InsetBox::Frameless);
}
-BoxTranslatorLoc const init_boxtranslator_loc()
+BoxTranslatorLoc initBoxtranslatorLoc()
{
BoxTranslatorLoc translator(_("simple frame"), InsetBox::Boxed);
translator.addPair(_("frameless"), InsetBox::Frameless);
BoxTranslator const & boxtranslator()
{
- static BoxTranslator translator = init_boxtranslator();
+ static BoxTranslator translator = initBoxtranslator();
return translator;
}
BoxTranslatorLoc const & boxtranslator_loc()
{
- static BoxTranslatorLoc translator = init_boxtranslator_loc();
+ static BoxTranslatorLoc translator = initBoxtranslatorLoc();
return translator;
}
-} // anon
+} // namespace anon
+
+/////////////////////////////////////////////////////////////////////////
+//
+// InsetBox
+//
+/////////////////////////////////////////////////////////////////////////
InsetBox::InsetBox(Buffer const & buffer, string const & label)
: InsetCollapsable(buffer), params_(label)
InsetBox::~InsetBox()
{
- InsetBoxMailer(*this).hideDialog();
+ hideDialogs("box", this);
}
// FIXME: UNICODE
string name = "Box";
if (boxtranslator().find(params_.type) == Shaded)
- name += string(":Shaded");
+ name += ":Shaded";
return from_ascii(name);
}
label += _("Parbox");
else
label += _("Minipage");
- } else
+ } else {
label += boxtranslator_loc().find(btype);
+ }
label += ")";
setLabel(label);
bool InsetBox::showInsetDialog(BufferView * bv) const
{
- InsetBoxMailer(const_cast<InsetBox &>(*this)).showDialog(bv);
+ bv->showDialog("box", params2string(params_),
+ const_cast<InsetBox *>(this));
return true;
}
if (cmd.getArg(0) == "changetype")
params_.type = cmd.getArg(1);
else
- InsetBoxMailer::string2params(to_utf8(cmd.argument()), params_);
+ string2params(to_utf8(cmd.argument()), params_);
setLayout(cur.buffer().params());
break;
}
case LFUN_INSET_DIALOG_UPDATE:
- InsetBoxMailer(*this).updateDialog(&cur.bv());
+ cur.bv().updateDialog("box", params2string(params_));
break;
default:
else
flag.enabled(true);
return true;
+
case LFUN_INSET_DIALOG_UPDATE:
flag.enabled(true);
return true;
+
case LFUN_BREAK_PARAGRAPH:
if (params_.inner_box) {
return InsetCollapsable::getStatus(cur, cmd, flag);
- } else {
- flag.enabled(false);
- return true;
- }
+ flag.enabled(false);
+ return true;
default:
return InsetCollapsable::getStatus(cur, cmd, flag);
if (params_.use_parbox)
os << "{";
os << "%\n";
- i += 1;
+ ++i;
}
- if (btype == Shaded)
+ if (btype == Shaded) {
os << "\\begin{shaded}%\n";
- i += 1;
+ ++i;
+ }
i += InsetText::latex(os, runparams);
}
-InsetBoxMailer::InsetBoxMailer(InsetBox & inset)
- : inset_(inset)
-{}
-
-
-string const InsetBoxMailer::name_ = "box";
-
-
-string const InsetBoxMailer::inset2string(Buffer const &) const
-{
- return params2string(inset_.params());
-}
-
-
-string const InsetBoxMailer::params2string(InsetBoxParams const & params)
+string InsetBox::params2string(InsetBoxParams const & params)
{
ostringstream data;
data << "box" << ' ';
}
-void InsetBoxMailer::string2params(string const & in,
- InsetBoxParams & params)
+void InsetBox::string2params(string const & in, InsetBoxParams & params)
{
params = InsetBoxParams(string());
if (in.empty())
string name;
lex >> name;
- if (!lex || name != name_)
- return print_mailer_error("InsetBoxMailer", in, 1, name_);
+ if (!lex || name != "box") {
+ LYXERR0("InsetBox::string2params(" << in << ")\n"
+ "Expected arg 1 to be \"box\"\n");
+ return;
+ }
// This is part of the inset proper that is usually swallowed
// by Text::readInset
string id;
lex >> id;
- if (!lex || id != "Box")
- return print_mailer_error("InsetBoxMailer", in, 2, "Box");
+ if (!lex || id != "Box") {
+ LYXERR0("InsetBox::string2params(" << in << ")\n"
+ "Expected arg 2 to be \"Box\"\n");
+ }
params.read(lex);
}
+/////////////////////////////////////////////////////////////////////////
+//
+// InsetBoxParams
+//
+/////////////////////////////////////////////////////////////////////////
+
InsetBoxParams::InsetBoxParams(string const & label)
: type(label),
use_parbox(false),
#include "InsetCollapsable.h"
#include "Length.h"
-#include "MailInset.h"
namespace lyx {
-class InsetBoxParams {
+class InsetBoxParams
+{
public:
///
InsetBoxParams(std::string const &);
void write(std::ostream & os) const;
///
void read(Lexer & lex);
+
///
std::string type;
/// Use a parbox (true) or minipage (false)
};
-/** The fbox/fancybox inset
-*/
-class InsetBox : public InsetCollapsable {
+///////////////////////////////////////////////////////////////////////
+//
+// The fbox/fancybox inset
+//
+///////////////////////////////////////////////////////////////////////
+
+
+class InsetBox : public InsetCollapsable
+{
public:
///
enum BoxType {
InsetBox(Buffer const &, std::string const &);
///
~InsetBox();
+ ///
+ static std::string params2string(InsetBoxParams const &);
+ ///
+ static void string2params(std::string const &, InsetBoxParams &);
private:
///
friend class InsetBoxParams;
///
DisplayType display() const { return Inline; }
///
- virtual bool allowParagraphCustomization(idx_type = 0)
- { return forceEmptyLayout(); }
+ bool allowParagraphCustomization(idx_type = 0) { return forceEmptyLayout(); }
///
- virtual bool forceEmptyLayout(idx_type = 0) const;
+ bool forceEmptyLayout(idx_type = 0) const;
///
bool neverIndent() const { return true; }
///
/// used by the constructors
void init();
///
- virtual docstring contextMenu(BufferView const & bv, int x, int y) const;
+ docstring contextMenu(BufferView const & bv, int x, int y) const;
///
InsetBoxParams params_;
};
-
-class InsetBoxMailer : public MailInset {
-public:
- ///
- InsetBoxMailer(InsetBox & inset);
- ///
- virtual Inset & inset() const { return inset_; }
- ///
- virtual std::string const & name() const { return name_; }
- ///
- virtual std::string const inset2string(Buffer const &) const;
- ///
- static std::string const params2string(InsetBoxParams const &);
- ///
- static void string2params(std::string const &, InsetBoxParams &);
-
-private:
- ///
- static std::string const name_;
- ///
- InsetBox & inset_;
-};
-
-
} // namespace lyx
-#endif // INSET_BOX_H
+#endif // INSETBOX_H