Rename InsetXXX::contextMenu to InsetXXX::contextMenuName. Now this function doesn't need all the parameters and we split the functionality of choosing which context menu to return, from the functionality of supplying the name for the Inset itself. Now, the InsetText context menu is returned for InsetCollapsables when the button is not hit by the mouse. There is no (intended) change in functionality for insets without a button, collapsed insets. This fixes partly bug #6642. A fix for InsetTabular and for insets with no button will follow.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36604 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Vincent van Ravesteijn 2010-11-29 21:27:25 +00:00
parent 5eb7add409
commit e7f2bbe1ee
56 changed files with 82 additions and 60 deletions

View File

@ -255,6 +255,12 @@ docstring Inset::toolTip(BufferView const &, int, int) const
docstring Inset::contextMenu(BufferView const &, int, int) const
{
return contextMenuName();
}
docstring Inset::contextMenuName() const
{
return docstring();
}

View File

@ -400,9 +400,14 @@ public:
/// This default implementation returns an empty string.
virtual docstring toolTip(BufferView const & bv, int x, int y) const;
/// \return Context menu identifier. This function determines
/// whose Inset's menu should be shown for the given position.
virtual docstring contextMenu(BufferView const & bv, int x, int y) const;
/// \return Context menu identifier for this inset.
/// This default implementation returns an empty string.
virtual docstring contextMenu(BufferView const & bv, int x, int y) const;
virtual docstring contextMenuName() const;
// FIXME This should really disappear in favor of
// docstring name() const { return from_ascii(insetName(lyxCode()))); }

View File

@ -987,7 +987,7 @@ docstring InsetBibtex::xhtml(XHTMLStream & xs, OutputParams const &) const
}
docstring InsetBibtex::contextMenu(BufferView const &, int, int) const
docstring InsetBibtex::contextMenuName() const
{
return from_ascii("context-bibtex");
}

View File

@ -58,7 +58,7 @@ public:
///
docstring xhtml(XHTMLStream &, OutputParams const &) const;
///
docstring contextMenu(BufferView const &, int, int) const;
docstring contextMenuName() const;
//@}
/// \name Static public methods obligated for InsetCommand derived classes

View File

@ -529,7 +529,7 @@ void InsetBox::validate(LaTeXFeatures & features) const
}
docstring InsetBox::contextMenu(BufferView const &, int, int) const
docstring InsetBox::contextMenuName() const
{
return from_ascii("context-box");
}

View File

@ -131,7 +131,7 @@ private:
/// used by the constructors
void init();
///
docstring contextMenu(BufferView const & bv, int x, int y) const;
docstring contextMenuName() const;
///
InsetBoxParams params_;

View File

@ -249,7 +249,7 @@ void InsetBranch::validate(LaTeXFeatures & features) const
}
docstring InsetBranch::contextMenu(BufferView const &, int, int) const
docstring InsetBranch::contextMenuName() const
{
return from_ascii("context-branch");
}

View File

@ -77,7 +77,7 @@ private:
///
void validate(LaTeXFeatures &) const;
///
docstring contextMenu(BufferView const &, int, int) const;
docstring contextMenuName() const;
///
void addToToc(DocIterator const &);
///

View File

@ -599,7 +599,7 @@ void InsetCitation::validate(LaTeXFeatures & features) const
}
docstring InsetCitation::contextMenu(BufferView const &, int, int) const
docstring InsetCitation::contextMenuName() const
{
return from_ascii("context-citation");
}

View File

@ -59,7 +59,7 @@ public:
///
void addToToc(DocIterator const &);
///
docstring contextMenu(BufferView const & bv, int x, int y) const;
docstring contextMenuName() const;
//@}
/// \name Static public methods obligated for InsetCommand derived classes

View File

@ -622,16 +622,25 @@ docstring InsetCollapsable::contextMenu(BufferView const & bv, int x,
int y) const
{
if (decoration() == InsetLayout::CONGLOMERATE)
return from_ascii("context-conglomerate");
return contextMenuName();
if (geometry(bv) == NoButton)
return from_ascii("context-collapsable");
return contextMenuName();
Dimension dim = dimensionCollapsed(bv);
if (x < xo(bv) + dim.wid && y < yo(bv) + dim.des)
return from_ascii("context-collapsable");
return contextMenuName();
return InsetText::contextMenu(bv, x, y);
return InsetText::contextMenuName();
}
docstring InsetCollapsable::contextMenuName() const
{
if (decoration() == InsetLayout::CONGLOMERATE)
return from_ascii("context-conglomerate");
else
return from_ascii("context-collapsable");
}
} // namespace lyx

