2
|
1 |
/*
|
|
2 |
* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
/**
|
|
20 |
* Create a contribution that sets up a CharFormat and CharFormatMask for use
|
|
21 |
* by CEikGlobalText and subcomponents (CEikRichText).
|
|
22 |
* @param contribs the contributions to append to
|
|
23 |
* @param instance instance of the component assumed to have the correct properties.
|
|
24 |
* @param location location to write to
|
|
25 |
* @param phase phase to write to
|
|
26 |
* @return true iff generated the contribution (if some property not default).
|
|
27 |
*/
|
|
28 |
function createCharFormatStructs(contribs, instance, location, phase) {
|
|
29 |
var generated = false;
|
|
30 |
var properties = instance.properties;
|
|
31 |
var contribText = "\tTCharFormatMask charFormatMask;\n\tTCharFormat charFormat;\n";
|
|
32 |
|
|
33 |
if (properties.charFormat.textColor != "") {
|
|
34 |
contribText += "\tcharFormatMask.SetAttrib( EAttColor );\n";
|
|
35 |
contribText += "\tcharFormat.iFontPresentation.iTextColor = TLogicalRgb( ";
|
|
36 |
contribText += this.getRgb(properties.charFormat.textColor);
|
|
37 |
contribText += " );\n";
|
|
38 |
generated = true;
|
|
39 |
}
|
|
40 |
|
|
41 |
if (properties.charFormat.highlightColor != "") {
|
|
42 |
contribText += "\tcharFormatMask.SetAttrib( EAttFontHighlightColor );\n";
|
|
43 |
contribText += "\tcharFormat.iFontPresentation.iHighlightColor = TLogicalRgb( ";
|
|
44 |
contribText += this.getRgb(properties.charFormat.highlightColor);
|
|
45 |
contribText += " );\n";
|
|
46 |
generated = true;
|
|
47 |
}
|
|
48 |
|
|
49 |
if (properties.charFormat.highlightStyle != "EFontHighlightNone") {
|
|
50 |
contribText += "\tcharFormatMask.SetAttrib( EAttFontHighlightStyle );\n";
|
|
51 |
contribText += "\tcharFormat.iFontPresentation.iHighlightStyle = ";
|
|
52 |
contribText += "\tTFontPresentation::";
|
|
53 |
contribText += properties.charFormat.highlightStyle;
|
|
54 |
contribText += ";\n";
|
|
55 |
generated = true;
|
|
56 |
}
|
|
57 |
|
|
58 |
if (properties.charFormat.strikethrough) {
|
|
59 |
contribText += "\tcharFormatMask.SetAttrib( EAttFontStrikethrough );\n";
|
|
60 |
contribText += "\tcharFormat.iFontPresentation.iStrikethrough = EStrikethroughOn;\n";
|
|
61 |
generated = true;
|
|
62 |
}
|
|
63 |
|
|
64 |
if (properties.charFormat.underline) {
|
|
65 |
contribText += "\tcharFormatMask.SetAttrib( EAttFontUnderline );\n";
|
|
66 |
contribText += "\tcharFormat.iFontPresentation.iUnderline = EUnderlineOn;\n";
|
|
67 |
generated = true;
|
|
68 |
}
|
|
69 |
|
|
70 |
if (properties.charFormat.italics) {
|
|
71 |
contribText += "\tcharFormatMask.SetAttrib( EAttFontPosture );\n";
|
|
72 |
contribText += "\tcharFormat.iFontSpec.iFontStyle.SetPosture( EPostureItalic );\n";
|
|
73 |
generated = true;
|
|
74 |
}
|
|
75 |
|
|
76 |
if (properties.charFormat.bold) {
|
|
77 |
contribText += "\tcharFormatMask.SetAttrib( EAttFontStrokeWeight );\n";
|
|
78 |
contribText += "\tcharFormat.iFontSpec.iFontStyle.SetStrokeWeight( EStrokeWeightBold );\n";
|
|
79 |
generated = true;
|
|
80 |
}
|
|
81 |
|
|
82 |
if (properties.charFormat.hiddenText) {
|
|
83 |
contribText += "\tcharFormatMask.SetAttrib( EAttFontHiddenText );\n";
|
|
84 |
contribText += "\tcharFormat.iFontPresentation.iHiddenText = ETrue;\n";
|
|
85 |
generated = true;
|
|
86 |
}
|
|
87 |
|
|
88 |
if (properties.charFormat.pictureAlignment != "EAlignBaseLine") {
|
|
89 |
contribText += "\tcharFormatMask.SetAttrib( EAttFontPictureAlignment );\n";
|
|
90 |
contribText += "\tcharFormat.iFontPresentation.iPictureAlignment = ";
|
|
91 |
contribText += "\tTFontPresentation::";
|
|
92 |
contribText += properties.charFormat.pictureAlignment;
|
|
93 |
contribText += ";\n";
|
|
94 |
generated = true;
|
|
95 |
}
|
|
96 |
|
|
97 |
if (generated) {
|
|
98 |
if (instance.component.id == "com.nokia.carbide.uiq.CEikRichText") {
|
|
99 |
contribText += "\tCRichText* richtxt = " + instance.memberName + "->RichText();\n";
|
|
100 |
contribText += "\trichtxt->ApplyCharFormatL( charFormat, charFormatMask, 0, richtxt->DocumentLength() );\n";
|
|
101 |
} else {
|
|
102 |
contribText += "\t" + instance.memberName + "->ApplyCharFormatL( charFormat, charFormatMask );\n";
|
|
103 |
}
|
|
104 |
}
|
|
105 |
|
|
106 |
if (generated) {
|
|
107 |
var contrib = null;
|
|
108 |
if (location != null) {
|
|
109 |
contrib = Engine.createContributionForLocation(location);
|
|
110 |
} else {
|
|
111 |
contrib = Engine.createContributionForPhase(phase);
|
|
112 |
}
|
|
113 |
var opening = "\nif ( " + instance.memberName + " != NULL )\n";
|
|
114 |
opening += "\t{\n";
|
|
115 |
var closing = "\t}\n"
|
|
116 |
contribText = opening + contribText + closing;
|
|
117 |
contrib.setText(contribText);
|
|
118 |
contribs.add(contrib);
|
|
119 |
}
|
|
120 |
|
|
121 |
return generated;
|
|
122 |
}
|
|
123 |
|
|
124 |
/**
|
|
125 |
* Create a contribution that sets up a CharFormat and CharFormatMask for use
|
|
126 |
* by CEikGlobalText and subcomponents (CEikRichText).
|
|
127 |
* @param contribs the contributions to append to
|
|
128 |
* @param instance instance of the component assumed to have the correct properties.
|
|
129 |
* @param phase phase to write to
|
|
130 |
* @return true if generated the contribution (if some property not default).
|
|
131 |
*/
|
|
132 |
function createCharFormatStructsForPhase(contribs, instance, phase) {
|
|
133 |
var generated = createCharFormatStructs(contribs, instance, null, phase);
|
|
134 |
return generated;
|
|
135 |
}
|
|
136 |
|
|
137 |
|
|
138 |
function getRgb(colorProperty) {
|
|
139 |
if (colorProperty.indexOf(',') > 0)
|
|
140 |
return "TRgb( " + colorProperty + " )";
|
|
141 |
else
|
|
142 |
return "iEikonEnv->Color( ( TLogicalColor ) " + colorProperty + " )";
|
|
143 |
}
|