]>
git.saurik.com Git - wxWidgets.git/blob - 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.
9 #include "LineMarker.h"
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;
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
) {
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
) {
36 Point(centreX
- dimOn4
, centreY
- dimOn2
),
37 Point(centreX
- dimOn4
, centreY
+ dimOn2
),
38 Point(centreX
+ dimOn2
- dimOn4
, centreY
),
40 surface
->Polygon(pts
, sizeof(pts
) / sizeof(pts
[0]),
41 fore
.allocated
, back
.allocated
);
43 } else if (markType
== SC_MARK_ARROWDOWN
) {
45 Point(centreX
- dimOn2
, centreY
- dimOn4
),
46 Point(centreX
+ dimOn2
, centreY
- dimOn4
),
47 Point(centreX
, centreY
+ dimOn2
- dimOn4
),
49 surface
->Polygon(pts
, sizeof(pts
) / sizeof(pts
[0]),
50 fore
.allocated
, back
.allocated
);
52 } else if (markType
== SC_MARK_PLUS
) {
53 int armSize
= dimOn2
-2;
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),
68 surface
->Polygon(pts
, sizeof(pts
) / sizeof(pts
[0]),
69 fore
.allocated
, back
.allocated
);
71 } else if (markType
== SC_MARK_MINUS
) {
72 int armSize
= dimOn2
-2;
74 Point(centreX
- armSize
, centreY
- 1),
75 Point(centreX
+ armSize
, centreY
-1),
76 Point(centreX
+ armSize
, centreY
+1),
77 Point(centreX
- armSize
, centreY
+ 1),
79 surface
->Polygon(pts
, sizeof(pts
) / sizeof(pts
[0]),
80 fore
.allocated
, back
.allocated
);
82 } else if (markType
== SC_MARK_SMALLRECT
) {
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
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
),
102 surface
->Polygon(pts
, sizeof(pts
) / sizeof(pts
[0]),
103 fore
.allocated
, back
.allocated
);