View File

@ -141,7 +141,9 @@ public:
///
virtual bool usePlainLayout() const { return true; }
///
virtual docstring contextMenu(BufferView const & bv, int x, int y) const;
docstring contextMenu(BufferView const & bv, int x, int y) const;
///
docstring contextMenuName() const;
///
docstring floatName(std::string const & type) const;
protected:

View File

@ -208,7 +208,7 @@ bool InsetCommand::getStatus(Cursor & cur, FuncRequest const & cmd,
}
docstring InsetCommand::contextMenu(BufferView const &, int, int) const
docstring InsetCommand::contextMenuName() const
{
return from_ascii("context-") + from_ascii(insetName(p_.code()));
}

View File

@ -91,7 +91,7 @@ protected:
/// \name Methods relaying to the InsetCommandParams p_
//@{
///
docstring contextMenu(BufferView const & bv, int x, int y) const;
docstring contextMenuName() const;
///
bool showInsetDialog(BufferView * bv) const;
///

View File

@ -38,7 +38,7 @@ public:
///
static std::string params2string(CollapseStatus);
docstring contextMenu(BufferView const &, int, int) const
docstring contextMenuName() const
{ return from_ascii("context-ert"); }
private:
///

View File

@ -789,7 +789,7 @@ void InsetExternal::addPreview(DocIterator const & /*inset_pos*/,
}
docstring InsetExternal::contextMenu(BufferView const &, int, int) const
docstring InsetExternal::contextMenuName() const
{
return from_ascii("context-external");
}

View File

@ -111,7 +111,7 @@ public:
/// \returns the number of rows (\n's) of generated code.
int latex(odocstream &, OutputParams const &) const;
///
docstring contextMenu(BufferView const & bv, int x, int y) const;
docstring contextMenuName() const;
///
bool setMouseHover(BufferView const * bv, bool mouse_hover);
///

View File

@ -1040,7 +1040,7 @@ void InsetGraphics::addToToc(DocIterator const & cpit)
}
docstring InsetGraphics::contextMenu(BufferView const &, int, int) const
docstring InsetGraphics::contextMenuName() const
{
return from_ascii("context-graphics");
}

View File

@ -98,7 +98,7 @@ private:
///
void addToToc(DocIterator const &);
///
docstring contextMenu(BufferView const & bv, int x, int y) const;
docstring contextMenuName() const;
/// Force inset into LTR environment if surroundings are RTL
bool forceLTR() const { return true; }
///

View File

@ -264,7 +264,7 @@ void InsetHyperlink::validate(LaTeXFeatures & features) const
}
docstring InsetHyperlink::contextMenu(BufferView const &, int, int) const
docstring InsetHyperlink::contextMenuName() const
{
return from_ascii("context-hyperlink");
}

View File

@ -40,7 +40,7 @@ public:
///
docstring toolTip(BufferView const & bv, int x, int y) const;
///
docstring contextMenu(BufferView const &, int, int) const;
docstring contextMenuName() const;
///
void validate(LaTeXFeatures &) const;
///

View File

@ -898,7 +898,7 @@ void InsetInclude::draw(PainterInfo & pi, int x, int y) const
}
docstring InsetInclude::contextMenu(BufferView const &, int, int) const
docstring InsetInclude::contextMenuName() const
{
return from_ascii("context-include");
}

View File

@ -103,7 +103,7 @@ public:
///
void updateBuffer(ParIterator const &, UpdateType);
///
docstring contextMenu(BufferView const & bv, int x, int y) const;
docstring contextMenuName() const;
//@}
/// \name Static public methods obligated for InsetCommand derived classes

View File

@ -376,7 +376,7 @@ void InsetIndex::validate(LaTeXFeatures & features) const
}
docstring InsetIndex::contextMenu(BufferView const &, int, int) const
docstring InsetIndex::contextMenuName() const
{
return from_ascii("context-index");
}
@ -576,7 +576,7 @@ void InsetPrintIndex::validate(LaTeXFeatures & features) const
}
docstring InsetPrintIndex::contextMenu(BufferView const &, int, int) const
docstring InsetPrintIndex::contextMenuName() const
{
return buffer().masterBuffer()->params().use_indices ?
from_ascii("context-indexprint") : docstring();

View File

@ -79,7 +79,7 @@ private:
/// Updates needed features for this inset.
void validate(LaTeXFeatures & features) const;
///
docstring contextMenu(BufferView const & bv, int x, int y) const;
docstring contextMenuName() const;
///
Inset * clone() const { return new InsetIndex(*this); }
@ -108,7 +108,7 @@ public:
///
bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
///
docstring contextMenu(BufferView const & bv, int x, int y) const;
docstring contextMenuName() const;
/// Updates needed features for this inset.
void validate(LaTeXFeatures & features) const;
///

View File

@ -452,7 +452,7 @@ void InsetInfo::updateInfo()
}
docstring InsetInfo::contextMenu(BufferView const &, int, int) const
docstring InsetInfo::contextMenuName() const
{
return from_ascii("context-info");
}

