]> git.saurik.com Git - wxWidgets.git/blame - src/stc/scintilla/src/ViewStyle.cxx
Added RTLD_GLOBAL to dlopen() flags which is needed if libraries depend
[wxWidgets.git] / src / stc / scintilla / src / ViewStyle.cxx
CommitLineData
9ce192d4
RD
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.
5
6#include <string.h>
7
8#include "Platform.h"
9
10#include "Scintilla.h"
11#include "Indicator.h"
12#include "LineMarker.h"
13#include "Style.h"
14#include "ViewStyle.h"
15
16MarginStyle::MarginStyle() :
17 symbol(false), width(16), mask(0xffffffff), sensitive(false) {
18}
19
20ViewStyle::ViewStyle() {
21 Init();
22}
23
24ViewStyle::ViewStyle(const ViewStyle &source) {
25 Init();
88b780d9 26 for (int sty=0;sty<=STYLE_MAX;sty++) {
9ce192d4
RD
27 styles[sty] = source.styles[sty];
28 }
29 for (int mrk=0;mrk<=MARKER_MAX;mrk++) {
30 markers[mrk] = source.markers[mrk];
31 }
32 for (int ind=0;ind<=INDIC_MAX;ind++) {
33 indicators[ind] = source.indicators[ind];
34 }
35
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++) {
47 ms[i] = source.ms[i];
48 }
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;
56}
57
58ViewStyle::~ViewStyle() {
59}
60
61void 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);
68
69 lineHeight = 1;
70 maxAscent = 1;
71 maxDescent = 1;
72 aveCharWidth = 8;
73 spaceWidth = 8;
74
75 selforeset = false;
76 selforeground.desired = Colour(0xff, 0, 0);
77 selbackset = true;
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);
86
87 leftMarginWidth = 1;
88 rightMarginWidth = 1;
89 ms[0].symbol = false;
90 ms[0].width = 0;
91 ms[0].mask = 0;
92 ms[1].symbol = true;
93 ms[1].width = 16;
94 ms[1].mask = ~SC_MASK_FOLDERS;
95 ms[2].symbol = true;
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
99 ms[2].mask = 0;
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;
108 }
109 zoomLevel = 0;
110 viewWhitespace = false;
111 viewEOL = false;
112 showMarkedLines = true;
113}
114
115void ViewStyle::RefreshColourPalette(Palette &pal, bool want) {
116 unsigned int i;
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);
120 }
121 for (i=0;i<(sizeof(indicators)/sizeof(indicators[0]));i++) {
122 pal.WantFind(indicators[i].fore, want);
123 }
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);
127 }
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);
134}
135
136void ViewStyle::Refresh(Surface &surface) {
137 selbar.desired = Platform::Chrome();
138 selbarlight.desired = Platform::ChromeHighlight();
88b780d9
RD
139 maxAscent = 1;
140 maxDescent = 1;
9ce192d4 141 for (unsigned int i=0;i<(sizeof(styles)/sizeof(styles[0]));i++) {
88b780d9
RD
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;
9ce192d4
RD
147 }
148
149 lineHeight = maxAscent + maxDescent;
150 aveCharWidth = styles[STYLE_DEFAULT].aveCharWidth;
151 spaceWidth = styles[STYLE_DEFAULT].spaceWidth;
152
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;
161 }
162}
163
164void ViewStyle::ResetDefaultStyle() {
88b780d9 165 styles[STYLE_DEFAULT].Clear();
9ce192d4
RD
166}
167
168void ViewStyle::ClearStyles() {
169 // Reset all styles to be like the default style
88b780d9 170 for (int i=0; i<=STYLE_MAX; i++) {
9ce192d4
RD
171 if (i != STYLE_DEFAULT) {
172 styles[i].Clear(
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,
88b780d9 178 styles[STYLE_DEFAULT].italic);
9ce192d4
RD
179 }
180 }
181 styles[STYLE_LINENUMBER].back.desired = Platform::Chrome();
182}
183