|
1 /* |
|
2 * Copyright (c) 2007-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 "cesmrvieweralarmdatefield.h" |
|
19 |
|
20 #include "cesmreditor.h" |
|
21 #include "mesmrlistobserver.h" |
|
22 #include "nmrlayoutmanager.h" |
|
23 #include "nmrbitmapmanager.h" |
|
24 #include "cmrlabel.h" |
|
25 #include "cmrimage.h" |
|
26 #include <esmrgui.rsg> |
|
27 |
|
28 #include <eiklabel.h> |
|
29 #include <caluser.h> |
|
30 #include <calalarm.h> |
|
31 #include <avkon.rsg> |
|
32 #include <calentry.h> |
|
33 #include <eikenv.h> |
|
34 #include <eikedwin.h> |
|
35 #include <StringLoader.h> |
|
36 #include <AknsConstants.h> |
|
37 #include <AknUtils.h> |
|
38 #include <AknLayout2ScalableDef.h> |
|
39 |
|
40 // ======== LOCAL FUNCTIONS ======== |
|
41 namespace // codescanner::namespace |
|
42 { |
|
43 const TInt KComponentCount( 2 ); // icon and label |
|
44 const TInt KMaxTimeBuffer( 32 ); // buffer for date formatting |
|
45 } // unnamed namespace |
|
46 |
|
47 // ======== MEMBER FUNCTIONS ======== |
|
48 |
|
49 // --------------------------------------------------------------------------- |
|
50 // CESMRViewerAlarmDateField::NewL() |
|
51 // --------------------------------------------------------------------------- |
|
52 // |
|
53 CESMRViewerAlarmDateField* CESMRViewerAlarmDateField::NewL() |
|
54 { |
|
55 CESMRViewerAlarmDateField* self = new (ELeave) CESMRViewerAlarmDateField(); |
|
56 CleanupStack::PushL( self ); |
|
57 self->ConstructL(); |
|
58 CleanupStack::Pop( self ); |
|
59 return self; |
|
60 } |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // CESMRViewerAlarmDateField::~CESMRViewerAlarmDateField() |
|
64 // --------------------------------------------------------------------------- |
|
65 // |
|
66 CESMRViewerAlarmDateField::~CESMRViewerAlarmDateField() |
|
67 { |
|
68 delete iLabel; |
|
69 delete iIcon; |
|
70 } |
|
71 |
|
72 // --------------------------------------------------------------------------- |
|
73 // CESMRViewerAlarmDateField::CESMRViewerAlarmDateField() |
|
74 // --------------------------------------------------------------------------- |
|
75 // |
|
76 CESMRViewerAlarmDateField::CESMRViewerAlarmDateField() |
|
77 { |
|
78 SetFieldId ( EESMRFieldAlarmDate ); |
|
79 SetFocusType( EESMRHighlightFocus ); |
|
80 } |
|
81 |
|
82 // ----------------------------------------------------------------------------- |
|
83 // CESMRViewerAlarmDateField::ConstructL() |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 void CESMRViewerAlarmDateField::ConstructL() |
|
87 { |
|
88 iLabel = CMRLabel::NewL(); |
|
89 iLabel->SetParent( this ); |
|
90 iIcon = CMRImage::NewL( NMRBitmapManager::EMRBitmapAlarmDate ); |
|
91 iIcon->SetParent( this ); |
|
92 } |
|
93 |
|
94 // --------------------------------------------------------------------------- |
|
95 // CESMRViewerAlarmDateField::InitializeL() |
|
96 // --------------------------------------------------------------------------- |
|
97 // |
|
98 void CESMRViewerAlarmDateField::InitializeL() |
|
99 { |
|
100 // Setting Font for the rich text viewer |
|
101 TAknLayoutText text = NMRLayoutManager::GetLayoutText( |
|
102 Rect(), |
|
103 NMRLayoutManager::EMRTextLayoutTextEditor ); |
|
104 |
|
105 iLabel->SetFont( text.Font() ); |
|
106 |
|
107 // This is called so theme changes will apply when changing theme "on the fly" |
|
108 if ( IsFocused() ) |
|
109 { |
|
110 iLabel->FocusChanged( EDrawNow ); |
|
111 } |
|
112 |
|
113 AknLayoutUtils::OverrideControlColorL( *iLabel, EColorLabelText, |
|
114 KRgbBlack ); |
|
115 } |
|
116 |
|
117 |
|
118 // --------------------------------------------------------------------------- |
|
119 // CESMRViewerAlarmDateField::InternalizeL() |
|
120 // --------------------------------------------------------------------------- |
|
121 // |
|
122 void CESMRViewerAlarmDateField::InternalizeL( MESMRCalEntry& aEntry ) |
|
123 { |
|
124 MESMRCalEntry::TESMRAlarmType alarmType; |
|
125 TTime alarmTime; |
|
126 |
|
127 aEntry.GetAlarmL( alarmType, alarmTime ); |
|
128 |
|
129 if( alarmType == MESMRCalEntry::EESMRAlarmAbsolute ) |
|
130 { |
|
131 // Read format string from AVKON resource |
|
132 HBufC* dateFormatString = iEikonEnv->AllocReadResourceLC( |
|
133 R_QTN_DATE_USUAL_WITH_ZERO ); |
|
134 TBuf<KMaxTimeBuffer> buf; |
|
135 |
|
136 alarmTime.FormatL( buf, *dateFormatString ); |
|
137 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( buf ); |
|
138 iLabel->SetTextL( buf ); |
|
139 |
|
140 CleanupStack::PopAndDestroy( dateFormatString ); |
|
141 } |
|
142 else // Remove the alarm fields |
|
143 { |
|
144 CCoeControl::MakeVisible(EFalse); |
|
145 iObserver->RemoveControl(EESMRFieldAlarmDate); |
|
146 } |
|
147 } |
|
148 |
|
149 // --------------------------------------------------------------------------- |
|
150 // CESMRViewerAlarmDateField::SizeChanged() |
|
151 // --------------------------------------------------------------------------- |
|
152 // |
|
153 void CESMRViewerAlarmDateField::SizeChanged() |
|
154 { |
|
155 TRect rect = Rect(); |
|
156 TAknLayoutRect rowLayoutRect = |
|
157 NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 ); |
|
158 rect = rowLayoutRect.Rect(); |
|
159 |
|
160 TAknWindowComponentLayout iconLayout = |
|
161 NMRLayoutManager::GetWindowComponentLayout( |
|
162 NMRLayoutManager::EMRLayoutTextEditorIcon ); |
|
163 AknLayoutUtils::LayoutImage( iIcon, rect, iconLayout ); |
|
164 |
|
165 TAknLayoutRect bgLayoutRect = |
|
166 NMRLayoutManager::GetLayoutRect( |
|
167 rect, NMRLayoutManager::EMRLayoutTextEditorBg ); |
|
168 TRect bgRect( bgLayoutRect.Rect() ); |
|
169 // Move focus rect so that it's relative to field's position. |
|
170 bgRect.Move( -Position() ); |
|
171 SetFocusRect( bgRect ); |
|
172 |
|
173 TAknLayoutText labelLayout = |
|
174 NMRLayoutManager::GetLayoutText( |
|
175 rect, NMRLayoutManager::EMRTextLayoutTextEditor ); |
|
176 iLabel->SetRect( labelLayout.TextRect() ); |
|
177 } |
|
178 |
|
179 // --------------------------------------------------------------------------- |
|
180 // CESMRViewerAlarmDateField::CountComponentControls() |
|
181 // --------------------------------------------------------------------------- |
|
182 // |
|
183 TInt CESMRViewerAlarmDateField::CountComponentControls() const |
|
184 { |
|
185 TInt count( KComponentCount ); |
|
186 return count; |
|
187 } |
|
188 |
|
189 // --------------------------------------------------------------------------- |
|
190 // CESMRViewerAlarmDateField::ComponentControl() |
|
191 // --------------------------------------------------------------------------- |
|
192 // |
|
193 CCoeControl* CESMRViewerAlarmDateField::ComponentControl( TInt aIndex ) const |
|
194 { |
|
195 switch ( aIndex ) |
|
196 { |
|
197 case 0: |
|
198 return iIcon; |
|
199 case 1: |
|
200 return iLabel; |
|
201 default: |
|
202 return NULL; |
|
203 } |
|
204 } |
|
205 |
|
206 // --------------------------------------------------------------------------- |
|
207 // CESMRViewerAlarmDateField::SetOutlineFocusL() |
|
208 // --------------------------------------------------------------------------- |
|
209 // |
|
210 void CESMRViewerAlarmDateField::SetOutlineFocusL( TBool aFocus ) |
|
211 { |
|
212 CESMRField::SetOutlineFocusL ( aFocus ); |
|
213 |
|
214 iLabel->SetFocus( aFocus ); |
|
215 |
|
216 if ( !aFocus ) |
|
217 { |
|
218 AknLayoutUtils::OverrideControlColorL ( *iLabel, EColorLabelText, |
|
219 KRgbBlack ); |
|
220 } |
|
221 } |
|
222 // EOF |
|
223 |