aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorZufu Liu <unknown>2022-03-04 08:17:07 +1100
committerZufu Liu <unknown>2022-03-04 08:17:07 +1100
commit66a542ff4f184ef10990c2dbaa0877cfe3a493bc (patch)
treef0c94e29748a8e1d08b0b1a4815519487621f145
parentc4600877277ae062a7543dba4521591ede7adc54 (diff)
downloadscintilla-mirror-66a542ff4f184ef10990c2dbaa0877cfe3a493bc.tar.gz
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.
-rw-r--r--src/CallTip.cxx16
-rw-r--r--src/CallTip.h4
-rw-r--r--src/ScintillaBase.cxx12
3 files changed, 9 insertions, 23 deletions
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> font_) {
clickPlace = 0;
val = defn;
codePage = codePage_;
- std::unique_ptr<Surface> surfaceMeasure = Surface::Allocate(technology);
- surfaceMeasure->Init(wParent.GetID());
- surfaceMeasure->SetMode(SurfaceMode(codePage, false));
highlight = Chunk();
inCallTipMode = true;
posStartCallTip = pos;
- const XYPOSITION deviceHeight = static_cast<XYPOSITION>(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<int>(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
diff --git a/src/CallTip.h b/src/CallTip.h
index dc1071baa..3f0e4f801 100644
--- a/src/CallTip.h
+++ b/src/CallTip.h
@@ -71,9 +71,7 @@ public:
/// Setup the calltip and return a rectangle of the area required.
PRectangle CallTipStart(Sci::Position pos, Point pt, int textHeight, const char *defn,
- const char *faceName, int size, int codePage_,
- Scintilla::CharacterSet characterSet, Scintilla::Technology technology, const char *localeName,
- const Window &wParent);
+ int codePage_, Surface *surfaceMeasure, std::shared_ptr<Font> font_);
void CallTipCancel() noexcept;
diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx
index 566a55a3c..979a8b07f 100644
--- a/src/ScintillaBase.cxx
+++ b/src/ScintillaBase.cxx
@@ -465,22 +465,20 @@ void ScintillaBase::CallTipShow(Point pt, const char *defn) {
// StyleDefault for the face name, size and character set. Also use it
// for the foreground and background colour.
const int ctStyle = ct.UseStyleCallTip() ? StyleCallTip : StyleDefault;
+ const Style &style = vs.styles[ctStyle];
if (ct.UseStyleCallTip()) {
- ct.SetForeBack(vs.styles[StyleCallTip].fore, vs.styles[StyleCallTip].back);
+ ct.SetForeBack(style.fore, style.back);
}
if (wMargin.Created()) {
pt = pt + GetVisibleOriginInMain();
}
+ AutoSurface surfaceMeasure(this);
PRectangle rc = ct.CallTipStart(sel.MainCaret(), pt,
vs.lineHeight,
defn,
- vs.styles[ctStyle].fontName,
- vs.styles[ctStyle].sizeZoomed,
CodePage(),
- vs.styles[ctStyle].characterSet,
- vs.technology,
- vs.localeName.c_str(),
- wMain);
+ surfaceMeasure,
+ style.font);
// If the call-tip window would be out of the client
// space
const PRectangle rcClient = GetClientRectangle();