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