diff options
-rw-r--r-- | doc/ScintillaDoc.html | 15 | ||||
-rw-r--r-- | include/Scintilla.h | 1 | ||||
-rw-r--r-- | include/Scintilla.iface | 1 | ||||
-rw-r--r-- | src/Indicator.cxx | 29 | ||||
-rw-r--r-- | src/XPM.cxx | 22 | ||||
-rw-r--r-- | src/XPM.h | 1 |
6 files changed, 61 insertions, 8 deletions
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index 7a8f03e88..f698a09ca 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -79,7 +79,7 @@ <h1>Scintilla Documentation</h1> - <p>Last edited 19/July/2011 NH</p> + <p>Last edited 21/July/2011 NH</p> <p>There is <a class="jump" href="Design.html">an overview of the internal design of Scintilla</a>.<br /> @@ -3737,6 +3737,19 @@ struct Sci_TextToFind { so will fit under small fonts.</td> </tr> + <tr> + <td align="left"><code>DOTBOX</code></td> + + <td align="center">12</td> + + <td>A dotted rectangle around the text using translucent drawing. + Translucency alternates between the alpha and outline alpha settings with the top-left pixel using the alpha setting. + <a class="message" href="#SCI_INDICSETALPHA">SCI_INDICSETALPHA</a> and + <a class="message" href="#SCI_INDICSETOUTLINEALPHA">SCI_INDICSETOUTLINEALPHA</a> + control the alpha transparency values. The default values are 30 for alpha and 50 for outline alpha. + To avoid excessive memory allocation the maximum width of a dotted box is 4000 pixels.</td> + </tr> + </tbody> </table> diff --git a/include/Scintilla.h b/include/Scintilla.h index 403c0dce7..34e4f793d 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -252,6 +252,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define INDIC_DASH 9 #define INDIC_DOTS 10 #define INDIC_SQUIGGLELOW 11 +#define INDIC_DOTBOX 12 #define INDIC_MAX 31 #define INDIC_CONTAINER 8 #define INDIC0_MASK 0x20 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index 95e784e19..36ead0ece 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -555,6 +555,7 @@ val INDIC_STRAIGHTBOX=8 val INDIC_DASH=9 val INDIC_DOTS=10 val INDIC_SQUIGGLELOW=11 +val INDIC_DOTBOX=12 val INDIC_MAX=31 val INDIC_CONTAINER=8 val INDIC0_MASK=0x20 diff --git a/src/Indicator.cxx b/src/Indicator.cxx index 5efee75e6..7059a55bd 100644 --- a/src/Indicator.cxx +++ b/src/Indicator.cxx @@ -5,9 +5,17 @@ // Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org> // The License.txt file describes the conditions under which this software may be distributed. +#include <vector> +#include <map> + +#ifdef _MSC_VER +#pragma warning(disable: 4786) +#endif + #include "Platform.h" #include "Scintilla.h" +#include "XPM.h" #include "Indicator.h" #ifdef SCI_NAMESPACE @@ -84,6 +92,27 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r rcBox.left = rc.left; rcBox.right = rc.right; surface->AlphaRectangle(rcBox, (style == INDIC_ROUNDBOX) ? 1 : 0, fore.allocated, fillAlpha, fore.allocated, outlineAlpha, 0); + } else if (style == INDIC_DOTBOX) { + PRectangle rcBox = rcLine; + rcBox.top = rcLine.top + 1; + rcBox.left = rc.left; + rcBox.right = rc.right; + // Cap width at 4000 to avoid large allocations when mistakes made + int width = Platform::Minimum(rcBox.Width(), 4000); + RGBAImage image(width, rcBox.Height(), 0); + // Draw horizontal lines top and bottom + for (int x=0; x<width; x++) { + for (int y=0; y<rcBox.Height(); y += rcBox.Height()-1) { + image.SetPixel(x, y, fore.desired, ((x + y) % 2) ? outlineAlpha : fillAlpha); + } + } + // Draw vertical lines left and right + for (int y=1; y<rcBox.Height(); y++) { + for (int x=0; x<width; x += width-1) { + image.SetPixel(x, y, fore.desired, ((x + y) % 2) ? outlineAlpha : fillAlpha); + } + } + surface->DrawRGBAImage(rcBox, image.GetWidth(), image.GetHeight(), image.Pixels()); } else if (style == INDIC_DASH) { int x = rc.left; while (x < rc.right) { diff --git a/src/XPM.cxx b/src/XPM.cxx index 6c615dd94..f0277c65f 100644 --- a/src/XPM.cxx +++ b/src/XPM.cxx @@ -353,7 +353,11 @@ int XPMSet::GetWidth() { RGBAImage::RGBAImage(int width_, int height_, const unsigned char *pixels_) : height(height_), width(width_) { - pixelBytes.assign(pixels_, pixels_ + CountBytes()); + if (pixels_) { + pixelBytes.assign(pixels_, pixels_ + CountBytes()); + } else { + pixelBytes.resize(CountBytes()); + } } RGBAImage::RGBAImage(const XPM &xpm) { @@ -365,12 +369,7 @@ RGBAImage::RGBAImage(const XPM &xpm) { ColourDesired colour; bool transparent = false; xpm.PixelAt(x, y, colour, transparent); - unsigned char *pixel = &pixelBytes[0] + (y*width+x) * 4; - // RGBA - pixel[0] = colour.GetRed(); - pixel[1] = colour.GetGreen(); - pixel[2] = colour.GetBlue(); - pixel[3] = transparent ? 0 : 255; + SetPixel(x, y, colour, transparent ? 0 : 255); } } } @@ -386,6 +385,15 @@ const unsigned char *RGBAImage::Pixels() const { return &pixelBytes[0]; } +void RGBAImage::SetPixel(int x, int y, ColourDesired colour, int alpha) { + unsigned char *pixel = &pixelBytes[0] + (y*width+x) * 4; + // RGBA + pixel[0] = colour.GetRed(); + pixel[1] = colour.GetGreen(); + pixel[2] = colour.GetBlue(); + pixel[3] = alpha; +} + RGBAImageSet::RGBAImageSet() : height(-1), width(-1){ } @@ -93,6 +93,7 @@ public: int GetWidth() const { return width; } int CountBytes() const; const unsigned char *Pixels() const; + void SetPixel(int x, int y, ColourDesired colour, int alpha=0xff); }; /** |