View File

@ -126,7 +126,7 @@ public:
///
docstring toolTip(BufferView const & bv, int x, int y) const;
///
docstring contextMenu(BufferView const &, int, int) const;
docstring contextMenuName() const;
/// should paragraph indendation be ommitted in any case?
bool neverIndent() const { return true; }

View File

@ -309,7 +309,7 @@ docstring InsetListings::xhtml(XHTMLStream & os, OutputParams const & rp) const
}
docstring InsetListings::contextMenu(BufferView const &, int, int) const
docstring InsetListings::contextMenuName() const
{
return from_ascii("context-listings");
}

View File

@ -67,7 +67,7 @@ private:
///
InsetListingsParams & params() { return params_; }
///
docstring contextMenu(BufferView const & bv, int x, int y) const;
docstring contextMenuName() const;
///
void doDispatch(Cursor & cur, FuncRequest & cmd);
///

View File

@ -261,7 +261,7 @@ void InsetNewline::draw(PainterInfo & pi, int x, int y) const
}
docstring InsetNewline::contextMenu(BufferView const &, int, int) const
docstring InsetNewline::contextMenuName() const
{
return from_ascii("context-newline");
}

View File

@ -77,7 +77,7 @@ private:
///
ColorCode ColorName() const;
///
docstring contextMenu(BufferView const & bv, int x, int y) const;
docstring contextMenuName() const;
///
Inset * clone() const { return new InsetNewline(*this); }
///

View File

@ -257,7 +257,7 @@ docstring InsetNewpage::xhtml(XHTMLStream & xs, OutputParams const &) const
}
docstring InsetNewpage::contextMenu(BufferView const &, int, int) const
docstring InsetNewpage::contextMenuName() const
{
return from_ascii("context-newpage");
}

View File

@ -81,7 +81,7 @@ private:
///
ColorCode ColorName() const;
///
docstring contextMenu(BufferView const & bv, int x, int y) const;
docstring contextMenuName() const;
///
Inset * clone() const { return new InsetNewpage(*this); }
///

View File

@ -333,7 +333,7 @@ InsetCode InsetPrintNomencl::lyxCode() const
}
docstring InsetPrintNomencl::contextMenu(BufferView const &, int, int) const
docstring InsetPrintNomencl::contextMenuName() const
{
return from_ascii("context-nomenclprint");
}

View File

@ -98,7 +98,7 @@ public:
///
int latex(odocstream &, OutputParams const &) const;
///
docstring contextMenu(BufferView const & bv, int x, int y) const;
docstring contextMenuName() const;
//@}
/// \name Static public methods obligated for InsetCommand derived classes

View File

@ -350,7 +350,7 @@ void InsetNote::validate(LaTeXFeatures & features) const
}
docstring InsetNote::contextMenu(BufferView const &, int, int) const
docstring InsetNote::contextMenuName() const
{
return from_ascii("context-note");
}

View File

@ -105,7 +105,7 @@ private:
/// used by the constructors
void init();
///
docstring contextMenu(BufferView const & bv, int x, int y) const;
docstring contextMenuName() const;
///
friend class InsetNoteParams;

View File

@ -358,7 +358,7 @@ docstring InsetPhantom::xhtml(XHTMLStream &, OutputParams const &) const
return docstring();
}
docstring InsetPhantom::contextMenu(BufferView const &, int, int) const
docstring InsetPhantom::contextMenuName() const
{
return from_ascii("context-phantom");
}

View File

@ -94,7 +94,7 @@ private:
/// used by the constructors
void init();
///
docstring contextMenu(BufferView const & bv, int x, int y) const;
docstring contextMenuName() const;
///
friend class InsetPhantomParams;

View File

@ -49,7 +49,7 @@ public:
bool descendable(BufferView const & /*bv*/) const { return true; }
docstring contextMenu(BufferView const &, int, int) const
docstring contextMenuName() const
{ return from_ascii("context-preview"); }
void metrics(MetricsInfo & mi, Dimension & dim) const;

View File

