Setting transparency of box indicator

Topics: User Forum
Mar 23, 2010 at 1:26 PM

I've been trying to figure out how to set the transparency used for the "Roundbox" indicator - now that I've figured out how to do this I thought I'd post here in case someone else has the same problem.

The Scintilla documentation states that the SCI_INDICSETALPHA message should be used to set the alpha transparency value used when drawing the "Roundbox" indicator - it defaults to 30%, however this message is not currentlly exposed in ScintillaNet and additionally the message is only present in Scintilla from version 1.78 (the version supplied with my download of ScintillaNet was 1.76).

To get this all hooked up and working I downloaded the latest version of Scintilla and modified ScintillaNet to expose the extra messages as a Alpha property (I'm pretty sure you could also achieve this as an extension method if you don't want to meddle with the ScintillaNet source).

Full detail of the changes:

Constants.cs (added 2 new constants):

public const uint SCI_INDICSETALPHA = 2523;
public const uint SCI_INDICGETALPHA = 2524;

Indicator.cs (added property to Indicator class):

/// <summary>
/// Gets and sets the alpha transparency used for drawing the fill color of the <see cref="ScintillaNet.IndicatorStyle.RoundBox" />
/// indicator style.  The alpha value can range from 0 (completely transparent) to 100 (no transparency).
/// </summary>
public int Alpha
        return NativeScintilla.IndicGetAlpha(_number);
        NativeScintilla.IndicSetAlpha(_number, value);

INativeScintilla.cs (Added 2 new methods to interface INativeScintilla):

int IndicGetAlpha(int indicatorNumber);
void IndicSetAlpha(int indicatorNumber, int alpha);

Scintilla.INativeScintilla.cs (Added 2 new methods to class Scintilla):

void INativeScintilla.IndicSetAlpha(int indicatorNumber, int alpha)
    _ns.SendMessageDirect(Constants.SCI_INDICSETALPHA, indicatorNumber, alpha);

int INativeScintilla.IndicGetFore(int indicatorNumber)
    return _ns.SendMessageDirect(Constants.SCI_INDICGETFORE, indicatorNumber, 0);

int INativeScintilla.IndicGetAlpha(int indicatorNumber)
    return _ns.SendMessageDirect(Constants.SCI_INDICGETALPHA, indicatorNumber, 0);

Just to stress - your version of Scilexer.dll needs to be 1.78 or later or this will do nothing! :-)