diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/CallTip.cxx | 18 | ||||
| -rw-r--r-- | src/CallTip.h | 6 | ||||
| -rw-r--r-- | src/ScintillaBase.cxx | 17 | 
3 files changed, 35 insertions, 6 deletions
diff --git a/src/CallTip.cxx b/src/CallTip.cxx index 8fc34eb0f..4da4142a8 100644 --- a/src/CallTip.cxx +++ b/src/CallTip.cxx @@ -33,6 +33,7 @@ CallTip::CallTip() {  	startHighlight = 0;  	endHighlight = 0;  	tabSize = 0; +	above = false;  	useStyleCallTip = false;    // for backwards compatibility  #ifdef __APPLE__ @@ -245,7 +246,7 @@ void CallTip::MouseClick(Point pt) {  		clickPlace = 2;  } -PRectangle CallTip::CallTipStart(int pos, Point pt, const char *defn, +PRectangle CallTip::CallTipStart(int pos, Point pt, int textHeight, const char *defn,                                   const char *faceName, int size,                                   int codePage_, int characterSet,  								 int technology, Window &wParent) { @@ -288,7 +289,14 @@ PRectangle CallTip::CallTipStart(int pos, Point pt, const char *defn,  	// the tip text, else to the tip text left edge.  	int height = lineHeight * numLines - surfaceMeasure->InternalLeading(font) + 2 + 2;  	delete surfaceMeasure; -	return PRectangle(pt.x - offsetMain, pt.y + 1, pt.x + width - offsetMain, pt.y + 1 + height); +	if (above) +	{ +		return PRectangle(pt.x - offsetMain, pt.y - 1 - height, pt.x + width - offsetMain, pt.y - 1); +	} +	else +	{ +		return PRectangle(pt.x - offsetMain, pt.y + 1 + textHeight, pt.x + width - offsetMain, pt.y + 1 + textHeight + height); +	}  }  void CallTip::CallTipCancel() { @@ -316,6 +324,12 @@ void CallTip::SetTabSize(int tabSz) {  	useStyleCallTip = true;  } +// Set the calltip position, below the text by default or if above is false +// else above the text. +void CallTip::SetPosition(bool aboveText) { +	above = aboveText; +} +  // It might be better to have two access functions for this and to use  // them for all settings of colours.  void CallTip::SetForeBack(const ColourDesired &fore, const ColourDesired &back) { diff --git a/src/CallTip.h b/src/CallTip.h index 0cb2ede72..657e0caa1 100644 --- a/src/CallTip.h +++ b/src/CallTip.h @@ -25,6 +25,7 @@ class CallTip {  	int offsetMain;         // The alignment point of the call tip  	int tabSize;            // Tab size in pixels, <=0 no TAB expand  	bool useStyleCallTip;   // if true, STYLE_CALLTIP should be used +	bool above;		// if true, display calltip above text  	// Private so CallTip objects can not be copied  	CallTip(const CallTip &); @@ -57,7 +58,7 @@ public:  	void MouseClick(Point pt);  	/// Setup the calltip and return a rectangle of the area required. -	PRectangle CallTipStart(int pos, Point pt, const char *defn, +	PRectangle CallTipStart(int pos, Point pt, int textHeight, const char *defn,  		const char *faceName, int size, int codePage_,  		int characterSet, int technology, Window &wParent); @@ -70,6 +71,9 @@ public:  	/// Set the tab size in pixels for the call tip. 0 or -ve means no tab expand.  	void SetTabSize(int tabSz); +	/// Set calltip position. +	void SetPosition(bool aboveText); +  	/// Used to determine which STYLE_xxxx to use for call tip information  	bool UseStyleCallTip() const { return useStyleCallTip;} diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx index 0f1c9cda3..e6f208ccc 100644 --- a/src/ScintillaBase.cxx +++ b/src/ScintillaBase.cxx @@ -400,7 +400,6 @@ int ScintillaBase::AutoCompleteGetCurrentText(char *buffer) {  void ScintillaBase::CallTipShow(Point pt, const char *defn) {  	ac.Cancel(); -	pt.y += vs.lineHeight;  	// If container knows about STYLE_CALLTIP then use it in place of the  	// STYLE_DEFAULT for the face name, size and character set. Also use it  	// for the foreground and background colour. @@ -409,6 +408,7 @@ void ScintillaBase::CallTipShow(Point pt, const char *defn) {  		ct.SetForeBack(vs.styles[STYLE_CALLTIP].fore, vs.styles[STYLE_CALLTIP].back);  	}  	PRectangle rc = ct.CallTipStart(sel.MainCaret(), pt, +		vs.lineHeight,  		defn,  		vs.styles[ctStyle].fontName,  		vs.styles[ctStyle].sizeZoomed, @@ -417,10 +417,16 @@ void ScintillaBase::CallTipShow(Point pt, const char *defn) {  		vs.technology,  		wMain);  	// If the call-tip window would be out of the client -	// space, adjust so it displays above the text. +	// space  	PRectangle rcClient = GetClientRectangle(); +	int offset = vs.lineHeight + rc.Height(); +	// adjust so it displays below the text. +	if (rc.top < rcClient.top) { +		rc.top += offset; +		rc.bottom += offset; +	} +	// adjust so it displays above the text.  	if (rc.bottom > rcClient.bottom) { -		int offset = vs.lineHeight + rc.Height();  		rc.top -= offset;  		rc.bottom -= offset;  	} @@ -814,6 +820,11 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara  		InvalidateStyleRedraw();  		break; +	case SCI_CALLTIPSETPOSITION: +		ct.SetPosition((bool)wParam); +		InvalidateStyleRedraw(); +		break; +  	case SCI_USEPOPUP:  		displayPopupMenu = wParam != 0;  		break;  | 
