]> git.saurik.com Git - wxWidgets.git/blob - src/stc/scintilla/src/LineMarker.cxx
changed version number
[wxWidgets.git] / src / stc / scintilla / src / LineMarker.cxx
1 // Scintilla source code edit control
2 // LineMarker.cxx - defines the look of a line marker in the margin
3 // Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
4 // The License.txt file describes the conditions under which this software may be distributed.
5
6 #include "Platform.h"
7
8 #include "Scintilla.h"
9 #include "LineMarker.h"
10
11 void LineMarker::Draw(Surface *surface, PRectangle &rc) {
12 int minDim = Platform::Minimum(rc.Width(), rc.Height());
13 minDim--; // Ensure does not go beyond edge
14 int centreX = (rc.right + rc.left) / 2;
15 int centreY = (rc.bottom + rc.top) / 2;
16 int dimOn2 = minDim / 2;
17 int dimOn4 = minDim / 4;
18 if (rc.Width() > (rc.Height() * 2)) {
19 // Wide column is line number so move to left to try to avoid overlapping number
20 centreX = rc.left + dimOn2 + 1;
21 }
22 if (markType == SC_MARK_ROUNDRECT) {
23 PRectangle rcRounded = rc;
24 rcRounded.left = rc.left + 1;
25 rcRounded.right = rc.right - 1;
26 surface->RoundedRectangle(rcRounded, fore.allocated, back.allocated);
27 } else if (markType == SC_MARK_CIRCLE) {
28 PRectangle rcCircle;
29 rcCircle.left = centreX - dimOn2;
30 rcCircle.top = centreY - dimOn2;
31 rcCircle.right = centreX + dimOn2;
32 rcCircle.bottom = centreY + dimOn2;
33 surface->Ellipse(rcCircle, fore.allocated, back.allocated);
34 } else if (markType == SC_MARK_ARROW) {
35 Point pts[] = {
36 Point(centreX - dimOn4, centreY - dimOn2),
37 Point(centreX - dimOn4, centreY + dimOn2),
38 Point(centreX + dimOn2 - dimOn4, centreY),
39 };
40 surface->Polygon(pts, sizeof(pts) / sizeof(pts[0]),
41 fore.allocated, back.allocated);
42
43 } else if (markType == SC_MARK_ARROWDOWN) {
44 Point pts[] = {
45 Point(centreX - dimOn2, centreY - dimOn4),
46 Point(centreX + dimOn2, centreY - dimOn4),
47 Point(centreX, centreY + dimOn2 - dimOn4),
48 };
49 surface->Polygon(pts, sizeof(pts) / sizeof(pts[0]),
50 fore.allocated, back.allocated);
51
52 } else if (markType == SC_MARK_PLUS) {
53 int armSize = dimOn2-2;
54 Point pts[] = {
55 Point(centreX - armSize, centreY - 1),
56 Point(centreX - 1, centreY - 1),
57 Point(centreX - 1, centreY - armSize),
58 Point(centreX + 1, centreY - armSize),
59 Point(centreX + 1, centreY - 1),
60 Point(centreX + armSize, centreY -1),
61 Point(centreX + armSize, centreY +1),
62 Point(centreX + 1, centreY + 1),
63 Point(centreX + 1, centreY + armSize),
64 Point(centreX - 1, centreY + armSize),
65 Point(centreX - 1, centreY + 1),
66 Point(centreX - armSize, centreY + 1),
67 };
68 surface->Polygon(pts, sizeof(pts) / sizeof(pts[0]),
69 fore.allocated, back.allocated);
70
71 } else if (markType == SC_MARK_MINUS) {
72 int armSize = dimOn2-2;
73 Point pts[] = {
74 Point(centreX - armSize, centreY - 1),
75 Point(centreX + armSize, centreY -1),
76 Point(centreX + armSize, centreY +1),
77 Point(centreX - armSize, centreY + 1),
78 };
79 surface->Polygon(pts, sizeof(pts) / sizeof(pts[0]),
80 fore.allocated, back.allocated);
81
82 } else if (markType == SC_MARK_SMALLRECT) {
83 PRectangle rcSmall;
84 rcSmall.left = rc.left + 1;
85 rcSmall.top = rc.top + 2;
86 rcSmall.right = rc.right - 1;
87 rcSmall.bottom = rc.bottom - 2;
88 surface->RectangleDraw(rcSmall, fore.allocated, back.allocated);
89 } else if (markType == SC_MARK_EMPTY) {
90 // An invisible marker so don't draw anything
91 } else { // SC_MARK_SHORTARROW
92 Point pts[] = {
93 Point(centreX, centreY + dimOn2),
94 Point(centreX + dimOn2, centreY),
95 Point(centreX, centreY - dimOn2),
96 Point(centreX, centreY - dimOn4),
97 Point(centreX - dimOn4, centreY - dimOn4),
98 Point(centreX - dimOn4, centreY + dimOn4),
99 Point(centreX, centreY + dimOn4),
100 Point(centreX, centreY + dimOn2),
101 };
102 surface->Polygon(pts, sizeof(pts) / sizeof(pts[0]),
103 fore.allocated, back.allocated);
104 }
105 }