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