From 66a542ff4f184ef10990c2dbaa0877cfe3a493bc Mon Sep 17 00:00:00 2001 From: Zufu Liu Date: Fri, 4 Mar 2022 08:17:07 +1100 Subject: Feature [feature-requests:#1432] Simplify CallTipStart by passing in surface and font. This allows customization of surface creation and ensures surface and font for calltip are the same as used in main window. --- src/CallTip.cxx | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'src/CallTip.cxx') diff --git a/src/CallTip.cxx b/src/CallTip.cxx index 9fb1b535c..0596214bf 100644 --- a/src/CallTip.cxx +++ b/src/CallTip.cxx @@ -272,24 +272,14 @@ void CallTip::MouseClick(Point pt) noexcept { } PRectangle CallTip::CallTipStart(Sci::Position pos, Point pt, int textHeight, const char *defn, - const char *faceName, int size, - int codePage_, CharacterSet characterSet, - Technology technology, - const char *localeName, - const Window &wParent) { + int codePage_, Surface *surfaceMeasure, std::shared_ptr font_) { clickPlace = 0; val = defn; codePage = codePage_; - std::unique_ptr surfaceMeasure = Surface::Allocate(technology); - surfaceMeasure->Init(wParent.GetID()); - surfaceMeasure->SetMode(SurfaceMode(codePage, false)); highlight = Chunk(); inCallTipMode = true; posStartCallTip = pos; - const XYPOSITION deviceHeight = static_cast(surfaceMeasure->DeviceHeightFont(size)); - const FontParameters fp(faceName, deviceHeight / FontSizeMultiplier, FontWeight::Normal, - false, FontQuality::QualityDefault, technology, characterSet, localeName); - font = Font::Allocate(fp); + font = font_; // Look for multiple lines in the text // Only support \n here - simply means container must avoid \r! const int numLines = 1 + static_cast(std::count(val.begin(), val.end(), '\n')); @@ -300,7 +290,7 @@ PRectangle CallTip::CallTipStart(Sci::Position pos, Point pt, int textHeight, co #if !PLAT_CURSES widthArrow = lineHeight * 9 / 10; #endif - const int width = PaintContents(surfaceMeasure.get(), false) + insetX; + const int width = PaintContents(surfaceMeasure, false) + insetX; // The returned // rectangle is aligned to the right edge of the last arrow encountered in -- cgit v1.2.3