|
1 /* |
|
2 * Copyright (c) 2007 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: For view of calendar application. |
|
15 * |
|
16 */ |
|
17 |
|
18 //debug |
|
19 #include "calendarui_debug.h" |
|
20 #include "calencontext.h" |
|
21 #include "CalenStatusPaneUtilsImpl.h" |
|
22 #include "calentitlepane.h" |
|
23 #include <Calendar.rsg> |
|
24 |
|
25 #include <aknnavi.h> |
|
26 #include <AknUtils.h> |
|
27 #include <akntitle.h> |
|
28 #include <StringLoader.h> |
|
29 #include <avkon.hrh> |
|
30 #include <eikspane.h> |
|
31 |
|
32 |
|
33 #include <calennavilabel.h> |
|
34 #include <aknnavide.h> |
|
35 |
|
36 |
|
37 |
|
38 // ================= MEMBER FUNCTIONS ========================================= |
|
39 |
|
40 // local static funtions |
|
41 static void ReplaceNewlines(TDes& aBuf) |
|
42 { |
|
43 TRACE_ENTRY_POINT; |
|
44 |
|
45 _LIT(KReplaceNewline, "\n"); |
|
46 const TChar KSpace(' '); |
|
47 AknTextUtils::ReplaceCharacters( aBuf, KReplaceNewline, KSpace ); |
|
48 |
|
49 TRACE_EXIT_POINT; |
|
50 } |
|
51 |
|
52 static void ReplaceNewlines(HBufC& aBuf) |
|
53 { |
|
54 TRACE_ENTRY_POINT; |
|
55 |
|
56 TPtr ptr = aBuf.Des(); |
|
57 ReplaceNewlines( ptr ); |
|
58 |
|
59 TRACE_EXIT_POINT; |
|
60 } |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // ?classname::?member_function |
|
64 // ?implementation_description |
|
65 // (other items were commented in a header). |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 void CCalenStatusPaneUtilsImpl::HideNaviPane() |
|
69 { |
|
70 TRACE_ENTRY_POINT; |
|
71 |
|
72 if( iNaviLabel != NULL ) |
|
73 { |
|
74 iNaviContainer->Pop( iNaviLabel ); |
|
75 delete iNaviLabel; |
|
76 iNaviLabel = NULL; |
|
77 } |
|
78 |
|
79 TRACE_EXIT_POINT; |
|
80 } |
|
81 // ----------------------------------------------------------------------------- |
|
82 // ?classname::?member_function |
|
83 // ?implementation_description |
|
84 // (other items were commented in a header). |
|
85 // ----------------------------------------------------------------------------- |
|
86 // |
|
87 CAknNavigationDecorator* CCalenStatusPaneUtilsImpl::ShowNaviPaneL( const TTime& aActiveDay ) |
|
88 { |
|
89 TRACE_ENTRY_POINT; |
|
90 |
|
91 TTime activeDay = aActiveDay; |
|
92 TBuf<KNaviLabelSize> naviDes; |
|
93 |
|
94 /* if( iNaviLabel != NULL ) |
|
95 { |
|
96 delete iNaviLabel; |
|
97 iNaviLabel = NULL; |
|
98 iNaviContainer->Pop( iNaviLabel ); |
|
99 } |
|
100 */ |
|
101 activeDay.FormatL(naviDes, *iLongDateFormat); |
|
102 AknTextUtils::DisplayTextLanguageSpecificNumberConversion(naviDes); |
|
103 |
|
104 iNaviLabel = iNaviContainer->Top(); |
|
105 if(iNaviLabel != NULL) |
|
106 { |
|
107 CCoeControl* coeRes = iNaviLabel->DecoratedControl(); |
|
108 CAknNaviLabel *actualLabel = static_cast<CAknNaviLabel*>(coeRes); |
|
109 actualLabel->SetTextL(naviDes); |
|
110 iNaviContainer->ReplaceL(*iNaviLabel, *iNaviLabel); |
|
111 } |
|
112 else |
|
113 { |
|
114 CCalenNaviLabel* label = new (ELeave) CCalenNaviLabel; |
|
115 CleanupStack::PushL(label); |
|
116 label->SetContainerWindowL( *iNaviContainer ); |
|
117 label->SetTextL(naviDes); |
|
118 label->SetNaviLabelType(CAknNaviLabel::ENavigationLabel); |
|
119 CleanupStack::Pop( label ); // label |
|
120 iNaviLabel = CAknNavigationDecorator::NewL( iNaviContainer, |
|
121 static_cast<CAknNaviLabel*>(label), |
|
122 CAknNavigationDecorator::ENaviLabel ); |
|
123 iNaviLabel->SetContainerWindowL( *iNaviContainer ); |
|
124 iNaviLabel->SetControlContext( iNaviContainer ); |
|
125 iNaviLabel->MakeScrollButtonVisible(EFalse); |
|
126 iNaviContainer->PushL(*iNaviLabel); |
|
127 } |
|
128 |
|
129 |
|
130 TRACE_EXIT_POINT; |
|
131 return iNaviLabel; |
|
132 } |
|
133 |
|
134 // ----------------------------------------------------------------------------- |
|
135 // ?classname::?member_function |
|
136 // ?implementation_description |
|
137 // (other items were commented in a header). |
|
138 // ----------------------------------------------------------------------------- |
|
139 // |
|
140 CCalenStatusPaneUtilsImpl* CCalenStatusPaneUtilsImpl::NewL( CEikStatusPane* aStatusPane ) |
|
141 { |
|
142 TRACE_ENTRY_POINT; |
|
143 |
|
144 CCalenStatusPaneUtilsImpl* self = new(ELeave) CCalenStatusPaneUtilsImpl( aStatusPane ); |
|
145 CleanupStack::PushL( self ); |
|
146 self->ConstructL(); |
|
147 CleanupStack::Pop( self ); |
|
148 |
|
149 TRACE_EXIT_POINT; |
|
150 return self; |
|
151 } |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // ?classname::?member_function |
|
155 // ?implementation_description |
|
156 // (other items were commented in a header). |
|
157 // ----------------------------------------------------------------------------- |
|
158 // |
|
159 CCalenStatusPaneUtilsImpl::CCalenStatusPaneUtilsImpl( CEikStatusPane* aStatusPane ) |
|
160 : iStatusPane( aStatusPane ) |
|
161 { |
|
162 TRACE_ENTRY_POINT; |
|
163 TRACE_EXIT_POINT; |
|
164 } |
|
165 |
|
166 // ----------------------------------------------------------------------------- |
|
167 // ?classname::?member_function |
|
168 // ?implementation_description |
|
169 // (other items were commented in a header). |
|
170 // ----------------------------------------------------------------------------- |
|
171 // |
|
172 void CCalenStatusPaneUtilsImpl::ConstructL() |
|
173 { |
|
174 TRACE_ENTRY_POINT; |
|
175 |
|
176 iTitlePane = static_cast<CCalenTitlePane*>( |
|
177 iStatusPane->ControlL( TUid::Uid( EEikStatusPaneUidTitle ))); |
|
178 iNaviContainer = static_cast<CAknNavigationControlContainer*>( |
|
179 iStatusPane->ControlL(TUid::Uid( EEikStatusPaneUidNavi ))); |
|
180 // Date format strings are used in all status pane variants |
|
181 iNoYearDateFormat = StringLoader::LoadL(R_QTN_DATE_WITHOUT_YEAR_WITH_ZERO); |
|
182 iShortDateFormat = StringLoader::LoadL(R_QTN_DATE_SHORT_WITH_ZERO); |
|
183 iLongDateFormat = StringLoader::LoadL(R_QTN_DATE_USUAL_WITH_ZERO); |
|
184 |
|
185 // construct Month name array |
|
186 iMonthArray = new(ELeave)CDesCArrayFlat(12); |
|
187 |
|
188 for (TInt i(0); i < 12; ++i) |
|
189 { |
|
190 HBufC* month = StringLoader::LoadLC(KMonthNames[i]); |
|
191 iMonthArray->AppendL(*month); |
|
192 CleanupStack::PopAndDestroy(month); |
|
193 } |
|
194 |
|
195 // construct Day name array |
|
196 iDayNameArray = new(ELeave)CDesCArrayFlat(KCalenDaysInWeek); |
|
197 for (TInt i(0); i < KCalenDaysInWeek; ++i) |
|
198 { |
|
199 HBufC* day = StringLoader::LoadLC( KDayNames[i] ); |
|
200 iDayNameArray->AppendL(*day); |
|
201 CleanupStack::PopAndDestroy(day); |
|
202 } |
|
203 TRACE_EXIT_POINT; |
|
204 } |
|
205 |
|
206 // ----------------------------------------------------------------------------- |
|
207 // ?classname::?member_function |
|
208 // ?implementation_description |
|
209 // (other items were commented in a header). |
|
210 // ----------------------------------------------------------------------------- |
|
211 // |
|
212 CCalenStatusPaneUtilsImpl::~CCalenStatusPaneUtilsImpl() |
|
213 { |
|
214 TRACE_ENTRY_POINT; |
|
215 |
|
216 delete iNoYearDateFormat; |
|
217 delete iShortDateFormat; |
|
218 delete iLongDateFormat; |
|
219 delete iMonthArray; |
|
220 delete iDayNameArray; |
|
221 if( iNaviLabel ) |
|
222 { |
|
223 delete iNaviLabel; |
|
224 } |
|
225 |
|
226 |
|
227 |
|
228 TRACE_EXIT_POINT; |
|
229 } |
|
230 |
|
231 // ----------------------------------------------------------------------------- |
|
232 // ?classname::?member_function |
|
233 // ?implementation_description |
|
234 // (other items were commented in a header). |
|
235 // ----------------------------------------------------------------------------- |
|
236 // |
|
237 void CCalenStatusPaneUtilsImpl::SetTitleTextL( TDes& aText ) |
|
238 { |
|
239 TRACE_ENTRY_POINT; |
|
240 // In Arabic variant, month names are not displayed because there is no |
|
241 // universal way to represent months in Arabic market area. |
|
242 // Instead, Avkon.loc contains month numbers for month names. |
|
243 // They are defined as latin numbers. |
|
244 // We need to convert number to display digits (e.g. Arabic-Indic) |
|
245 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( aText ); |
|
246 TBool isOneRowTitle = iTitlePane->MaxNumberOfVisibleTextRows() == 1; |
|
247 if ( isOneRowTitle ) |
|
248 { |
|
249 ReplaceNewlines( aText ); |
|
250 } |
|
251 iTitlePane->SetTextL( aText ); |
|
252 |
|
253 TRACE_EXIT_POINT; |
|
254 } |
|
255 |
|
256 // ----------------------------------------------------------------------------- |
|
257 // ?classname::?member_function |
|
258 // ?implementation_description |
|
259 // (other items were commented in a header). |
|
260 // ----------------------------------------------------------------------------- |
|
261 // |
|
262 void CCalenStatusPaneUtilsImpl::SetTitleText( HBufC* aText ) |
|
263 { |
|
264 TRACE_ENTRY_POINT; |
|
265 // In Arabic variant, month names are not displayed because there is no |
|
266 // universal way to represent months in Arabic market area. |
|
267 // Instead, Avkon.loc contains month numbers for month names. |
|
268 // They are defined as latin numbers. |
|
269 // We need to convert number to display digits (e.g. Arabic-Indic) |
|
270 TPtr ptr( aText->Des() ); |
|
271 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr ); |
|
272 TBool isOneRowTitle = iTitlePane->MaxNumberOfVisibleTextRows() == 1; |
|
273 if ( isOneRowTitle ) |
|
274 { |
|
275 ReplaceNewlines( *aText ); |
|
276 } |
|
277 iTitlePane->SetText( aText ); |
|
278 |
|
279 TRACE_EXIT_POINT; |
|
280 } |
|
281 |
|
282 // ----------------------------------------------------------------------------- |
|
283 // ?classname::?member_function |
|
284 // ?implementation_description |
|
285 // (other items were commented in a header). |
|
286 // ----------------------------------------------------------------------------- |
|
287 // |
|
288 void CCalenStatusPaneUtilsImpl::UnderLineTitleText( TBool aUnderLine ) |
|
289 { |
|
290 TRACE_ENTRY_POINT; |
|
291 |
|
292 // Only CCalenTitlePane can SetUnderLine |
|
293 iTitlePane->SetUnderLine( aUnderLine ); |
|
294 |
|
295 TRACE_EXIT_POINT; |
|
296 } |
|
297 |
|
298 // ----------------------------------------------------------------------------- |
|
299 // ?classname::?member_function |
|
300 // ?implementation_description |
|
301 // (other items were commented in a header). |
|
302 // ----------------------------------------------------------------------------- |
|
303 // |
|
304 void CCalenStatusPaneUtilsImpl::MonthNameByActiveTime( TDes& name, const TTime& aTime ) |
|
305 { |
|
306 TRACE_ENTRY_POINT; |
|
307 |
|
308 name = (*iMonthArray)[aTime.DateTime().Month()]; |
|
309 |
|
310 TRACE_EXIT_POINT; |
|
311 } |
|
312 |
|
313 // ----------------------------------------------------------------------------- |
|
314 // ?classname::?member_function |
|
315 // ?implementation_description |
|
316 // (other items were commented in a header). |
|
317 // ----------------------------------------------------------------------------- |
|
318 // |
|
319 void CCalenStatusPaneUtilsImpl::DayNameByActiveTime( TDes& name, const TTime& aTime ) |
|
320 { |
|
321 TRACE_ENTRY_POINT; |
|
322 |
|
323 name = (*iDayNameArray)[aTime.DayNoInWeek()]; |
|
324 |
|
325 TRACE_EXIT_POINT |
|
326 } |
|
327 |
|
328 // ----------------------------------------------------------------------------- |
|
329 // ?classname::?member_function |
|
330 // ?implementation_description |
|
331 // (other items were commented in a header). |
|
332 // ----------------------------------------------------------------------------- |
|
333 // |
|
334 HBufC* CCalenStatusPaneUtilsImpl::WeekNameByActiveTimeL( const TTime& aTime, |
|
335 TDay aDayFormat, |
|
336 TCalenWeekTitle aType ) |
|
337 { |
|
338 TRACE_ENTRY_POINT; |
|
339 |
|
340 HBufC* firstRow = NULL; |
|
341 // Calculate first day of week |
|
342 TTime firstDay(aTime); |
|
343 TLocale locale; |
|
344 TInt column = aTime.DayNoInWeek() - locale.StartOfWeek(); |
|
345 if (column < 0) |
|
346 { |
|
347 column += KCalenDaysInWeek; |
|
348 } |
|
349 firstDay -= TTimeIntervalDays(column); |
|
350 |
|
351 // Decide what goes to first row |
|
352 // Week view duration is shown. |
|
353 if ( aDayFormat != EMonday || aType == EWeekTitleDuration) |
|
354 { |
|
355 TTime lastDay(firstDay + TTimeIntervalDays(KCalenDaysInWeek - 1)); |
|
356 |
|
357 CDesCArrayFlat* array = new(ELeave)CDesCArrayFlat(2); |
|
358 CleanupStack::PushL(array); |
|
359 TBuf<KWeekTitleSize> tmp; |
|
360 TBool isOneRowTitle = iTitlePane->MaxNumberOfVisibleTextRows() == 1; |
|
361 |
|
362 const TDesC& fmt = isOneRowTitle ? |
|
363 *iNoYearDateFormat : *iShortDateFormat; |
|
364 |
|
365 firstDay.FormatL(tmp, fmt ); |
|
366 AknTextUtils::DisplayTextLanguageSpecificNumberConversion(tmp); |
|
367 array->AppendL(tmp); |
|
368 |
|
369 lastDay.FormatL(tmp, fmt ); |
|
370 AknTextUtils::DisplayTextLanguageSpecificNumberConversion(tmp); |
|
371 array->AppendL(tmp); |
|
372 |
|
373 firstRow = StringLoader::LoadL( R_CALENDAR_WEEK_PERIOD_TITLE, *array ); |
|
374 CleanupStack::PopAndDestroy( array ); |
|
375 } |
|
376 // Week number is shown |
|
377 else |
|
378 { |
|
379 firstRow = StringLoader::LoadL( R_CALENDAR_WEEK_VIEW_TITLE, |
|
380 firstDay.WeekNoInYear() ); |
|
381 } |
|
382 |
|
383 TRACE_EXIT_POINT; |
|
384 return firstRow; |
|
385 } |
|
386 |
|
387 // ----------------------------------------------------------------------------- |
|
388 // ?classname::?member_function |
|
389 // ?implementation_description |
|
390 // (other items were commented in a header). |
|
391 // ----------------------------------------------------------------------------- |
|
392 // |
|
393 void CCalenStatusPaneUtilsImpl::RefreshStatusPane() |
|
394 { |
|
395 TRACE_ENTRY_POINT; |
|
396 |
|
397 iStatusPane->DrawNow(); |
|
398 |
|
399 TRACE_EXIT_POINT; |
|
400 } |
|
401 // End of file |