Prepare the code for context menu support.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22300 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2007-12-25 20:12:07 +00:00
parent 2148f86b27
commit 02110a3d5b
4 changed files with 32 additions and 2 deletions

View File

@ -39,6 +39,7 @@
#include "LyXFunc.h"
#include "Layout.h"
#include "LyXRC.h"
#include "MenuBackend.h"
#include "MetricsInfo.h"
#include "Paragraph.h"
#include "paragraph_funcs.h"
@ -490,6 +491,13 @@ docstring BufferView::toolTip(int x, int y) const
}
Menu const & BufferView::contextMenu(int x, int y) const
{
// FIXME: Do something more elaborate here.
return menubackend.getMenu(from_ascii("edit"));
}
void BufferView::scrollDocView(int value)
{
int const offset = value - d->scrollbarParameters_.position;

View File

@ -36,6 +36,7 @@ class FuncRequest;
class FuncStatus;
class Intl;
class Inset;
class Menu;
class ParIterator;
class ParagraphMetrics;
class Point;
@ -106,6 +107,8 @@ public:
ScrollbarParameters const & scrollbarParameters() const;
/// \return Tool tip for the given position.
docstring toolTip(int x, int y) const;
/// \return the context menu for the given position.
Menu const & contextMenu(int x, int y) const;
/// Save the current position as bookmark.
/// if idx == 0, save to temp_bookmark

View File

@ -23,6 +23,7 @@
#include "GuiApplication.h"
#include "GuiKeySymbol.h"
#include "GuiPainter.h"
#include "GuiPopupMenu.h"
#include "GuiView.h"
#include "KeySymbol.h"
#include "Language.h"
@ -44,15 +45,17 @@
#include "frontends/FontMetrics.h"
#include "frontends/WorkAreaManager.h"
#include <QContextMenuEvent>
#include <QInputContext>
#include <QHelpEvent>
#include <QLayout>
#include <QMainWindow>
#include <QPainter>
#include <QToolButton>
#include <QPalette>
#include <QScrollBar>
#include <QTabBar>
#include <QTimer>
#include <QToolButton>
#include <boost/bind.hpp>
@ -512,6 +515,19 @@ bool GuiWorkArea::event(QEvent * e)
}
void GuiWorkArea::contextMenuEvent(QContextMenuEvent * e)
{
QPoint pos = e->pos();
Menu const & menu = buffer_view_->contextMenu(pos.x(), pos.y());
LYXERR(Debug::GUI, "context menu resquested: " << menu.name());
// FIXME: do something with GuiPopupMenu and MenuBackend.
// Some cleanups of GuiPopupMenu and GuiMenubar are needed
// before!
QAbstractScrollArea::contextMenuEvent(e);
}
void GuiWorkArea::focusInEvent(QFocusEvent * /*event*/)
{
// Repaint the whole screen.

View File

@ -25,12 +25,13 @@
#include <QTabWidget>
#include <QTimer>
class QWidget;
class QContextMenuEvent;
class QDragEnterEvent;
class QDropEvent;
class QKeyEvent;
class QWheelEvent;
class QPaintEvent;
class QWidget;
#ifdef CursorShape
#undef CursorShape
@ -167,6 +168,8 @@ private:
///
bool event(QEvent *);
///
void contextMenuEvent(QContextMenuEvent *);
///
void focusInEvent(QFocusEvent *);
///
void focusOutEvent(QFocusEvent *);