1 /* |
|
2 * Copyright (c) 2003 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 "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: LandmarksUi Content File - |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 /* |
|
24 Change History |
|
25 22-05-2007 To resolve tool IDO warnings Komala Nagaraju |
|
26 */ |
|
27 |
|
28 // INCLUDE FILES |
|
29 #include "UTAppLmkEditorContainer.h" |
|
30 |
|
31 #include <eikrted.h> |
|
32 #include <barsread.h> |
|
33 #include <txtrich.h> |
|
34 #include <aknutils.h> |
|
35 #include <UTAppLmkEditor.rsg> |
|
36 #include <fontids.hrh> |
|
37 #include <gulfont.h> |
|
38 #include <aknnotewrappers.h> |
|
39 |
|
40 |
|
41 // ================= MEMBER FUNCTIONS ======================= |
|
42 |
|
43 // --------------------------------------------------------- |
|
44 // CUTAppLmkEditorContainer::ConstructL(const TRect& aRect) |
|
45 // EPOC two phased constructor |
|
46 // --------------------------------------------------------- |
|
47 // |
|
48 void CUTAppLmkEditorContainer::ConstructL(const TRect& aRect) |
|
49 { |
|
50 CreateWindowL(); |
|
51 Window().SetShadowDisabled(EFalse); |
|
52 |
|
53 SetBlank(); |
|
54 |
|
55 // construct main text display window |
|
56 TFontSpec fontspec = AknLayoutUtils::FontFromId(EAknLogicalFontSecondaryFont)->FontSpecInTwips(); |
|
57 |
|
58 TCharFormat defaultCharFormat( fontspec.iTypeface.iName, fontspec.iHeight ); |
|
59 TCharFormatMask defaultCharFormatMask; |
|
60 |
|
61 defaultCharFormatMask.SetAttrib(EAttFontTypeface); |
|
62 defaultCharFormatMask.SetAttrib(EAttFontHeight); |
|
63 |
|
64 iParaFormat = CParaFormatLayer::NewL(); |
|
65 iCharFormat = CCharFormatLayer::NewL(defaultCharFormat,defaultCharFormatMask); |
|
66 |
|
67 iRichText = CRichText::NewL(iParaFormat, iCharFormat); |
|
68 |
|
69 iOutputWindow = new (ELeave) CEikRichTextEditor(TGulBorder(TGulBorder::ENone)); |
|
70 iOutputWindow->ConstructL(this,0,0,EEikEdwinOwnsWindow|EEikEdwinInclusiveSizeFixed| |
|
71 EEikEdwinKeepDocument|EEikEdwinUserSuppliedText| |
|
72 EEikEdwinLineCursor|EEikEdwinAlwaysShowSelection); |
|
73 |
|
74 SetRect(aRect); |
|
75 ActivateL(); |
|
76 } |
|
77 |
|
78 // Destructor |
|
79 CUTAppLmkEditorContainer::~CUTAppLmkEditorContainer() |
|
80 { |
|
81 delete iParaFormat; |
|
82 iParaFormat = NULL; |
|
83 |
|
84 delete iCharFormat; |
|
85 iCharFormat = NULL; |
|
86 |
|
87 delete iOutputWindow; |
|
88 iOutputWindow = NULL; |
|
89 |
|
90 delete iRichText; |
|
91 iRichText = NULL; |
|
92 } |
|
93 |
|
94 // --------------------------------------------------------- |
|
95 // CUTAppLmkEditorContainer::SizeChanged() |
|
96 // Called by framework when the view size is changed |
|
97 // --------------------------------------------------------- |
|
98 // |
|
99 void CUTAppLmkEditorContainer::SizeChanged() |
|
100 { |
|
101 TRAP_IGNORE(SizeChangedL()); |
|
102 } |
|
103 |
|
104 // --------------------------------------------------------- |
|
105 // CUTAppLmkEditorContainer::SizeChangedL() |
|
106 // Methods that can leave and are needed by SizeChanged |
|
107 // are collected into this method. |
|
108 // --------------------------------------------------------- |
|
109 // |
|
110 void CUTAppLmkEditorContainer::SizeChangedL() |
|
111 { |
|
112 TSize outputRect; |
|
113 AknLayoutUtils::LayoutMetricsSize(AknLayoutUtils::EMainPane, outputRect); |
|
114 |
|
115 iOutputWindow->SetAknEditorFlags(EAknEditorFlagEnableScrollBars); |
|
116 iOutputWindow->CreateScrollBarFrameL(); |
|
117 iOutputWindow->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto); |
|
118 |
|
119 iOutputWindow->SetDocumentContentL(*iRichText,CEikEdwin::EUseText); |
|
120 iOutputWindow->SetRect(outputRect); |
|
121 iOutputWindow->ActivateL(); |
|
122 iOutputWindow->SetFocus(ETrue); |
|
123 } |
|
124 |
|
125 // --------------------------------------------------------- |
|
126 // CUTAppLmkEditorContainer::CountComponentControls() const |
|
127 // --------------------------------------------------------- |
|
128 // |
|
129 TInt CUTAppLmkEditorContainer::CountComponentControls() const |
|
130 { |
|
131 return 0; // return nbr of controls inside this container |
|
132 } |
|
133 |
|
134 // --------------------------------------------------------- |
|
135 // CUTAppLmkEditorContainer::ComponentControl(TInt aIndex) const |
|
136 // --------------------------------------------------------- |
|
137 // |
|
138 CCoeControl* CUTAppLmkEditorContainer::ComponentControl(TInt /*aIndex*/) const |
|
139 { |
|
140 return NULL; |
|
141 } |
|
142 |
|
143 // --------------------------------------------------------- |
|
144 // CUTAppLmkEditorContainer::Draw(const TRect& aRect) const |
|
145 // --------------------------------------------------------- |
|
146 // |
|
147 void CUTAppLmkEditorContainer::Draw(const TRect& aRect) const |
|
148 { |
|
149 CWindowGc& gc = SystemGc(); |
|
150 gc.Clear(aRect); } |
|
151 |
|
152 // --------------------------------------------------------- |
|
153 // CUTAppLmkEditorContainer::HandleControlEventL( |
|
154 // CCoeControl* aControl,TCoeEvent aEventType) |
|
155 // --------------------------------------------------------- |
|
156 // |
|
157 void CUTAppLmkEditorContainer::HandleControlEventL( |
|
158 CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/) |
|
159 { |
|
160 } |
|
161 |
|
162 |
|
163 // --------------------------------------------------------- |
|
164 // CUTAppLmkEditorContainer::SetFontStyle(TUint aFontStyle) |
|
165 // Set font style for output window. |
|
166 // --------------------------------------------------------- |
|
167 // |
|
168 void CUTAppLmkEditorContainer::SetFontStyle(TUint aFontStyle) |
|
169 { |
|
170 // Set current main window style to match that requested |
|
171 UpdateFontAttribute(aFontStyle, CEikGlobalTextEditor::EBold); |
|
172 UpdateFontAttribute(aFontStyle, CEikGlobalTextEditor::EItalic); |
|
173 UpdateFontAttribute(aFontStyle, CEikGlobalTextEditor::EUnderline); |
|
174 } |
|
175 |
|
176 |
|
177 // --------------------------------------------------------- |
|
178 // CUTAppLmkEditorContainer::UpdateFontAttribute(TUint aFontStyle, |
|
179 // TInt aAttribute) |
|
180 // Do the real work of setting the font style. |
|
181 // --------------------------------------------------------- |
|
182 // |
|
183 void CUTAppLmkEditorContainer::UpdateFontAttribute(TUint aFontStyle, |
|
184 TInt aAttribute) |
|
185 { |
|
186 // Ensure an individual attribute is on or off as requested |
|
187 if ((aFontStyle & aAttribute) != (iFontStyle & aAttribute)) |
|
188 { |
|
189 TRAP_IGNORE(iOutputWindow->BoldItalicUnderlineEventL(aAttribute)); |
|
190 iFontStyle ^= aAttribute; |
|
191 } |
|
192 } |
|
193 |
|
194 |
|
195 // --------------------------------------------------------- |
|
196 // CUTAppLmkEditorContainer::PrintNotify(const TDesC& aDes, TUint aFontStyle) |
|
197 // Print text into output window. |
|
198 // --------------------------------------------------------- |
|
199 // |
|
200 void CUTAppLmkEditorContainer::PrintNotify(const TDesC& aDes, TUint aFontStyle) |
|
201 { |
|
202 SetFontStyle(aFontStyle); |
|
203 TChar ch; |
|
204 |
|
205 for (TInt i = 0; i < aDes.Length(); i++) |
|
206 { |
|
207 RDebug::Print(_L("aDes[i]=%d"), aDes[i]); |
|
208 |
|
209 // Add linebreak if character is '\n', otherwise |
|
210 // add character as it is. |
|
211 ch = aDes[i] != 10 ? (TChar)aDes[i] : (TChar)CEditableText::ELineBreak; |
|
212 TRAP_IGNORE(iRichText->InsertL(iOutputWindow->TextLength(), ch)); |
|
213 } |
|
214 |
|
215 TRAP_IGNORE(iOutputWindow->NotifyNewDocumentL()); |
|
216 |
|
217 TRAP_IGNORE(iOutputWindow->SetCursorPosL(iOutputWindow->TextLength(), EFalse)); |
|
218 } |
|
219 |
|
220 |
|
221 // --------------------------------------------------------- |
|
222 // CUTAppLmkEditorContainer::PrintNotify(const TDesC8& aDes, TUint aFontStyle) |
|
223 // Print text into output window. |
|
224 // --------------------------------------------------------- |
|
225 // |
|
226 void CUTAppLmkEditorContainer::PrintNotify(const TDesC8& aDes, TUint aFontStyle) |
|
227 { |
|
228 SetFontStyle(aFontStyle); |
|
229 TChar ch; |
|
230 |
|
231 for (TInt i = 0; i < aDes.Length(); i++) |
|
232 { |
|
233 RDebug::Print(_L("aDes[i]=%d"), aDes[i]); |
|
234 |
|
235 // Add linebreak if character is '\n', otherwise |
|
236 // add character as it is. |
|
237 ch = aDes[i] != 10 ? (TChar)aDes[i] : (TChar)CEditableText::ELineBreak; |
|
238 TRAP_IGNORE(iRichText->InsertL(iOutputWindow->TextLength(), ch)); |
|
239 } |
|
240 |
|
241 TRAP_IGNORE(iOutputWindow->NotifyNewDocumentL()); |
|
242 |
|
243 TRAP_IGNORE(iOutputWindow->SetCursorPosL(iOutputWindow->TextLength(), EFalse)); |
|
244 } |
|
245 |
|
246 |
|
247 // --------------------------------------------------------- |
|
248 // CUTAppLmkEditorContainer::PrintNotify(TInt aIn) |
|
249 // Print integer into output window. |
|
250 // --------------------------------------------------------- |
|
251 // |
|
252 void CUTAppLmkEditorContainer::PrintNotify(TInt aInt) |
|
253 { |
|
254 // Display number in ascii decimal |
|
255 TBuf<50> buf; |
|
256 buf.Num(aInt); |
|
257 PrintNotify(buf); |
|
258 } |
|
259 |
|
260 // --------------------------------------------------------- |
|
261 // CUTAppLmkEditorContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, |
|
262 // TEventCode aType) |
|
263 // Handle key event. Only up and down key arrow events are |
|
264 // consumed in order to enable scrolling in output window. |
|
265 // --------------------------------------------------------- |
|
266 // |
|
267 TKeyResponse CUTAppLmkEditorContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) |
|
268 { |
|
269 if(aType != EEventKey) |
|
270 return EKeyWasNotConsumed; |
|
271 |
|
272 if(aKeyEvent.iCode == EKeyUpArrow) |
|
273 { |
|
274 iOutputWindow->MoveCursorL(TCursorPosition::EFLineUp,EFalse); |
|
275 return EKeyWasConsumed; |
|
276 } |
|
277 |
|
278 if(aKeyEvent.iCode == EKeyDownArrow) |
|
279 { |
|
280 iOutputWindow->MoveCursorL(TCursorPosition::EFLineDown,EFalse); |
|
281 return EKeyWasConsumed; |
|
282 } |
|
283 |
|
284 return EKeyWasNotConsumed; |
|
285 } |
|
286 |
|
287 |
|
288 // --------------------------------------------------------- |
|
289 // CUTAppLmkEditorContainer::ClearOutputWindow() |
|
290 // Clear the output window. |
|
291 // --------------------------------------------------------- |
|
292 // |
|
293 void CUTAppLmkEditorContainer::ClearOutputWindow() |
|
294 { |
|
295 iRichText->Reset(); |
|
296 TRAP_IGNORE(iOutputWindow->NotifyNewDocumentL()); |
|
297 } |
|
298 |
|
299 // End of File |
|