I'd like comments as to whether the following patch is foolish or usable.
It addresses the constant complaints about the popups font for defaultWrite mode being too big.
It de-scales the font and width of the defaultWrite mode wxPopupWindow (an idea taken from a cryptic statement by New Pegodi and code by Miguel Gimenez) for defaultWrite CallTip and AutoCompletion.
Suggestions for improvement (if it's usable) are welcome.
Index: src/sdk/wxscintilla/src/PlatWX.cpp
===================================================================
--- src/sdk/wxscintilla/src/PlatWX.cpp (revision 13319)
+++ src/sdk/wxscintilla/src/PlatWX.cpp (working copy)
@@ -2429,19 +2429,22 @@
/* C::B begin */
// GETLB(wid)->SetFont(*((wxFont*)font.GetID()));
wxFont *NewFont = (wxFont*)font.GetID();
+#if wxCHECK_VERSION(3, 1, 4)
+ const double scale = GETLB(wid)->GetDPIScaleFactor();
+ #else
+ const double scale = GETLB(wid)->GetContentScaleFactor();
+ #endif
+
if (technology == wxSCI_TECHNOLOGY_DIRECTWRITE)
- {
-#if wxCHECK_VERSION(3, 1, 4)
- const double scale = GETLB(wid)->GetDPIScaleFactor();
-#else
- const double scale = GETLB(wid)->GetContentScaleFactor();
-#endif
GETLB(wid)->SetFont(NewFont->Scaled(72.0/(96.0*scale)));
- }
- else
+ else // non direct write mode (wxSCI_TECHNOLOGY_DEFAULT)
+ #if wxCHECK_VERSION(3, 1, 4)
+ GETLB(wid)->SetFont(NewFont->Scaled(72.0/(72.0*scale))); //(ph 2023/07/18)
+ #else
GETLB(wid)->SetFont(*NewFont);
+ #endif
+}
/* C::B end */
-}
void ListBoxImpl::Create(Window &parent, int ctrlID, Point location_, int lineHeight_, bool unicodeMode_, int technology_) {
Index: src/sdk/wxscintilla/src/scintilla/src/CallTip.cxx
===================================================================
--- src/sdk/wxscintilla/src/scintilla/src/CallTip.cxx (revision 13319)
+++ src/sdk/wxscintilla/src/scintilla/src/CallTip.cxx (working copy)
@@ -26,6 +26,13 @@
using namespace Scintilla;
#endif
+/* C::B begin */ //(ph 2023/07/23)
+#include <wx/version.h>
+#if wxCHECK_VERSION(3, 1, 4)
+#include "wx/window.h" //(ph 2023/07/22)
+#endif
+/* C::B end */
+
CallTip::CallTip() {
wCallTip = 0;
inCallTipMode = false;
@@ -283,6 +290,20 @@
look = newline + 1;
numLines++;
}
+
+/* C::B begin */
+ #if wxCHECK_VERSION(3, 1, 4)
+ // Scale the popup window size for non DirectWrite (defaultWrite) mode
+ if (technology == SC_TECHNOLOGY_DEFAULT) //(ph 2023/07/22)
+ {
+ std::unique_ptr<wxWindow> pwxWin;
+ pwxWin.reset(new wxWindow());
+ double sysScaling = pwxWin->GetDPIScaleFactor();
+ int* pWidth = const_cast<int*>(&width);
+ *pWidth = ((width*72*sysScaling)/72) + fp.size;
+ }
+ #endif
+/* C::B end */
lineHeight = RoundXYPosition(surfaceMeasure->Height(font));
// The returned
Index: src/sdk/wxscintilla/src/scintilla/src/ScintillaBase.cxx
===================================================================
--- src/sdk/wxscintilla/src/scintilla/src/ScintillaBase.cxx (revision 13319)
+++ src/sdk/wxscintilla/src/scintilla/src/ScintillaBase.cxx (working copy)
@@ -60,6 +60,13 @@
#include "AutoComplete.h"
#include "ScintillaBase.h"
+/* C::B begin */
+#include <wx/version.h>
+#if wxCHECK_VERSION(3, 1, 4)
+#include <wx/window.h> //(ph 2023/07/22)
+#endif
+/* C::B end */
+
#ifdef SCI_NAMESPACE
using namespace Scintilla;
#endif
@@ -428,7 +435,6 @@
*buffer = '\0';
return 0;
}
-
void ScintillaBase::CallTipShow(Point pt, const char *defn) {
ac.Cancel();
// If container knows about STYLE_CALLTIP then use it in place of the
@@ -443,6 +449,26 @@
pt.x += ptOrigin.x;
pt.y += ptOrigin.y;
}
+
+ /* C::B begin */
+ #if wxCHECK_VERSION(3, 1, 4)
+ // Correct non-DirectWrite sizeZoomed for defaultWrite mode //(ph 2023/07/19)
+ if (vs.technology == SC_TECHNOLOGY_DEFAULT)
+ {
+ std::unique_ptr<wxWindow> pwxWin;
+ pwxWin.reset(new wxWindow());
+ double sysScaleFactor = pwxWin->GetDPIScaleFactor();
+ int fontsize = vs.styles[ctStyle].size;
+ double dsizeZoomed = fontsize + vs.zoomLevel * SC_FONT_SIZE_MULTIPLIER;
+ double dscale = (72.0 /(72.0 * sysScaleFactor)) +0.01;
+ dsizeZoomed = dsizeZoomed * dscale;
+ if (dsizeZoomed <= 2 * SC_FONT_SIZE_MULTIPLIER) // Hangs if sizeZoomed <= 1
+ dsizeZoomed = 2 * SC_FONT_SIZE_MULTIPLIER;
+ vs.styles[ctStyle].sizeZoomed = dsizeZoomed;
+ }
+ #endif // wxCHECK_VERSION
+ /* C::B end */
+
PRectangle rc = ct.CallTipStart(sel.MainCaret(), pt,
vs.lineHeight,
defn,
The patch applies to Head r13319 .
The debugging tags like "//(ph 2023/07/23)" will be removed later; if we use it.