}
+docstring BufferView::toolTip(int x, int y) const
+{
+ // Get inset under mouse, if there is one.
+ Inset const * covering_inset = getCoveringInset(buffer_.text(), x, y);
+ if (!covering_inset)
+ // No inset, no tooltip...
+ return docstring();
+ return covering_inset->toolTip(*this, x, y);
+}
+
+
void BufferView::scrollDocView(int value)
{
int const offset = value - d->scrollbarParameters_.position;
}
-Inset const * BufferView::getCoveringInset(Text const & text, int x, int y)
+Inset const * BufferView::getCoveringInset(Text const & text,
+ int x, int y) const
{
TextMetrics & tm = d->text_metrics_[&text];
Inset * inset = tm.checkInsetHit(x, y);
void updateScrollbar();
/// return the Scrollbar Parameters.
ScrollbarParameters const & scrollbarParameters() const;
+ /// \return Tool tip for the given position.
+ docstring toolTip(int x, int y) const;
/// Save the current position as bookmark.
/// if idx == 0, save to temp_bookmark
/// return the pixel height of the document view.
int workHeight() const;
+
/// translate and insert a character, using the correct keymap.
void translateAndInsert(char_type c, Text * t, Cursor & cur);
Text const & text, //< The Text where we start searching.
int x, //< x-coordinate on screen
int y //< y-coordinate on screen
- );
+ ) const;
///
int width_;
void GuiWorkArea::adjustViewWithScrollBar(int action)
{
stopBlinkingCursor();
+// QToolTip::hideText();
if (action == QAbstractSlider::SliderPageStepAdd)
buffer_view_->scrollDown(viewport()->height());
else if (action == QAbstractSlider::SliderPageStepSub)
buffer_view_->setCursorFromScrollbar();
lyx_view_->updateLayoutList();
}
+/*
+ lyxerr << "QCursor::pos() = "
+ << QCursor::pos().x() << " "
+ << QCursor::pos().y() << " "
+ <<endl;
+ QToolTip::showText(QCursor::pos(), "toto"), verticalScrollBar());
+*/
// Show the cursor immediately after any operation.
startBlinkingCursor();
QApplication::syncX();
}
+bool GuiWorkArea::event(QEvent * e)
+{
+ if (e->type() == QEvent::ToolTip) {
+ QHelpEvent * helpEvent = static_cast<QHelpEvent *>(e);
+ QPoint pos = helpEvent->pos();
+ if (pos.x() < viewport()->width()) {
+ QString s = toqstr(buffer_view_->toolTip(pos.x(), pos.y()));
+ QToolTip::showText(helpEvent->globalPos(), s);
+ }
+ else
+ QToolTip::hideText();
+ }
+ return QAbstractScrollArea::event(e);
+}
+
+
void GuiWorkArea::focusInEvent(QFocusEvent * /*event*/)
{
// Repaint the whole screen.
/// Update window titles of all users.
void updateWindowTitle();
///
+ bool event(QEvent *);
+ ///
void focusInEvent(QFocusEvent *);
///
void focusOutEvent(QFocusEvent *);
}
+docstring Inset::toolTip(BufferView const &, int, int) const
+{
+ return docstring();
+}
+
+
Dimension const Inset::dimension(BufferView const & bv) const
{
return bv.coordCache().getInsets().dim(this);
/// Is the width forced to some value?
virtual bool hasFixedWidth() const { return false; }
+ /// \return Tool tip for this inset.
+ /// This default implementation returns an empty string.
+ virtual docstring toolTip(BufferView const & bv, int x, int y) const;
// FIXME This should really disappear in favor of
// docstring name() const { return from_ascii(insetName(lyxCode()))); }
}
-void InsetCollapsable::setLayout(BufferParams const & bp)
+docstring InsetCollapsable::toolTip(BufferView const & bv, int x, int y) const
+{
+ Dimension dim = dimensionCollapsed();
+ if (x > xo(bv) + dim.wid || y > yo(bv) + dim.des)
+ return docstring();
+
+ switch (status_) {
+ case Open:
+ return _("Left-click to collapse the inset");
+ case Collapsed:
+ return _("Left-click to open the inset");
+ }
+ return docstring();
+}
+
+
+void InsetCollapsable::setLayout(BufferParams const & bp)
{
setLayout(bp.getTextClass().insetlayout(name()));
}
InsetCollapsable * asInsetCollapsable() { return this; }
InsetCollapsable const * asInsetCollapsable() const { return this; }
+ docstring toolTip(BufferView const & bv, int x, int y) const;
docstring name() const { return from_ascii("Collapsable"); }
InsetLayout const & getLayout(BufferParams const &) const
{ return *layout_; }