diff options
| author | Sébastien Granjoux <seb.sfo@free.fr> | 2011-09-23 23:16:12 +0200 | 
|---|---|---|
| committer | Sébastien Granjoux <seb.sfo@free.fr> | 2011-09-23 23:16:12 +0200 | 
| commit | c89ae1e2153477f2d369b82dacafa10cd417c704 (patch) | |
| tree | 212fce702cde5bf0ceafedbd7bd115d267cef200 | |
| parent | a407a6330fa1d41aecc2816cf5f079bac5dd3304 (diff) | |
| download | scintilla-mirror-c89ae1e2153477f2d369b82dacafa10cd417c704.tar.gz | |
Allow to display calltip above or below the text
| -rw-r--r-- | doc/ScintillaDoc.html | 5 | ||||
| -rw-r--r-- | include/Scintilla.h | 1 | ||||
| -rw-r--r-- | include/Scintilla.iface | 3 | ||||
| -rw-r--r-- | src/CallTip.cxx | 18 | ||||
| -rw-r--r-- | src/CallTip.h | 6 | ||||
| -rw-r--r-- | src/ScintillaBase.cxx | 17 | 
6 files changed, 44 insertions, 6 deletions
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index f78a0a74a..bbae413a4 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -4143,6 +4143,7 @@ struct Sci_TextToFind {       <a class="message" href="#SCI_CALLTIPSETFORE">SCI_CALLTIPSETFORE(int colour)</a><br />       <a class="message" href="#SCI_CALLTIPSETFOREHLT">SCI_CALLTIPSETFOREHLT(int colour)</a><br />       <a class="message" href="#SCI_CALLTIPUSESTYLE">SCI_CALLTIPUSESTYLE(int tabsize)</a><br /> +     <a class="message" href="#SCI_CALLTIPSETPOSITION">SCI_CALLTIPSETPOSITION(bool above)</a><br />      </code>      <p><b id="SCI_CALLTIPSHOW">SCI_CALLTIPSHOW(int posStart, const char *definition)</b><br /> @@ -4206,6 +4207,10 @@ struct Sci_TextToFind {      less than 1, Tab characters are not treated specially. Once this call has been used, the      call tip foreground and background colours are also taken from the style.</p> +    <p><b id="SCI_CALLTIPSETPOSITION">SCI_CALLTIPSETPOSITION(bool above)</b><br /> +     By default the calltip is displayed below the text, setting above to <code>true</code> +    (1) will display it above the text.</p> +          <h2 id="KeyboardCommands">Keyboard commands</h2> diff --git a/include/Scintilla.h b/include/Scintilla.h index 10f290822..1cccd7872 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -415,6 +415,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,  #define SCI_CALLTIPSETFORE 2206  #define SCI_CALLTIPSETFOREHLT 2207  #define SCI_CALLTIPUSESTYLE 2212 +#define SCI_CALLTIPSETPOSITION 2213  #define SCI_VISIBLEFROMDOCLINE 2220  #define SCI_DOCLINEFROMVISIBLE 2221  #define SCI_WRAPCOUNT 2235 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index e77675567..e0462a3fd 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -1039,6 +1039,9 @@ set void CallTipSetForeHlt=2207(colour fore,)  # Enable use of STYLE_CALLTIP and set call tip tab size in pixels.  set void CallTipUseStyle=2212(int tabSize,) +# Set position of calltip, above or below text. +set void CallTipSetPosition=2213(bool above,) +  # Find the display line of a document line taking hidden lines into account.  fun int VisibleFromDocLine=2220(int line,) 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;  | 
