remove InsetVSpaceMailer class

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23992 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2008-03-27 00:21:35 +00:00
parent 209b04eaa9
commit 241575ed86
5 changed files with 34 additions and 57 deletions

View File

@ -1243,7 +1243,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
} }
case VSPACE_CODE: { case VSPACE_CODE: {
VSpace space; VSpace space;
data = InsetVSpaceMailer::params2string(space); data = InsetVSpace::params2string(space);
break; break;
} }
case WRAP_CODE: { case WRAP_CODE: {

View File

@ -315,7 +315,7 @@ Inset * createInsetHelper(Buffer & buf, FuncRequest const & cmd)
case VSPACE_CODE: { case VSPACE_CODE: {
VSpace vspace; VSpace vspace;
InsetVSpaceMailer::string2params(to_utf8(cmd.argument()), vspace); InsetVSpace::string2params(to_utf8(cmd.argument()), vspace);
return new InsetVSpace(vspace); return new InsetVSpace(vspace);
} }

View File

@ -24,6 +24,7 @@
#include "LyXRC.h" // to set the default length values #include "LyXRC.h" // to set the default length values
#include "Spacing.h" #include "Spacing.h"
#include "FuncRequest.h" #include "FuncRequest.h"
#include "insets/InsetVSpace.h" #include "insets/InsetVSpace.h"
#include "support/gettext.h" #include "support/gettext.h"
@ -168,9 +169,8 @@ void GuiVSpace::updateContents()
bool GuiVSpace::initialiseParams(string const & data) bool GuiVSpace::initialiseParams(string const & data)
{ {
InsetVSpaceMailer::string2params(data, params_); InsetVSpace::string2params(data, params_);
setButtonsValid(true); setButtonsValid(true);
return true; return true;
} }
@ -183,7 +183,7 @@ void GuiVSpace::clearParams()
void GuiVSpace::dispatchParams() void GuiVSpace::dispatchParams()
{ {
dispatch(FuncRequest(getLfun(), InsetVSpaceMailer::params2string(params_))); dispatch(FuncRequest(getLfun(), InsetVSpace::params2string(params_)));
} }

View File

@ -14,17 +14,21 @@
#include "InsetVSpace.h" #include "InsetVSpace.h"
#include "Buffer.h" #include "Buffer.h"
#include "BufferView.h"
#include "Cursor.h" #include "Cursor.h"
#include "Dimension.h" #include "Dimension.h"
#include "DispatchResult.h" #include "DispatchResult.h"
#include "FuncRequest.h" #include "FuncRequest.h"
#include "FuncStatus.h" #include "FuncStatus.h"
#include "support/gettext.h"
#include "Lexer.h" #include "Lexer.h"
#include "Text.h" #include "Text.h"
#include "MetricsInfo.h" #include "MetricsInfo.h"
#include "OutputParams.h" #include "OutputParams.h"
#include "support/debug.h"
#include "support/gettext.h"
#include "frontends/Application.h"
#include "frontends/FontMetrics.h" #include "frontends/FontMetrics.h"
#include "frontends/Painter.h" #include "frontends/Painter.h"
@ -48,7 +52,7 @@ InsetVSpace::InsetVSpace(VSpace const & space)
InsetVSpace::~InsetVSpace() InsetVSpace::~InsetVSpace()
{ {
InsetVSpaceMailer(*this).hideDialog(); hideDialogs("vspace", this);
} }
@ -57,13 +61,14 @@ void InsetVSpace::doDispatch(Cursor & cur, FuncRequest & cmd)
switch (cmd.action) { switch (cmd.action) {
case LFUN_INSET_MODIFY: { case LFUN_INSET_MODIFY: {
InsetVSpaceMailer::string2params(to_utf8(cmd.argument()), space_); InsetVSpace::string2params(to_utf8(cmd.argument()), space_);
break; break;
} }
case LFUN_MOUSE_RELEASE: case LFUN_MOUSE_RELEASE:
if (!cur.selection() && cmd.button() == mouse_button::button1) if (!cur.selection() && cmd.button() == mouse_button::button1)
InsetVSpaceMailer(*this).showDialog(&cur.bv()); cur.bv().showDialog("vspace", params2string(space()),
const_cast<InsetVSpace *>(this));
break; break;
default: default:
@ -81,10 +86,11 @@ bool InsetVSpace::getStatus(Cursor & cur, FuncRequest const & cmd,
case LFUN_INSET_MODIFY: case LFUN_INSET_MODIFY:
if (cmd.getArg(0) == "vspace") { if (cmd.getArg(0) == "vspace") {
VSpace vspace; VSpace vspace;
InsetVSpaceMailer::string2params(to_utf8(cmd.argument()), vspace); InsetVSpace::string2params(to_utf8(cmd.argument()), vspace);
status.setOnOff(vspace == space_); status.setOnOff(vspace == space_);
} else } else {
status.enabled(true); status.enabled(true);
}
return true; return true;
default: default:
return Inset::getStatus(cur, cmd, status); return Inset::getStatus(cur, cmd, status);
@ -94,7 +100,8 @@ bool InsetVSpace::getStatus(Cursor & cur, FuncRequest const & cmd,
void InsetVSpace::edit(Cursor & cur, bool, EntryDirection) void InsetVSpace::edit(Cursor & cur, bool, EntryDirection)
{ {
InsetVSpaceMailer(*this).showDialog(&cur.bv()); cur.bv().showDialog("vspace", params2string(space()),
const_cast<InsetVSpace *>(this));
} }
@ -241,21 +248,7 @@ docstring InsetVSpace::contextMenu(BufferView const &, int, int) const
} }
string const InsetVSpaceMailer::name_ = "vspace"; void InsetVSpace::string2params(string const & in, VSpace & vspace)
InsetVSpaceMailer::InsetVSpaceMailer(InsetVSpace & inset)
: inset_(inset)
{}
string const InsetVSpaceMailer::inset2string(Buffer const &) const
{
return params2string(inset_.space());
}
void InsetVSpaceMailer::string2params(string const & in, VSpace & vspace)
{ {
vspace = VSpace(); vspace = VSpace();
if (in.empty()) if (in.empty())
@ -267,8 +260,11 @@ void InsetVSpaceMailer::string2params(string const & in, VSpace & vspace)
string name; string name;
lex >> name; lex >> name;
if (!lex || name != name_) if (!lex || name != "ert") {
return print_mailer_error("InsetVSpaceMailer", in, 1, name_); LYXERR0("InsetVSPace::string2params(" << in << ")\n"
"Expected arg 1 to be \"vspace\"\n");
return;
}
string vsp; string vsp;
lex >> vsp; lex >> vsp;
@ -277,10 +273,10 @@ void InsetVSpaceMailer::string2params(string const & in, VSpace & vspace)
} }
string const InsetVSpaceMailer::params2string(VSpace const & vspace) string InsetVSpace::params2string(VSpace const & vspace)
{ {
ostringstream data; ostringstream data;
data << name_ << ' ' << vspace.asLyXCommand(); data << "vspace" << ' ' << vspace.asLyXCommand();
return data.str(); return data.str();
} }

View File

@ -12,15 +12,14 @@
#ifndef INSET_VSPACE_H #ifndef INSET_VSPACE_H
#define INSET_VSPACE_H #define INSET_VSPACE_H
#include "Inset.h" #include "Inset.h"
#include "VSpace.h" #include "VSpace.h"
#include "MailInset.h"
namespace lyx { namespace lyx {
class InsetVSpace : public Inset { class InsetVSpace : public Inset
{
public: public:
/// ///
InsetVSpace() {} InsetVSpace() {}
@ -38,7 +37,11 @@ public:
/// ///
EDITABLE editable() const { return IS_EDITABLE; } EDITABLE editable() const { return IS_EDITABLE; }
/// ///
virtual docstring contextMenu(BufferView const & bv, int x, int y) const; docstring contextMenu(BufferView const & bv, int x, int y) const;
///
static void string2params(std::string const &, VSpace &);
///
static std::string params2string(VSpace const &);
private: private:
/// ///
void metrics(MetricsInfo & mi, Dimension & dim) const; void metrics(MetricsInfo & mi, Dimension & dim) const;
@ -70,28 +73,6 @@ private:
}; };
class InsetVSpaceMailer : public MailInset {
public:
///
InsetVSpaceMailer(InsetVSpace & inset);
///
virtual Inset & inset() const { return inset_; }
///
virtual std::string const & name() const { return name_; }
///
virtual std::string const inset2string(Buffer const &) const;
///
static void string2params(std::string const &, VSpace &);
///
static std::string const params2string(VSpace const &);
private:
///
static std::string const name_;
///
InsetVSpace & inset_;
};
} // namespace lyx } // namespace lyx
#endif #endif