From ca6456fe971e9a6270c01c22bcbc39a91e583aa8 Mon Sep 17 00:00:00 2001
From: mitchell
Date: Sun, 17 Feb 2019 17:45:23 -0500
Subject: Backport: Bug [#1548]. Implement calltips on Qt.
Backport of changeset 7237:a82b87a88556 and 7238:ba336ac439f0.
---
doc/ScintillaDoc.html | 2 --
doc/ScintillaHistory.html | 5 +++++
qt/ScintillaEditBase/ScintillaQt.cpp | 29 ++++++++++++++++++++++++++++-
3 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html
index fdf1e36c0..e897060ae 100644
--- a/doc/ScintillaDoc.html
+++ b/doc/ScintillaDoc.html
@@ -4975,8 +4975,6 @@ struct Sci_TextToFind {
There is some interaction between call tips and autocompletion lists in that showing a
call tip cancels any active autocompletion list, and vice versa.
- Call tips are not implemented on Qt.
-
Call tips can highlight part of the text within them. You could use this to highlight the
current argument to a function by counting the number of commas (or whatever separator your
language uses). See SciTEBase::CharAdded() in SciTEBase.cxx for an
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html
index bf31ff711..7ede2b761 100644
--- a/doc/ScintillaHistory.html
+++ b/doc/ScintillaHistory.html
@@ -530,6 +530,7 @@
Gokul Krishnan |
| Jad Altahan |
+ Andrea Ricchi |
@@ -548,6 +549,10 @@
Released 10 January 2019.
+
+ Calltips implemented on Qt.
+ Bug #1548.
+
The C++ lexer, with styling.within.preprocessor on, now interprets "(" in preprocessor "#if("
as an operator instead of part of the directive. This improves folding as well which could become
diff --git a/qt/ScintillaEditBase/ScintillaQt.cpp b/qt/ScintillaEditBase/ScintillaQt.cpp
index 804cd2dc0..98a8000fa 100644
--- a/qt/ScintillaEditBase/ScintillaQt.cpp
+++ b/qt/ScintillaEditBase/ScintillaQt.cpp
@@ -613,11 +613,38 @@ void ScintillaQt::StartDrag()
SetDragPosition(SelectionPosition(Sci::invalidPosition));
}
+class CallTipImpl : public QWidget {
+public:
+ CallTipImpl(CallTip *pct_)
+ : QWidget(nullptr, Qt::ToolTip),
+ pct(pct_)
+ {
+#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)
+ setWindowFlag(Qt::WindowTransparentForInput);
+#endif
+ }
+
+ void paintEvent(QPaintEvent *) override
+ {
+ if (pct->inCallTipMode) {
+ Surface *surfaceWindow = Surface::Allocate(0);
+ surfaceWindow->Init(this);
+ surfaceWindow->SetUnicodeMode(SC_CP_UTF8 == pct->codePage);
+ surfaceWindow->SetDBCSMode(pct->codePage);
+ pct->PaintCT(surfaceWindow);
+ delete surfaceWindow;
+ }
+ }
+
+private:
+ CallTip *pct;
+};
+
void ScintillaQt::CreateCallTipWindow(PRectangle rc)
{
if (!ct.wCallTip.Created()) {
- QWidget *pCallTip = new QWidget(0, Qt::ToolTip);
+ QWidget *pCallTip = new CallTipImpl(&ct);
ct.wCallTip = pCallTip;
pCallTip->move(rc.left, rc.top);
pCallTip->resize(rc.Width(), rc.Height());
--
cgit v1.2.3