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". |
19 #include "nmrlayoutmanager.h" |
19 #include "nmrlayoutmanager.h" |
20 #include "nmrbitmapmanager.h" |
20 #include "nmrbitmapmanager.h" |
21 #include "cmrlabel.h" |
21 #include "cmrlabel.h" |
22 #include "cmrimage.h" |
22 #include "cmrimage.h" |
23 #include "mesmrlistobserver.h" |
23 #include "mesmrlistobserver.h" |
|
24 #include "cesmrglobalnote.h" |
24 |
25 |
25 #include <calentry.h> |
26 #include <calentry.h> |
26 #include <StringLoader.h> |
27 #include <stringloader.h> |
27 #include <AknLayout2ScalableDef.h> |
28 #include <aknlayout2scalabledef.h> |
28 |
29 |
29 #include <esmrgui.rsg> |
30 #include <esmrgui.rsg> |
30 // DEBUG |
31 // DEBUG |
31 #include "emailtrace.h" |
32 #include "emailtrace.h" |
32 |
33 |
52 // |
53 // |
53 CESMRViewerSyncField::~CESMRViewerSyncField() |
54 CESMRViewerSyncField::~CESMRViewerSyncField() |
54 { |
55 { |
55 FUNC_LOG; |
56 FUNC_LOG; |
56 delete iIcon; |
57 delete iIcon; |
57 delete iLabel; |
58 delete iLockIcon; |
58 } |
59 } |
59 |
60 |
60 // --------------------------------------------------------------------------- |
61 // --------------------------------------------------------------------------- |
61 // CESMRViewerSyncField::CESMRViewerSyncField() |
62 // CESMRViewerSyncField::CESMRViewerSyncField() |
62 // --------------------------------------------------------------------------- |
63 // --------------------------------------------------------------------------- |
63 // |
64 // |
64 CESMRViewerSyncField::CESMRViewerSyncField() |
65 CESMRViewerSyncField::CESMRViewerSyncField() |
65 { |
66 { |
66 FUNC_LOG; |
67 FUNC_LOG; |
67 SetFieldId( EESMRFieldSync ); |
68 SetFieldId( EESMRFieldSync ); |
|
69 SetFocusType( EESMRHighlightFocus ); |
68 } |
70 } |
69 |
71 |
70 // --------------------------------------------------------------------------- |
72 // --------------------------------------------------------------------------- |
71 // CESMRViewerSyncField::ConstructL() |
73 // CESMRViewerSyncField::ConstructL() |
72 // --------------------------------------------------------------------------- |
74 // --------------------------------------------------------------------------- |
74 void CESMRViewerSyncField::ConstructL() |
76 void CESMRViewerSyncField::ConstructL() |
75 { |
77 { |
76 FUNC_LOG; |
78 FUNC_LOG; |
77 iLabel = CMRLabel::NewL(); |
79 iLabel = CMRLabel::NewL(); |
78 iLabel->SetParent( this ); |
80 iLabel->SetParent( this ); |
|
81 CESMRField::ConstructL( iLabel ); // ownership transfered |
|
82 |
79 iIcon = CMRImage::NewL( NMRBitmapManager::EMRBitmapSynchronization ); |
83 iIcon = CMRImage::NewL( NMRBitmapManager::EMRBitmapSynchronization ); |
80 iIcon->SetParent( this ); |
84 iIcon->SetParent( this ); |
81 |
|
82 SetFocusType( EESMRHighlightFocus ); |
|
83 } |
85 } |
84 |
86 |
85 // --------------------------------------------------------------------------- |
87 // --------------------------------------------------------------------------- |
86 // CESMRViewerSyncField::InternalizeL() |
88 // CESMRViewerSyncField::InternalizeL() |
87 // --------------------------------------------------------------------------- |
89 // --------------------------------------------------------------------------- |
132 // |
134 // |
133 void CESMRViewerSyncField::InitializeL() |
135 void CESMRViewerSyncField::InitializeL() |
134 { |
136 { |
135 FUNC_LOG; |
137 FUNC_LOG; |
136 // Setting Font for the rich text viewer |
138 // Setting Font for the rich text viewer |
137 TAknLayoutText text = NMRLayoutManager::GetLayoutText( |
139 TAknLayoutText text = NMRLayoutManager::GetLayoutText( |
138 Rect(), |
140 Rect(), |
139 NMRLayoutManager::EMRTextLayoutTextEditor ); |
141 NMRLayoutManager::EMRTextLayoutTextEditor ); |
140 |
142 |
141 iLabel->SetFont( text.Font() ); |
143 iLabel->SetFont( text.Font() ); |
142 |
144 |
143 // This is called so theme changes will apply when changing theme "on the fly" |
145 // This is called so theme changes will apply when changing theme "on the fly" |
144 if ( IsFocused() ) |
146 if ( IsFocused() ) |
145 { |
147 { |
146 iLabel->FocusChanged( EDrawNow ); |
148 iLabel->FocusChanged( EDrawNow ); |
147 } |
149 } |
148 |
|
149 AknLayoutUtils::OverrideControlColorL( *iLabel, EColorLabelText, |
|
150 KRgbBlack ); |
|
151 } |
150 } |
152 |
151 |
153 // --------------------------------------------------------------------------- |
152 // --------------------------------------------------------------------------- |
154 // CESMRViewerSyncField::SizeChanged() |
153 // CESMRViewerSyncField::SizeChanged() |
155 // --------------------------------------------------------------------------- |
154 // --------------------------------------------------------------------------- |
158 { |
157 { |
159 TRect rect = Rect(); |
158 TRect rect = Rect(); |
160 TAknLayoutRect rowLayoutRect = |
159 TAknLayoutRect rowLayoutRect = |
161 NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 ); |
160 NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 ); |
162 rect = rowLayoutRect.Rect(); |
161 rect = rowLayoutRect.Rect(); |
163 |
162 |
164 TAknWindowComponentLayout iconLayout = |
163 TAknWindowComponentLayout iconLayout = |
165 NMRLayoutManager::GetWindowComponentLayout( |
164 NMRLayoutManager::GetWindowComponentLayout( |
166 NMRLayoutManager::EMRLayoutTextEditorIcon ); |
165 NMRLayoutManager::EMRLayoutTextEditorIcon ); |
167 AknLayoutUtils::LayoutImage( iIcon, rect, iconLayout ); |
166 AknLayoutUtils::LayoutImage( iIcon, rect, iconLayout ); |
168 |
167 |
169 TAknLayoutRect bgLayoutRect = |
168 // Layouting lock icon |
170 NMRLayoutManager::GetLayoutRect( |
169 if( iLockIcon ) |
171 rect, NMRLayoutManager::EMRLayoutTextEditorBg ); |
170 { |
172 TRect bgRect( bgLayoutRect.Rect() ); |
171 TAknWindowComponentLayout iconLayout( |
|
172 NMRLayoutManager::GetWindowComponentLayout( |
|
173 NMRLayoutManager::EMRLayoutSingleRowDColumnGraphic ) ); |
|
174 AknLayoutUtils::LayoutImage( iLockIcon, rect, iconLayout ); |
|
175 } |
|
176 |
|
177 // Layouting label |
|
178 TAknLayoutText viewerLayoutText; |
|
179 if( iLockIcon ) |
|
180 { |
|
181 viewerLayoutText = NMRLayoutManager::GetLayoutText( rect, |
|
182 NMRLayoutManager::EMRTextLayoutSingleRowEditorText ); |
|
183 } |
|
184 else |
|
185 { |
|
186 viewerLayoutText = NMRLayoutManager::GetLayoutText( rect, |
|
187 NMRLayoutManager::EMRTextLayoutTextEditor ); |
|
188 } |
|
189 |
|
190 TRect viewerRect( viewerLayoutText.TextRect() ); |
|
191 iLabel->SetRect( viewerRect ); |
|
192 |
173 // Move focus rect so that it's relative to field's position. |
193 // Move focus rect so that it's relative to field's position. |
174 bgRect.Move( -Position() ); |
194 viewerRect.Move( -Position() ); |
175 SetFocusRect( bgRect ); |
195 SetFocusRect( viewerRect ); |
176 |
196 |
177 TAknLayoutText labelLayout = |
197 // Setting font also for the label |
178 NMRLayoutManager::GetLayoutText( |
198 iLabel->SetFont( viewerLayoutText.Font() ); |
179 rect, NMRLayoutManager::EMRTextLayoutTextEditor ); |
|
180 iLabel->SetRect( labelLayout.TextRect() ); |
|
181 } |
199 } |
182 |
200 |
183 // --------------------------------------------------------------------------- |
201 // --------------------------------------------------------------------------- |
184 // CESMRViewerSyncField::CountComponentControls() |
202 // CESMRViewerSyncField::CountComponentControls() |
185 // --------------------------------------------------------------------------- |
203 // --------------------------------------------------------------------------- |
221 // --------------------------------------------------------------------------- |
245 // --------------------------------------------------------------------------- |
222 // |
246 // |
223 void CESMRViewerSyncField::SetOutlineFocusL( TBool aFocus ) |
247 void CESMRViewerSyncField::SetOutlineFocusL( TBool aFocus ) |
224 { |
248 { |
225 CESMRField::SetOutlineFocusL ( aFocus ); |
249 CESMRField::SetOutlineFocusL ( aFocus ); |
226 |
250 |
227 iLabel->SetFocus( aFocus ); |
251 iLabel->SetFocus( aFocus ); |
228 |
252 } |
229 if ( !aFocus ) |
253 |
230 { |
254 // --------------------------------------------------------------------------- |
231 AknLayoutUtils::OverrideControlColorL ( *iLabel, EColorLabelText, |
255 // CESMRViewerSyncField::LockL() |
232 KRgbBlack ); |
256 // --------------------------------------------------------------------------- |
233 } |
257 // |
234 } |
258 void CESMRViewerSyncField::LockL() |
|
259 { |
|
260 FUNC_LOG; |
|
261 if( IsLocked() ) |
|
262 { |
|
263 return; |
|
264 } |
|
265 |
|
266 CESMRField::LockL(); |
|
267 |
|
268 delete iLockIcon; |
|
269 iLockIcon = NULL; |
|
270 iLockIcon = CMRImage::NewL( NMRBitmapManager::EMRBitmapLockField, ETrue ); |
|
271 iLockIcon->SetParent( this ); |
|
272 } |
|
273 |
|
274 // --------------------------------------------------------------------------- |
|
275 // CESMRViewerSyncField::ExecuteGenericCommandL() |
|
276 // --------------------------------------------------------------------------- |
|
277 // |
|
278 TBool CESMRViewerSyncField::ExecuteGenericCommandL( TInt aCommand ) |
|
279 { |
|
280 FUNC_LOG; |
|
281 |
|
282 TBool retValue( EFalse ); |
|
283 |
|
284 if( (aCommand == EAknCmdOpen) && IsLocked() ) |
|
285 { |
|
286 HandleTactileFeedbackL(); |
|
287 |
|
288 CESMRGlobalNote::ExecuteL( |
|
289 CESMRGlobalNote::EESMRUnableToEdit ); |
|
290 retValue = ETrue; |
|
291 } |
|
292 |
|
293 return retValue; |
|
294 } |
235 // EOF |
295 // EOF |
236 |
296 |