66
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: Calendar Toolbar Implementation
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include <gulicon.h>
|
|
21 |
#include <eikapp.h>
|
|
22 |
#include <StringLoader.h>
|
|
23 |
#include <aknappui.h>
|
|
24 |
#include <aknlayoutscalable_apps.cdl.h>
|
|
25 |
#include <eikcolib.h>
|
|
26 |
#include <akntoolbarextension.h>
|
|
27 |
#include <aknViewAppUi.h>
|
|
28 |
#include <aknbutton.h>
|
|
29 |
#include <akntoolbar.h>
|
|
30 |
#include <akntouchpane.h>
|
|
31 |
#include <calenview.h>
|
|
32 |
#include <missedalarmstore.h>
|
|
33 |
#include <calencommonui.rsg>
|
|
34 |
#include <Calendar.rsg>
|
|
35 |
#include <calencommands.hrh> // Calendar commands
|
|
36 |
#include <calenservices.h>
|
|
37 |
|
|
38 |
#include "calendarui_debug.h"
|
|
39 |
#include "calentoolbarimpl.h"
|
|
40 |
#include "calencontroller.h"
|
|
41 |
#include "calendar.hrh"
|
|
42 |
#include "calenviewmanager.h"
|
|
43 |
#include "CalenUid.h"
|
|
44 |
#include "calenviewinfo.h"
|
|
45 |
|
|
46 |
const TInt KPositionZero( 0 );
|
|
47 |
|
|
48 |
|
|
49 |
// ---------------------------------------------------------------------------
|
|
50 |
// CCalenToolbarImpl::NewL
|
|
51 |
// 1st phase of construction
|
|
52 |
// (other items were commented in a header).
|
|
53 |
// ---------------------------------------------------------------------------
|
|
54 |
//
|
|
55 |
CCalenToolbarImpl* CCalenToolbarImpl::NewL( CCalenController& aController )
|
|
56 |
{
|
|
57 |
TRACE_ENTRY_POINT;
|
|
58 |
|
|
59 |
CCalenToolbarImpl* self = new( ELeave ) CCalenToolbarImpl( aController );
|
|
60 |
CleanupStack::PushL( self );
|
|
61 |
self->ConstructL();
|
|
62 |
CleanupStack::Pop( self );
|
|
63 |
|
|
64 |
TRACE_EXIT_POINT;
|
|
65 |
return self;
|
|
66 |
}
|
|
67 |
|
|
68 |
// ---------------------------------------------------------------------------
|
|
69 |
// CCalenToolbarImpl::CCalenToolbarImpl
|
|
70 |
// C++ constructor
|
|
71 |
// (other items were commented in a header).
|
|
72 |
// ---------------------------------------------------------------------------
|
|
73 |
//
|
|
74 |
CCalenToolbarImpl::CCalenToolbarImpl( CCalenController& aController )
|
|
75 |
: iController( aController )
|
|
76 |
{
|
|
77 |
TRACE_ENTRY_POINT;
|
|
78 |
TRACE_EXIT_POINT;
|
|
79 |
}
|
|
80 |
|
|
81 |
// ---------------------------------------------------------------------------
|
|
82 |
// CCalenToolbarImpl::ConstructL
|
|
83 |
// 2nd phase of construction
|
|
84 |
// (other items were commented in a header).
|
|
85 |
// ---------------------------------------------------------------------------
|
|
86 |
//
|
|
87 |
void CCalenToolbarImpl::ConstructL()
|
|
88 |
{
|
|
89 |
TRACE_ENTRY_POINT;
|
|
90 |
|
|
91 |
iAppUi = static_cast<CAknAppUi*>( CEikonEnv::Static()->EikAppUi() );
|
|
92 |
iAppToolbar = iAppUi->CurrentFixedToolbar();
|
|
93 |
|
|
94 |
if(!AknLayoutUtils::LayoutMirrored())
|
|
95 |
{
|
|
96 |
iCalenToolbar = CAknToolbar::NewL(R_CALEN_TOOLBAR_EXTENSION);
|
|
97 |
}
|
|
98 |
else
|
|
99 |
{
|
|
100 |
iCalenToolbar = CAknToolbar::NewL(R_CALEN_TOOLBAR_EXTENSION_MIRRORED);
|
|
101 |
}
|
|
102 |
iCalenToolbar->SetToolbarObserver( static_cast<MAknToolbarObserver*>(this) );
|
|
103 |
iCalenToolbar->SetWithSliding(ETrue);
|
|
104 |
iCalenToolbar->SetCloseOnAllCommands(EFalse);
|
|
105 |
iStartUpToolbar = ETrue;
|
|
106 |
|
|
107 |
TRACE_EXIT_POINT;
|
|
108 |
}
|
|
109 |
|
|
110 |
// ---------------------------------------------------------------------------
|
|
111 |
// CCalenToolbarImpl::SetNextViewIcon
|
|
112 |
// When view is changed, update button icon for the next view
|
|
113 |
// (other items were commented in a header).
|
|
114 |
// ---------------------------------------------------------------------------
|
|
115 |
//
|
|
116 |
void CCalenToolbarImpl::SetNextViewIcon( CGulIcon *aIcon )
|
|
117 |
{
|
|
118 |
TRACE_ENTRY_POINT;
|
|
119 |
CAknButton* button = static_cast<CAknButton*>(
|
|
120 |
iCalenToolbar->ControlOrNull( ECalenNextView ) );
|
|
121 |
if( button )
|
|
122 |
{
|
|
123 |
CAknButtonState* state = button->State(); // get current button state, not own
|
|
124 |
state->SetIcon( aIcon );
|
|
125 |
}
|
|
126 |
else
|
|
127 |
{
|
|
128 |
delete aIcon;
|
|
129 |
}
|
|
130 |
iCalenToolbar->DrawDeferred();
|
|
131 |
TRACE_EXIT_POINT;
|
|
132 |
}
|
|
133 |
|
|
134 |
// ---------------------------------------------------------------------------
|
|
135 |
// CCalenToolbarImpl::~CCalenToolbarImpl
|
|
136 |
// Destructor
|
|
137 |
// ---------------------------------------------------------------------------
|
|
138 |
//
|
|
139 |
CCalenToolbarImpl::~CCalenToolbarImpl()
|
|
140 |
{
|
|
141 |
TRACE_ENTRY_POINT;
|
|
142 |
if(iCalenToolbar)
|
|
143 |
{
|
|
144 |
delete iCalenToolbar;
|
|
145 |
iCalenToolbar = NULL;
|
|
146 |
}
|
|
147 |
if(iExtensionToolbarCommands.Count())
|
|
148 |
{
|
|
149 |
iExtensionToolbarCommands.Close();
|
|
150 |
}
|
|
151 |
TRACE_EXIT_POINT;
|
|
152 |
}
|
|
153 |
|
|
154 |
// ----------------------------------------------------------------------------
|
|
155 |
// CCalenToolbarImpl::IsVisible
|
|
156 |
// Check if the toolbar is currently visible
|
|
157 |
// ----------------------------------------------------------------------------
|
|
158 |
TBool CCalenToolbarImpl::IsVisible()
|
|
159 |
{
|
|
160 |
TRACE_ENTRY_POINT;
|
|
161 |
TRACE_EXIT_POINT;
|
|
162 |
return iCalenToolbar->IsShown();
|
|
163 |
}
|
|
164 |
|
|
165 |
// ----------------------------------------------------------------------------
|
|
166 |
// CCalenToolbarImpl::SetToolbarVisibility
|
|
167 |
// Show or hide the toolbar. Has no effect if the toolbar is disabled
|
|
168 |
// ----------------------------------------------------------------------------
|
|
169 |
void CCalenToolbarImpl::SetToolbarVisibilityL( TBool aMakeVisible )
|
|
170 |
{
|
|
171 |
TRACE_ENTRY_POINT;
|
|
172 |
|
|
173 |
// Hides/Unhides toolbar items temporarily.
|
|
174 |
// EFalse :: drawing the items normally in portrait and landscape
|
|
175 |
// ETrue :: toolbar draws just background in landscape and is hidden in portrait
|
|
176 |
iAppToolbar->HideItemsAndDrawOnlyBackground(!aMakeVisible);
|
|
177 |
iCalenToolbar->HideItemsAndDrawOnlyBackground(!aMakeVisible);
|
|
178 |
|
|
179 |
TRACE_EXIT_POINT;
|
|
180 |
}
|
|
181 |
|
|
182 |
// ----------------------------------------------------------------------------
|
|
183 |
// CCalenToolbarImpl::UpdateToolbar
|
|
184 |
// Update the toolbar using Calendar layout information
|
|
185 |
// ----------------------------------------------------------------------------
|
|
186 |
void CCalenToolbarImpl::UpdateToolbar()
|
|
187 |
{
|
|
188 |
TRACE_ENTRY_POINT;
|
|
189 |
|
|
190 |
if( AknLayoutUtils::PenEnabled() )
|
|
191 |
{
|
|
192 |
TRect mainPaneRect;
|
|
193 |
AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane,
|
|
194 |
mainPaneRect );
|
|
195 |
|
|
196 |
TAknLayoutRect popup_toolbar_window_cp01;
|
|
197 |
popup_toolbar_window_cp01.LayoutRect(
|
|
198 |
mainPaneRect,
|
|
199 |
AknLayoutScalable_Apps::popup_toolbar_window_cp01().LayoutLine() );
|
|
200 |
TRect toolbar_rect( popup_toolbar_window_cp01.Rect() );
|
|
201 |
|
|
202 |
iCalenToolbar->SetPosition( toolbar_rect.iTl );
|
|
203 |
}
|
|
204 |
|
|
205 |
TRACE_EXIT_POINT;
|
|
206 |
}
|
|
207 |
|
|
208 |
// ----------------------------------------------------------------------------
|
|
209 |
// CCalenToolbarImpl::Toolbar
|
|
210 |
// Returns a reference to the CAknToolbar
|
|
211 |
// ----------------------------------------------------------------------------
|
|
212 |
CAknToolbar& CCalenToolbarImpl::Toolbar()
|
|
213 |
{
|
|
214 |
TRACE_ENTRY_POINT;
|
|
215 |
TRACE_EXIT_POINT;
|
|
216 |
return *iCalenToolbar;
|
|
217 |
}
|
|
218 |
|
|
219 |
// ---------------------------------------------------------------------------
|
|
220 |
// CCalenToolbarImpl::CalenToolbarExtensionL
|
|
221 |
// Dummy implementation.
|
|
222 |
// (other items were commented in a header).
|
|
223 |
// ---------------------------------------------------------------------------
|
|
224 |
//
|
|
225 |
TAny* CCalenToolbarImpl::CalenToolbarExtensionL( TUid /*aExtensionUid*/ )
|
|
226 |
{
|
|
227 |
TRACE_ENTRY_POINT;
|
|
228 |
TRACE_EXIT_POINT;
|
|
229 |
return NULL;
|
|
230 |
}
|
|
231 |
|
|
232 |
// ----------------------------------------------------------------------------
|
|
233 |
// CCalenToolbarImpl::DynInitToolbarL
|
|
234 |
// Called before toolbar is drawn. Allows modification of toolbar components
|
|
235 |
// based on current context
|
|
236 |
// ----------------------------------------------------------------------------
|
|
237 |
void CCalenToolbarImpl::DynInitToolbarL( TInt aResourceId, CAknToolbar* aToolbar )
|
|
238 |
{
|
|
239 |
TRACE_ENTRY_POINT;
|
|
240 |
|
|
241 |
if( aResourceId == R_CALEN_TOOLBAR &&
|
|
242 |
aToolbar == iCalenToolbar )
|
|
243 |
{
|
|
244 |
UpdateToolbar();
|
|
245 |
|
|
246 |
iCalenToolbar->SetFocusing( EFalse );
|
|
247 |
}
|
|
248 |
// for handling switchview command to populate the toolbar extension
|
|
249 |
if(aResourceId == ECalenSwitchView)
|
|
250 |
{
|
|
251 |
PopulateChangeViewToolbarExtensionL();
|
|
252 |
}
|
|
253 |
|
|
254 |
if(iStartUpToolbar)
|
|
255 |
{
|
|
256 |
CAknToolbarExtension* extension = iCalenToolbar->ToolbarExtension();
|
|
257 |
extension->RemoveItemL(ECalenLastCommand);
|
|
258 |
iStartUpToolbar = EFalse;
|
|
259 |
}
|
|
260 |
TRACE_EXIT_POINT;
|
|
261 |
}
|
|
262 |
|
|
263 |
// ----------------------------------------------------------------------------
|
|
264 |
// CCalenToolbarImpl::OfferToolbarEventL
|
|
265 |
// Handles toolbar events for a toolbar item
|
|
266 |
// ----------------------------------------------------------------------------
|
|
267 |
void CCalenToolbarImpl::OfferToolbarEventL( TInt aCommand )
|
|
268 |
{
|
|
269 |
TRACE_ENTRY_POINT;
|
|
270 |
|
|
271 |
if (iCalenToolbar)
|
|
272 |
{
|
|
273 |
iCalenToolbar->ToolbarExtension()->SetShown( EFalse );
|
|
274 |
}
|
|
275 |
|
|
276 |
// For handling toolbar extension commands
|
|
277 |
TInt position = iExtensionToolbarCommands.Find(aCommand);
|
|
278 |
if(position!=KErrNotFound)
|
|
279 |
{
|
|
280 |
TUid viewUid;
|
|
281 |
TVwsViewId targetViewId( KUidCalendar, viewUid.Uid(aCommand));
|
|
282 |
iController.ViewManager().SetRepopulation(EFalse);
|
|
283 |
iController.ViewManager().RequestActivationL(targetViewId);
|
|
284 |
}
|
|
285 |
else
|
|
286 |
{
|
|
287 |
// Send all the other toolbar events to the controller.
|
|
288 |
// This allows customisations
|
|
289 |
// to handle commands from custom toolbar buttons.
|
|
290 |
iController.IssueCommandL( aCommand );
|
|
291 |
}
|
|
292 |
TRACE_EXIT_POINT;
|
|
293 |
}
|
|
294 |
|
|
295 |
// ----------------------------------------------------------------------------
|
|
296 |
// CCalenToolbarImpl::HandleControlEvent
|
|
297 |
// Handles an event from an observed control
|
|
298 |
// ----------------------------------------------------------------------------
|
|
299 |
void CCalenToolbarImpl::HandleControlEventL( CCoeControl* aControl,
|
|
300 |
TCoeEvent aEventType )
|
|
301 |
{
|
|
302 |
TRACE_ENTRY_POINT;
|
|
303 |
|
|
304 |
if( AknLayoutUtils::PenEnabled() )
|
|
305 |
{
|
|
306 |
// forward control event to touch pane
|
|
307 |
if( iAppUi->TouchPane() )
|
|
308 |
{
|
|
309 |
iAppUi->TouchPane()->HandleControlEventL( aControl, aEventType );
|
|
310 |
}
|
|
311 |
}
|
|
312 |
|
|
313 |
TRACE_EXIT_POINT;
|
|
314 |
}
|
|
315 |
|
|
316 |
// ----------------------------------------------------------------------------
|
|
317 |
// CCalenToolbarImpl::CreateButtonL
|
|
318 |
// Create calendar toolbar buttons
|
|
319 |
// ----------------------------------------------------------------------------
|
|
320 |
CAknButton* CCalenToolbarImpl::CreateButtonL( CGulIcon* aIcon,
|
|
321 |
TInt aIconTextId,
|
|
322 |
TInt aToolTipId )
|
|
323 |
{
|
|
324 |
TRACE_ENTRY_POINT;
|
|
325 |
|
|
326 |
CAknButton* button = NULL;
|
|
327 |
HBufC* iconText = StringLoader::LoadLC(aIconTextId);
|
|
328 |
HBufC* toolTipText = StringLoader::LoadLC(aToolTipId);
|
|
329 |
|
|
330 |
button = CAknButton::NewL( aIcon, NULL, NULL, NULL, iconText->Des(),
|
|
331 |
toolTipText->Des(), KAknButtonTextInsideFrame, 0 );
|
|
332 |
|
|
333 |
CleanupStack::PopAndDestroy(toolTipText);
|
|
334 |
CleanupStack::PopAndDestroy(iconText);
|
|
335 |
|
|
336 |
button->SetIconScaleMode( EAspectRatioNotPreserved );
|
|
337 |
button->SetFocusing( EFalse );
|
|
338 |
button->SetTextAndIconAlignment(CAknButton::EIconOverText );
|
|
339 |
|
|
340 |
TRACE_EXIT_POINT;
|
|
341 |
return button;
|
|
342 |
}
|
|
343 |
|
|
344 |
// ----------------------------------------------------------------------------
|
|
345 |
// CCalenToolbarImpl::CreateButtonForCustomViewsL
|
|
346 |
// Create calendar toolbar buttons
|
|
347 |
// ----------------------------------------------------------------------------
|
|
348 |
CAknButton* CCalenToolbarImpl::CreateButtonForCustomViewsL( CGulIcon* aIcon,
|
|
349 |
TInt aIconTextId,
|
|
350 |
const TDesC &aIconText )
|
|
351 |
{
|
|
352 |
TRACE_ENTRY_POINT;
|
|
353 |
|
|
354 |
CAknButton* button = NULL;
|
|
355 |
HBufC* iconText = StringLoader::LoadLC(aIconTextId);
|
|
356 |
HBufC* toolTipText = HBufC::NewLC(aIconText.Length()+ iconText->Length()+1);
|
|
357 |
toolTipText->Des().Append(iconText->Des());
|
|
358 |
toolTipText->Des().Append(_L(" "));
|
|
359 |
toolTipText->Des().Append(aIconText);
|
|
360 |
|
|
361 |
button = CAknButton::NewL( aIcon, NULL, NULL, NULL, aIconText,
|
|
362 |
toolTipText->Des(), KAknButtonTextInsideFrame, 0 );
|
|
363 |
|
|
364 |
CleanupStack::PopAndDestroy(toolTipText);
|
|
365 |
CleanupStack::PopAndDestroy(iconText);
|
|
366 |
|
|
367 |
button->SetIconScaleMode( EAspectRatioNotPreserved );
|
|
368 |
button->SetFocusing( EFalse );
|
|
369 |
button->SetTextAndIconAlignment(CAknButton::EIconOverText );
|
|
370 |
|
|
371 |
TRACE_EXIT_POINT;
|
|
372 |
return button;
|
|
373 |
}
|
|
374 |
|
|
375 |
// ----------------------------------------------------------------------------
|
|
376 |
// CCalenToolbarImpl::PopulateChangeViewToolbarExtensionL
|
|
377 |
// Populate the change view toolbar extension with available cycling views
|
|
378 |
// read from viewinfoaray from view manager
|
|
379 |
// ----------------------------------------------------------------------------
|
|
380 |
void CCalenToolbarImpl::PopulateChangeViewToolbarExtensionL()
|
|
381 |
{
|
|
382 |
TRACE_ENTRY_POINT;
|
|
383 |
|
|
384 |
TInt viewPosition(KErrNotFound);
|
|
385 |
// get the view info array from viewmanager
|
|
386 |
RPointerArray<CCalenViewInfo>& viewInfoArray = iController.ViewManager().ViewInfoArray();
|
|
387 |
// get the current view id
|
|
388 |
TUid currentViewUid = iController.ViewManager().CurrentView();
|
|
389 |
|
|
390 |
// get view cycle position list
|
|
391 |
RArray<TUid> viewPositionArray;
|
|
392 |
GetViewPositionList( currentViewUid , viewPositionArray, viewInfoArray);
|
|
393 |
TInt position(KPositionZero);
|
|
394 |
|
|
395 |
ResetToolbarExtensionCommandsL();
|
|
396 |
// add toolbar items for native views
|
|
397 |
for(TInt index = KPositionZero ;index < viewPositionArray.Count() ;index++)
|
|
398 |
{
|
|
399 |
viewPosition = viewInfoArray.Find( viewPositionArray[index],
|
|
400 |
CCalenViewInfo::ViewInfoIdentifier );
|
|
401 |
if( viewPosition != KErrNotFound )
|
|
402 |
{
|
|
403 |
// add view toolbar items to the extendable toolbar
|
|
404 |
AddItemsToExtendableToolbarL( position,
|
|
405 |
*(viewInfoArray[viewPosition]) );
|
|
406 |
position++;
|
|
407 |
}
|
|
408 |
}
|
|
409 |
viewPositionArray.Reset();
|
|
410 |
|
|
411 |
TRACE_EXIT_POINT;
|
|
412 |
}
|
|
413 |
|
|
414 |
// ----------------------------------------------------------------------------
|
|
415 |
// CCalenToolbarImpl::ResetCalenToolbar
|
|
416 |
// Delete calendar toolbar
|
|
417 |
// ----------------------------------------------------------------------------
|
|
418 |
void CCalenToolbarImpl::ResetCalendarToolbar()
|
|
419 |
{
|
|
420 |
TRACE_ENTRY_POINT;
|
|
421 |
|
|
422 |
if(iCalenToolbar)
|
|
423 |
{
|
|
424 |
delete iCalenToolbar;
|
|
425 |
iCalenToolbar = NULL;
|
|
426 |
}
|
|
427 |
|
|
428 |
TRACE_EXIT_POINT;
|
|
429 |
}
|
|
430 |
|
|
431 |
// ----------------------------------------------------------------------------
|
|
432 |
// CCalenToolbarImpl::SetToolbarExtensionFocus
|
|
433 |
// For handling focus in toolbar extension
|
|
434 |
// ----------------------------------------------------------------------------
|
|
435 |
void CCalenToolbarImpl::SetToolbarExtensionFocus(TBool aFocus)
|
|
436 |
{
|
|
437 |
TRACE_ENTRY_POINT;
|
|
438 |
|
|
439 |
iCalenToolbar->ToolbarExtension()->SetShown(aFocus);
|
|
440 |
|
|
441 |
TRACE_EXIT_POINT;
|
|
442 |
}
|
|
443 |
|
|
444 |
// ----------------------------------------------------------------------------
|
|
445 |
// CCalenToolbarImpl::GetViewPositionList
|
|
446 |
// Get view position list based on the cycling positions
|
|
447 |
// ----------------------------------------------------------------------------
|
|
448 |
void CCalenToolbarImpl::GetViewPositionList( TUid aCurrentViewUid,
|
|
449 |
RArray<TUid>& aViewPositionArray,
|
|
450 |
RPointerArray<CCalenViewInfo>& aViewInfoArray)
|
|
451 |
{
|
|
452 |
TRACE_ENTRY_POINT;
|
|
453 |
TInt currViewInfoPos = aViewInfoArray.Find( aCurrentViewUid ,
|
|
454 |
CCalenViewInfo::ViewInfoIdentifier );
|
|
455 |
|
|
456 |
TInt index = aViewInfoArray.Find( KUidCalenMonthView , CCalenViewInfo::ViewInfoIdentifier );
|
|
457 |
|
|
458 |
while( index!= aViewInfoArray.Count() )
|
|
459 |
{
|
|
460 |
if( index == currViewInfoPos) // If last item,
|
|
461 |
{
|
|
462 |
index ++;
|
|
463 |
continue;
|
|
464 |
}
|
|
465 |
if(( aViewInfoArray[index]->CyclePosition() != CCalenView::ENoCyclePosition ) )
|
|
466 |
{
|
|
467 |
aViewPositionArray.Append(aViewInfoArray[index]->ViewUid());
|
|
468 |
}
|
|
469 |
index++;
|
|
470 |
}
|
|
471 |
|
|
472 |
TRACE_EXIT_POINT;
|
|
473 |
}
|
|
474 |
|
|
475 |
// ----------------------------------------------------------------------------
|
|
476 |
// CCalenToolbarImpl::AddItemsToExtendableToolbarL
|
|
477 |
// Add view toolbar items to the extendable toolbar as per view cycle positions
|
|
478 |
// ----------------------------------------------------------------------------
|
|
479 |
void CCalenToolbarImpl::AddItemsToExtendableToolbarL( TInt aIndex,
|
|
480 |
CCalenViewInfo& aViewInformation )
|
|
481 |
{
|
|
482 |
TRACE_ENTRY_POINT;
|
|
483 |
CGulIcon* icon = NULL;
|
|
484 |
CAknButton* button = NULL;
|
|
485 |
|
|
486 |
CCalenView* viewIcon = static_cast<CCalenView*>(
|
|
487 |
iController.AppUi().View( aViewInformation.ViewUid()) );
|
|
488 |
// get view icon
|
|
489 |
icon = viewIcon->ViewIconL();
|
|
490 |
|
|
491 |
TInt iconTextId(KErrNotFound);
|
|
492 |
TInt toolTipTextId(KErrNotFound);
|
|
493 |
|
|
494 |
if( ( iController.ViewManager().IsNativeView(aViewInformation.ViewUid() ) ) )
|
|
495 |
{
|
|
496 |
|
|
497 |
GetResourceIdForToolTip( aViewInformation.ViewUid(), iconTextId,
|
|
498 |
toolTipTextId );
|
|
499 |
// create toolbar button
|
|
500 |
button = CreateButtonL( icon,iconTextId, toolTipTextId );
|
|
501 |
}
|
|
502 |
|
|
503 |
else
|
|
504 |
{
|
|
505 |
const TDesC& iconText = aViewInformation.MenuName();
|
|
506 |
iconTextId = R_QTN_CALE_TB_CUSTOM_VIEW;
|
|
507 |
|
|
508 |
button = CreateButtonForCustomViewsL( icon, iconTextId, iconText );
|
|
509 |
}
|
|
510 |
|
|
511 |
// assign viewId as command
|
|
512 |
TInt command = viewIcon->ViewId().iViewUid.iUid;
|
|
513 |
|
|
514 |
CAknToolbarExtension* extension = iCalenToolbar->ToolbarExtension();
|
|
515 |
// Append the toolbar button to the calendar toolbar
|
|
516 |
extension->AddItemL( button, EAknCtButton, command , KAknButtonSizeFitText, aIndex );
|
|
517 |
|
|
518 |
iExtensionToolbarCommands.Append(command);
|
|
519 |
|
|
520 |
TRACE_EXIT_POINT;
|
|
521 |
}
|
|
522 |
|
|
523 |
// ----------------------------------------------------------------------------
|
|
524 |
// CCalenToolbarImpl::ResetToolbarExtensionCommandsL
|
|
525 |
// Reset toolbar extension commands
|
|
526 |
// ----------------------------------------------------------------------------
|
|
527 |
void CCalenToolbarImpl::ResetToolbarExtensionCommandsL()
|
|
528 |
{
|
|
529 |
TRACE_ENTRY_POINT;
|
|
530 |
if(iExtensionToolbarCommands.Count())
|
|
531 |
{
|
|
532 |
for(TInt index = 0; index < iExtensionToolbarCommands.Count();index++)
|
|
533 |
{
|
|
534 |
CAknToolbarExtension* extension = iCalenToolbar->ToolbarExtension();
|
|
535 |
extension->RemoveItemL(iExtensionToolbarCommands[index]);
|
|
536 |
}
|
|
537 |
iExtensionToolbarCommands.Close();
|
|
538 |
}
|
|
539 |
TRACE_EXIT_POINT;
|
|
540 |
}
|
|
541 |
|
|
542 |
// ----------------------------------------------------------------------------
|
|
543 |
// Get IconText and tooltip text resource ids for extendable toolbar items
|
|
544 |
// ----------------------------------------------------------------------------
|
|
545 |
void CCalenToolbarImpl::GetResourceIdForToolTip( TUid aViewUid, TInt& aIconTextId,
|
|
546 |
TInt& aToolTipTextId )
|
|
547 |
{
|
|
548 |
TRACE_ENTRY_POINT;
|
|
549 |
|
|
550 |
switch(aViewUid.iUid)
|
|
551 |
{
|
|
552 |
case KCalenMonthViewUidValue:
|
|
553 |
{
|
|
554 |
aIconTextId = R_QTN_CALE_TB_MONTH_VIEW;
|
|
555 |
aToolTipTextId = R_QTN_CALE_TB_MONTH_VIEW_TOOLTIP;
|
|
556 |
}
|
|
557 |
break;
|
|
558 |
case KCalenWeekViewUidValue:
|
|
559 |
{
|
|
560 |
aIconTextId = R_QTN_CALE_TB_WEEK_VIEW;
|
|
561 |
aToolTipTextId = R_QTN_CALE_TB_WEEK_VIEW_TOOLTIP;
|
|
562 |
}
|
|
563 |
break;
|
|
564 |
case KCalenDayViewUidValue:
|
|
565 |
{
|
|
566 |
aIconTextId = R_QTN_CALE_TB_DAY_VIEW;
|
|
567 |
aToolTipTextId = R_QTN_CALE_TB_DAY_VIEW_TOOLTIP;
|
|
568 |
}
|
|
569 |
break;
|
|
570 |
case KCalenTodoViewUidValue:
|
|
571 |
{
|
|
572 |
aIconTextId = R_QTN_CALE_TB_TODO_VIEW;
|
|
573 |
aToolTipTextId = R_QTN_CALE_TB_TODO_VIEW_TOOLTIP;
|
|
574 |
}
|
|
575 |
break;
|
|
576 |
default:
|
|
577 |
break;
|
|
578 |
}
|
|
579 |
|
|
580 |
TRACE_EXIT_POINT;
|
|
581 |
}
|
|
582 |
|
|
583 |
// End of file
|