~ubuntu-branches/ubuntu/raring/codeblocks/raring-proposed

« back to all changes in this revision

Viewing changes to src/sdk/wxscintilla/src/scintilla/src/ViewStyle.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Cosme Domínguez Díaz
  • Date: 2010-08-09 04:38:38 UTC
  • mfrom: (1.1.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20100809043838-a59ygguym4eg0jgw
Tags: 10.05-0ubuntu1
* New upstream release. Closes (LP: #322350)
 - Switch to dpkg-source 3.0 (quilt) format
 - Remove unneeded README.source
 - Add debian/get-source-orig script that removes all
   Windows prebuilt binaries
* Bump Standards-Version to 3.9.1
 - Stop shipping *.la files
* debian/control
 - Add cdbs package as Build-Depend
 - Add libbz2-dev and zlib1g-dev packages as
   Build-Depends (needed by libhelp_plugin.so)
 - Remove dpatch package of Build-Depends
 - Add codeblocks-contrib-debug package
 - Split architecture-independent files of codeblocks
   package in codeblocks-common package
* debian/rules
 - Switch to CDBS rules system
 - Add parallel build support
 - Add a call to debian/get-source-orig script
 - Use lzma compression (saves 23,5 MB of free space)
* debian/patches
 - Refresh 01_codeblocks_plugin_path
 - Add 02_no_Makefiles_in_debian_dir to remove any link
   in codeblocks build system to deleted Makefiles of debian directory
 - Drop 02_ftbfs_gcc44 and 03_ftbfs_glib221 (merged in upstream)
* debian/watch
 - Update to use the new host (berlios.de)

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
#include "Platform.h"
11
11
 
12
12
#include "Scintilla.h"
 
13
#include "SplitVector.h"
 
14
#include "Partitioning.h"
 
15
#include "RunStyles.h"
13
16
#include "Indicator.h"
14
17
#include "XPM.h"
15
18
#include "LineMarker.h"
16
19
#include "Style.h"
17
20
#include "ViewStyle.h"
18
21
 
 
22
#ifdef SCI_NAMESPACE
 
23
using namespace Scintilla;
 
24
#endif
 
25
 
19
26
MarginStyle::MarginStyle() :
20
 
        symbol(false), width(16), mask(0xffffffff), sensitive(false) {
 
27
        style(SC_MARGIN_SYMBOL), width(0), mask(0), sensitive(false) {
21
28
}
22
29
 
23
30
// A list of the fontnames - avoids wasting space in each style
24
31
FontNames::FontNames() {
 
32
        size = 8;
 
33
        names = new char *[size];
25
34
        max = 0;
26
35
}
27
36
 
28
37
FontNames::~FontNames() {
29
38
        Clear();
 
39
        delete []names;
 
40
        names = 0;
30
41
}
31
42
 
32
43
void FontNames::Clear() {
44
55
                        return names[i];
45
56
                }
46
57
        }
 
58
        if (max >= size) {
 
59
                // Grow array
 
60
                int sizeNew = size * 2;
 
61
                char **namesNew = new char *[sizeNew];
 
62
                for (int j=0;j<max;j++) {
 
63
                        namesNew[j] = names[j];
 
64
                }
 
65
                delete []names;
 
66
                names = namesNew;
 
67
                size = sizeNew;
 
68
        }
47
69
        names[max] = new char[strlen(name) + 1];
48
70
        strcpy(names[max], name);
49
71
        max++;
55
77
}
56
78
 
57
79
ViewStyle::ViewStyle(const ViewStyle &source) {
58
 
        Init();
59
 
        for (unsigned int sty=0;sty<(sizeof(styles)/sizeof(styles[0]));sty++) {
 
80
        Init(source.stylesSize);
 
81
        for (unsigned int sty=0;sty<source.stylesSize;sty++) {
60
82
                styles[sty] = source.styles[sty];
61
83
                // Can't just copy fontname as its lifetime is relative to its owning ViewStyle
62
84
                styles[sty].fontName = fontNames.Save(source.styles[sty].fontName);
70
92
 
71
93
        selforeset = source.selforeset;
72
94
        selforeground.desired = source.selforeground.desired;
 
95
        selAdditionalForeground.desired = source.selAdditionalForeground.desired;
73
96
        selbackset = source.selbackset;
74
97
        selbackground.desired = source.selbackground.desired;
 
98
        selAdditionalBackground.desired = source.selAdditionalBackground.desired;
75
99
        selbackground2.desired = source.selbackground2.desired;
 
100
        selAlpha = source.selAlpha;
 
101
        selAdditionalAlpha = source.selAdditionalAlpha;
 
102
        selEOLFilled = source.selEOLFilled;
76
103
 
77
104
        foldmarginColourSet = source.foldmarginColourSet;
78
105
        foldmarginColour.desired = source.foldmarginColour.desired;
93
120
        selbar.desired = source.selbar.desired;
94
121
        selbarlight.desired = source.selbarlight.desired;
95
122
        caretcolour.desired = source.caretcolour.desired;
 
123
        additionalCaretColour.desired = source.additionalCaretColour.desired;
96
124
        showCaretLineBackground = source.showCaretLineBackground;
97
125
        caretLineBackground.desired = source.caretLineBackground.desired;
 
126
        caretLineAlpha = source.caretLineAlpha;
98
127
        edgecolour.desired = source.edgecolour.desired;
99
128
        edgeState = source.edgeState;
 
129
        caretStyle = source.caretStyle;
100
130
        caretWidth = source.caretWidth;
101
131
        someStylesProtected = false;
102
132
        leftMarginWidth = source.leftMarginWidth;
109
139
        fixedColumnWidth = source.fixedColumnWidth;
110
140
        zoomLevel = source.zoomLevel;
111
141
        viewWhitespace = source.viewWhitespace;
 
142
        whitespaceSize = source.whitespaceSize;
112
143
        viewIndentationGuides = source.viewIndentationGuides;
113
144
        viewEOL = source.viewEOL;
114
145
        showMarkedLines = source.showMarkedLines;
115
146
        extraFontFlag = source.extraFontFlag;
 
147
        extraAscent = source.extraAscent;
 
148
        extraDescent = source.extraDescent;
 
149
        marginStyleOffset = source.marginStyleOffset;
 
150
        annotationVisible = source.annotationVisible;
 
151
        annotationStyleOffset = source.annotationStyleOffset;
116
152
}
117
153
 
118
154
ViewStyle::~ViewStyle() {
 
155
        delete []styles;
 
156
        styles = NULL;
119
157
}
120
158
 
121
 
void ViewStyle::Init() {
 
159
void ViewStyle::Init(size_t stylesSize_) {
 
160
        stylesSize = 0;
 
161
        styles = NULL;
 
162
        AllocStyles(stylesSize_);
122
163
        fontNames.Clear();
123
164
        ResetDefaultStyle();
124
165
 
125
166
        indicators[0].style = INDIC_SQUIGGLE;
 
167
        indicators[0].under = false;
126
168
        indicators[0].fore = ColourDesired(0, 0x7f, 0);
127
169
        indicators[1].style = INDIC_TT;
 
170
        indicators[1].under = false;
128
171
        indicators[1].fore = ColourDesired(0, 0, 0xff);
129
172
        indicators[2].style = INDIC_PLAIN;
 
173
        indicators[2].under = false;
130
174
        indicators[2].fore = ColourDesired(0xff, 0, 0);
131
175
 
132
176
        lineHeight = 1;
137
181
 
138
182
        selforeset = false;
139
183
        selforeground.desired = ColourDesired(0xff, 0, 0);
 
184
        selAdditionalForeground.desired = ColourDesired(0xff, 0, 0);
140
185
        selbackset = true;
141
186
        selbackground.desired = ColourDesired(0xc0, 0xc0, 0xc0);
 
187
        selAdditionalBackground.desired = ColourDesired(0xd7, 0xd7, 0xd7);
142
188
        selbackground2.desired = ColourDesired(0xb0, 0xb0, 0xb0);
 
189
        selAlpha = SC_ALPHA_NOALPHA;
 
190
        selAdditionalAlpha = SC_ALPHA_NOALPHA;
 
191
        selEOLFilled = false;
143
192
 
144
193
        foldmarginColourSet = false;
145
194
        foldmarginColour.desired = ColourDesired(0xff, 0, 0);
155
204
        styles[STYLE_LINENUMBER].fore.desired = ColourDesired(0, 0, 0);
156
205
        styles[STYLE_LINENUMBER].back.desired = Platform::Chrome();
157
206
        caretcolour.desired = ColourDesired(0, 0, 0);
 
207
        additionalCaretColour.desired = ColourDesired(0x7f, 0x7f, 0x7f);
158
208
        showCaretLineBackground = false;
159
209
        caretLineBackground.desired = ColourDesired(0xff, 0xff, 0);
 
210
        caretLineAlpha = SC_ALPHA_NOALPHA;
160
211
        edgecolour.desired = ColourDesired(0xc0, 0xc0, 0xc0);
161
212
        edgeState = EDGE_NONE;
 
213
        caretStyle = CARETSTYLE_LINE;
162
214
        caretWidth = 1;
163
215
        someStylesProtected = false;
164
216
 
171
223
 
172
224
        leftMarginWidth = 1;
173
225
        rightMarginWidth = 1;
174
 
        ms[0].symbol = false;
 
226
        ms[0].style = SC_MARGIN_NUMBER;
175
227
        ms[0].width = 0;
176
228
        ms[0].mask = 0;
177
 
        ms[1].symbol = true;
 
229
        ms[1].style = SC_MARGIN_SYMBOL;
178
230
        ms[1].width = 16;
179
231
        ms[1].mask = ~SC_MASK_FOLDERS;
180
 
        ms[2].symbol = true;
 
232
        ms[2].style = SC_MARGIN_SYMBOL;
181
233
        ms[2].width = 0;
182
234
        ms[2].mask = 0;
183
235
        fixedColumnWidth = leftMarginWidth;
185
237
        maskInLine = 0xffffffff;
186
238
        for (int margin=0; margin < margins; margin++) {
187
239
                fixedColumnWidth += ms[margin].width;
188
 
                symbolMargin = symbolMargin || ms[margin].symbol;
 
240
                symbolMargin = symbolMargin || (ms[margin].style != SC_MARGIN_NUMBER);
189
241
                if (ms[margin].width > 0)
190
242
                        maskInLine &= ~ms[margin].mask;
191
243
        }
192
244
        zoomLevel = 0;
193
245
        viewWhitespace = wsInvisible;
194
 
        viewIndentationGuides = false;
 
246
        whitespaceSize = 1;
 
247
        viewIndentationGuides = ivNone;
195
248
        viewEOL = false;
196
249
        showMarkedLines = true;
197
 
        extraFontFlag = false;
 
250
        extraFontFlag = 0;
 
251
        extraAscent = 0;
 
252
        extraDescent = 0;
 
253
        marginStyleOffset = 0;
 
254
        annotationVisible = ANNOTATION_HIDDEN;
 
255
        annotationStyleOffset = 0;
198
256
}
199
257
 
200
258
void ViewStyle::RefreshColourPalette(Palette &pal, bool want) {
201
259
        unsigned int i;
202
 
        for (i=0;i<(sizeof(styles)/sizeof(styles[0]));i++) {
 
260
        for (i=0;i<stylesSize;i++) {
203
261
                pal.WantFind(styles[i].fore, want);
204
262
                pal.WantFind(styles[i].back, want);
205
263
        }
210
268
                markers[i].RefreshColourPalette(pal, want);
211
269
        }
212
270
        pal.WantFind(selforeground, want);
 
271
        pal.WantFind(selAdditionalForeground, want);
213
272
        pal.WantFind(selbackground, want);
 
273
        pal.WantFind(selAdditionalBackground, want);
214
274
        pal.WantFind(selbackground2, want);
215
275
 
216
276
        pal.WantFind(foldmarginColour, want);
221
281
        pal.WantFind(selbar, want);
222
282
        pal.WantFind(selbarlight, want);
223
283
        pal.WantFind(caretcolour, want);
 
284
        pal.WantFind(additionalCaretColour, want);
224
285
        pal.WantFind(caretLineBackground, want);
225
286
        pal.WantFind(edgecolour, want);
226
287
        pal.WantFind(hotspotForeground, want);
234
295
        maxAscent = styles[STYLE_DEFAULT].ascent;
235
296
        maxDescent = styles[STYLE_DEFAULT].descent;
236
297
        someStylesProtected = false;
237
 
        for (unsigned int i=0;i<(sizeof(styles)/sizeof(styles[0]));i++) {
 
298
        for (unsigned int i=0; i<stylesSize; i++) {
238
299
                if (i != STYLE_DEFAULT) {
239
300
                        styles[i].Realise(surface, zoomLevel, &styles[STYLE_DEFAULT], extraFontFlag);
240
301
                        if (maxAscent < styles[i].ascent)
246
307
                        someStylesProtected = true;
247
308
                }
248
309
        }
 
310
        maxAscent += extraAscent;
 
311
        maxDescent += extraDescent;
249
312
 
250
313
        lineHeight = maxAscent + maxDescent;
251
314
        aveCharWidth = styles[STYLE_DEFAULT].aveCharWidth;
256
319
        maskInLine = 0xffffffff;
257
320
        for (int margin=0; margin < margins; margin++) {
258
321
                fixedColumnWidth += ms[margin].width;
259
 
                symbolMargin = symbolMargin || ms[margin].symbol;
 
322
                symbolMargin = symbolMargin || (ms[margin].style != SC_MARGIN_NUMBER);
260
323
                if (ms[margin].width > 0)
261
324
                        maskInLine &= ~ms[margin].mask;
262
325
        }
263
326
}
264
327
 
 
328
void ViewStyle::AllocStyles(size_t sizeNew) {
 
329
        Style *stylesNew = new Style[sizeNew];
 
330
        size_t i=0;
 
331
        for (; i<stylesSize; i++) {
 
332
                stylesNew[i] = styles[i];
 
333
                stylesNew[i].fontName = styles[i].fontName;
 
334
        }
 
335
        if (stylesSize > STYLE_DEFAULT) {
 
336
                for (; i<sizeNew; i++) {
 
337
                        if (i != STYLE_DEFAULT) {
 
338
                                stylesNew[i].ClearTo(styles[STYLE_DEFAULT]);
 
339
                        }
 
340
                }
 
341
        }
 
342
        delete []styles;
 
343
        styles = stylesNew;
 
344
        stylesSize = sizeNew;
 
345
}
 
346
 
 
347
void ViewStyle::EnsureStyle(size_t index) {
 
348
        if (index >= stylesSize) {
 
349
                size_t sizeNew = stylesSize * 2;
 
350
                while (sizeNew <= index)
 
351
                        sizeNew *= 2;
 
352
                AllocStyles(sizeNew);
 
353
        }
 
354
}
 
355
 
265
356
void ViewStyle::ResetDefaultStyle() {
266
357
        styles[STYLE_DEFAULT].Clear(ColourDesired(0,0,0),
267
358
                ColourDesired(0xff,0xff,0xff),
268
 
                Platform::DefaultFontSize(), fontNames.Save(Platform::DefaultFont()),
 
359
                Platform::DefaultFontSize(), fontNames.Save(Platform::DefaultFont()),
269
360
                SC_CHARSET_DEFAULT,
270
361
                false, false, false, false, Style::caseMixed, true, true, false);
271
362
}
272
363
 
273
364
void ViewStyle::ClearStyles() {
274
365
        // Reset all styles to be like the default style
275
 
        for (unsigned int i=0;i<(sizeof(styles)/sizeof(styles[0]));i++) {
 
366
        for (unsigned int i=0; i<stylesSize; i++) {
276
367
                if (i != STYLE_DEFAULT) {
277
368
                        styles[i].ClearTo(styles[STYLE_DEFAULT]);
278
369
                }
279
370
        }
280
371
        styles[STYLE_LINENUMBER].back.desired = Platform::Chrome();
 
372
 
 
373
        // Set call tip fore/back to match the values previously set for call tips
 
374
        styles[STYLE_CALLTIP].back.desired = ColourDesired(0xff, 0xff, 0xff);
 
375
        styles[STYLE_CALLTIP].fore.desired = ColourDesired(0x80, 0x80, 0x80);
281
376
}
282
377
 
283
378
void ViewStyle::SetStyleFontName(int styleIndex, const char *name) {
285
380
}
286
381
 
287
382
bool ViewStyle::ProtectionActive() const {
288
 
    return someStylesProtected;
289
 
}
 
383
        return someStylesProtected;
 
384
}
 
385
 
 
386
bool ViewStyle::ValidStyle(size_t styleIndex) const {
 
387
        return styleIndex < stylesSize;
 
388
}
 
389