64
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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: ESMR UI Container class
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "cesmrvieweralarmtimefield.h"
|
|
19 |
|
|
20 |
#include "cesmreditor.h"
|
|
21 |
#include "mesmrlistobserver.h"
|
|
22 |
#include "esmrfieldbuilderdef.h"
|
|
23 |
#include "cmrimage.h"
|
|
24 |
#include "cmrlabel.h"
|
|
25 |
#include "nmrlayoutmanager.h"
|
|
26 |
#include "cesmrglobalnote.h"
|
|
27 |
|
|
28 |
#include <caluser.h>
|
|
29 |
#include <calalarm.h>
|
|
30 |
#include <avkon.rsg>
|
|
31 |
#include <calentry.h>
|
|
32 |
#include <eikenv.h>
|
|
33 |
|
|
34 |
#include "emailtrace.h"
|
|
35 |
|
|
36 |
// ======== MEMBER FUNCTIONS ========
|
|
37 |
|
|
38 |
// ---------------------------------------------------------------------------
|
|
39 |
// CESMRViewerAlarmTimeField::CESMRViewerAlarmTimeField()
|
|
40 |
// ---------------------------------------------------------------------------
|
|
41 |
//
|
|
42 |
CESMRViewerAlarmTimeField::CESMRViewerAlarmTimeField()
|
|
43 |
{
|
|
44 |
FUNC_LOG;
|
|
45 |
SetFieldId ( EESMRFieldAlarmTime );
|
|
46 |
SetFocusType( EESMRHighlightFocus );
|
|
47 |
}
|
|
48 |
|
|
49 |
// ---------------------------------------------------------------------------
|
|
50 |
// CESMRViewerAlarmTimeField::~CESMRViewerAlarmTimeField()
|
|
51 |
// ---------------------------------------------------------------------------
|
|
52 |
//
|
|
53 |
CESMRViewerAlarmTimeField::~CESMRViewerAlarmTimeField()
|
|
54 |
{
|
|
55 |
FUNC_LOG;
|
|
56 |
delete iIcon;
|
|
57 |
delete iLockIcon;
|
|
58 |
}
|
|
59 |
|
|
60 |
// ---------------------------------------------------------------------------
|
|
61 |
// CESMRViewerAlarmTimeField::NewL
|
|
62 |
// ---------------------------------------------------------------------------
|
|
63 |
//
|
|
64 |
CESMRViewerAlarmTimeField* CESMRViewerAlarmTimeField::NewL()
|
|
65 |
{
|
|
66 |
FUNC_LOG;
|
|
67 |
CESMRViewerAlarmTimeField* self = new (ELeave) CESMRViewerAlarmTimeField();
|
|
68 |
CleanupStack::PushL( self );
|
|
69 |
self->ConstructL();
|
|
70 |
CleanupStack::Pop( self );
|
|
71 |
return self;
|
|
72 |
}
|
|
73 |
|
|
74 |
// ---------------------------------------------------------------------------
|
|
75 |
// CESMRViewerAlarmTimeField::ConstructL()
|
|
76 |
// ---------------------------------------------------------------------------
|
|
77 |
//
|
|
78 |
void CESMRViewerAlarmTimeField::ConstructL()
|
|
79 |
{
|
|
80 |
FUNC_LOG;
|
|
81 |
iLabel = CMRLabel::NewL( this );
|
|
82 |
CESMRField::ConstructL( iLabel ); // ownership transfered
|
|
83 |
|
|
84 |
iIcon = CMRImage::NewL( NMRBitmapManager::EMRBitmapAlarmClock, this );
|
|
85 |
}
|
|
86 |
|
|
87 |
// ---------------------------------------------------------------------------
|
|
88 |
// CESMRViewerAlarmTimeField::InternalizeL()
|
|
89 |
// ---------------------------------------------------------------------------
|
|
90 |
//
|
|
91 |
void CESMRViewerAlarmTimeField::InternalizeL( MESMRCalEntry& aEntry )
|
|
92 |
{
|
|
93 |
FUNC_LOG;
|
|
94 |
MESMRCalEntry::TESMRAlarmType alarmType;
|
|
95 |
aEntry.GetAlarmL( alarmType, iAlarmTime );
|
|
96 |
|
|
97 |
if( alarmType == MESMRCalEntry::EESMRAlarmAbsolute )
|
|
98 |
{
|
|
99 |
FormatAlarmTimeL();
|
|
100 |
}
|
|
101 |
else // Remove the alarm fields
|
|
102 |
{
|
|
103 |
CCoeControl::MakeVisible( EFalse );
|
|
104 |
iObserver->HideControl( EESMRFieldAlarmTime );
|
|
105 |
}
|
|
106 |
}
|
|
107 |
|
|
108 |
// ---------------------------------------------------------------------------
|
|
109 |
// CESMRViewerAlarmTimeField::SizeChanged()
|
|
110 |
// ---------------------------------------------------------------------------
|
|
111 |
//
|
|
112 |
void CESMRViewerAlarmTimeField::SizeChanged()
|
|
113 |
{
|
|
114 |
FUNC_LOG;
|
|
115 |
TRect rect = Rect();
|
|
116 |
TAknLayoutRect rowLayoutRect =
|
|
117 |
NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 );
|
|
118 |
rect = rowLayoutRect.Rect();
|
|
119 |
|
|
120 |
TAknWindowComponentLayout iconLayout =
|
|
121 |
NMRLayoutManager::GetWindowComponentLayout(
|
|
122 |
NMRLayoutManager::EMRLayoutTextEditorIcon );
|
|
123 |
AknLayoutUtils::LayoutImage( iIcon, rect, iconLayout );
|
|
124 |
|
|
125 |
// Layouting lock icon
|
|
126 |
if( iLockIcon )
|
|
127 |
{
|
|
128 |
TAknWindowComponentLayout iconLayout(
|
|
129 |
NMRLayoutManager::GetWindowComponentLayout(
|
|
130 |
NMRLayoutManager::EMRLayoutSingleRowDColumnGraphic ) );
|
|
131 |
AknLayoutUtils::LayoutImage( iLockIcon, rect, iconLayout );
|
|
132 |
}
|
|
133 |
|
|
134 |
// Layouting label
|
|
135 |
TAknTextComponentLayout viewerLayoutText;
|
|
136 |
|
|
137 |
if( iLockIcon )
|
|
138 |
{
|
|
139 |
viewerLayoutText = NMRLayoutManager::GetTextComponentLayout(
|
|
140 |
NMRLayoutManager::EMRTextLayoutSingleRowEditorText );
|
|
141 |
}
|
|
142 |
else
|
|
143 |
{
|
|
144 |
viewerLayoutText = NMRLayoutManager::GetTextComponentLayout(
|
|
145 |
NMRLayoutManager::EMRTextLayoutTextEditor );
|
|
146 |
}
|
|
147 |
|
|
148 |
AknLayoutUtils::LayoutLabel( iLabel, rect, viewerLayoutText );
|
|
149 |
TRect viewerRect( iLabel->Rect() );
|
|
150 |
|
|
151 |
// Move focus rect so that it's relative to field's position.
|
|
152 |
viewerRect.Move( -Position() );
|
|
153 |
SetFocusRect( viewerRect );
|
|
154 |
}
|
|
155 |
|
|
156 |
// ---------------------------------------------------------------------------
|
|
157 |
// CESMRViewerAlarmTimeField::CountComponentControls()
|
|
158 |
// ---------------------------------------------------------------------------
|
|
159 |
//
|
|
160 |
TInt CESMRViewerAlarmTimeField::CountComponentControls() const
|
|
161 |
{
|
|
162 |
FUNC_LOG;
|
|
163 |
TInt count( 0 );
|
|
164 |
if ( iIcon )
|
|
165 |
{
|
|
166 |
++count;
|
|
167 |
}
|
|
168 |
|
|
169 |
if ( iLabel )
|
|
170 |
{
|
|
171 |
++count;
|
|
172 |
}
|
|
173 |
|
|
174 |
if ( iLockIcon )
|
|
175 |
{
|
|
176 |
++count;
|
|
177 |
}
|
|
178 |
return count;
|
|
179 |
}
|
|
180 |
|
|
181 |
// ---------------------------------------------------------------------------
|
|
182 |
// CESMRViewerAlarmTimeField::ComponentControl()
|
|
183 |
// ---------------------------------------------------------------------------
|
|
184 |
//
|
|
185 |
CCoeControl* CESMRViewerAlarmTimeField::ComponentControl( TInt aIndex ) const
|
|
186 |
{
|
|
187 |
FUNC_LOG;
|
|
188 |
switch ( aIndex )
|
|
189 |
{
|
|
190 |
case 0:
|
|
191 |
return iIcon;
|
|
192 |
case 1:
|
|
193 |
return iLabel;
|
|
194 |
case 2:
|
|
195 |
return iLockIcon;
|
|
196 |
default:
|
|
197 |
return NULL;
|
|
198 |
}
|
|
199 |
}
|
|
200 |
|
|
201 |
// ---------------------------------------------------------------------------
|
|
202 |
// CESMRViewerAlarmTimeField::SetOutlineFocusL()
|
|
203 |
// ---------------------------------------------------------------------------
|
|
204 |
//
|
|
205 |
void CESMRViewerAlarmTimeField::SetOutlineFocusL( TBool aFocus )
|
|
206 |
{
|
|
207 |
FUNC_LOG;
|
|
208 |
CESMRField::SetOutlineFocusL ( aFocus );
|
|
209 |
|
|
210 |
iLabel->SetFocus( aFocus );
|
|
211 |
}
|
|
212 |
|
|
213 |
// ---------------------------------------------------------------------------
|
|
214 |
// CESMRViewerAlarmTimeField::ExecuteGenericCommandL()
|
|
215 |
// ---------------------------------------------------------------------------
|
|
216 |
//
|
|
217 |
TBool CESMRViewerAlarmTimeField::ExecuteGenericCommandL( TInt aCommand )
|
|
218 |
{
|
|
219 |
FUNC_LOG;
|
|
220 |
|
|
221 |
TBool retValue( EFalse );
|
|
222 |
|
|
223 |
if( (aCommand == EAknCmdOpen) && IsLocked() )
|
|
224 |
{
|
|
225 |
HandleTactileFeedbackL();
|
|
226 |
|
|
227 |
CESMRGlobalNote::ExecuteL(
|
|
228 |
CESMRGlobalNote::EESMRUnableToEdit );
|
|
229 |
retValue = ETrue;
|
|
230 |
}
|
|
231 |
|
|
232 |
if ( EMRCmdDoEnvironmentChange == aCommand )
|
|
233 |
{
|
|
234 |
FormatAlarmTimeL();
|
|
235 |
retValue = ETrue;
|
|
236 |
}
|
|
237 |
|
|
238 |
return retValue;
|
|
239 |
}
|
|
240 |
|
|
241 |
// ---------------------------------------------------------------------------
|
|
242 |
// CESMRViewerAlarmTimeField::LockL()
|
|
243 |
// ---------------------------------------------------------------------------
|
|
244 |
//
|
|
245 |
void CESMRViewerAlarmTimeField::LockL()
|
|
246 |
{
|
|
247 |
FUNC_LOG;
|
|
248 |
if( IsLocked() )
|
|
249 |
{
|
|
250 |
return;
|
|
251 |
}
|
|
252 |
|
|
253 |
CESMRField::LockL();
|
|
254 |
|
|
255 |
delete iLockIcon;
|
|
256 |
iLockIcon = NULL;
|
|
257 |
iLockIcon = CMRImage::NewL(
|
|
258 |
NMRBitmapManager::EMRBitmapLockField,
|
|
259 |
this,
|
|
260 |
ETrue );
|
|
261 |
}
|
|
262 |
|
|
263 |
// ---------------------------------------------------------------------------
|
|
264 |
// CESMRViewerAlarmTimeField::FormatAlarmTimeL
|
|
265 |
// ---------------------------------------------------------------------------
|
|
266 |
//
|
|
267 |
void CESMRViewerAlarmTimeField::FormatAlarmTimeL()
|
|
268 |
{
|
|
269 |
FUNC_LOG;
|
|
270 |
|
|
271 |
// Read format string from AVKON resource
|
|
272 |
HBufC* dateFormatString =
|
|
273 |
iEikonEnv->AllocReadResourceLC( R_QTN_TIME_USUAL_WITH_ZERO );
|
|
274 |
HBufC* buf = HBufC::NewLC( KBufferLength );
|
|
275 |
TPtr ptr( buf->Des() );
|
|
276 |
|
|
277 |
iAlarmTime.FormatL( ptr, *dateFormatString );
|
|
278 |
AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr );
|
|
279 |
iLabel->SetTextL( ptr );
|
|
280 |
CleanupStack::PopAndDestroy( 2, dateFormatString );
|
|
281 |
}
|
|
282 |
// EOF
|
|
283 |
|