|
1 /* |
|
2 * Copyright (c) 2002 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: |
|
15 * Contact Info View common base navigation stategy. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CPbkContactInfoBaseNavigationStrategy.h" // This class' declaration |
|
22 |
|
23 #include <barsread.h> // TResourceReader |
|
24 #include <aknnavide.h> |
|
25 #include <StringLoader.h> |
|
26 #include <akntabgrp.h> |
|
27 #include <gulicon.h> |
|
28 #include <eikspane.h> |
|
29 |
|
30 // Phonebook.app include files |
|
31 #include <Phonebook.rsg> |
|
32 #include <PbkView.rsg> |
|
33 #include <pbkdebug.h> |
|
34 |
|
35 // PbkEng.dll include files |
|
36 #include <PbkIconInfo.h> |
|
37 #include <CPbkContactItem.h> |
|
38 #include "MPbkContactInfoNavigationCallback.h" |
|
39 #include <Phonebook.hrh> |
|
40 |
|
41 |
|
42 /// Unnamed namespace for local definitions |
|
43 namespace { |
|
44 |
|
45 // LOCAL CONSTANTS AND MACROS |
|
46 // |
|
47 |
|
48 #ifdef _DEBUG |
|
49 enum TPanicCode |
|
50 { |
|
51 EPanicIcon_StatusPaneUpdateL |
|
52 }; |
|
53 #endif |
|
54 |
|
55 |
|
56 // ==================== LOCAL FUNCTIONS ==================== |
|
57 |
|
58 #ifdef _DEBUG |
|
59 void Panic(TPanicCode aReason) |
|
60 { |
|
61 _LIT(KPanicText, "CPbkContactInfoBaseNavigationStrategy"); |
|
62 User::Panic(KPanicText, aReason); |
|
63 } |
|
64 #endif |
|
65 |
|
66 } // namespace |
|
67 |
|
68 |
|
69 // ================= MEMBER FUNCTIONS ======================= |
|
70 |
|
71 CPbkContactInfoBaseNavigationStrategy::CPbkContactInfoBaseNavigationStrategy |
|
72 (CPbkContactEngine& aEngine, |
|
73 MPbkContactInfoNavigationCallback& aCallback) : |
|
74 iEngine(aEngine), |
|
75 iNavigationCallback(aCallback), |
|
76 iViewReady(EFalse) |
|
77 { |
|
78 } |
|
79 |
|
80 CPbkContactInfoBaseNavigationStrategy::~CPbkContactInfoBaseNavigationStrategy() |
|
81 { |
|
82 delete iNaviDeco; |
|
83 } |
|
84 |
|
85 TBool CPbkContactInfoBaseNavigationStrategy::HandleCommandKeyL |
|
86 (const TKeyEvent& aKeyEvent, |
|
87 TEventCode /*aType*/) |
|
88 { |
|
89 if (iViewReady) |
|
90 { |
|
91 switch (aKeyEvent.iCode) |
|
92 { |
|
93 case EKeyLeftArrow: // FALLTHROUGH |
|
94 case EKeyRightArrow: |
|
95 { |
|
96 TInt dir = 0; |
|
97 switch (aKeyEvent.iCode) |
|
98 { |
|
99 case EKeyLeftArrow: |
|
100 { |
|
101 dir = -1; |
|
102 break; |
|
103 } |
|
104 case EKeyRightArrow: |
|
105 { |
|
106 dir = 1; |
|
107 break; |
|
108 } |
|
109 } |
|
110 // Handle mirrored layout by negating the directionality |
|
111 if (AknLayoutUtils::LayoutMirrored()) |
|
112 { |
|
113 dir = -1 * dir; |
|
114 } |
|
115 NavigateContactL(dir); |
|
116 return ETrue; |
|
117 } |
|
118 } |
|
119 } |
|
120 return EFalse; |
|
121 } |
|
122 |
|
123 void CPbkContactInfoBaseNavigationStrategy::StatusPaneUpdateL() |
|
124 { |
|
125 // update the navi decorator |
|
126 if (iViewReady) |
|
127 { |
|
128 // check the index and count of the groups to navi pane |
|
129 const TInt index = iScrollView->FindL(iNavigationCallback.GetContactItemId()) + 1; |
|
130 |
|
131 // create navi pane text |
|
132 CArrayFixFlat<TInt>* values = new (ELeave) CArrayFixFlat<TInt>(2); |
|
133 CleanupStack::PushL(values); |
|
134 values->AppendL(index); |
|
135 values->AppendL(iScrollView->CountL()); |
|
136 HBufC* buf = StringLoader::LoadLC(R_QTN_PHOB_NAVI_POS_INDICATOR, |
|
137 *values); |
|
138 |
|
139 CPbkIconInfoContainer* iconInfoContainer = |
|
140 CPbkIconInfoContainer::NewL(R_PBK_ICON_INFO_ARRAY, CCoeEnv::Static()); |
|
141 CleanupStack::PushL(iconInfoContainer); |
|
142 |
|
143 CGulIcon* icon = iconInfoContainer->LoadBitmapL( |
|
144 EPbkqgn_prop_pb_contacts_tab1 ); |
|
145 __ASSERT_DEBUG(icon, Panic(EPanicIcon_StatusPaneUpdateL)); |
|
146 CleanupStack::PopAndDestroy(); // iconInfoContainer |
|
147 CleanupStack::PushL(icon); |
|
148 |
|
149 static_cast<CAknTabGroup*>(iNaviDeco->DecoratedControl()) |
|
150 ->ReplaceTabL(EPbkContactInfoViewId, *buf, icon->Bitmap(), |
|
151 icon->Mask()); |
|
152 // tab group takes ownership of bitmap and mask |
|
153 icon->SetBitmapsOwnedExternally(ETrue); |
|
154 CleanupStack::PopAndDestroy(3); // icon, buf, values |
|
155 } |
|
156 } |
|
157 |
|
158 void CPbkContactInfoBaseNavigationStrategy::ConstructNaviIndicatorsL() |
|
159 { |
|
160 // navi indicators |
|
161 CEikStatusPane* statusPane = iNavigationCallback.GetStatusPane(); |
|
162 if (statusPane && statusPane->PaneCapabilities |
|
163 (TUid::Uid(EEikStatusPaneUidNavi)).IsPresent()) |
|
164 { |
|
165 CAknNavigationControlContainer* naviPane = |
|
166 static_cast<CAknNavigationControlContainer*> |
|
167 (statusPane->ControlL(TUid::Uid(EEikStatusPaneUidNavi))); |
|
168 if (!iNaviDeco) |
|
169 { |
|
170 TResourceReader resReader; |
|
171 CCoeEnv::Static()->CreateResourceReaderLC(resReader, |
|
172 R_PBK_CONTACT_INFO_TAB_GROUP); |
|
173 iNaviDeco = naviPane->CreateTabGroupL(resReader); |
|
174 CleanupStack::PopAndDestroy(); // resReader |
|
175 } |
|
176 |
|
177 iNaviDeco->MakeScrollButtonVisible(ETrue); |
|
178 if (iScrollView->CountL() > 1) |
|
179 { |
|
180 iNaviDeco->SetScrollButtonDimmed |
|
181 (CAknNavigationDecorator::ERightButton, EFalse); |
|
182 iNaviDeco->SetScrollButtonDimmed |
|
183 (CAknNavigationDecorator::ELeftButton, EFalse); |
|
184 } |
|
185 else |
|
186 { |
|
187 iNaviDeco->SetScrollButtonDimmed |
|
188 (CAknNavigationDecorator::ERightButton, ETrue); |
|
189 iNaviDeco->SetScrollButtonDimmed |
|
190 (CAknNavigationDecorator::ELeftButton, ETrue); |
|
191 } |
|
192 naviPane->PushL(*iNaviDeco); |
|
193 } |
|
194 StatusPaneUpdateL(); |
|
195 } |
|
196 |
|
197 void CPbkContactInfoBaseNavigationStrategy::NavigateContactL |
|
198 (TInt aDir) |
|
199 { |
|
200 if (aDir == 0) |
|
201 { |
|
202 // no change |
|
203 return; |
|
204 } |
|
205 |
|
206 TInt contactIndex = iScrollView->FindL(iNavigationCallback.GetContactItemId()) + aDir; |
|
207 const TInt contactCount = iScrollView->CountL(); |
|
208 if (contactCount > 1) |
|
209 { |
|
210 if (contactIndex < 0) |
|
211 { |
|
212 contactIndex = contactCount + contactIndex; |
|
213 } |
|
214 else if (contactIndex >= contactCount) |
|
215 { |
|
216 contactIndex = contactIndex - contactCount; |
|
217 } |
|
218 const TContactItemId contactId = iScrollView->AtL(contactIndex); |
|
219 iNavigationCallback.ChangeContactL(contactId); |
|
220 |
|
221 StatusPaneUpdateL(); |
|
222 } |
|
223 } |
|
224 |
|
225 |
|
226 void CPbkContactInfoBaseNavigationStrategy::HandleContactViewEvent |
|
227 (const CContactViewBase& aView, |
|
228 const TContactViewEvent& aEvent) |
|
229 { |
|
230 if (&aView == iScrollView && |
|
231 aEvent.iEventType == TContactViewEvent::EReady) |
|
232 { |
|
233 iViewReady = ETrue; |
|
234 // navi pane construction |
|
235 TRAPD(err, ConstructNaviIndicatorsL()); |
|
236 if (err != KErrNone) |
|
237 { |
|
238 CCoeEnv::Static()->HandleError(err); |
|
239 } |
|
240 } |
|
241 } |
|
242 |
|
243 void CPbkContactInfoBaseNavigationStrategy::HandleContactViewListControlEventL |
|
244 (CPbkContactViewListControl& /*aControl*/, |
|
245 const TPbkContactViewListControlEvent& aEvent) |
|
246 { |
|
247 if (aEvent.iEventType == TPbkContactViewListControlEvent::EReady) |
|
248 { |
|
249 // navi pane update |
|
250 StatusPaneUpdateL(); |
|
251 } |
|
252 } |
|
253 |
|
254 // End of File |