@ -423,7 +423,7 @@ docstring InsetScript::xhtml(XHTMLStream & xs, OutputParams const & runparams) c
}
docstring InsetScript::contextMenu(BufferView const &, int, int) const
docstring InsetScript::contextMenuName() const
{
return from_ascii("context-script");
}

View File

@ -109,7 +109,7 @@ public:
///
Inset * clone() const { return new InsetScript(*this); }
///
docstring contextMenu(BufferView const & bv, int x, int y) const;
docstring contextMenuName() const;
//@}
/// \name Public functions inherited from InsetText class

View File

@ -753,7 +753,7 @@ bool InsetSpace::isStretchableSpace() const
}
docstring InsetSpace::contextMenu(BufferView const &, int, int) const
docstring InsetSpace::contextMenuName() const
{
return from_ascii("context-space");
}

View File

@ -146,7 +146,7 @@ public:
// a line separator)?
bool isSpace() const { return true; }
///
docstring contextMenu(BufferView const & bv, int x, int y) const;
docstring contextMenuName() const;
///
bool clickable(int /* x */, int /* y */) const { return true; }
protected:

View File

@ -3327,7 +3327,7 @@ void InsetTabular::write(ostream & os) const
}
docstring InsetTabular::contextMenu(BufferView const &, int, int) const
docstring InsetTabular::contextMenuName() const
{
// FIXME: depending on the selection state, we could offer a different menu.
return from_ascii("context-tabular");

View File

@ -813,7 +813,7 @@ public:
///
InsetCode lyxCode() const { return TABULAR_CODE; }
///
docstring contextMenu(BufferView const & bv, int x, int y) const;
docstring contextMenuName() const;
/// get offset of this cursor slice relative to our upper left corner
void cursorPos(BufferView const & bv, CursorSlice const & sl,
bool boundary, int & x, int & y) const;

View File

@ -813,7 +813,7 @@ void InsetText::completionPosAndDim(Cursor const & cur, int & x, int & y,
}
docstring InsetText::contextMenu(BufferView const &, int, int) const
docstring InsetText::contextMenuName() const
{
return from_ascii("context-edit");
}

View File

@ -196,7 +196,7 @@ public:
docstring toolTipText(docstring prefix = empty_docstring()) const;
///
virtual docstring contextMenu(BufferView const & bv, int x, int y) const;
docstring contextMenuName() const;
///
void doDispatch(Cursor & cur, FuncRequest & cmd);
protected:

View File

@ -233,7 +233,7 @@ docstring InsetVSpace::xhtml(XHTMLStream &, OutputParams const &) const
}
docstring InsetVSpace::contextMenu(BufferView const &, int, int) const
docstring InsetVSpace::contextMenuName() const
{
return from_ascii("context-vspace");
}

View File

@ -32,7 +32,7 @@ public:
///
bool hasSettings() const { return true; }
///
docstring contextMenu(BufferView const & bv, int x, int y) const;
docstring contextMenuName() const;
///
static void string2params(std::string const &, VSpace &);
///

View File

@ -1968,7 +1968,7 @@ void InsetMathHull::tocString(odocstream & os) const
}
docstring InsetMathHull::contextMenu(BufferView const &, int, int) const
docstring InsetMathHull::contextMenuName() const
{
return from_ascii("context-math");
}

View File

@ -154,7 +154,7 @@ public:
void recordLocation(DocIterator const & di);
///
virtual docstring contextMenu(BufferView const &, int, int) const;
docstring contextMenuName() const;
///
InsetCode lyxCode() const { return MATH_HULL_CODE; }

View File

@ -268,7 +268,7 @@ InsetSpaceParams InsetMathSpace::params() const
}
docstring InsetMathSpace::contextMenu(BufferView const &, int, int) const
docstring InsetMathSpace::contextMenuName() const
{
return from_ascii("context-mathspace");
}

View File

@ -61,7 +61,7 @@ public:
///
bool hasSettings() const { return true; }
///
docstring contextMenu(BufferView const &, int, int) const;
docstring contextMenuName() const;
///
bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
///

View File

@ -1353,7 +1353,7 @@ void MathMacroTemplate::infoize(odocstream & os) const
}
docstring MathMacroTemplate::contextMenu(BufferView const &, int, int) const
docstring MathMacroTemplate::contextMenuName() const
{
return from_ascii("context-math-macro-definition");
}

View File

@ -104,7 +104,7 @@ public:
///
void infoize(odocstream & os) const;
///
docstring contextMenu(BufferView const &, int, int) const;
docstring contextMenuName() const;
protected:
///
virtual void doDispatch(Cursor & cur, FuncRequest & cmd);