X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Finsetcommand.C;h=6d5248844b923d5650941ffb563ea74feb0313ae;hb=e28331ed63062dea10d0a21b9ec12034b4b17b9a;hp=7f47611bb3065359416297226c6d9082d7a48579;hpb=bc1582b0b1d24d1429227ea5f4afdc0ffb4e0f4e;p=lyx.git diff --git a/src/insets/insetcommand.C b/src/insets/insetcommand.C index 7f47611bb3..6d5248844b 100644 --- a/src/insets/insetcommand.C +++ b/src/insets/insetcommand.C @@ -23,6 +23,8 @@ #include +namespace lyx { + using std::string; using std::istringstream; using std::ostream; @@ -31,8 +33,9 @@ using std::ostringstream; InsetCommand::InsetCommand(InsetCommandParams const & p, string const & mailer_name) - : p_(p.getCmdName(), p.getContents(), p.getOptions(), p.getSecOptions()), + : p_(p), mailer_name_(mailer_name), + mouse_hover_(false), updateButtonLabel_(true) {} @@ -44,7 +47,7 @@ InsetCommand::~InsetCommand() } -void InsetCommand::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetCommand::metrics(MetricsInfo & mi, Dimension & dim) const { if (updateButtonLabel_) { updateButtonLabel_ = false; @@ -52,13 +55,23 @@ void InsetCommand::metrics(MetricsInfo & mi, Dimension & dim) const editable() != NOT_EDITABLE); } button_.metrics(mi, dim); + bool const changed = dim_ != dim; dim_ = dim; + return changed; +} + + +bool InsetCommand::setMouseHover(bool mouse_hover) +{ + mouse_hover_ = mouse_hover; + return true; } void InsetCommand::draw(PainterInfo & pi, int x, int y) const { setPosCache(pi, x, y); + button_.setRenderState(mouse_hover_); button_.draw(pi, x, y); } @@ -70,7 +83,7 @@ void InsetCommand::setParams(InsetCommandParams const & p) } -int InsetCommand::latex(Buffer const &, ostream & os, +int InsetCommand::latex(Buffer const &, odocstream & os, OutputParams const &) const { os << getCommand(); @@ -78,21 +91,14 @@ int InsetCommand::latex(Buffer const &, ostream & os, } -int InsetCommand::plaintext(Buffer const &, ostream &, +int InsetCommand::plaintext(Buffer const &, odocstream &, OutputParams const &) const { return 0; } -int InsetCommand::linuxdoc(Buffer const &, ostream &, - OutputParams const &) const -{ - return 0; -} - - -int InsetCommand::docbook(Buffer const &, ostream &, +int InsetCommand::docbook(Buffer const &, odocstream &, OutputParams const &) const { return 0; @@ -107,8 +113,8 @@ void InsetCommand::doDispatch(LCursor & cur, FuncRequest & cmd) break; case LFUN_INSET_MODIFY: { - InsetCommandParams p; - InsetCommandMailer::string2params(mailer_name_, cmd.argument, p); + InsetCommandParams p(p_.getCmdName()); + InsetCommandMailer::string2params(mailer_name_, to_utf8(cmd.argument()), p); if (p.getCmdName().empty()) cur.noUpdate(); else @@ -116,9 +122,11 @@ void InsetCommand::doDispatch(LCursor & cur, FuncRequest & cmd) break; } - case LFUN_INSET_DIALOG_UPDATE: - InsetCommandMailer(cmd.argument, *this).updateDialog(&cur.bv()); + case LFUN_INSET_DIALOG_UPDATE: { + string const name = to_utf8(cmd.argument()); + InsetCommandMailer(name, *this).updateDialog(&cur.bv()); break; + } case LFUN_MOUSE_RELEASE: { if (!mailer_name_.empty()) @@ -154,6 +162,13 @@ bool InsetCommand::getStatus(LCursor & cur, FuncRequest const & cmd, } +void InsetCommand::replaceContents(std::string const & from, string const & to) +{ + if (getContents() == from) + setContents(to); +} + + InsetCommandMailer::InsetCommandMailer(string const & name, InsetCommand & inset) : name_(name), inset_(inset) @@ -170,7 +185,7 @@ void InsetCommandMailer::string2params(string const & name, string const & in, InsetCommandParams & params) { - params = InsetCommandParams(); + params.clear(); if (in.empty()) return; @@ -204,3 +219,6 @@ InsetCommandMailer::params2string(string const & name, data << "\\end_inset\n"; return data.str(); } + + +} // namespace lyx