30
|
1 |
/*
|
|
2 |
* Copyright (c) 2002-2008 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 MonthView of the Calendar application.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
#include <Calendar.rsg>
|
|
22 |
#include <calenconstants.h>
|
|
23 |
#include <calendateutils.h>
|
|
24 |
#include <calenagendautils.h>
|
|
25 |
#include <calendar.mbg>
|
|
26 |
#include <csxhelp/cale.hlp.hrh>
|
|
27 |
#include <calencontext.h>
|
|
28 |
#include <aknlists.h>
|
|
29 |
#include <akntoolbar.h>
|
|
30 |
#include <gulicon.h>
|
|
31 |
#include <AknIconArray.h>
|
|
32 |
#include <AknsFrameBackgroundControlContext.h>
|
|
33 |
#include <calinstance.h>
|
|
34 |
#include <calinstanceview.h>
|
|
35 |
#include <calenservices.h>
|
|
36 |
#include <calenviewutils.h>
|
|
37 |
// Layouts
|
|
38 |
#include <aknlayoutscalable_apps.cdl.h>
|
|
39 |
#include <gesturehelper.h> //CGestureHelper
|
|
40 |
|
|
41 |
// INCLUDE FILES
|
|
42 |
#include "calenmonthcontainer.h"
|
|
43 |
#include "calencontroller.h"
|
|
44 |
#include "calencontainerlayoutmanager.h"
|
|
45 |
#include "calendrawutils.h"
|
|
46 |
#include "calenmonthconst.h"
|
|
47 |
#include "calenmonthgrid.h"
|
|
48 |
#include "calenmonthview.h"
|
|
49 |
#include "calenpreview.h"
|
|
50 |
#include "CalenUid.h"
|
|
51 |
#include "CleanupResetAndDestroy.h"
|
|
52 |
#include "CalenUid.h"
|
|
53 |
#include "calendar.hrh"
|
|
54 |
//debug
|
|
55 |
#include "calendarui_debug.h"
|
|
56 |
|
|
57 |
// LOCAL CONSTANTS AND MACROS
|
|
58 |
_LIT(KMonthCellFormat, "%F%*D\t");
|
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
// New line color groups in enhanced skinning
|
|
63 |
static void DrawLAFLine(CWindowGc& aGc, const TAknLayoutRect& aArea,
|
|
64 |
const TAknsItemID& aSkinComponent, TInt aColorGroup)
|
|
65 |
{
|
|
66 |
TRACE_ENTRY_POINT;
|
|
67 |
|
|
68 |
TRgb lineColor = aArea.Color();
|
|
69 |
AknsUtils::GetCachedColor(AknsUtils::SkinInstance(), lineColor,
|
|
70 |
aSkinComponent, aColorGroup);
|
|
71 |
aGc.SetBrushColor( lineColor );
|
|
72 |
aGc.SetBrushStyle( CGraphicsContext::ESolidBrush );
|
|
73 |
aGc.Clear( aArea.Rect() );
|
|
74 |
|
|
75 |
TRACE_EXIT_POINT;
|
|
76 |
}
|
|
77 |
|
|
78 |
// New line color groups in enhanced skinning
|
|
79 |
static void DrawPrimaryLine(CWindowGc& aGc, const TAknLayoutRect& aArea)
|
|
80 |
{
|
|
81 |
TRACE_ENTRY_POINT;
|
|
82 |
|
|
83 |
DrawLAFLine(aGc, aArea, KAknsIIDQsnLineColors, EAknsCIQsnLineColorsCG1);
|
|
84 |
|
|
85 |
TRACE_EXIT_POINT;
|
|
86 |
}
|
|
87 |
|
|
88 |
// ================= MEMBER FUNCTIONS =======================
|
|
89 |
|
|
90 |
// ----------------------------------------------------------------------------
|
|
91 |
// CCalenMonthContainer::CCalenMonthContainer
|
|
92 |
// C++ default constructor can NOT contain any code, that might leave.
|
|
93 |
// (other items were commented in a header).
|
|
94 |
// ----------------------------------------------------------------------------
|
|
95 |
//
|
|
96 |
CCalenMonthContainer::CCalenMonthContainer( CCalenNativeView* aView,
|
|
97 |
TTime& aDate,
|
|
98 |
MCalenServices& aServices )
|
|
99 |
: CCalenContainer( aView, aServices ),
|
|
100 |
iDate( aDate )
|
|
101 |
{
|
|
102 |
TRACE_ENTRY_POINT;
|
|
103 |
TRACE_EXIT_POINT;
|
|
104 |
}
|
|
105 |
|
|
106 |
// ----------------------------------------------------------------------------
|
|
107 |
// CCalenMonthContainer::~CCalenMonthContainer
|
|
108 |
// Destructor
|
|
109 |
// (other items were commented in a header).
|
|
110 |
// ----------------------------------------------------------------------------
|
|
111 |
//
|
|
112 |
CCalenMonthContainer::~CCalenMonthContainer()
|
|
113 |
{
|
|
114 |
TRACE_ENTRY_POINT;
|
|
115 |
|
|
116 |
delete iGrid;
|
|
117 |
delete iMonthDataArray;
|
|
118 |
delete iBackgroundSkinContext;
|
|
119 |
delete iGestureControl;
|
|
120 |
|
|
121 |
TRACE_EXIT_POINT;
|
|
122 |
}
|
|
123 |
|
|
124 |
// ----------------------------------------------------------------------------
|
|
125 |
// CCalenMonthContainer::ChangesMidnightCrossover
|
|
126 |
// Called when Midnight cross over
|
|
127 |
// (other items were commented in a header).
|
|
128 |
// ----------------------------------------------------------------------------
|
|
129 |
//
|
|
130 |
void CCalenMonthContainer::ChangesMidnightCrossover()
|
|
131 |
{
|
|
132 |
TRACE_ENTRY_POINT;
|
|
133 |
|
|
134 |
TTime baseTime( TInt64(0) );
|
|
135 |
TTime today = CalenDateUtils::Today();
|
|
136 |
TTimeIntervalDays daysToToday( today.DaysFrom( baseTime ) );
|
|
137 |
TTimeIntervalDays daysToGridStart( iFirstDayOfGrid.DaysFrom( baseTime ) );
|
|
138 |
TInt dataIndex( daysToToday.Int() -daysToGridStart.Int() );
|
|
139 |
TInt listBoxIndex( 0 );
|
|
140 |
|
|
141 |
if( dataIndex >= 0 && dataIndex < KNumberOfRows * KCalenDaysInWeek )
|
|
142 |
{
|
|
143 |
listBoxIndex = static_cast<CAknGridView*>( iGrid->View() )->ListBoxIndex( dataIndex );
|
|
144 |
iGrid->View()->DrawItem( listBoxIndex );
|
|
145 |
}
|
|
146 |
|
|
147 |
dataIndex--;
|
|
148 |
|
|
149 |
if( dataIndex >= 0 && dataIndex < KNumberOfRows * KCalenDaysInWeek )
|
|
150 |
{
|
|
151 |
listBoxIndex = static_cast<CAknGridView*>( iGrid->View() )->ListBoxIndex( dataIndex );
|
|
152 |
iGrid->View()->DrawItem( listBoxIndex );
|
|
153 |
}
|
|
154 |
|
|
155 |
TRACE_EXIT_POINT;
|
|
156 |
}
|
|
157 |
|
|
158 |
// ----------------------------------------------------------------------------
|
|
159 |
// CCalenMonthContainer::SetDataL
|
|
160 |
// Set data from beginning.
|
|
161 |
// ----------------------------------------------------------------------------
|
|
162 |
//
|
|
163 |
void CCalenMonthContainer::InitDataForMonthL()
|
|
164 |
{
|
|
165 |
TRACE_ENTRY_POINT;
|
|
166 |
|
|
167 |
SetActiveDayL( CCalenContainer::DateFromContextL( iServices.Context() ) );
|
|
168 |
iView->BeginRepopulationL();
|
|
169 |
TRACE_EXIT_POINT;
|
|
170 |
}
|
|
171 |
|
|
172 |
// ----------------------------------------------------------------------------
|
|
173 |
// CCalenMonthContainer::SetActiveDayL
|
|
174 |
// Set iDate to argument's aDay,
|
|
175 |
// (other items were commented in a header).
|
|
176 |
// ----------------------------------------------------------------------------
|
|
177 |
//
|
|
178 |
void CCalenMonthContainer::SetActiveDayL(TTime aDay)
|
|
179 |
{
|
|
180 |
TRACE_ENTRY_POINT;
|
|
181 |
|
|
182 |
// test
|
|
183 |
TDateTime aDayTime = aDay.DateTime();
|
|
184 |
iDate = aDay;
|
|
185 |
TLocale locale;
|
|
186 |
|
|
187 |
// day number of iDate in month
|
|
188 |
TInt dayNumberOfCurrentDay( iDate.DayNoInMonth() );
|
|
189 |
// 1th of month of iDate
|
|
190 |
TTime firstDay( iDate - TTimeIntervalDays(dayNumberOfCurrentDay) );
|
|
191 |
TInt firstDayNoInWeek(firstDay.DayNoInWeek() - locale.StartOfWeek());
|
|
192 |
if (firstDayNoInWeek < 0)
|
|
193 |
{
|
|
194 |
firstDayNoInWeek += KCalenDaysInWeek;
|
|
195 |
}
|
|
196 |
|
|
197 |
iFirstDayOfGrid = firstDay - TTimeIntervalDays(firstDayNoInWeek);
|
|
198 |
|
|
199 |
//test
|
|
200 |
TDateTime firstDayOfGrid = iFirstDayOfGrid.DateTime();
|
|
201 |
|
|
202 |
iGrid->SetFirstDayOfGrid(iFirstDayOfGrid);
|
|
203 |
|
|
204 |
TRACE_EXIT_POINT;
|
|
205 |
}
|
|
206 |
|
|
207 |
// ----------------------------------------------------------------------------
|
|
208 |
// CCalenMonthContainer::DayOfIndex
|
|
209 |
// Return a day from Grid index
|
|
210 |
// (other items were commented in a header).
|
|
211 |
// ----------------------------------------------------------------------------
|
|
212 |
//
|
|
213 |
TTime CCalenMonthContainer::DayOfIndex(TInt aIndex)
|
|
214 |
{
|
|
215 |
TRACE_ENTRY_POINT;
|
|
216 |
|
|
217 |
TRACE_EXIT_POINT;
|
|
218 |
return iFirstDayOfGrid + TTimeIntervalDays(aIndex);
|
|
219 |
}
|
|
220 |
|
|
221 |
// ----------------------------------------------------------------------------
|
|
222 |
// CCalenMonthContainer::SetCursorToActiveDay
|
|
223 |
// Sets cursor to Active day
|
|
224 |
// (other items were commented in a header).
|
|
225 |
// ----------------------------------------------------------------------------
|
|
226 |
//
|
|
227 |
void CCalenMonthContainer::SetCursorToActiveDay()
|
|
228 |
{
|
|
229 |
TRACE_ENTRY_POINT;
|
|
230 |
|
|
231 |
TTimeIntervalDays intervalDays( iDate.DaysFrom( iFirstDayOfGrid ) );
|
|
232 |
TInt index = static_cast<CAknGridView*>( iGrid->View() )->ListBoxIndex( intervalDays.Int() );
|
|
233 |
iGrid->SetCurrentItemIndex(index);
|
|
234 |
|
|
235 |
TRACE_EXIT_POINT;
|
|
236 |
}
|
|
237 |
|
|
238 |
// ----------------------------------------------------------------------------
|
|
239 |
// CCalenMonthContainer::ApplySelGridGraphicStyleL
|
|
240 |
// Month grid cells setup method
|
|
241 |
// (other items were commented in a header).
|
|
242 |
// ----------------------------------------------------------------------------
|
|
243 |
// FIXME: this should be renamed
|
|
244 |
void CCalenMonthContainer::ApplySelGridGraphicStyleL(CAknGrid& aListBox)
|
|
245 |
{
|
|
246 |
TRACE_ENTRY_POINT;
|
|
247 |
|
|
248 |
// Setup subcells of grid.
|
|
249 |
//
|
|
250 |
// Subcell index | type | purpose
|
|
251 |
// 0 | text cell | day number
|
|
252 |
// 1 | graphics | triangle icon
|
|
253 |
const TInt KDayNumberSubcell = 0;
|
|
254 |
const TInt KTriangleIconSubcell = 1;
|
|
255 |
|
|
256 |
TRect main_pane( ReducePreview( Rect() ) );
|
|
257 |
|
|
258 |
TAknLayoutRect main_cale_month_pane;
|
|
259 |
TInt layoutVariant = LayoutVariantIndex( EMainCaleMonthPane );
|
|
260 |
main_cale_month_pane.LayoutRect( main_pane, AknLayoutScalable_Apps::main_cale_month_pane(layoutVariant).LayoutLine() );
|
|
261 |
|
|
262 |
// Layout variant index to Table 4.38 Main cale month pane contents.
|
|
263 |
TAknLayoutRect grid_cale_month_pane, cell_cale_month_pane;
|
|
264 |
layoutVariant = LayoutVariantIndex( EGridCaleMonthPane );
|
|
265 |
grid_cale_month_pane.LayoutRect( main_cale_month_pane.Rect(), AknLayoutScalable_Apps::grid_cale_month_pane( layoutVariant ).LayoutLine() );
|
|
266 |
|
|
267 |
TRect tmpRect = grid_cale_month_pane.Rect();
|
|
268 |
//tmpRect.iTl.iY -= 10;
|
|
269 |
layoutVariant = LayoutVariantIndex( ECellCaleMonthPane );
|
|
270 |
cell_cale_month_pane.LayoutRect( tmpRect /*grid_cale_month_pane.Rect()*/, AknLayoutScalable_Apps::cell_cale_month_pane( layoutVariant, 0, 0 ).LayoutLine() );
|
|
271 |
|
|
272 |
// cellRect for AknListBoxLayouts functions has to be _inside_ cell rect,
|
|
273 |
// so we take only size to make origin to be (0,0)
|
|
274 |
TRect cellRect(cell_cale_month_pane.Rect().Size());
|
|
275 |
layoutVariant = LayoutVariantIndex( ECellCaleMonthPaneT1 );
|
|
276 |
|
|
277 |
// Setup day number text cell
|
|
278 |
AknListBoxLayouts::SetupFormTextCell( aListBox,
|
|
279 |
aListBox.ItemDrawer(),
|
|
280 |
KDayNumberSubcell,
|
|
281 |
AknLayoutScalable_Apps::cell_cale_month_pane_t1( layoutVariant ).LayoutLine(),
|
|
282 |
cellRect.iTl,
|
|
283 |
cellRect.iBr );
|
|
284 |
|
|
285 |
// Setup triangle icons
|
|
286 |
TAknLayoutRect cell_cale_month_pane_g1;
|
|
287 |
layoutVariant = LayoutVariantIndex( ECellCaleMonthPaneG1 );
|
|
288 |
// Note: we pass cellRect as parent, not cell_cale_month_pane.Rect(), because AknListbox subcell layouting expect cell origin to be 0,0
|
|
289 |
cell_cale_month_pane_g1.LayoutRect( cellRect, AknLayoutScalable_Apps::cell_cale_month_pane_g1(layoutVariant).LayoutLine() ); // <CDL LAYOUT>
|
|
290 |
TRect triangleRect = cell_cale_month_pane_g1.Rect();
|
|
291 |
|
|
292 |
SetupSelgridFormBitmapCellL( aListBox, KTriangleIconSubcell, triangleRect.iTl, triangleRect.Size() );
|
|
293 |
CalenDrawUtils::SetIconSizes( cell_cale_month_pane_g1, iGrid->ItemDrawer()->FormattedCellData()->IconArray() );
|
|
294 |
|
|
295 |
TRACE_EXIT_POINT;
|
|
296 |
}
|
|
297 |
|
|
298 |
// ----------------------------------------------------------------------------
|
|
299 |
// CCalenMonthContainer::ChangeMonthL
|
|
300 |
// Change Active Day and Data.
|
|
301 |
// (other items were commented in a header).
|
|
302 |
// ----------------------------------------------------------------------------
|
|
303 |
//
|
|
304 |
void CCalenMonthContainer::ChangeMonthL()
|
|
305 |
{
|
|
306 |
TRACE_ENTRY_POINT;
|
|
307 |
|
|
308 |
// Call diable redraw right before view repopulation starts to
|
|
309 |
// prevent flashing focus on cell
|
|
310 |
iGrid->View()->SetDisableRedraw( ETrue );
|
|
311 |
iView->BeginRepopulationL();
|
|
312 |
// FIXME: Examine if SetCursorToActiveDay is needed for all cases, where
|
|
313 |
// InitDataForMonthL or SetActiveDayL is called
|
|
314 |
// Hide/unhide "today" toolbar item based on the focused day
|
|
315 |
UpdateTodayToolbarItemL();
|
|
316 |
|
|
317 |
TRACE_EXIT_POINT;
|
|
318 |
}
|
|
319 |
|
|
320 |
// ----------------------------------------------------------------------------
|
|
321 |
// CCalenMonthContainer::SetupSelgridFormBitmapCellL
|
|
322 |
// Icon column setting for CAknGrid
|
|
323 |
// (other items were commented in a header).
|
|
324 |
// ----------------------------------------------------------------------------
|
|
325 |
//
|
|
326 |
void CCalenMonthContainer::SetupSelgridFormBitmapCellL( CAknGrid& aListBox,
|
|
327 |
TInt aIndex,
|
|
328 |
TPoint aP1,
|
|
329 |
TSize aSize )
|
|
330 |
{
|
|
331 |
TRACE_ENTRY_POINT;
|
|
332 |
|
|
333 |
CFormattedCellListBoxData* cellData =
|
|
334 |
aListBox.ItemDrawer()->FormattedCellData();
|
|
335 |
|
|
336 |
cellData->SetGraphicsSubCellL(aIndex,ETrue);
|
|
337 |
cellData->SetSubCellPositionL(aIndex, aP1);
|
|
338 |
cellData->SetSubCellSizeL(aIndex, aSize);
|
|
339 |
cellData->SetSubCellAlignmentL(aIndex, CGraphicsContext::ECenter);
|
|
340 |
|
|
341 |
TRACE_EXIT_POINT;
|
|
342 |
}
|
|
343 |
|
|
344 |
// ----------------------------------------------------------------------------
|
|
345 |
// CCalenMonthContainer::DrawColLabel
|
|
346 |
// Drawing days of the week.
|
|
347 |
// (other items were commented in a header).
|
|
348 |
// ----------------------------------------------------------------------------
|
|
349 |
//
|
|
350 |
void CCalenMonthContainer::DrawColLabel( CWindowGc& aGc, TBool /*aUseWeeks*/ ) const
|
|
351 |
{
|
|
352 |
TRACE_ENTRY_POINT;
|
|
353 |
|
|
354 |
TRect main_pane( ReducePreview( Rect() ) );
|
|
355 |
|
|
356 |
TAknLayoutRect cale_month_day_heading_pane;
|
|
357 |
TAknLayoutRect main_cale_month_pane;
|
|
358 |
TInt layoutVariant = LayoutVariantIndex( EMainCaleMonthPane );
|
|
359 |
main_cale_month_pane.LayoutRect( main_pane, AknLayoutScalable_Apps::main_cale_month_pane(layoutVariant).LayoutLine() );
|
|
360 |
|
|
361 |
layoutVariant = LayoutVariantIndex( ECaleMonthDayHeadingPane );
|
|
362 |
cale_month_day_heading_pane.LayoutRect( main_cale_month_pane.Rect(), AknLayoutScalable_Apps::cale_month_day_heading_pane( layoutVariant ).LayoutLine() );
|
|
363 |
TRect tmpRect = cale_month_day_heading_pane.Rect();
|
|
364 |
|
|
365 |
// Draw weekday names
|
|
366 |
TLocale locale;
|
|
367 |
aGc.SetBrushStyle( CGraphicsContext::ENullBrush );
|
|
368 |
TAknLayoutText layoutText;
|
|
369 |
TRgb textColor;
|
|
370 |
MAknsSkinInstance* skinInst = AknsUtils::SkinInstance();
|
|
371 |
TRect parent( main_pane );
|
|
372 |
|
|
373 |
TAknLayoutScalableTableLimits limits = AknLayoutScalable_Apps::cale_month_day_heading_pane_t_Limits();
|
|
374 |
TInt index = limits.FirstIndex();
|
|
375 |
TInt end = limits.LastIndex() +1;
|
|
376 |
TRect parentRect = tmpRect /*cale_month_day_heading_pane.Rect()*/;
|
|
377 |
|
|
378 |
for( ; index < end; ++index )
|
|
379 |
{
|
|
380 |
// Calculate day number of week
|
|
381 |
TInt dayNoInWeek( index + locale.StartOfWeek() );
|
|
382 |
if (dayNoInWeek >= KCalenDaysInWeek)
|
|
383 |
{
|
|
384 |
dayNoInWeek -= KCalenDaysInWeek;
|
|
385 |
}
|
|
386 |
|
|
387 |
// Layout
|
|
388 |
layoutVariant = LayoutVariantIndex( ECaleMonthDayHeadingPaneT );
|
|
389 |
layoutText.LayoutText( parentRect, AknLayoutScalable_Apps::cale_month_day_heading_pane_t( index, layoutVariant ).LayoutLine() );
|
|
390 |
|
|
391 |
// Get colors
|
|
392 |
textColor = layoutText.Color();
|
|
393 |
AknsUtils::GetCachedColor( skinInst, textColor,
|
|
394 |
KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG23);
|
|
395 |
|
|
396 |
TRAPD(error,
|
|
397 |
const CDesCArrayFlat& abbArray = MonthView().AbbreviatedDayArrayL();
|
|
398 |
// Draw correct week day name
|
|
399 |
layoutText.DrawText( aGc,
|
|
400 |
abbArray[dayNoInWeek],
|
|
401 |
ETrue,
|
|
402 |
textColor );
|
|
403 |
);
|
|
404 |
if(error!=KErrNone)
|
|
405 |
{
|
|
406 |
// Do nothing to avoid warning
|
|
407 |
}
|
|
408 |
}
|
|
409 |
|
|
410 |
TRACE_EXIT_POINT;
|
|
411 |
}
|
|
412 |
|
|
413 |
// ----------------------------------------------------------------------------
|
|
414 |
// CCalenMonthContainer::DrawRowLabel
|
|
415 |
// Drawing week numbers.
|
|
416 |
// (other items were commented in a header).
|
|
417 |
// ----------------------------------------------------------------------------
|
|
418 |
//
|
|
419 |
void CCalenMonthContainer::DrawRowLabel( CWindowGc& aGc ) const
|
|
420 |
{
|
|
421 |
TRACE_ENTRY_POINT;
|
|
422 |
|
|
423 |
TRect main_pane( ReducePreview( Rect() ) );
|
|
424 |
|
|
425 |
TAknLayoutRect main_cale_month_pane;
|
|
426 |
TInt layoutVariant = LayoutVariantIndex( EMainCaleMonthPane );
|
|
427 |
main_cale_month_pane.LayoutRect( main_pane, AknLayoutScalable_Apps::main_cale_month_pane(layoutVariant).LayoutLine() );
|
|
428 |
|
|
429 |
MAknsSkinInstance* skinInst = AknsUtils::SkinInstance();
|
|
430 |
|
|
431 |
// clear week number area
|
|
432 |
TRect weekArea;
|
|
433 |
|
|
434 |
// Side (week) pane layout
|
|
435 |
TAknLayoutRect cale_month_week_pane;
|
|
436 |
layoutVariant = LayoutVariantIndex( ECaleMonthWeekPane );
|
|
437 |
cale_month_week_pane.LayoutRect( main_cale_month_pane.Rect(), AknLayoutScalable_Apps::cale_month_week_pane( layoutVariant ).LayoutLine() );
|
|
438 |
|
|
439 |
AknsDrawUtils::Background( skinInst, AknsDrawUtils::ControlContext( this ), NULL, aGc,
|
|
440 |
cale_month_week_pane.Rect(), KAknsDrawParamNoClearUnderImage );
|
|
441 |
|
|
442 |
TAknLayoutText weekNumberLayout;
|
|
443 |
|
|
444 |
TAknLayoutScalableTableLimits cale_month_week_pane_t_Limits = AknLayoutScalable_Apps::cale_month_week_pane_t_Limits();
|
|
445 |
TInt first = cale_month_week_pane_t_Limits.FirstIndex();
|
|
446 |
TInt last = cale_month_week_pane_t_Limits.LastIndex();
|
|
447 |
|
|
448 |
for ( TInt i = first; i <= last; ++i )
|
|
449 |
{
|
|
450 |
// Calculate week number
|
|
451 |
TTime currentWeek( iFirstDayOfGrid + TTimeIntervalDays( KCalenDaysInWeek * i) );
|
|
452 |
TInt64 weekNumber( currentWeek.WeekNoInYear() );
|
|
453 |
|
|
454 |
// Visual stirng
|
|
455 |
TBuf<3> weekNumberBuffer;
|
|
456 |
weekNumberBuffer.Num( weekNumber );
|
|
457 |
AknTextUtils::DisplayTextLanguageSpecificNumberConversion( weekNumberBuffer );
|
|
458 |
|
|
459 |
// Layout
|
|
460 |
layoutVariant = LayoutVariantIndex( ECaleMonthWeekPaneT);
|
|
461 |
weekNumberLayout.LayoutText( cale_month_week_pane.Rect(), AknLayoutScalable_Apps::cale_month_week_pane_t( i, layoutVariant ).LayoutLine() );
|
|
462 |
|
|
463 |
|
|
464 |
// Decide color
|
|
465 |
TRgb textColor = weekNumberLayout.Color();
|
|
466 |
AknsUtils::GetCachedColor( skinInst, textColor,
|
|
467 |
KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG23);
|
|
468 |
|
|
469 |
weekNumberLayout.DrawText( aGc, weekNumberBuffer, ETrue, textColor );
|
|
470 |
}
|
|
471 |
|
|
472 |
TRACE_EXIT_POINT;
|
|
473 |
}
|
|
474 |
|
|
475 |
// ----------------------------------------------------------------------------
|
|
476 |
// CCalenMonthContainer::SetDateL
|
|
477 |
// Set Date(1-28,29,30,31) to iMonthDataArray.
|
|
478 |
// (other items were commented in a header).
|
|
479 |
// ----------------------------------------------------------------------------
|
|
480 |
//
|
|
481 |
void CCalenMonthContainer::SetDateL()
|
|
482 |
{
|
|
483 |
TRACE_ENTRY_POINT;
|
|
484 |
|
|
485 |
iMonthDataArray->Reset();
|
|
486 |
for (TInt i(0); i < KNumberOfRows * KCalenDaysInWeek; ++i)
|
|
487 |
{
|
|
488 |
TTime currentDay(iFirstDayOfGrid + TTimeIntervalDays(i));
|
|
489 |
TCalenMonthData element(currentDay);
|
|
490 |
iMonthDataArray->InsertL(i, element);
|
|
491 |
}
|
|
492 |
|
|
493 |
TRACE_EXIT_POINT;
|
|
494 |
}
|
|
495 |
|
|
496 |
// ----------------------------------------------------------------------------
|
|
497 |
// CCalenMonthContainer::HandleDayChangeL
|
|
498 |
// (other items were commented in a header).
|
|
499 |
// ----------------------------------------------------------------------------
|
|
500 |
//
|
|
501 |
void CCalenMonthContainer::HandleDayChangeL( TTime aNewActiveDay )
|
|
502 |
{
|
|
503 |
TRACE_ENTRY_POINT;
|
|
504 |
|
|
505 |
SetActiveDayL( aNewActiveDay );
|
|
506 |
|
|
507 |
// dont focus the preview popup/previewpane if any dialog or faster app is active
|
|
508 |
if( iPreview && !iView->IsEditorActiveOrFasterAppExit())
|
|
509 |
{
|
|
510 |
iPreview->FocusChangedL( aNewActiveDay );
|
|
511 |
}
|
|
512 |
|
|
513 |
UpdateStatusPaneAndExtensionsL();
|
|
514 |
// Hide/unhide "today" toolbar item based on the focused day
|
|
515 |
UpdateTodayToolbarItemL();
|
|
516 |
|
|
517 |
TRACE_EXIT_POINT;
|
|
518 |
}
|
|
519 |
|
|
520 |
// ----------------------------------------------------------------------------
|
|
521 |
// CCalenMonthContainer::NotifyChangeDateL
|
|
522 |
// Date change operation notification handler.
|
|
523 |
// (other items were commented in a header).
|
|
524 |
// ----------------------------------------------------------------------------
|
|
525 |
//
|
|
526 |
void CCalenMonthContainer::NotifyChangeDateL()
|
|
527 |
{
|
|
528 |
TRACE_ENTRY_POINT;
|
|
529 |
|
|
530 |
TTime newActiveDay = iServices.Context().FocusDateAndTimeL().TimeLocalL();
|
|
531 |
|
|
532 |
//test
|
|
533 |
TDateTime newActiveDayTime = newActiveDay.DateTime();
|
|
534 |
if ( CalenDateUtils::OnSameMonth( iDate, newActiveDay ) )
|
|
535 |
{
|
|
536 |
HandleDayChangeL(newActiveDay);
|
|
537 |
SetCursorToActiveDay();
|
|
538 |
// Changed DrawDeferred to Invalidate
|
|
539 |
Window().Invalidate();
|
|
540 |
}
|
|
541 |
else
|
|
542 |
{
|
|
543 |
iGrid->View()->SetDisableRedraw( ETrue );
|
|
544 |
iView->BeginRepopulationL();
|
|
545 |
}
|
|
546 |
|
|
547 |
// Hide/unhide "today" toolbar item based on the focused day
|
|
548 |
UpdateTodayToolbarItemL();
|
|
549 |
TRACE_EXIT_POINT;
|
|
550 |
}
|
|
551 |
|
|
552 |
// ----------------------------------------------------------------------------
|
|
553 |
// CCalenMonthContainer::CountComponentControls
|
|
554 |
// return number of components
|
|
555 |
// ----------------------------------------------------------------------------
|
|
556 |
TInt CCalenMonthContainer::CountComponentControls() const
|
|
557 |
{
|
|
558 |
TRACE_ENTRY_POINT;
|
|
559 |
|
|
560 |
TInt controlCount;
|
|
561 |
|
|
562 |
if ( iLayoutManager->ControlOrNull() )
|
|
563 |
{
|
|
564 |
controlCount = 2;
|
|
565 |
}
|
|
566 |
else
|
|
567 |
{
|
|
568 |
controlCount = 1;
|
|
569 |
}
|
|
570 |
|
|
571 |
TRACE_EXIT_POINT;
|
|
572 |
return controlCount;
|
|
573 |
}
|
|
574 |
|
|
575 |
// ----------------------------------------------------------------------------
|
|
576 |
// CCalenMonthContainer::ComponentControl
|
|
577 |
// retrun the component specified by aIndex
|
|
578 |
// (other items were commented in a header).
|
|
579 |
// ----------------------------------------------------------------------------
|
|
580 |
//
|
|
581 |
CCoeControl* CCalenMonthContainer::ComponentControl(TInt aIndex) const
|
|
582 |
{
|
|
583 |
TRACE_ENTRY_POINT;
|
|
584 |
|
|
585 |
CCoeControl* control( NULL );
|
|
586 |
|
|
587 |
switch (aIndex)
|
|
588 |
{
|
|
589 |
case 0:
|
|
590 |
control = iGrid;
|
|
591 |
break;
|
|
592 |
|
|
593 |
case 1:
|
|
594 |
control = iLayoutManager->ControlOrNull();
|
|
595 |
break;
|
|
596 |
|
|
597 |
default:
|
|
598 |
__ASSERT_DEBUG( 0, User::Invariant() );
|
|
599 |
break;
|
|
600 |
}
|
|
601 |
|
|
602 |
TRACE_EXIT_POINT;
|
|
603 |
return control;
|
|
604 |
}
|
|
605 |
|
|
606 |
// ----------------------------------------------------------------------------
|
|
607 |
// CCalenMonthContainer::OfferKeyEventL
|
|
608 |
// processing of a key event
|
|
609 |
// (other items were commented in a header).
|
|
610 |
// ----------------------------------------------------------------------------
|
|
611 |
//
|
|
612 |
TKeyResponse CCalenMonthContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent,
|
|
613 |
TEventCode aType )
|
|
614 |
{
|
|
615 |
TRACE_ENTRY_POINT;
|
|
616 |
|
|
617 |
if (iPreview && aType == EEventKeyDown)
|
|
618 |
{
|
|
619 |
iPreview->Hide();
|
|
620 |
}
|
|
621 |
|
|
622 |
// Common view key handling - view switching etc.
|
|
623 |
TKeyResponse exitCode( EKeyWasNotConsumed );
|
|
624 |
|
|
625 |
exitCode = CCalenContainer::OfferKeyEventL( aKeyEvent, aType );
|
|
626 |
|
|
627 |
|
|
628 |
if ( exitCode == EKeyWasNotConsumed && aType == EEventKey )
|
|
629 |
{
|
|
630 |
switch (aKeyEvent.iCode)
|
|
631 |
{
|
|
632 |
case EKeyOK:
|
|
633 |
{
|
|
634 |
iServices.IssueCommandL( ECalenForwardsToDayView );
|
|
635 |
exitCode = EKeyWasConsumed;
|
|
636 |
}
|
|
637 |
break;
|
|
638 |
case EKeyEnter:
|
|
639 |
{
|
|
640 |
iView->HandleCommandL(EAknSoftkeyOpen);
|
|
641 |
exitCode = EKeyWasConsumed;
|
|
642 |
}
|
|
643 |
break;
|
|
644 |
case EKeyUpArrow: /* fall through... */
|
|
645 |
case EKeyDownArrow: /* fall through... */
|
|
646 |
case EKeyRightArrow: /* fall through... */
|
|
647 |
case EKeyLeftArrow:
|
|
648 |
#ifdef SUPPORT_NAVISCROLL_EVENTS
|
|
649 |
case EKeyNext:
|
|
650 |
case EKeyPrevious:
|
|
651 |
#endif
|
|
652 |
{
|
|
653 |
// Update the view's data.
|
|
654 |
exitCode = HandleAttemptToMoveL( aKeyEvent.iCode );
|
|
655 |
}
|
|
656 |
break;
|
|
657 |
default:
|
|
658 |
break;
|
|
659 |
}
|
|
660 |
}
|
|
661 |
|
|
662 |
|
|
663 |
// grid key handling
|
|
664 |
if (exitCode == EKeyWasConsumed || !iGrid)
|
|
665 |
{
|
|
666 |
// do nothing
|
|
667 |
}
|
|
668 |
else
|
|
669 |
{
|
|
670 |
// Attempt to move the highlight of the AknGrid.
|
|
671 |
TInt oldIndex( iGrid->CurrentItemIndex() );
|
|
672 |
CAknGridM* gridModel = static_cast<CAknGridM*>( iGrid->Model() );
|
|
673 |
if ( gridModel->NumberOfData() != 0 )
|
|
674 |
{
|
|
675 |
exitCode = iGrid->OfferKeyEventL(aKeyEvent, aType);
|
|
676 |
}
|
|
677 |
|
|
678 |
|
|
679 |
if (exitCode == EKeyWasConsumed)
|
|
680 |
{
|
|
681 |
TInt newIndex(iGrid->CurrentItemIndex());
|
|
682 |
if (oldIndex != newIndex)
|
|
683 |
{
|
|
684 |
TInt gridIndex = GridIndex();
|
|
685 |
TTime newActiveDay(iFirstDayOfGrid +
|
|
686 |
TTimeIntervalDays(gridIndex));
|
|
687 |
HandleDayChangeL(newActiveDay);
|
|
688 |
}
|
|
689 |
}
|
|
690 |
}
|
|
691 |
|
|
692 |
|
|
693 |
TRACE_EXIT_POINT;
|
|
694 |
return exitCode;
|
|
695 |
}
|
|
696 |
|
|
697 |
// ----------------------------------------------------------------------------
|
|
698 |
// CCalenMonthContainer::HandleAttemptToMoveL
|
|
699 |
// Try to move by the given amount of days.
|
|
700 |
// (other items were commented in a header).
|
|
701 |
// ----------------------------------------------------------------------------
|
|
702 |
//
|
|
703 |
TKeyResponse CCalenMonthContainer::HandleAttemptToMoveL( TUint aKeyCode )
|
|
704 |
{
|
|
705 |
TRACE_ENTRY_POINT;
|
|
706 |
|
|
707 |
const TBool mirrored( AknLayoutUtils::LayoutMirrored() );
|
|
708 |
TInt intervalDays( 0 );
|
|
709 |
switch( aKeyCode )
|
|
710 |
{
|
|
711 |
case EKeyUpArrow:
|
|
712 |
intervalDays = -KCalenDaysInWeek;
|
|
713 |
break;
|
|
714 |
case EKeyDownArrow:
|
|
715 |
intervalDays = KCalenDaysInWeek;
|
|
716 |
break;
|
|
717 |
case EKeyRightArrow:
|
|
718 |
intervalDays = mirrored ? -1 : 1;
|
|
719 |
break;
|
|
720 |
case EKeyLeftArrow:
|
|
721 |
intervalDays = mirrored ? 1 : -1;
|
|
722 |
break;
|
|
723 |
default:
|
|
724 |
ASSERT( EFalse );
|
|
725 |
break;
|
|
726 |
}
|
|
727 |
|
|
728 |
TTime newDay( iDate + TTimeIntervalDays( intervalDays ) );
|
|
729 |
|
|
730 |
if ( !CalenDateUtils::IsValidDay( newDay ) )
|
|
731 |
{
|
|
732 |
CalenViewUtils::ShowDateOutOfRangeErrorNoteL();
|
|
733 |
|
|
734 |
TRACE_EXIT_POINT;
|
|
735 |
return EKeyWasConsumed;
|
|
736 |
}
|
|
737 |
// test
|
|
738 |
TDateTime newDayTime = newDay.DateTime();
|
|
739 |
TCalTime time;
|
|
740 |
time.SetTimeLocalL( newDay );
|
|
741 |
iServices.Context().SetFocusDateL( time,
|
|
742 |
TVwsViewId( KUidCalendar, KUidCalenMonthView ) );
|
|
743 |
|
|
744 |
// Check to see if we go over a month boundary.
|
|
745 |
TMonth activeMonth( iDate.DateTime().Month() );
|
|
746 |
TMonth newMonth( newDay.DateTime().Month() );
|
|
747 |
if ( activeMonth != newMonth )
|
|
748 |
{
|
|
749 |
ChangeMonthL();
|
|
750 |
TRACE_EXIT_POINT;
|
|
751 |
return EKeyWasConsumed;
|
|
752 |
}
|
|
753 |
|
|
754 |
TRACE_EXIT_POINT;
|
|
755 |
return EKeyWasNotConsumed;
|
|
756 |
}
|
|
757 |
|
|
758 |
// ----------------------------------------------------------------------------
|
|
759 |
// CCalenMonthContainer::Draw
|
|
760 |
// drawing month view
|
|
761 |
// (other items were commented in a header).
|
|
762 |
// ----------------------------------------------------------------------------
|
|
763 |
//
|
|
764 |
void CCalenMonthContainer::Draw(const TRect& /*aRect*/) const
|
|
765 |
{
|
|
766 |
TRACE_ENTRY_POINT;
|
|
767 |
|
|
768 |
const TBool useWeeks( UseWeeks() );
|
|
769 |
|
|
770 |
CWindowGc& gc = SystemGc();
|
|
771 |
TAknLayoutRect area;
|
|
772 |
MAknsSkinInstance* skinInst = AknsUtils::SkinInstance();
|
|
773 |
|
|
774 |
TRect main_pane( ReducePreview( Rect() ) );
|
|
775 |
|
|
776 |
|
|
777 |
MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
|
|
778 |
AknsDrawUtils::Background( skinInst,
|
|
779 |
cc,
|
|
780 |
NULL,
|
|
781 |
gc,
|
|
782 |
Rect()
|
|
783 |
);
|
|
784 |
|
|
785 |
gc.SetPenStyle( CGraphicsContext::ENullPen );
|
|
786 |
gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
|
|
787 |
|
|
788 |
|
|
789 |
// Draw week & day name separator lines
|
|
790 |
|
|
791 |
|
|
792 |
TAknLayoutRect main_cale_month_pane;
|
|
793 |
TInt layoutVariant = LayoutVariantIndex( EMainCaleMonthPane );
|
|
794 |
main_cale_month_pane.LayoutRect( main_pane, AknLayoutScalable_Apps::main_cale_month_pane(layoutVariant).LayoutLine() );
|
|
795 |
|
|
796 |
// draw vertical line between week numbers and grid elements
|
|
797 |
if( useWeeks )
|
|
798 |
{
|
|
799 |
TAknLayoutRect cale_month_pane_g2;
|
|
800 |
layoutVariant = LayoutVariantIndex( ECaleMonthPaneG2 );
|
|
801 |
cale_month_pane_g2.LayoutRect( main_cale_month_pane.Rect(), AknLayoutScalable_Apps::cale_month_pane_g2( layoutVariant).LayoutLine() );
|
|
802 |
|
|
803 |
DrawPrimaryLine(gc, cale_month_pane_g2);
|
|
804 |
}
|
|
805 |
|
|
806 |
// draw horizontal line between week days and grid elements
|
|
807 |
TAknLayoutRect cale_month_pane_g1;
|
|
808 |
layoutVariant = LayoutVariantIndex(ECaleMonthPaneG1);
|
|
809 |
cale_month_pane_g1.LayoutRect( main_cale_month_pane.Rect(), AknLayoutScalable_Apps::cale_month_pane_g1( layoutVariant ).LayoutLine() );
|
|
810 |
DrawPrimaryLine(gc, cale_month_pane_g1);
|
|
811 |
|
|
812 |
// write week days.
|
|
813 |
DrawColLabel( gc, useWeeks );
|
|
814 |
|
|
815 |
// write week numbers
|
|
816 |
if( useWeeks )
|
|
817 |
{
|
|
818 |
DrawRowLabel( gc );
|
|
819 |
}
|
|
820 |
|
|
821 |
TRACE_EXIT_POINT;
|
|
822 |
}
|
|
823 |
|
|
824 |
|
|
825 |
// ----------------------------------------------------------------------------
|
|
826 |
// CCalenMonthContainer::GetHelpContext
|
|
827 |
// Gets help context
|
|
828 |
// (other items were commented in a header).
|
|
829 |
// ----------------------------------------------------------------------------
|
|
830 |
//
|
|
831 |
void CCalenMonthContainer::GetHelpContext( TCoeHelpContext& aContext ) const
|
|
832 |
{
|
|
833 |
TRACE_ENTRY_POINT;
|
|
834 |
|
|
835 |
aContext.iMajor = KUidCalendar;
|
|
836 |
// This is specified in HRH file.
|
|
837 |
aContext.iContext = KCALE_HLP_MONTH_VIEW;
|
|
838 |
|
|
839 |
TRACE_EXIT_POINT;
|
|
840 |
}
|
|
841 |
|
|
842 |
void CCalenMonthContainer::SizeChanged()
|
|
843 |
{
|
|
844 |
TRACE_ENTRY_POINT;
|
|
845 |
|
|
846 |
PIM_TRAPD_HANDLE( DoSizeChangedL() );
|
|
847 |
|
|
848 |
TRACE_EXIT_POINT;
|
|
849 |
}
|
|
850 |
// ----------------------------------------------------------------------------
|
|
851 |
// CCalenMonthContainer::DoSizeChanged
|
|
852 |
// Resizes child controls
|
|
853 |
// (other items were commented in a header).
|
|
854 |
// ----------------------------------------------------------------------------
|
|
855 |
//
|
|
856 |
void CCalenMonthContainer::DoSizeChangedL()
|
|
857 |
{
|
|
858 |
TRACE_ENTRY_POINT;
|
|
859 |
|
|
860 |
// Setup grid layout
|
|
861 |
CCalenContainer::SizeChanged( Rect() );
|
|
862 |
|
|
863 |
iLayoutManager->GetLayoutAndExtensionL();
|
|
864 |
|
|
865 |
TRect main_pane( ReducePreview( Rect() ) );
|
|
866 |
|
|
867 |
TAknLayoutRect grid_cale_month_pane, cell, vLine, hLine;
|
|
868 |
|
|
869 |
TAknLayoutRect main_cale_month_pane;
|
|
870 |
TInt layoutVariant = LayoutVariantIndex( EMainCaleMonthPane );
|
|
871 |
|
|
872 |
|
|
873 |
main_cale_month_pane.LayoutRect( main_pane, AknLayoutScalable_Apps::main_cale_month_pane( layoutVariant ).LayoutLine() );
|
|
874 |
|
|
875 |
|
|
876 |
layoutVariant = LayoutVariantIndex( EGridCaleMonthPane );
|
|
877 |
grid_cale_month_pane.LayoutRect( main_cale_month_pane.Rect(), AknLayoutScalable_Apps::grid_cale_month_pane(layoutVariant).LayoutLine() );
|
|
878 |
|
|
879 |
TRect gridRect = grid_cale_month_pane.Rect();
|
|
880 |
|
|
881 |
iGrid->SetRect( gridRect );
|
|
882 |
|
|
883 |
layoutVariant = LayoutVariantIndex( ECellCaleMonthPane );
|
|
884 |
cell.LayoutRect( gridRect, AknLayoutScalable_Apps::cell_cale_month_pane( layoutVariant, 0, 0 ).LayoutLine() );
|
|
885 |
layoutVariant = LayoutVariantIndex( ECaleMonthPaneG3 );
|
|
886 |
vLine.LayoutRect( main_cale_month_pane.Rect(), AknLayoutScalable_Apps::cale_month_pane_g3( layoutVariant ).LayoutLine() );
|
|
887 |
layoutVariant = LayoutVariantIndex( ECaleMonthPaneG9 );
|
|
888 |
hLine.LayoutRect( main_cale_month_pane.Rect(), AknLayoutScalable_Apps::cale_month_pane_g9( layoutVariant ).LayoutLine() );
|
|
889 |
|
|
890 |
// This could be done somewhere else, e.g. in construction
|
|
891 |
// and HandleResourceChange (for dynamic layout changes)
|
|
892 |
iGrid->SetLayoutL( EFalse, // aVerticalOrientation
|
|
893 |
!AknLayoutUtils::LayoutMirrored(), // aLeftToRight
|
|
894 |
ETrue, // aTopToBottom
|
|
895 |
KCalenDaysInWeek, // aNumOfItemsInPrimaryOrient
|
|
896 |
KNumberOfRows, // aNumOfItemsInSecondaryOrient
|
|
897 |
cell.Rect().Size(), // aSizeOfItems
|
|
898 |
vLine.Rect().Width(), // aWidthOfSpaceBetweenItems=0
|
|
899 |
hLine.Rect().Height() ); // aHeightOfSpaceBetweenItems=0
|
|
900 |
|
|
901 |
|
|
902 |
|
|
903 |
// Setup grid cell texts and graphics properties
|
|
904 |
ApplySelGridGraphicStyleL( *iGrid );
|
|
905 |
|
|
906 |
// Remove scrollbar
|
|
907 |
CEikScrollBarFrame* frame = iGrid->ScrollBarFrame();
|
|
908 |
if( frame )
|
|
909 |
{
|
|
910 |
frame->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff );
|
|
911 |
}
|
|
912 |
|
|
913 |
// Set size for skin backgrounds
|
|
914 |
if( iBackgroundSkinContext && iHeadingBgContext && iSideBgContext )
|
|
915 |
{
|
|
916 |
// Calendar background skin
|
|
917 |
TAknLayoutRect bg_cale_pane_cp02;
|
|
918 |
layoutVariant = LayoutVariantIndex( EBgCalePaneCp02);
|
|
919 |
bg_cale_pane_cp02.LayoutRect( main_cale_month_pane.Rect(), AknLayoutScalable_Apps::bg_cale_pane_cp02( layoutVariant ).LayoutLine() );
|
|
920 |
|
|
921 |
TRect tempRect = bg_cale_pane_cp02.Rect();
|
|
922 |
|
|
923 |
TAknLayoutRect cale_bg_pane_g1; // skin-center
|
|
924 |
cale_bg_pane_g1.LayoutRect( tempRect /*bg_cale_pane_cp02.Rect()*/, AknLayoutScalable_Apps::cale_bg_pane_g1().LayoutLine() );
|
|
925 |
|
|
926 |
iBackgroundSkinContext->SetFrameRects( bg_cale_pane_cp02.Rect(), cale_bg_pane_g1.Rect() );
|
|
927 |
|
|
928 |
|
|
929 |
// Heading pane skin
|
|
930 |
TAknLayoutRect bg_cale_heading_pane_cp01;
|
|
931 |
layoutVariant = LayoutVariantIndex( EBgCaleHeadingPaneCp01);
|
|
932 |
bg_cale_heading_pane_cp01.LayoutRect( main_cale_month_pane.Rect(), AknLayoutScalable_Apps::bg_cale_heading_pane_cp01( layoutVariant ).LayoutLine() );
|
|
933 |
|
|
934 |
tempRect = bg_cale_heading_pane_cp01.Rect();
|
|
935 |
|
|
936 |
TAknLayoutRect bg_cale_heading_pane_g1;
|
|
937 |
bg_cale_heading_pane_g1.LayoutRect( tempRect /*bg_cale_heading_pane_cp01.Rect() */ , AknLayoutScalable_Apps::bg_cale_heading_pane_g1().LayoutLine() );
|
|
938 |
|
|
939 |
iHeadingBgContext->SetFrameRects( bg_cale_heading_pane_cp01.Rect(), bg_cale_heading_pane_g1.Rect() );
|
|
940 |
|
|
941 |
// Side pane skin
|
|
942 |
if(UseWeeks())
|
|
943 |
{
|
|
944 |
TAknLayoutRect cale_month_week_pane;
|
|
945 |
layoutVariant = LayoutVariantIndex( ECaleMonthWeekPane );
|
|
946 |
cale_month_week_pane.LayoutRect( main_cale_month_pane.Rect(), AknLayoutScalable_Apps::cale_month_week_pane( layoutVariant ).LayoutLine() );
|
|
947 |
|
|
948 |
tempRect = cale_month_week_pane.Rect();
|
|
949 |
TAknLayoutRect bg_cale_side_pane_cp01;
|
|
950 |
layoutVariant = LayoutVariantIndex( EBgCaleSidePaneCp01 );
|
|
951 |
bg_cale_side_pane_cp01.LayoutRect( tempRect /*cale_month_week_pane.Rect()*/, AknLayoutScalable_Apps::bg_cale_side_pane_cp01(layoutVariant).LayoutLine() );
|
|
952 |
|
|
953 |
TAknLayoutRect bg_cale_side_pane_g1;
|
|
954 |
bg_cale_side_pane_g1.LayoutRect( bg_cale_side_pane_cp01.Rect(), AknLayoutScalable_Apps::bg_cale_side_pane_g1().LayoutLine() );
|
|
955 |
|
|
956 |
iSideBgContext->SetFrameRects( bg_cale_side_pane_cp01.Rect(), bg_cale_side_pane_g1.Rect() );
|
|
957 |
}
|
|
958 |
|
|
959 |
iBackgroundSkinContext->SetParentContext( iBgContext );
|
|
960 |
iHeadingBgContext->SetParentContext( iBackgroundSkinContext );
|
|
961 |
iSideBgContext->SetParentContext( iHeadingBgContext );
|
|
962 |
}
|
|
963 |
|
|
964 |
TRACE_EXIT_POINT;
|
|
965 |
}
|
|
966 |
|
|
967 |
// ----------------------------------------------------------------------------
|
|
968 |
// CCalenMonthContainer::FocusChanged
|
|
969 |
// (other items were commented in a header).
|
|
970 |
// ----------------------------------------------------------------------------
|
|
971 |
//
|
|
972 |
void CCalenMonthContainer::FocusChanged( TDrawNow aDrawNow )
|
|
973 |
{
|
|
974 |
TRACE_ENTRY_POINT;
|
|
975 |
|
|
976 |
CCalenContainer::FocusChanged( aDrawNow );
|
|
977 |
if( iGrid )
|
|
978 |
{
|
|
979 |
iGrid->SetFocus( IsFocused() );
|
|
980 |
}
|
|
981 |
|
|
982 |
TRACE_EXIT_POINT;
|
|
983 |
}
|
|
984 |
|
|
985 |
// ----------------------------------------------------------------------------
|
|
986 |
// CCalenMonthContainer::HandleResourceChange
|
|
987 |
// Handles a resource change relative events
|
|
988 |
// (other items were commented in a header).
|
|
989 |
// ----------------------------------------------------------------------------
|
|
990 |
//
|
|
991 |
void CCalenMonthContainer::HandleResourceChange(TInt aType)
|
|
992 |
{
|
|
993 |
TRACE_ENTRY_POINT;
|
|
994 |
|
|
995 |
CCalenContainer::HandleResourceChange( aType );
|
|
996 |
|
|
997 |
if ( aType == KAknsMessageSkinChange || aType == KEikDynamicLayoutVariantSwitch )
|
|
998 |
{
|
|
999 |
CArrayPtr<CGulIcon>* iconArray = iGrid->ItemDrawer()->FormattedCellData()->IconArray();
|
|
1000 |
if(iconArray)
|
|
1001 |
{
|
|
1002 |
iconArray->ResetAndDestroy();
|
|
1003 |
delete iconArray; // owned by CFormattedCellListBoxData
|
|
1004 |
iconArray = NULL; // to suppress codescanner error
|
|
1005 |
iGrid->ItemDrawer()->FormattedCellData()->SetIconArray(NULL);
|
|
1006 |
}
|
|
1007 |
|
|
1008 |
TRAPD(leave, iconArray = CreateIconsL( iIconIndices ));
|
|
1009 |
if(!leave && iconArray)
|
|
1010 |
{
|
|
1011 |
iGrid->ItemDrawer()->FormattedCellData()->SetIconArray(iconArray);
|
|
1012 |
}
|
|
1013 |
|
|
1014 |
SizeChanged();
|
|
1015 |
|
|
1016 |
// Update date formats to status pane
|
|
1017 |
TRAP_IGNORE(UpdateStatusPaneAndExtensionsL());
|
|
1018 |
|
|
1019 |
// if we have layout change and resource change is allowed do the refresh
|
|
1020 |
if (aType == KEikDynamicLayoutVariantSwitch)
|
|
1021 |
{
|
|
1022 |
iLayoutManager->HandleResourceChange( aType );
|
|
1023 |
TRAP_IGNORE(iView->BeginRepopulationL());
|
|
1024 |
}
|
|
1025 |
}
|
|
1026 |
|
|
1027 |
CCoeControl::HandleResourceChange( aType );
|
|
1028 |
|
|
1029 |
TRACE_EXIT_POINT;
|
|
1030 |
}
|
|
1031 |
|
|
1032 |
// ----------------------------------------------------------------------------
|
|
1033 |
// CCalenMonthContainer::PreviewPane
|
|
1034 |
// Returns previewpane pointer
|
|
1035 |
// ----------------------------------------------------------------------------
|
|
1036 |
const MCalenPreview* CCalenMonthContainer::PreviewPane()
|
|
1037 |
{
|
|
1038 |
TRACE_ENTRY_POINT
|
|
1039 |
TRACE_EXIT_POINT
|
|
1040 |
return iPreview;
|
|
1041 |
}
|
|
1042 |
|
|
1043 |
// CCalenMonthContainer::ConstructImplL
|
|
1044 |
// Third phase constructor.
|
|
1045 |
// This function was called CCalenNativeView::ConstructL().
|
|
1046 |
// (other items were commented in a header).
|
|
1047 |
// ----------------------------------------------------------------------------
|
|
1048 |
//
|
|
1049 |
void CCalenMonthContainer::ConstructImplL()
|
|
1050 |
{
|
|
1051 |
TRACE_ENTRY_POINT;
|
|
1052 |
|
|
1053 |
iChangeMonth = EFalse;
|
|
1054 |
iChangeDay = EFalse;
|
|
1055 |
iDayFormat = KMonthCellFormat;
|
|
1056 |
|
|
1057 |
iMonthDataArray = new(ELeave) CMonthDataArray(KCalenDaysInWeek * KNumberOfRows);
|
|
1058 |
|
|
1059 |
TLocale locale;
|
|
1060 |
|
|
1061 |
// Create preview pane
|
|
1062 |
TRect aRect = PreviewRectL();
|
|
1063 |
iPreview = iServices.CustomPreviewPaneL(aRect);
|
|
1064 |
|
|
1065 |
// grid
|
|
1066 |
iGrid = new(ELeave) CCalenMonthGrid(iFirstDayOfGrid,this);
|
|
1067 |
iGrid->SetContainerWindowL(*this);
|
|
1068 |
iGrid->ConstructL(this, CEikListBox::EMultipleSelection);
|
|
1069 |
|
|
1070 |
iGrid->SetListBoxObserver(this );
|
|
1071 |
iGrid->DisableScrolling( ETrue );
|
|
1072 |
iGrid->DisableSingleClick( ETrue );
|
|
1073 |
|
|
1074 |
|
|
1075 |
CDesCArray* itemArray =
|
|
1076 |
static_cast<CDesCArray*>( iGrid->Model()->ItemTextArray() );
|
|
1077 |
_LIT(KDesAny, "a"); // Evasion of CAknGrid's bug
|
|
1078 |
itemArray->AppendL(KDesAny);
|
|
1079 |
|
|
1080 |
iGrid->SetPrimaryScrollingType(
|
|
1081 |
CAknGridView::EScrollFollowsItemsAndLoops );
|
|
1082 |
iGrid->SetSecondaryScrollingType(
|
|
1083 |
CAknGridView::EScrollFollowsItemsAndLoops );
|
|
1084 |
|
|
1085 |
|
|
1086 |
CArrayPtr<CGulIcon>* iconArray = iGrid->ItemDrawer()->FormattedCellData()->IconArray();
|
|
1087 |
if(iconArray)
|
|
1088 |
{
|
|
1089 |
iconArray->ResetAndDestroy();
|
|
1090 |
delete iconArray; // owned by CFormattedCellListBoxData
|
|
1091 |
iconArray = NULL; // to suppress codescanner error
|
|
1092 |
iGrid->ItemDrawer()->FormattedCellData()->SetIconArray(NULL);
|
|
1093 |
}
|
|
1094 |
|
|
1095 |
iGrid->ItemDrawer()->FormattedCellData()->SetIconArray( CreateIconsL( iIconIndices ));
|
|
1096 |
iGrid->View()->SetDisableRedraw(ETrue);
|
|
1097 |
|
|
1098 |
|
|
1099 |
iGestureControl = GestureHelper::CGestureHelper::NewL( *this );
|
|
1100 |
iGestureControl->SetDoubleTapEnabled( EFalse );
|
|
1101 |
iGestureControl->SetHoldingEnabled( EFalse );
|
|
1102 |
|
|
1103 |
|
|
1104 |
PIM_TRAPD_HANDLE( ConstructBackgroundContextL() );
|
|
1105 |
|
|
1106 |
TRACE_EXIT_POINT;
|
|
1107 |
}
|
|
1108 |
|
|
1109 |
// ----------------------------------------------------------------------------
|
|
1110 |
// CCalenMonthContainer::ConstructBackgroundContextL
|
|
1111 |
// Constructs the background context
|
|
1112 |
// (other items were commented in a header).
|
|
1113 |
// ----------------------------------------------------------------------------
|
|
1114 |
//
|
|
1115 |
void CCalenMonthContainer::ConstructBackgroundContextL()
|
|
1116 |
{
|
|
1117 |
TRACE_ENTRY_POINT;
|
|
1118 |
|
|
1119 |
TRect dummy(0,0,0,0);
|
|
1120 |
if( AknLayoutUtils::ScalableLayoutInterfaceAvailable() )
|
|
1121 |
{
|
|
1122 |
iHeadingBgContext = CAknsFrameBackgroundControlContext::NewL( KAknsIIDQsnFrCaleHeading, dummy, dummy, EFalse );
|
|
1123 |
iSideBgContext = CAknsFrameBackgroundControlContext::NewL( KAknsIIDQsnFrCaleSide, dummy, dummy, EFalse );
|
|
1124 |
iBackgroundSkinContext = CAknsFrameBackgroundControlContext::NewL(
|
|
1125 |
KAknsIIDQsnFrCale, dummy, dummy, EFalse );
|
|
1126 |
}
|
|
1127 |
|
|
1128 |
TRACE_EXIT_POINT;
|
|
1129 |
}
|
|
1130 |
|
|
1131 |
// ----------------------------------------------------------------------------
|
|
1132 |
// CCalenMonthContainer::UpdateSize
|
|
1133 |
// Do layout changes after calendar settings are
|
|
1134 |
// changed.
|
|
1135 |
// Implementation for month view without week numbers.
|
|
1136 |
// ----------------------------------------------------------------------------
|
|
1137 |
//
|
|
1138 |
void CCalenMonthContainer::UpdateSize()
|
|
1139 |
{
|
|
1140 |
TRACE_ENTRY_POINT;
|
|
1141 |
|
|
1142 |
SizeChanged();
|
|
1143 |
// Update date formats to status pane
|
|
1144 |
TRAPD(error,UpdateStatusPaneAndExtensionsL());
|
|
1145 |
if(error!=KErrNone)
|
|
1146 |
{
|
|
1147 |
// do avoid warning
|
|
1148 |
}
|
|
1149 |
|
|
1150 |
TRACE_EXIT_POINT;
|
|
1151 |
}
|
|
1152 |
|
|
1153 |
// ----------------------------------------------------------------------------
|
|
1154 |
// CCalenMonthContainer::MopSupplyObject()
|
|
1155 |
// Pass skin information if needed.
|
|
1156 |
// ----------------------------------------------------------------------------
|
|
1157 |
//
|
|
1158 |
TTypeUid::Ptr CCalenMonthContainer::MopSupplyObject(TTypeUid aId)
|
|
1159 |
{
|
|
1160 |
TRACE_ENTRY_POINT;
|
|
1161 |
TBool useWeeksBool = EFalse;
|
|
1162 |
useWeeksBool = UseWeeks();
|
|
1163 |
|
|
1164 |
MAknsControlContext* cc = useWeeksBool ? iSideBgContext : iHeadingBgContext;
|
|
1165 |
|
|
1166 |
if( !cc )
|
|
1167 |
{
|
|
1168 |
cc = iBgContext;
|
|
1169 |
}
|
|
1170 |
|
|
1171 |
if( aId.iUid == MAknsControlContext::ETypeId && cc )
|
|
1172 |
{
|
|
1173 |
TRACE_EXIT_POINT;
|
|
1174 |
return MAknsControlContext::SupplyMopObject( aId, cc );
|
|
1175 |
}
|
|
1176 |
|
|
1177 |
TRACE_EXIT_POINT;
|
|
1178 |
return CCoeControl::MopSupplyObject( aId );
|
|
1179 |
}
|
|
1180 |
|
|
1181 |
// ----------------------------------------------------------------------------
|
|
1182 |
// CCalenMonthContainer::GridIndex
|
|
1183 |
// ----------------------------------------------------------------------------
|
|
1184 |
//
|
|
1185 |
TInt CCalenMonthContainer::GridIndex() const
|
|
1186 |
{
|
|
1187 |
TRACE_ENTRY_POINT;
|
|
1188 |
|
|
1189 |
TRACE_EXIT_POINT;
|
|
1190 |
return reinterpret_cast<CAknGridView*>( iGrid->View() )
|
|
1191 |
->ActualDataIndex(iGrid->CurrentItemIndex());
|
|
1192 |
}
|
|
1193 |
|
|
1194 |
// ----------------------------------------------------------------------------
|
|
1195 |
// CCalenMonthContainer::UseWeeks
|
|
1196 |
// ----------------------------------------------------------------------------
|
|
1197 |
TBool CCalenMonthContainer::UseWeeks() const
|
|
1198 |
{
|
|
1199 |
TRACE_ENTRY_POINT;
|
|
1200 |
|
|
1201 |
TBool useWeeks( EFalse );
|
|
1202 |
|
|
1203 |
TRAPD(err,useWeeks = UseWeeksL());
|
|
1204 |
if(err==KErrNone)
|
|
1205 |
{
|
|
1206 |
// to avoid warning
|
|
1207 |
}
|
|
1208 |
|
|
1209 |
TRACE_EXIT_POINT;
|
|
1210 |
return useWeeks;
|
|
1211 |
}
|
|
1212 |
|
|
1213 |
// ----------------------------------------------------------------------------
|
|
1214 |
// CCalenMonthContainer::UseWeeks
|
|
1215 |
// ----------------------------------------------------------------------------
|
|
1216 |
TBool CCalenMonthContainer::UseWeeksL() const
|
|
1217 |
{
|
|
1218 |
TRACE_ENTRY_POINT;
|
|
1219 |
|
|
1220 |
TBool useWeeks( EFalse );
|
|
1221 |
|
|
1222 |
// Week numbers are not shown if layout is mirrored
|
|
1223 |
// or monday isn't the default week start day
|
|
1224 |
if( !AknLayoutUtils::LayoutMirrored() )
|
|
1225 |
{
|
|
1226 |
CCalenSetting* setting(NULL);
|
|
1227 |
setting = CCalenSetting::InstanceL();
|
|
1228 |
|
|
1229 |
CleanupReleasePushL( *setting ) ;
|
|
1230 |
|
|
1231 |
if( setting->WeekFormat() == EMonday && setting->WeekNumberEnable() )
|
|
1232 |
{
|
|
1233 |
useWeeks = ETrue;
|
|
1234 |
}
|
|
1235 |
CleanupStack::PopAndDestroy( setting );
|
|
1236 |
}
|
|
1237 |
|
|
1238 |
TRACE_EXIT_POINT;
|
|
1239 |
return useWeeks;
|
|
1240 |
}
|
|
1241 |
|
|
1242 |
// ----------------------------------------------------------------------------
|
|
1243 |
// CCalenMonthContainer::LayoutVariantIndex
|
|
1244 |
// ----------------------------------------------------------------------------
|
|
1245 |
//
|
|
1246 |
TInt CCalenMonthContainer::LayoutVariantIndex(TMonthLayoutVariant aLayout) const
|
|
1247 |
{
|
|
1248 |
TRACE_ENTRY_POINT;
|
|
1249 |
|
|
1250 |
TBitFlags layoutFlags = iLayoutManager->LayoutFlags();
|
|
1251 |
|
|
1252 |
TInt layoutVariant (ENoLayoutVariantSet);
|
|
1253 |
switch (aLayout)
|
|
1254 |
{
|
|
1255 |
case ENoLayoutVariantSet:
|
|
1256 |
{
|
|
1257 |
ASSERT(EFalse);
|
|
1258 |
}
|
|
1259 |
case EMainCaleMonthPane:
|
|
1260 |
{
|
|
1261 |
if( layoutFlags.IsSet( CCalenContainerLayoutManager::ECalenContainerToolbar ) )
|
|
1262 |
layoutVariant = 1;
|
|
1263 |
else
|
|
1264 |
layoutVariant = 0;
|
|
1265 |
break;
|
|
1266 |
}
|
|
1267 |
case ECaleMonthPaneT1:
|
|
1268 |
{
|
|
1269 |
if( layoutFlags.IsSet( CCalenContainerLayoutManager::ECalenContainerToolbar ) )
|
|
1270 |
{
|
|
1271 |
if(UseWeeks() && layoutFlags.IsSet( CCalenContainerLayoutManager::ECalenContainerInfobar ))
|
|
1272 |
layoutVariant = 2;
|
|
1273 |
else if( layoutFlags.IsSet( CCalenContainerLayoutManager::ECalenContainerInfobar ))
|
|
1274 |
layoutVariant = 3;
|
|
1275 |
else
|
|
1276 |
__ASSERT_DEBUG(0, User::Invariant());
|
|
1277 |
}
|
|
1278 |
else
|
|
1279 |
{
|
|
1280 |
if(UseWeeks() && layoutFlags.IsSet( CCalenContainerLayoutManager::ECalenContainerInfobar ))
|
|
1281 |
layoutVariant = 0;
|
|
1282 |
else if( layoutFlags.IsSet( CCalenContainerLayoutManager::ECalenContainerInfobar ))
|
|
1283 |
layoutVariant = 1;
|
|
1284 |
else
|
|
1285 |
__ASSERT_DEBUG(0, User::Invariant());
|
|
1286 |
}
|
|
1287 |
break;
|
|
1288 |
}
|
|
1289 |
case ECaleMonthWeekPane:
|
|
1290 |
case ECaleMonthPaneG2:
|
|
1291 |
{
|
|
1292 |
if( layoutFlags.IsSet( CCalenContainerLayoutManager::ECalenContainerToolbar ) )
|
|
1293 |
{
|
|
1294 |
if(UseWeeks() && layoutFlags.IsSet( CCalenContainerLayoutManager::ECalenContainerInfobar ))
|
|
1295 |
layoutVariant = 3;
|
|
1296 |
else if(UseWeeks())
|
|
1297 |
layoutVariant = 2;
|
|
1298 |
else
|
|
1299 |
__ASSERT_DEBUG(0, User::Invariant());
|
|
1300 |
}
|
|
1301 |
else
|
|
1302 |
{
|
|
1303 |
if(UseWeeks() && layoutFlags.IsSet( CCalenContainerLayoutManager::ECalenContainerInfobar ))
|
|
1304 |
layoutVariant = 1;
|
|
1305 |
else if(UseWeeks())
|
|
1306 |
layoutVariant = 0;
|
|
1307 |
else
|
|
1308 |
__ASSERT_DEBUG(0, User::Invariant());
|
|
1309 |
}
|
|
1310 |
break;
|
|
1311 |
}
|
|
1312 |
case EBgCalePaneCp02:
|
|
1313 |
case ECaleMonthDayHeadingPane:
|
|
1314 |
case EGridCaleMonthPane:
|
|
1315 |
case ECaleMonthPaneG:
|
|
1316 |
case ECaleMonthPaneG1:
|
|
1317 |
case ECaleMonthPaneG3:
|
|
1318 |
case ECaleMonthPaneG9:
|
|
1319 |
case EBgCaleHeadingPaneCp01:
|
|
1320 |
case ECaleMonthDayHeadingPaneT:
|
|
1321 |
case ECellCaleMonthPane:
|
|
1322 |
{
|
|
1323 |
if( layoutFlags.IsSet( CCalenContainerLayoutManager::ECalenContainerToolbar ) )
|
|
1324 |
{
|
|
1325 |
if(UseWeeks() && layoutFlags.IsSet( CCalenContainerLayoutManager::ECalenContainerInfobar ))
|
|
1326 |
layoutVariant = 6;
|
|
1327 |
else if ( layoutFlags.IsSet( CCalenContainerLayoutManager::ECalenContainerInfobar ))
|
|
1328 |
layoutVariant = 7;
|
|
1329 |
else if(UseWeeks())
|
|
1330 |
layoutVariant = 4;
|
|
1331 |
else
|
|
1332 |
layoutVariant = 5;
|
|
1333 |
}
|
|
1334 |
else
|
|
1335 |
{
|
|
1336 |
if(UseWeeks() && layoutFlags.IsSet( CCalenContainerLayoutManager::ECalenContainerInfobar ))
|
|
1337 |
layoutVariant = 2;
|
|
1338 |
else if (layoutFlags.IsSet( CCalenContainerLayoutManager::ECalenContainerInfobar ))
|
|
1339 |
layoutVariant = 3;
|
|
1340 |
else if(UseWeeks())
|
|
1341 |
layoutVariant = 0;
|
|
1342 |
else
|
|
1343 |
layoutVariant = 1;
|
|
1344 |
}
|
|
1345 |
break;
|
|
1346 |
}
|
|
1347 |
|
|
1348 |
case ECaleMonthWeekPaneT:
|
|
1349 |
case EBgCaleSidePaneCp01:
|
|
1350 |
{
|
|
1351 |
if( layoutFlags.IsSet( CCalenContainerLayoutManager::ECalenContainerToolbar ) )
|
|
1352 |
{
|
|
1353 |
if(layoutFlags.IsSet( CCalenContainerLayoutManager::ECalenContainerInfobar ))
|
|
1354 |
layoutVariant = 3;
|
|
1355 |
else
|
|
1356 |
layoutVariant = 2;
|
|
1357 |
}
|
|
1358 |
else
|
|
1359 |
{
|
|
1360 |
if(layoutFlags.IsSet( CCalenContainerLayoutManager::ECalenContainerInfobar ))
|
|
1361 |
layoutVariant = 1;
|
|
1362 |
else
|
|
1363 |
layoutVariant = 0;
|
|
1364 |
}
|
|
1365 |
break;
|
|
1366 |
}
|
|
1367 |
|
|
1368 |
case ECellCaleMonthPaneG1:
|
|
1369 |
{
|
|
1370 |
if( layoutFlags.IsSet( CCalenContainerLayoutManager::ECalenContainerToolbar ) )
|
|
1371 |
{
|
|
1372 |
if(UseWeeks() && layoutFlags.IsSet( CCalenContainerLayoutManager::ECalenContainerInfobar ))
|
|
1373 |
layoutVariant = 6;
|
|
1374 |
else if(layoutFlags.IsSet( CCalenContainerLayoutManager::ECalenContainerInfobar ))
|
|
1375 |
layoutVariant = 7;
|
|
1376 |
else if(UseWeeks())
|
|
1377 |
layoutVariant = 4;
|
|
1378 |
else
|
|
1379 |
layoutVariant = 5;
|
|
1380 |
}
|
|
1381 |
else
|
|
1382 |
{
|
|
1383 |
if(UseWeeks() && layoutFlags.IsSet( CCalenContainerLayoutManager::ECalenContainerInfobar ))
|
|
1384 |
layoutVariant = 2;
|
|
1385 |
else if(layoutFlags.IsSet( CCalenContainerLayoutManager::ECalenContainerInfobar ))
|
|
1386 |
layoutVariant = 3;
|
|
1387 |
else if(UseWeeks())
|
|
1388 |
layoutVariant = 0;
|
|
1389 |
else
|
|
1390 |
layoutVariant = 1;
|
|
1391 |
}
|
|
1392 |
break;
|
|
1393 |
}
|
|
1394 |
case ECellCaleMonthPaneT1:
|
|
1395 |
{
|
|
1396 |
if( layoutFlags.IsSet( CCalenContainerLayoutManager::ECalenContainerToolbar ) )
|
|
1397 |
{
|
|
1398 |
if(UseWeeks() && layoutFlags.IsSet( CCalenContainerLayoutManager::ECalenContainerInfobar ))
|
|
1399 |
layoutVariant = 7;
|
|
1400 |
else if(layoutFlags.IsSet( CCalenContainerLayoutManager::ECalenContainerInfobar ))
|
|
1401 |
layoutVariant = 8;
|
|
1402 |
else if(UseWeeks())
|
|
1403 |
layoutVariant = 5;
|
|
1404 |
else
|
|
1405 |
layoutVariant = 6;
|
|
1406 |
}
|
|
1407 |
else
|
|
1408 |
{
|
|
1409 |
if(UseWeeks() && layoutFlags.IsSet( CCalenContainerLayoutManager::ECalenContainerInfobar ))
|
|
1410 |
layoutVariant = 3;
|
|
1411 |
else if(layoutFlags.IsSet( CCalenContainerLayoutManager::ECalenContainerInfobar ))
|
|
1412 |
layoutVariant = 4;
|
|
1413 |
else if(UseWeeks())
|
|
1414 |
layoutVariant = 0;
|
|
1415 |
else
|
|
1416 |
layoutVariant = 2;
|
|
1417 |
}
|
|
1418 |
break;
|
|
1419 |
}
|
|
1420 |
}
|
|
1421 |
|
|
1422 |
TRACE_EXIT_POINT;
|
|
1423 |
return layoutVariant;
|
|
1424 |
}
|
|
1425 |
|
|
1426 |
// ----------------------------------------------------------------------------
|
|
1427 |
// CCalenMonthContainer::DoEntryTimeCompareL
|
|
1428 |
// ----------------------------------------------------------------------------
|
|
1429 |
//
|
|
1430 |
TInt CCalenMonthContainer::DoEntryTimeCompareL( const CCalInstance& aInstance_1,
|
|
1431 |
const CCalInstance& aInstance_2 )
|
|
1432 |
{
|
|
1433 |
TRACE_ENTRY_POINT;
|
|
1434 |
|
|
1435 |
TInt ret( EEqual );
|
|
1436 |
|
|
1437 |
TTime time_1;
|
|
1438 |
TTime time_2;
|
|
1439 |
|
|
1440 |
if( aInstance_1.Entry().EntryTypeL() == CCalEntry::ETodo )
|
|
1441 |
{
|
|
1442 |
time_1 = aInstance_1.EndTimeL().TimeUtcL();
|
|
1443 |
}
|
|
1444 |
else
|
|
1445 |
{
|
|
1446 |
time_1 = aInstance_1.StartTimeL().TimeUtcL();
|
|
1447 |
}
|
|
1448 |
|
|
1449 |
if( aInstance_2.Entry().EntryTypeL() == CCalEntry::ETodo )
|
|
1450 |
{
|
|
1451 |
time_2 = aInstance_2.EndTimeL().TimeUtcL();
|
|
1452 |
}
|
|
1453 |
else
|
|
1454 |
{
|
|
1455 |
time_2 = aInstance_2.StartTimeL().TimeUtcL();
|
|
1456 |
}
|
|
1457 |
|
|
1458 |
if( time_1 == time_2 )
|
|
1459 |
{
|
|
1460 |
ret = EEqual;
|
|
1461 |
}
|
|
1462 |
else if( time_1 > time_2 )
|
|
1463 |
{
|
|
1464 |
ret = EGreaterThan; // oldest first
|
|
1465 |
}
|
|
1466 |
else
|
|
1467 |
{
|
|
1468 |
ret = ELessThan;
|
|
1469 |
}
|
|
1470 |
|
|
1471 |
TRACE_EXIT_POINT;
|
|
1472 |
return ret;
|
|
1473 |
}
|
|
1474 |
|
|
1475 |
// ----------------------------------------------------------------------------
|
|
1476 |
// Utility function to compare entry times, handles Todos correctly.
|
|
1477 |
// ----------------------------------------------------------------------------
|
|
1478 |
//
|
|
1479 |
TInt CCalenMonthContainer::EntryTimeCompare(const CCalInstance& aInstance_1,
|
|
1480 |
const CCalInstance& aInstance_2)
|
|
1481 |
{
|
|
1482 |
TRACE_ENTRY_POINT;
|
|
1483 |
|
|
1484 |
TInt ret( EEqual );
|
|
1485 |
PIM_TRAPD_HANDLE( (ret = DoEntryTimeCompareL(aInstance_1, aInstance_2)) );
|
|
1486 |
|
|
1487 |
TRACE_EXIT_POINT;
|
|
1488 |
return ret;
|
|
1489 |
}
|
|
1490 |
|
|
1491 |
// ----------------------------------------------------------------------------
|
|
1492 |
//
|
|
1493 |
// ----------------------------------------------------------------------------
|
|
1494 |
//
|
|
1495 |
CCalenMonthView& CCalenMonthContainer::MonthView() const
|
|
1496 |
{
|
|
1497 |
TRACE_ENTRY_POINT;
|
|
1498 |
|
|
1499 |
TRACE_EXIT_POINT;
|
|
1500 |
return *(static_cast<CCalenMonthView*>(iView));
|
|
1501 |
}
|
|
1502 |
|
|
1503 |
|
|
1504 |
// ----------------------------------------------------------------------------
|
|
1505 |
// CCalenMonthContainer::HandleNaviDecorationPointerEventL
|
|
1506 |
// processing of a navi decoration event
|
|
1507 |
// (other items were commented in a header).
|
|
1508 |
// ----------------------------------------------------------------------------
|
|
1509 |
//
|
|
1510 |
void CCalenMonthContainer::HandleNaviDecoratorEventL(TInt aEventID)
|
|
1511 |
{
|
|
1512 |
TRACE_ENTRY_POINT;
|
|
1513 |
|
|
1514 |
if(AknLayoutUtils::PenEnabled())
|
|
1515 |
{
|
|
1516 |
TInt direction(0);
|
|
1517 |
if(aEventID == EAknNaviDecoratorEventLeftTabArrow)
|
|
1518 |
{
|
|
1519 |
if(AknLayoutUtils::LayoutMirrored())
|
|
1520 |
{
|
|
1521 |
direction = 1;
|
|
1522 |
}
|
|
1523 |
else
|
|
1524 |
{
|
|
1525 |
direction = -1;
|
|
1526 |
}
|
|
1527 |
}
|
|
1528 |
|
|
1529 |
else if(aEventID == EAknNaviDecoratorEventRightTabArrow)
|
|
1530 |
{
|
|
1531 |
if(AknLayoutUtils::LayoutMirrored())
|
|
1532 |
{
|
|
1533 |
direction = -1;
|
|
1534 |
}
|
|
1535 |
else
|
|
1536 |
{
|
|
1537 |
direction = 1;
|
|
1538 |
}
|
|
1539 |
}
|
|
1540 |
else
|
|
1541 |
return;
|
|
1542 |
/**
|
|
1543 |
* Tapping of navi arrows in month view
|
|
1544 |
* should change month.
|
|
1545 |
*/
|
|
1546 |
TTime newDay( iDate + TTimeIntervalMonths(direction) );
|
|
1547 |
|
|
1548 |
// test
|
|
1549 |
TDateTime newDayTime = newDay.DateTime();
|
|
1550 |
|
|
1551 |
// set the context
|
|
1552 |
TCalTime time;
|
|
1553 |
time.SetTimeLocalL( newDay );
|
|
1554 |
iServices.Context().SetFocusDateL( time,
|
|
1555 |
TVwsViewId( KUidCalendar, KUidCalenMonthView ) );
|
|
1556 |
|
|
1557 |
|
|
1558 |
if (!CalenDateUtils::IsValidDay(newDay))
|
|
1559 |
{
|
|
1560 |
CalenViewUtils::ShowDateOutOfRangeErrorNoteL();
|
|
1561 |
}
|
|
1562 |
else
|
|
1563 |
{
|
|
1564 |
iGrid->View()->SetDisableRedraw(ETrue);
|
|
1565 |
iView->BeginRepopulationL();
|
|
1566 |
}
|
|
1567 |
// Hide/unhide "today" toolbar item based on the focused day
|
|
1568 |
UpdateTodayToolbarItemL();
|
|
1569 |
}
|
|
1570 |
|
|
1571 |
TRACE_EXIT_POINT;
|
|
1572 |
}
|
|
1573 |
|
|
1574 |
// ----------------------------------------------------------------------------
|
|
1575 |
// CCalenMonthContainer::HandleWeekNumberTapL
|
|
1576 |
// processing of a week number tap
|
|
1577 |
// (other items were commented in a header).
|
|
1578 |
// ----------------------------------------------------------------------------
|
|
1579 |
//
|
|
1580 |
void CCalenMonthContainer::HandleWeekNumberTapL(const TPoint &aPosition)
|
|
1581 |
{
|
|
1582 |
TRACE_ENTRY_POINT;
|
|
1583 |
|
|
1584 |
TInt layoutVariant( ENoLayoutVariantSet );
|
|
1585 |
if(AknLayoutUtils::PenEnabled())
|
|
1586 |
{
|
|
1587 |
/* Steps to implement week number tapping
|
|
1588 |
* 1. find out tapped row in week number area.
|
|
1589 |
* 2. change current day of the week active in new row
|
|
1590 |
* 3. open week view
|
|
1591 |
*/
|
|
1592 |
TRect main_pane( ReducePreview( Rect() ) );
|
|
1593 |
|
|
1594 |
TAknLayoutRect main_cale_month_pane;
|
|
1595 |
layoutVariant = LayoutVariantIndex( EMainCaleMonthPane );
|
|
1596 |
main_cale_month_pane.LayoutRect(main_pane,
|
|
1597 |
AknLayoutScalable_Apps::main_cale_month_pane(layoutVariant).LayoutLine());
|
|
1598 |
TAknLayoutRect cale_month_week_pane;
|
|
1599 |
layoutVariant = LayoutVariantIndex( ECaleMonthWeekPane);
|
|
1600 |
cale_month_week_pane.LayoutRect(main_cale_month_pane.Rect(),
|
|
1601 |
AknLayoutScalable_Apps::cale_month_week_pane(layoutVariant).LayoutLine());
|
|
1602 |
if(cale_month_week_pane.Rect().Contains(aPosition))
|
|
1603 |
{
|
|
1604 |
TInt tappedRow (0);
|
|
1605 |
tappedRow = (aPosition.iY - cale_month_week_pane.Rect().iTl.iY)/
|
|
1606 |
(iGrid->View()->ItemSize(iGrid->CurrentItemIndex()).iHeight);
|
|
1607 |
|
|
1608 |
TAknLayoutScalableTableLimits cale_month_week_pane_t_limits =
|
|
1609 |
AknLayoutScalable_Apps::cale_month_week_pane_t_Limits();
|
|
1610 |
if(tappedRow > cale_month_week_pane_t_limits.LastIndex())
|
|
1611 |
tappedRow = cale_month_week_pane_t_limits.LastIndex();
|
|
1612 |
|
|
1613 |
TTime newWeekFirst(iFirstDayOfGrid +
|
|
1614 |
TTimeIntervalDays(KCalenDaysInWeek * tappedRow));
|
|
1615 |
iDate = newWeekFirst;
|
|
1616 |
TInt direction = newWeekFirst.WeekNoInYear() -
|
|
1617 |
iDate.WeekNoInYear();
|
|
1618 |
|
|
1619 |
TTime newActiveDay(iDate +
|
|
1620 |
TTimeIntervalDays(KCalenDaysInWeek * direction));
|
|
1621 |
if ( !CalenDateUtils::IsValidDay(newActiveDay) )
|
|
1622 |
{
|
|
1623 |
CalenViewUtils::ShowDateOutOfRangeErrorNoteL();
|
|
1624 |
return;
|
|
1625 |
}
|
|
1626 |
|
|
1627 |
// set the context
|
|
1628 |
TCalTime time;
|
|
1629 |
time.SetTimeLocalL( newActiveDay );
|
|
1630 |
iServices.Context().SetFocusDateL( time,
|
|
1631 |
TVwsViewId( KUidCalendar, KUidCalenMonthView ) );
|
|
1632 |
|
|
1633 |
SetActiveDayL( newActiveDay );
|
|
1634 |
//iServices.IssueCommandL( ECalenWeekView );
|
|
1635 |
iServices.IssueCommandL( ECalenForwardsToWeekView );
|
|
1636 |
}
|
|
1637 |
}
|
|
1638 |
|
|
1639 |
TRACE_EXIT_POINT;
|
|
1640 |
}
|
|
1641 |
|
|
1642 |
// ----------------------------------------------------------------------------
|
|
1643 |
// CCalenMonthContainer::HandleLongTapEventL
|
|
1644 |
// processing of a long tap event
|
|
1645 |
// (other items were commented in a header).
|
|
1646 |
// ----------------------------------------------------------------------------
|
|
1647 |
//
|
|
1648 |
void CCalenMonthContainer::HandleLongTapEventL( const TPoint& /*aPenEventLocation*/,
|
|
1649 |
const TPoint& /*aPenEventScreenLocation*/ )
|
|
1650 |
{
|
|
1651 |
TRACE_ENTRY_POINT;
|
|
1652 |
|
|
1653 |
|
|
1654 |
TRACE_EXIT_POINT;
|
|
1655 |
}
|
|
1656 |
|
|
1657 |
// ----------------------------------------------------------------------------
|
|
1658 |
// CCalenMonthContainer::HandlePointerEventL
|
|
1659 |
// processing of a pointer event
|
|
1660 |
// (other items were commented in a header).
|
|
1661 |
// ----------------------------------------------------------------------------
|
|
1662 |
//
|
|
1663 |
void CCalenMonthContainer::HandlePointerEventL(const TPointerEvent& aPointerEvent)
|
|
1664 |
{
|
|
1665 |
TRACE_ENTRY_POINT;
|
|
1666 |
|
|
1667 |
if(AknLayoutUtils::PenEnabled())
|
|
1668 |
{
|
|
1669 |
if(iView->IsEventViewLaunchedFromAlarm())
|
|
1670 |
{
|
|
1671 |
return;
|
|
1672 |
}
|
|
1673 |
CCoeControl* control( NULL );
|
|
1674 |
if(aPointerEvent.iType == TPointerEvent::EButton1Down)
|
|
1675 |
{
|
|
1676 |
this->GenerateTactileFeedback(); //Tactile feedback.
|
|
1677 |
control = iLayoutManager->ControlOrNull();
|
|
1678 |
if(control)
|
|
1679 |
{
|
|
1680 |
if(control->Rect().Contains(aPointerEvent.iPosition))
|
|
1681 |
{
|
|
1682 |
control->HandlePointerEventL(aPointerEvent);
|
|
1683 |
return;
|
|
1684 |
}
|
|
1685 |
}
|
|
1686 |
}
|
|
1687 |
TInt pointerIndex(-1);
|
|
1688 |
TBool isItem (iGrid->View()->XYPosToItemIndex(aPointerEvent.iPosition, pointerIndex));
|
|
1689 |
if( isItem )
|
|
1690 |
{
|
|
1691 |
pointerIndex = static_cast<CAknGridView*>(iGrid->View())->ActualDataIndex( pointerIndex );
|
|
1692 |
}
|
|
1693 |
CAknGridM* gridModel = static_cast<CAknGridM*>(iGrid->Model());
|
|
1694 |
|
|
1695 |
if(gridModel->NumberOfData() <= 0)
|
|
1696 |
return;
|
|
1697 |
|
|
1698 |
if ( iGestureControl )
|
|
1699 |
{
|
|
1700 |
iGestureControl->HandlePointerEventL( aPointerEvent );
|
|
1701 |
if ( iGestureHandled )
|
|
1702 |
{
|
|
1703 |
TRACE_EXIT_POINT;
|
|
1704 |
return;
|
|
1705 |
}
|
|
1706 |
}
|
|
1707 |
|
|
1708 |
if(isItem == EFalse)
|
|
1709 |
/* Handle pointer event in week number area */
|
|
1710 |
{
|
|
1711 |
switch(aPointerEvent.iType)
|
|
1712 |
{
|
|
1713 |
case TPointerEvent::EButton1Up:
|
|
1714 |
{
|
|
1715 |
HandleWeekNumberTapL(aPointerEvent.iPosition);
|
|
1716 |
break;
|
|
1717 |
}
|
|
1718 |
default:
|
|
1719 |
break;
|
|
1720 |
}
|
|
1721 |
}
|
|
1722 |
else
|
|
1723 |
/* Handle pointer event in months day area */
|
|
1724 |
{
|
|
1725 |
|
|
1726 |
#ifdef _DEBUG
|
|
1727 |
RDebug::Print( _L("pointerEvent.iModifiers = 0x%08x"),
|
|
1728 |
aPointerEvent.iModifiers );
|
|
1729 |
#endif
|
|
1730 |
// Event modifiers are ignored for now because
|
|
1731 |
// those are not needed but cause problems
|
|
1732 |
TPointerEvent pointerEvent( aPointerEvent );
|
|
1733 |
pointerEvent.iModifiers =
|
|
1734 |
( aPointerEvent.iModifiers & ( ~EAllModifiers ) );
|
|
1735 |
TInt index( iGrid->CurrentDataIndex() );
|
|
1736 |
TTime isValidDay;
|
|
1737 |
if( TPointerEvent::EButton1Up == aPointerEvent.iType )
|
|
1738 |
{
|
|
1739 |
isValidDay = iOldFirstDayOfGrid +
|
|
1740 |
TTimeIntervalDays(pointerIndex);
|
|
1741 |
}
|
|
1742 |
else
|
|
1743 |
{
|
|
1744 |
iOldFirstDayOfGrid = iFirstDayOfGrid;
|
|
1745 |
isValidDay = iFirstDayOfGrid +
|
|
1746 |
TTimeIntervalDays(pointerIndex);
|
|
1747 |
}
|
|
1748 |
if (!CalenDateUtils::IsValidDay(isValidDay))
|
|
1749 |
{
|
|
1750 |
if( aPointerEvent.iType == TPointerEvent::EButton1Up )
|
|
1751 |
{
|
|
1752 |
CalenViewUtils::ShowDateOutOfRangeErrorNoteL();
|
|
1753 |
}
|
|
1754 |
TRACE_EXIT_POINT;
|
|
1755 |
return;
|
|
1756 |
}
|
|
1757 |
|
|
1758 |
if ( aPointerEvent.iType == TPointerEvent::EButton1Down
|
|
1759 |
|| aPointerEvent.iType == TPointerEvent::EDrag )
|
|
1760 |
{
|
|
1761 |
TTime newActiveDay(
|
|
1762 |
iDate + TTimeIntervalDays( pointerIndex - index ) );
|
|
1763 |
TDateTime newActiveDayTime = newActiveDay.DateTime();
|
|
1764 |
|
|
1765 |
TMonth activeMonth( iDate.DateTime().Month() );
|
|
1766 |
TMonth newMonth( newActiveDay.DateTime().Month() );
|
|
1767 |
if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
|
|
1768 |
{
|
|
1769 |
// set the context
|
|
1770 |
TCalTime time;
|
|
1771 |
time.SetTimeLocalL( newActiveDay );
|
|
1772 |
iServices.Context().SetFocusDateL( time,
|
|
1773 |
TVwsViewId( KUidCalendar, KUidCalenMonthView ) );
|
|
1774 |
iGrid->HandlePointerEventL( pointerEvent );
|
|
1775 |
if (iPreview)
|
|
1776 |
{
|
|
1777 |
iPreview->Hide();
|
|
1778 |
}
|
|
1779 |
if ( pointerIndex != index )
|
|
1780 |
{
|
|
1781 |
iChangeMonth = EFalse;
|
|
1782 |
if ( activeMonth != newMonth )
|
|
1783 |
{
|
|
1784 |
iChangeMonth = ETrue;
|
|
1785 |
iGrid->View()->SetDisableRedraw(ETrue);
|
|
1786 |
iView->BeginRepopulationL();
|
|
1787 |
iDate = newActiveDay;
|
|
1788 |
}
|
|
1789 |
HandleDayChangeL( newActiveDay );
|
|
1790 |
}
|
|
1791 |
}
|
|
1792 |
else if ( activeMonth == newMonth
|
|
1793 |
&& newActiveDay != iDate && !iChangeMonth )
|
|
1794 |
{
|
|
1795 |
iChangeDay = ETrue;
|
|
1796 |
// use grid index to make sure that correct grid
|
|
1797 |
// element is focused when dragged
|
|
1798 |
TInt gridIndex = GridIndex();
|
|
1799 |
newActiveDay =
|
|
1800 |
( iFirstDayOfGrid + TTimeIntervalDays( gridIndex ) );
|
|
1801 |
}
|
|
1802 |
}
|
|
1803 |
else if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
|
|
1804 |
{
|
|
1805 |
if( !iChangeDay && !iChangeMonth )
|
|
1806 |
{
|
|
1807 |
iGrid->HandlePointerEventL( pointerEvent );
|
|
1808 |
}
|
|
1809 |
iChangeDay = EFalse;
|
|
1810 |
iChangeMonth = EFalse;
|
|
1811 |
}
|
|
1812 |
}
|
|
1813 |
}
|
|
1814 |
|
|
1815 |
TRACE_EXIT_POINT;
|
|
1816 |
}
|
|
1817 |
|
|
1818 |
|
|
1819 |
|
|
1820 |
// ----------------------------------------------------------------------------
|
|
1821 |
// CCalenMonthContainer::HandleListBoxEventL
|
|
1822 |
// ----------------------------------------------------------------------------
|
|
1823 |
//
|
|
1824 |
void CCalenMonthContainer::HandleListBoxEventL(
|
|
1825 |
CEikListBox* /*aListBox*/, TListBoxEvent aEventType )
|
|
1826 |
{
|
|
1827 |
switch ( aEventType )
|
|
1828 |
{
|
|
1829 |
case ( MEikListBoxObserver::EEventItemClicked ):
|
|
1830 |
{
|
|
1831 |
if ( !iView->MenuBar()->IsDisplayed() && !iGestureHandled )
|
|
1832 |
{
|
|
1833 |
iServices.IssueCommandL( ECalenForwardsToDayView );
|
|
1834 |
}
|
|
1835 |
break;
|
|
1836 |
}
|
|
1837 |
}
|
|
1838 |
}
|
|
1839 |
|
|
1840 |
// ----------------------------------------------------------------------------
|
|
1841 |
// CCalenMonthContainer::HandleGestureL
|
|
1842 |
//
|
|
1843 |
// ----------------------------------------------------------------------------
|
|
1844 |
void CCalenMonthContainer::HandleGestureL( const GestureHelper::MGestureEvent& aEvent )
|
|
1845 |
{
|
|
1846 |
GestureHelper::TGestureCode code = aEvent.Code( GestureHelper::MGestureEvent::EAxisBoth );
|
|
1847 |
|
|
1848 |
switch ( code )
|
|
1849 |
{
|
|
1850 |
case GestureHelper::EGestureStart:
|
|
1851 |
{
|
|
1852 |
iGestureHandled = EFalse;
|
|
1853 |
break;
|
|
1854 |
}
|
|
1855 |
case GestureHelper::EGestureSwipeRight:
|
|
1856 |
{
|
|
1857 |
if(!iChangeMonth)
|
|
1858 |
{
|
|
1859 |
HandleNaviDecoratorEventL( EAknNaviDecoratorEventLeftTabArrow );
|
|
1860 |
}
|
|
1861 |
|
|
1862 |
iGestureHandled = ETrue;
|
|
1863 |
break;
|
|
1864 |
}
|
|
1865 |
case GestureHelper::EGestureSwipeLeft:
|
|
1866 |
{
|
|
1867 |
if(!iChangeMonth)
|
|
1868 |
{
|
|
1869 |
HandleNaviDecoratorEventL( EAknNaviDecoratorEventRightTabArrow );
|
|
1870 |
}
|
|
1871 |
iGestureHandled = ETrue;
|
|
1872 |
break;
|
|
1873 |
}
|
|
1874 |
default:
|
|
1875 |
// Other gestures are not handled here
|
|
1876 |
break;
|
|
1877 |
}
|
|
1878 |
}
|
|
1879 |
|
|
1880 |
// ----------------------------------------------------------------------------
|
|
1881 |
// CCalenMonthContainer::HidePopup
|
|
1882 |
// ----------------------------------------------------------------------------
|
|
1883 |
void CCalenMonthContainer::HidePopup()
|
|
1884 |
{
|
|
1885 |
TRACE_ENTRY_POINT;
|
|
1886 |
if (iPreview)
|
|
1887 |
{
|
|
1888 |
iPreview->Hide();
|
|
1889 |
}
|
|
1890 |
TRACE_EXIT_POINT;
|
|
1891 |
}
|
|
1892 |
|
|
1893 |
// ----------------------------------------------------------------------------
|
|
1894 |
// CCalenMonthContainer::RedrawPreviewPane
|
|
1895 |
// Redraws the preview pane
|
|
1896 |
// ----------------------------------------------------------------------------
|
|
1897 |
void CCalenMonthContainer::RedrawPreviewPane()
|
|
1898 |
{
|
|
1899 |
// dont focus the preview popup/previewpane if any dialog or faster app is active
|
|
1900 |
if(iPreview && ! iView->IsEditorActiveOrFasterAppExit())
|
|
1901 |
{
|
|
1902 |
TRAPD(error,iPreview->FocusChangedL( iServices.Context().FocusDateAndTimeL().TimeLocalL() ) );
|
|
1903 |
if(error!=KErrNone)
|
|
1904 |
{
|
|
1905 |
// Do nothing to avoid warning
|
|
1906 |
}
|
|
1907 |
}
|
|
1908 |
}
|
|
1909 |
|
|
1910 |
// ----------------------------------------------------------------------------
|
|
1911 |
// CCalenMonthContainer::PrepareForPopulationL
|
|
1912 |
// First population step (with no instance view).
|
|
1913 |
// (other items were commented in a header).
|
|
1914 |
// ----------------------------------------------------------------------------
|
|
1915 |
//
|
|
1916 |
void CCalenMonthContainer::PrepareForPopulationL()
|
|
1917 |
{
|
|
1918 |
TRACE_ENTRY_POINT;
|
|
1919 |
|
|
1920 |
iGrid->View()->SetDisableRedraw( ETrue );
|
|
1921 |
HidePopup();
|
|
1922 |
UpdateSize();
|
|
1923 |
SetActiveDayL( CCalenContainer::DateFromContextL( iServices.Context() ) );
|
|
1924 |
SetDateL();
|
|
1925 |
|
|
1926 |
TRACE_EXIT_POINT;
|
|
1927 |
}
|
|
1928 |
|
|
1929 |
// ----------------------------------------------------------------------------
|
|
1930 |
// CCalenMonthContainer::PopulateWithInstanceViewL
|
|
1931 |
// Second population step (first with instance view).
|
|
1932 |
// Populates data from agenda server and sets number of notes.
|
|
1933 |
// (other items were commented in a header).
|
|
1934 |
// ----------------------------------------------------------------------------
|
|
1935 |
//
|
|
1936 |
void CCalenMonthContainer::PopulateWithInstanceViewL()
|
|
1937 |
{
|
|
1938 |
TRACE_ENTRY_POINT;
|
|
1939 |
RArray<TInt> colIdArray;
|
|
1940 |
CCalenNativeView::GetActiveCollectionidsL( iServices, colIdArray );
|
|
1941 |
|
|
1942 |
CCalInstanceView* instView = NULL;
|
|
1943 |
if( colIdArray.Count() > 0 )
|
|
1944 |
{
|
|
1945 |
instView = iServices.InstanceViewL( colIdArray );
|
|
1946 |
}
|
|
1947 |
|
|
1948 |
colIdArray.Reset();
|
|
1949 |
|
|
1950 |
if( !instView )
|
|
1951 |
{
|
|
1952 |
TRACE_EXIT_POINT;
|
|
1953 |
return;
|
|
1954 |
}
|
|
1955 |
|
|
1956 |
// 1) Find passed incompleted todos
|
|
1957 |
RPointerArray<CCalInstance> list;
|
|
1958 |
CleanupResetAndDestroyPushL( list );
|
|
1959 |
|
|
1960 |
TCalTime dummy;
|
|
1961 |
CalCommon::TCalTimeRange dayRange( dummy, dummy );
|
|
1962 |
|
|
1963 |
const TTime today( CalenDateUtils::Today() );
|
|
1964 |
const TTime gridStart( CalenDateUtils::BeginningOfDay( iFirstDayOfGrid ) );
|
|
1965 |
|
|
1966 |
const TInt todayIndex( today.DaysFrom( gridStart ).Int() ); // grid index for "today"
|
|
1967 |
const TInt cellCount( KCalenDaysInWeek * KNumberOfRows );
|
|
1968 |
|
|
1969 |
CalCommon::TCalViewFilter filter;
|
|
1970 |
|
|
1971 |
//If we are viewing months in the past
|
|
1972 |
if( todayIndex >= cellCount )
|
|
1973 |
{
|
|
1974 |
filter = CalCommon::EIncludeEvents |
|
|
1975 |
CalCommon::EIncludeAppts |
|
|
1976 |
CalCommon::EIncludeReminder |
|
|
1977 |
CalCommon::EIncludeAnnivs;
|
|
1978 |
}
|
|
1979 |
else //else we are viewing current or future months
|
|
1980 |
{
|
|
1981 |
filter = CalCommon::EIncludeEvents |
|
|
1982 |
CalCommon::EIncludeIncompletedTodos |
|
|
1983 |
CalCommon::EIncludeAppts |
|
|
1984 |
CalCommon::EIncludeReminder |
|
|
1985 |
CalCommon::EIncludeAnnivs;
|
|
1986 |
}
|
|
1987 |
|
|
1988 |
// Find To Dos, Meetings, Reminders, Anniversaries and Day Notes
|
|
1989 |
CalenDateUtils::GetDayRangeL( gridStart,
|
|
1990 |
gridStart + TTimeIntervalDays(cellCount-1),
|
|
1991 |
dayRange );
|
|
1992 |
instView->FindInstanceL( list, filter, dayRange );
|
|
1993 |
|
|
1994 |
//Parse fetched items
|
|
1995 |
if( list.Count() )
|
|
1996 |
{
|
|
1997 |
CCalInstance* instance = NULL;
|
|
1998 |
for (TInt i(0); i < list.Count(); i++)
|
|
1999 |
{
|
|
2000 |
instance = list[i];
|
|
2001 |
CCalEntry& entry = instance->Entry();
|
|
2002 |
//Parse Day Notes, Appointments and Reminders
|
|
2003 |
//Start and end time of Event/Appointment/Reminders has to be indentified before marking the tags
|
|
2004 |
//EEvents/Appointments can span multiple days, while Anniversaries cannot.
|
|
2005 |
if( ( entry.EntryTypeL() == CCalEntry::EEvent ) ||
|
|
2006 |
( entry.EntryTypeL() == CCalEntry::EAppt ) ||
|
|
2007 |
( entry.EntryTypeL() == CCalEntry::EReminder ) )
|
|
2008 |
{
|
|
2009 |
// The start time of the instance
|
|
2010 |
TTime instStartTime = instance->StartTimeL().TimeLocalL();
|
|
2011 |
// The instance's start index from the grid start
|
|
2012 |
TInt startIndex(instStartTime.DaysFrom(gridStart).Int());
|
|
2013 |
// The end time of the instance
|
|
2014 |
TTime instEndTime = instance->EndTimeL().TimeLocalL();
|
|
2015 |
|
|
2016 |
if( CalenAgendaUtils::EndsAtStartOfDayL( instance, instEndTime ) )
|
|
2017 |
{
|
|
2018 |
// prevent problems with items ending tomorrow at 00:00
|
|
2019 |
instEndTime -= TTimeIntervalMinutes( 1 );
|
|
2020 |
|
|
2021 |
if( instEndTime <= gridStart )
|
|
2022 |
{
|
|
2023 |
// ends at the start of the grid -> not visible
|
|
2024 |
continue; // skip
|
|
2025 |
}
|
|
2026 |
}
|
|
2027 |
// The instance's end index from the grid start
|
|
2028 |
TInt endIndex(instEndTime.DaysFrom(gridStart).Int());
|
|
2029 |
|
|
2030 |
// Mark the days from start index to end index
|
|
2031 |
for( ; startIndex <= endIndex; startIndex++)
|
|
2032 |
{
|
|
2033 |
if( startIndex >= 0 && startIndex < cellCount )
|
|
2034 |
{
|
|
2035 |
iMonthDataArray->At( startIndex ).SetHasEvents( ETrue );
|
|
2036 |
}
|
|
2037 |
}
|
|
2038 |
}
|
|
2039 |
//Parse Anniversaries
|
|
2040 |
else if( entry.EntryTypeL() == CCalEntry::EAnniv )
|
|
2041 |
{
|
|
2042 |
// The start time of the instance
|
|
2043 |
TTime instStartTime = instance->StartTimeL().TimeLocalL();
|
|
2044 |
// The instance's start index from the grid start
|
|
2045 |
TInt index(instStartTime.DaysFrom(gridStart).Int());
|
|
2046 |
// Mark the particular day
|
|
2047 |
if( index >= 0 && index < cellCount)
|
|
2048 |
{
|
|
2049 |
iMonthDataArray->At( index ).SetHasEvents( ETrue );
|
|
2050 |
}
|
|
2051 |
}
|
|
2052 |
//Parse To DOs
|
|
2053 |
else if( entry.EntryTypeL() == CCalEntry::ETodo )
|
|
2054 |
{
|
|
2055 |
// The start time of the instance
|
|
2056 |
TTime instStartTime = instance->StartTimeL().TimeLocalL();
|
|
2057 |
TInt index;
|
|
2058 |
// Mark the particular day if the instance's start time is not in the past
|
|
2059 |
if( instStartTime >= today )
|
|
2060 |
{
|
|
2061 |
index = instStartTime.DaysFrom(gridStart).Int();
|
|
2062 |
}
|
|
2063 |
else // Mark for today if the instance's start time is in the past
|
|
2064 |
{
|
|
2065 |
index = todayIndex;
|
|
2066 |
}
|
|
2067 |
if( index >= 0 && index < cellCount)
|
|
2068 |
{
|
|
2069 |
iMonthDataArray->At( index ).SetHasEvents( ETrue );
|
|
2070 |
}
|
|
2071 |
}
|
|
2072 |
}
|
|
2073 |
}
|
|
2074 |
list.ResetAndDestroy();
|
|
2075 |
|
|
2076 |
//Fetch incomplete To Dos if todayindex is not marked
|
|
2077 |
if( todayIndex >= 0 && todayIndex < cellCount )
|
|
2078 |
{
|
|
2079 |
// If today is not marked
|
|
2080 |
if( !iMonthDataArray->At( todayIndex ).HasEvents() )
|
|
2081 |
{
|
|
2082 |
// Find incomplete ToDos from MinTime() to end of this month
|
|
2083 |
CalenDateUtils::GetDayRangeL( TCalTime::MinTime(),
|
|
2084 |
today,
|
|
2085 |
dayRange );
|
|
2086 |
instView->FindInstanceL( list, CalCommon::EIncludeIncompletedTodos |
|
|
2087 |
// only fetch the first instance for repeating to-dos!
|
|
2088 |
CalCommon::EIncludeRptsNextInstanceOnly, dayRange );
|
|
2089 |
|
|
2090 |
// If there exists any To do, the mark for today
|
|
2091 |
if( list.Count() )
|
|
2092 |
{
|
|
2093 |
iMonthDataArray->At( todayIndex ).SetHasEvents( ETrue );
|
|
2094 |
}
|
|
2095 |
list.ResetAndDestroy();
|
|
2096 |
}
|
|
2097 |
}
|
|
2098 |
CleanupStack::PopAndDestroy( &list );
|
|
2099 |
|
|
2100 |
TRACE_EXIT_POINT;
|
|
2101 |
}
|
|
2102 |
|
|
2103 |
// ----------------------------------------------------------------------------
|
|
2104 |
// CCalenMonthContainer::SetIndicatorL
|
|
2105 |
// Set event indicator to each day.
|
|
2106 |
// Third population step (second with instance view).
|
|
2107 |
// (other items were commented in a header).
|
|
2108 |
// ----------------------------------------------------------------------------
|
|
2109 |
//
|
|
2110 |
void CCalenMonthContainer::SetIndicatorL()
|
|
2111 |
{
|
|
2112 |
TRACE_ENTRY_POINT;
|
|
2113 |
|
|
2114 |
// set data for note's indicators
|
|
2115 |
CDesCArray* itemArray =
|
|
2116 |
static_cast<CDesCArray*>( iGrid->Model()->ItemTextArray() );
|
|
2117 |
itemArray->Reset();
|
|
2118 |
|
|
2119 |
TDateTime currentTime( iDate.DateTime() );
|
|
2120 |
TInt days(Time::DaysInMonth(currentTime.Year(), currentTime.Month()));
|
|
2121 |
TLocale locale;
|
|
2122 |
TTime firstDay(iDate -
|
|
2123 |
TTimeIntervalDays(iDate.DayNoInMonth()));
|
|
2124 |
TInt start(firstDay.DayNoInWeek() - locale.StartOfWeek());
|
|
2125 |
if (start < 0)
|
|
2126 |
{
|
|
2127 |
start += KCalenDaysInWeek;
|
|
2128 |
}
|
|
2129 |
TInt end(days + start);
|
|
2130 |
|
|
2131 |
TInt i(0);
|
|
2132 |
for ( ; i < KNumberOfRows * KCalenDaysInWeek; ++i )
|
|
2133 |
{
|
|
2134 |
TBuf<16> data; // Enough for day number (2) + '\t' + icon number
|
|
2135 |
TCalenMonthData orgData(iMonthDataArray->At(i));
|
|
2136 |
TTime time(orgData.Day());
|
|
2137 |
time.FormatL(data, iDayFormat);
|
|
2138 |
|
|
2139 |
TIconIndex iconIndex = EIconNull;
|
|
2140 |
if (orgData.HasEvents())
|
|
2141 |
{
|
|
2142 |
if (i < start || i >= end )
|
|
2143 |
{
|
|
2144 |
iconIndex = EIconGrayed;
|
|
2145 |
}
|
|
2146 |
else
|
|
2147 |
{
|
|
2148 |
iconIndex = EIconMany;
|
|
2149 |
}
|
|
2150 |
}
|
|
2151 |
else
|
|
2152 |
{
|
|
2153 |
iconIndex = EIconNull;
|
|
2154 |
}
|
|
2155 |
|
|
2156 |
TBuf<3> icon;
|
|
2157 |
icon.Num(static_cast<TInt64>(iconIndex));
|
|
2158 |
data.Append(icon);
|
|
2159 |
|
|
2160 |
itemArray->AppendL(data);
|
|
2161 |
}
|
|
2162 |
iGrid->HandleItemAdditionL();
|
|
2163 |
|
|
2164 |
// if month of item of index is same as month of active day,
|
|
2165 |
// then item is selected,if not, item is deselected.
|
|
2166 |
// Deselected items will be writted in light.
|
|
2167 |
for ( i = 0; i < KNumberOfRows * KCalenDaysInWeek; ++i )
|
|
2168 |
{
|
|
2169 |
TCalenMonthData orgData(iMonthDataArray->At(i));
|
|
2170 |
TTime time(orgData.Day());
|
|
2171 |
|
|
2172 |
TInt listBoxIndex(static_cast<CAknGridView*>(
|
|
2173 |
iGrid->View())->ListBoxIndex(i));
|
|
2174 |
|
|
2175 |
if (time.DateTime().Month() == iDate.DateTime().Month())
|
|
2176 |
{
|
|
2177 |
iGrid->View()->SelectItemL(listBoxIndex);
|
|
2178 |
}
|
|
2179 |
else
|
|
2180 |
{
|
|
2181 |
iGrid->View()->DeselectItem(listBoxIndex);
|
|
2182 |
}
|
|
2183 |
}
|
|
2184 |
|
|
2185 |
TRACE_EXIT_POINT;
|
|
2186 |
}
|
|
2187 |
|
|
2188 |
// ----------------------------------------------------------------------------
|
|
2189 |
// CCalenMonthContainer::SetFocusL
|
|
2190 |
// Sets the current focus.
|
|
2191 |
// Fourth population step (third with instance view).
|
|
2192 |
// (other items were commented in a header).
|
|
2193 |
// ----------------------------------------------------------------------------
|
|
2194 |
//
|
|
2195 |
void CCalenMonthContainer::SetFocusL()
|
|
2196 |
{
|
|
2197 |
TRACE_ENTRY_POINT;
|
|
2198 |
|
|
2199 |
SetActiveDayL( CCalenContainer::DateFromContextL( iServices.Context() ) );
|
|
2200 |
iGrid->View()->SetDisableRedraw( EFalse );
|
|
2201 |
SetCursorToActiveDay();
|
|
2202 |
DrawDeferred();
|
|
2203 |
|
|
2204 |
TRACE_EXIT_POINT;
|
|
2205 |
}
|
|
2206 |
|
|
2207 |
// ----------------------------------------------------------------------------
|
|
2208 |
// CCalenMonthContainer::CompletePopulationL
|
|
2209 |
// Completes population.
|
|
2210 |
// Fifth population step (fourth with instance view).
|
|
2211 |
// (other items were commented in a header).
|
|
2212 |
// ----------------------------------------------------------------------------
|
|
2213 |
//
|
|
2214 |
void CCalenMonthContainer::CompletePopulationL()
|
|
2215 |
{
|
|
2216 |
TRACE_ENTRY_POINT;
|
|
2217 |
|
|
2218 |
AddToStackAndMakeVisibleL();
|
|
2219 |
|
|
2220 |
iView->SetEditorActive( EFalse );
|
|
2221 |
|
|
2222 |
// dont focus the preview popup/previewpane if any dialog or faster app is active
|
|
2223 |
if(iPreview && !iView->IsEditorActiveOrFasterAppExit())
|
|
2224 |
{
|
|
2225 |
// preview popup is shown when application comes to foreground
|
|
2226 |
iPreview->FocusChangedL( iServices.Context().FocusDateAndTimeL().TimeLocalL() );
|
|
2227 |
}
|
|
2228 |
|
|
2229 |
UpdateStatusPaneAndExtensionsL();
|
|
2230 |
// Hide/unhide "today" toolbar item based on the focused day
|
|
2231 |
UpdateTodayToolbarItemL();
|
|
2232 |
TRACE_EXIT_POINT;
|
|
2233 |
}
|
|
2234 |
|
|
2235 |
// ----------------------------------------------------------------------------
|
|
2236 |
// CCalenMonthContainer::InfoBarRectL
|
|
2237 |
// Returns the available info bar rect for this container
|
|
2238 |
// ----------------------------------------------------------------------------
|
|
2239 |
TRect CCalenMonthContainer::InfoBarRectL( TBool aToolbarAvailable )
|
|
2240 |
{
|
|
2241 |
TRACE_ENTRY_POINT;
|
|
2242 |
|
|
2243 |
TRect rect = Rect();
|
|
2244 |
|
|
2245 |
// Get the main pane
|
|
2246 |
TAknLayoutRect main_cale_month_pane;
|
|
2247 |
main_cale_month_pane.LayoutRect( Rect(),
|
|
2248 |
AknLayoutScalable_Apps::main_cale_month_pane().LayoutLine() );
|
|
2249 |
|
|
2250 |
TRect monthrect = main_cale_month_pane.Rect();
|
|
2251 |
|
|
2252 |
// Create a dummy label to find the layout rect
|
|
2253 |
CEikLabel* dummyLabel = new( ELeave ) CEikLabel;
|
|
2254 |
CleanupStack::PushL( dummyLabel );
|
|
2255 |
|
|
2256 |
// Get the layout variant for the month view infobar.
|
|
2257 |
// We assume that we have one for this check, as we need to
|
|
2258 |
// find the size that would be available if we do have one.
|
|
2259 |
TInt layoutVariant = 0;
|
|
2260 |
if( aToolbarAvailable )
|
|
2261 |
{
|
|
2262 |
layoutVariant = UseWeeks() ? 2 : 3 ;
|
|
2263 |
}
|
|
2264 |
else
|
|
2265 |
{
|
|
2266 |
layoutVariant = UseWeeks() ? 0 : 1 ;
|
|
2267 |
}
|
|
2268 |
|
|
2269 |
// Layout the dummy label to set its size
|
|
2270 |
AknLayoutUtils::LayoutLabel( dummyLabel, main_cale_month_pane.Rect(),
|
|
2271 |
AknLayoutScalable_Apps::cale_month_pane_t1( layoutVariant ).LayoutLine() );
|
|
2272 |
|
|
2273 |
TRect infoRect = dummyLabel->Rect();
|
|
2274 |
//TRect rect1;
|
|
2275 |
|
|
2276 |
// Discard the label
|
|
2277 |
CleanupStack::PopAndDestroy( dummyLabel );
|
|
2278 |
|
|
2279 |
TRACE_EXIT_POINT;
|
|
2280 |
return infoRect;
|
|
2281 |
}
|
|
2282 |
|
|
2283 |
// ----------------------------------------------------------------------------
|
|
2284 |
// CCalenMonthContainer::CreateIconIndicesL
|
|
2285 |
// Create icon index for day view
|
|
2286 |
// ----------------------------------------------------------------------------
|
|
2287 |
void CCalenMonthContainer::CreateIconIndicesL( RArray<MCalenServices::TCalenIcons>& aIndexArray)
|
|
2288 |
{
|
|
2289 |
TRACE_ENTRY_POINT;
|
|
2290 |
// Icons needed for the day view
|
|
2291 |
aIndexArray.Reset();
|
|
2292 |
aIndexArray.AppendL( MCalenServices::ECalenMonthManyEventIcon );
|
|
2293 |
aIndexArray.AppendL( MCalenServices::ECalenMonthGrayedEventIcon );
|
|
2294 |
|
|
2295 |
TRACE_EXIT_POINT;
|
|
2296 |
}
|
|
2297 |
|
|
2298 |
// End of File
|