]>
git.saurik.com Git - wxWidgets.git/blob - contrib/src/stc/scintilla/src/ViewStyle.cxx
001ecdb31933c839c976dac1d9a7a34fd40ccd1a
1 // Scintilla source code edit control
2 // ViewStyle.cxx - store information on how the document is to be viewed
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.
10 #include "Scintilla.h"
11 #include "Indicator.h"
12 #include "LineMarker.h"
14 #include "ViewStyle.h"
16 MarginStyle::MarginStyle() :
17 symbol(false), width(16), mask(0xffffffff), sensitive(false) {
20 ViewStyle::ViewStyle() {
24 ViewStyle::ViewStyle(const ViewStyle
&source
) {
26 for (int sty
=0;sty
<=STYLE_MAX
;sty
++) {
27 styles
[sty
] = source
.styles
[sty
];
29 for (int mrk
=0;mrk
<=MARKER_MAX
;mrk
++) {
30 markers
[mrk
] = source
.markers
[mrk
];
32 for (int ind
=0;ind
<=INDIC_MAX
;ind
++) {
33 indicators
[ind
] = source
.indicators
[ind
];
36 selforeset
= source
.selforeset
;
37 selforeground
.desired
= source
.selforeground
.desired
;
38 selbackset
= source
.selbackset
;
39 selbackground
.desired
= source
.selbackground
.desired
;
40 selbar
.desired
= source
.selbar
.desired
;
41 selbarlight
.desired
= source
.selbarlight
.desired
;
42 caretcolour
.desired
= source
.caretcolour
.desired
;
43 edgecolour
.desired
= source
.edgecolour
.desired
;
44 leftMarginWidth
= source
.leftMarginWidth
;
45 rightMarginWidth
= source
.rightMarginWidth
;
46 for (int i
=0;i
< margins
; i
++) {
49 symbolMargin
= source
.symbolMargin
;
50 maskInLine
= source
.maskInLine
;
51 fixedColumnWidth
= source
.fixedColumnWidth
;
52 zoomLevel
= source
.zoomLevel
;
53 viewWhitespace
= source
.viewWhitespace
;
54 viewEOL
= source
.viewEOL
;
55 showMarkedLines
= source
.showMarkedLines
;
58 ViewStyle::~ViewStyle() {
61 void ViewStyle::Init() {
62 indicators
[0].style
= INDIC_SQUIGGLE
;
63 indicators
[0].fore
= Colour(0, 0x7f, 0);
64 indicators
[1].style
= INDIC_TT
;
65 indicators
[1].fore
= Colour(0, 0, 0xff);
66 indicators
[2].style
= INDIC_PLAIN
;
67 indicators
[2].fore
= Colour(0xff, 0, 0);
76 selforeground
.desired
= Colour(0xff, 0, 0);
78 selbackground
.desired
= Colour(0xc0, 0xc0, 0xc0);
79 selbar
.desired
= Platform::Chrome();
80 selbarlight
.desired
= Platform::ChromeHighlight();
81 styles
[STYLE_LINENUMBER
].fore
.desired
= Colour(0, 0, 0);
82 styles
[STYLE_LINENUMBER
].back
.desired
= Platform::Chrome();
83 //caretcolour.desired = Colour(0xff, 0, 0);
84 caretcolour
.desired
= Colour(0, 0, 0);
85 edgecolour
.desired
= Colour(0xc0, 0xc0, 0xc0);
94 ms
[1].mask
= ~SC_MASK_FOLDERS
;
96 ms
[2].width
= 14; // Nice width for arrows
97 ms
[2].mask
= SC_MASK_FOLDERS
;
98 ms
[2].width
= 0; // Nice width for arrows
100 fixedColumnWidth
= leftMarginWidth
;
101 symbolMargin
= false;
102 maskInLine
= 0xffffffff;
103 for (int margin
=0; margin
< margins
; margin
++) {
104 fixedColumnWidth
+= ms
[margin
].width
;
105 symbolMargin
= symbolMargin
|| ms
[margin
].symbol
;
106 if (ms
[margin
].width
> 0)
107 maskInLine
&= ~ms
[margin
].mask
;
110 viewWhitespace
= false;
112 showMarkedLines
= true;
115 void ViewStyle::RefreshColourPalette(Palette
&pal
, bool want
) {
117 for (i
=0;i
<(sizeof(styles
)/sizeof(styles
[0]));i
++) {
118 pal
.WantFind(styles
[i
].fore
, want
);
119 pal
.WantFind(styles
[i
].back
, want
);
121 for (i
=0;i
<(sizeof(indicators
)/sizeof(indicators
[0]));i
++) {
122 pal
.WantFind(indicators
[i
].fore
, want
);
124 for (i
=0;i
<(sizeof(markers
)/sizeof(markers
[0]));i
++) {
125 pal
.WantFind(markers
[i
].fore
, want
);
126 pal
.WantFind(markers
[i
].back
, want
);
128 pal
.WantFind(selforeground
, want
);
129 pal
.WantFind(selbackground
, want
);
130 pal
.WantFind(selbar
, want
);
131 pal
.WantFind(selbarlight
, want
);
132 pal
.WantFind(caretcolour
, want
);
133 pal
.WantFind(edgecolour
, want
);
136 void ViewStyle::Refresh(Surface
&surface
) {
137 selbar
.desired
= Platform::Chrome();
138 selbarlight
.desired
= Platform::ChromeHighlight();
141 for (unsigned int i
=0;i
<(sizeof(styles
)/sizeof(styles
[0]));i
++) {
142 styles
[i
].Realise(surface
, zoomLevel
);
143 if (maxAscent
< styles
[i
].ascent
)
144 maxAscent
= styles
[i
].ascent
;
145 if (maxDescent
< styles
[i
].descent
)
146 maxDescent
= styles
[i
].descent
;
149 lineHeight
= maxAscent
+ maxDescent
;
150 aveCharWidth
= styles
[STYLE_DEFAULT
].aveCharWidth
;
151 spaceWidth
= styles
[STYLE_DEFAULT
].spaceWidth
;
153 fixedColumnWidth
= leftMarginWidth
;
154 symbolMargin
= false;
155 maskInLine
= 0xffffffff;
156 for (int margin
=0; margin
< margins
; margin
++) {
157 fixedColumnWidth
+= ms
[margin
].width
;
158 symbolMargin
= symbolMargin
|| ms
[margin
].symbol
;
159 if (ms
[margin
].width
> 0)
160 maskInLine
&= ~ms
[margin
].mask
;
164 void ViewStyle::ResetDefaultStyle() {
165 styles
[STYLE_DEFAULT
].Clear();
168 void ViewStyle::ClearStyles() {
169 // Reset all styles to be like the default style
170 for (int i
=0; i
<=STYLE_MAX
; i
++) {
171 if (i
!= STYLE_DEFAULT
) {
173 styles
[STYLE_DEFAULT
].fore
.desired
,
174 styles
[STYLE_DEFAULT
].back
.desired
,
175 styles
[STYLE_DEFAULT
].size
,
176 styles
[STYLE_DEFAULT
].fontName
,
177 styles
[STYLE_DEFAULT
].bold
,
178 styles
[STYLE_DEFAULT
].italic
);
181 styles
[STYLE_LINENUMBER
].back
.desired
= Platform::Chrome();