]> git.saurik.com Git - wxWidgets.git/blob - contrib/src/stc/scintilla/src/Indicator.cxx
a42abb2037de1583aec37833bad773f3f1bd17f0
[wxWidgets.git] / contrib / src / stc / scintilla / src / Indicator.cxx
1 // Scintilla source code edit control
2 /** @file Indicator.cxx
3 ** Defines the style of indicators which are text decorations such as underlining.
4 **/
5 // Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
6 // The License.txt file describes the conditions under which this software may be distributed.
7
8 #include "Platform.h"
9
10 #include "Scintilla.h"
11 #include "Indicator.h"
12
13 void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine) {
14 surface->PenColour(fore.allocated);
15 int ymid = (rc.bottom + rc.top) / 2;
16 if (style == INDIC_SQUIGGLE) {
17 surface->MoveTo(rc.left, rc.top);
18 int x = rc.left + 2;
19 int y = 2;
20 while (x < rc.right) {
21 surface->LineTo(x, rc.top + y);
22 x += 2;
23 y = 2 - y;
24 }
25 surface->LineTo(rc.right, rc.top + y); // Finish the line
26 } else if (style == INDIC_TT) {
27 surface->MoveTo(rc.left, ymid);
28 int x = rc.left + 5;
29 while (x < rc.right) {
30 surface->LineTo(x, ymid);
31 surface->MoveTo(x-3, ymid);
32 surface->LineTo(x-3, ymid+2);
33 x++;
34 surface->MoveTo(x, ymid);
35 x += 5;
36 }
37 surface->LineTo(rc.right, ymid); // Finish the line
38 if (x - 3 <= rc.right) {
39 surface->MoveTo(x-3, ymid);
40 surface->LineTo(x-3, ymid+2);
41 }
42 } else if (style == INDIC_DIAGONAL) {
43 int x = rc.left;
44 while (x < rc.right) {
45 surface->MoveTo(x, rc.top+2);
46 int endX = x+3;
47 int endY = rc.top - 1;
48 if (endX > rc.right) {
49 endY += endX - rc.right;
50 endX = rc.right;
51 }
52 surface->LineTo(endX, endY);
53 x += 4;
54 }
55 } else if (style == INDIC_STRIKE) {
56 surface->MoveTo(rc.left, rc.top - 4);
57 surface->LineTo(rc.right, rc.top - 4);
58 } else if (style == INDIC_HIDDEN) {
59 // Draw nothing
60 } else if (style == INDIC_BOX) {
61 surface->MoveTo(rc.left, ymid+1);
62 surface->LineTo(rc.right, ymid+1);
63 surface->LineTo(rc.right, rcLine.top+1);
64 surface->LineTo(rc.left, rcLine.top+1);
65 surface->LineTo(rc.left, ymid+1);
66 } else { // Either INDIC_PLAIN or unknown
67 surface->MoveTo(rc.left, ymid);
68 surface->LineTo(rc.right, ymid);
69 }
70 }
71