1 /* |
1 /* |
2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
14 * Description: Response dialog's custom control implementation |
14 * Description: Response dialog's custom control implementation |
15 * |
15 * |
16 */ |
16 */ |
17 #include "cmrresponsedialogview.h" |
17 #include "cmrresponsedialogview.h" |
18 // System includes |
18 // System includes |
19 #include <AknsDrawUtils.h> |
19 #include <aknsdrawutils.h> |
20 #include <AknsBasicBackgroundControlContext.h> |
20 #include <aknsbasicbackgroundcontrolcontext.h> |
21 #include <eikrted.h> |
21 #include <eikrted.h> |
22 #include <eiksbfrm.h> |
22 #include <akndef.h> |
23 #include <AknDef.h> |
|
24 #include <AknUtils.h> |
|
25 #include <gdi.h> |
|
26 |
|
27 // DEBUG |
23 // DEBUG |
28 #include "emailtrace.h" |
24 #include "emailtrace.h" |
29 |
|
30 // LOCAL DEFINITIONS |
|
31 namespace // codescanner::namespace |
|
32 { |
|
33 #define KDefaultTextColor TRgb( 0x000000 ); |
|
34 /// Get the text color from skin |
|
35 TRgb TextColor( TInt aSkinColorId ) |
|
36 { |
|
37 TRgb bgColor; |
|
38 TInt err; |
|
39 |
|
40 err = AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), |
|
41 bgColor, |
|
42 KAknsIIDQsnTextColors, |
|
43 aSkinColorId ); |
|
44 if( err != KErrNone ) |
|
45 { |
|
46 bgColor = KDefaultTextColor; |
|
47 } |
|
48 return bgColor; |
|
49 } |
|
50 } |
|
51 |
25 |
52 // --------------------------------------------------------------------------- |
26 // --------------------------------------------------------------------------- |
53 // CESMRResponseDialogView::NewL |
27 // CESMRResponseDialogView::NewL |
54 // --------------------------------------------------------------------------- |
28 // --------------------------------------------------------------------------- |
55 // |
29 // |
175 { |
149 { |
176 FUNC_LOG; |
150 FUNC_LOG; |
177 CCoeControl::SetContainerWindowL( aContainer ); |
151 CCoeControl::SetContainerWindowL( aContainer ); |
178 iEditor = new (ELeave )CEikRichTextEditor(); |
152 iEditor = new (ELeave )CEikRichTextEditor(); |
179 iEditor->ConstructL( this, 0, 0, CEikEdwin::ENoAutoSelection, 0, 0 ); |
153 iEditor->ConstructL( this, 0, 0, CEikEdwin::ENoAutoSelection, 0, 0 ); |
180 iEditor->SetContainerWindowL(*this); |
154 iEditor->SetFocus( ETrue ); |
181 iEditor->SetSize(Rect().Size()); |
155 iEditor->SetContainerWindowL( *this ); |
|
156 iEditor->SetSize( Rect().Size() ); |
182 iEditor->SetSkinBackgroundControlContextL( iBgContext ); |
157 iEditor->SetSkinBackgroundControlContextL( iBgContext ); |
183 iEditor->SetFocus( ETrue ); |
158 iEditor->EnableCcpuSupportL(ETrue); |
184 |
|
185 // Create vertical scrollbar for editor |
|
186 iScrollBarFrame = iEditor->CreateScrollBarFrameL(); |
|
187 iScrollBarFrame->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOn ); |
|
188 |
|
189 TRAP_IGNORE( SetFontColorL() ); |
|
190 } |
159 } |
191 |
160 |
192 // --------------------------------------------------------------------------- |
161 // --------------------------------------------------------------------------- |
193 // CESMRResponseDialogView::HandleResourceChange() |
162 // CESMRResponseDialogView::HandleResourceChange() |
194 // --------------------------------------------------------------------------- |
163 // --------------------------------------------------------------------------- |
198 FUNC_LOG; |
167 FUNC_LOG; |
199 CCoeControl::HandleResourceChange( aType ); |
168 CCoeControl::HandleResourceChange( aType ); |
200 |
169 |
201 if ( aType == KEikDynamicLayoutVariantSwitch ) |
170 if ( aType == KEikDynamicLayoutVariantSwitch ) |
202 { |
171 { |
203 SizeChanged(); |
172 iEditor->SetRect( Rect() ); |
204 } |
|
205 else if ( aType == KAknsMessageSkinChange || |
|
206 aType == KEikMessageColorSchemeChange ) |
|
207 { |
|
208 TRAP_IGNORE( SetFontColorL() ); |
|
209 } |
173 } |
210 } |
174 } |
211 |
175 |
212 // --------------------------------------------------------------------------- |
176 // --------------------------------------------------------------------------- |
213 // CESMRResponseDialogView::SizeChanged() |
177 // CESMRResponseDialogView::SizeChanged() |
223 iBgContext->SetParentPos( PositionRelativeToScreen() ); |
187 iBgContext->SetParentPos( PositionRelativeToScreen() ); |
224 } |
188 } |
225 } |
189 } |
226 if( iEditor ) |
190 if( iEditor ) |
227 { |
191 { |
228 // Reduce scrollbar width from the editor width |
192 iEditor->SetRect( Rect() ); |
229 TRect rect = Rect(); |
|
230 TInt scrollbarWidth = iEditor->ScrollBarFrame()->ScrollBarBreadth( CEikScrollBar::EVertical ); |
|
231 TInt editorWidth = rect.Width() - scrollbarWidth; |
|
232 if ( AknLayoutUtils::LayoutMirrored() ) |
|
233 { |
|
234 iEditor->SetExtent( TPoint( scrollbarWidth, 0 ), TSize( editorWidth, rect.Height() ) ); |
|
235 } |
|
236 else |
|
237 { |
|
238 iEditor->SetExtent( TPoint( 0, 0 ), TSize( editorWidth, rect.Height() ) ); |
|
239 } |
|
240 } |
193 } |
241 } |
194 } |
242 |
195 |
243 // --------------------------------------------------------------------------- |
|
244 // CESMRResponseDialogView::MinimumSize() |
|
245 // --------------------------------------------------------------------------- |
|
246 // |
|
247 TSize CESMRResponseDialogView::MinimumSize() |
|
248 { |
|
249 FUNC_LOG; |
|
250 TRect rect; |
|
251 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, rect ); |
|
252 return rect.Size(); |
|
253 } |
|
254 |
|
255 // ----------------------------------------------------------------------------- |
|
256 // CESMRResponseDialogView::SetFontColorL() |
|
257 // ----------------------------------------------------------------------------- |
|
258 // |
|
259 void CESMRResponseDialogView::SetFontColorL() |
|
260 { |
|
261 const CFont* sysfont = AknLayoutUtils::FontFromId( EAknLogicalFontPrimaryFont, NULL ); |
|
262 TFontSpec fontSpec = sysfont->FontSpecInTwips(); |
|
263 TCharFormat charFormat; |
|
264 TCharFormatMask formatMask; |
|
265 charFormat.iFontSpec = fontSpec; |
|
266 |
|
267 formatMask.SetAttrib( EAttFontTypeface ); |
|
268 formatMask.SetAttrib( EAttFontHeight ); |
|
269 formatMask.SetAttrib( EAttFontPosture ); |
|
270 |
|
271 charFormat.iFontPresentation.iTextColor = TextColor( EAknsCIQsnTextColorsCG6 ); |
|
272 formatMask.SetAttrib( EAttColor ); |
|
273 |
|
274 CCharFormatLayer* charFormatLayer = |
|
275 CCharFormatLayer::NewL( charFormat, formatMask ); |
|
276 |
|
277 iEditor->SetCharFormatLayer( charFormatLayer ); |
|
278 } |
|
279 |
|
280 // end of file |
196 // end of file |