From 22aa0137d3f7346c0701a60dddac3da5a442a676 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Sat, 8 Mar 2008 22:57:22 +0000 Subject: [PATCH] Transfer general edit context menu from BufferView to InsetText. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23574 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView.cpp | 3 +-- src/insets/InsetCollapsable.cpp | 12 ++++++++++++ src/insets/InsetCollapsable.h | 2 ++ src/insets/InsetRef.cpp | 7 +++++++ src/insets/InsetRef.h | 2 ++ src/insets/InsetText.cpp | 7 +++++++ src/insets/InsetText.h | 3 ++- 7 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/BufferView.cpp b/src/BufferView.cpp index 73de542638..b13d4cebd1 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -531,8 +531,7 @@ docstring BufferView::contextMenu(int x, int y) const if (covering_inset) return covering_inset->contextMenu(*this, x, y); - // FIXME: Do something more elaborate here. - return from_ascii("edit"); + return buffer_.inset().contextMenu(*this, x, y); } diff --git a/src/insets/InsetCollapsable.cpp b/src/insets/InsetCollapsable.cpp index 8a97f4073e..f9f8f36376 100644 --- a/src/insets/InsetCollapsable.cpp +++ b/src/insets/InsetCollapsable.cpp @@ -896,4 +896,16 @@ bool InsetCollapsable::undefined() const } +docstring InsetCollapsable::contextMenu(BufferView const & bv, int x, + int y) const +{ + if (geometry() != NoButton) { + Dimension dim = dimensionCollapsed(); + if (x < xo(bv) + dim.wid && y < yo(bv) + dim.des) + return docstring(); + } + + return InsetText::contextMenu(bv, x, y); +} + } // namespace lyx diff --git a/src/insets/InsetCollapsable.h b/src/insets/InsetCollapsable.h index b35a2bd096..99679d315b 100644 --- a/src/insets/InsetCollapsable.h +++ b/src/insets/InsetCollapsable.h @@ -151,6 +151,8 @@ public: /// Is this inset's layout defined in the document's textclass? /// May be wrong after textclass change or paste from another document bool undefined() const; + /// + virtual docstring contextMenu(BufferView const & bv, int x, int y) const; protected: /// void doDispatch(Cursor & cur, FuncRequest & cmd); diff --git a/src/insets/InsetRef.cpp b/src/insets/InsetRef.cpp index c2c3358ddd..f908a13598 100644 --- a/src/insets/InsetRef.cpp +++ b/src/insets/InsetRef.cpp @@ -183,6 +183,13 @@ void InsetRef::addToToc(ParConstIterator const & cpit) const } +docstring InsetRef::contextMenu(BufferView const &, int, int) const +{ + // FIXME: find a way to create a menu with "Goto label" inside. + return docstring(); +} + + void InsetRef::validate(LaTeXFeatures & features) const { if (getCmdName() == "vref" || getCmdName() == "vpageref") diff --git a/src/insets/InsetRef.h b/src/insets/InsetRef.h index 9bb4521aa2..a9c8f7c887 100644 --- a/src/insets/InsetRef.h +++ b/src/insets/InsetRef.h @@ -71,6 +71,8 @@ public: void updateLabels(ParIterator const & it); /// void addToToc(ParConstIterator const &) const; + /// + virtual docstring contextMenu(BufferView const & bv, int x, int y) const; protected: /// InsetRef(InsetRef const &); diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp index 172255bc69..9277878054 100644 --- a/src/insets/InsetText.cpp +++ b/src/insets/InsetText.cpp @@ -596,4 +596,11 @@ void InsetText::completionPosAndDim(Cursor const & cur, int & x, int & y, } +docstring InsetText::contextMenu(BufferView const &, int, int) const +{ + // FIXME: Do something more elaborate here. + return from_ascii("edit"); +} + + } // namespace lyx diff --git a/src/insets/InsetText.h b/src/insets/InsetText.h index bc7a56b531..2d183c1106 100644 --- a/src/insets/InsetText.h +++ b/src/insets/InsetText.h @@ -158,7 +158,8 @@ public: bool insertCompletion(Cursor & cur, docstring const & s, bool finished); /// void completionPosAndDim(Cursor const &, int & x, int & y, Dimension & dim) const; - + /// + virtual docstring contextMenu(BufferView const & bv, int x, int y) const; /// void doDispatch(Cursor & cur, FuncRequest & cmd); private: -- 2.39.2