|
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 * Phonebook view navigation implementation base class. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDES |
|
21 #include "CPbkViewNavigator.h" |
|
22 #include <barsread.h> |
|
23 #include <aknnavi.h> |
|
24 #include <aknnavide.h> |
|
25 #include <akntabgrp.h> |
|
26 #include <AknsUtils.h> |
|
27 |
|
28 #include <CPbkAppUiBase.h> |
|
29 #include <DigViewGraph.h> |
|
30 |
|
31 #include <PbkIcons.hrh> |
|
32 |
|
33 #include <CPbkExtGlobals.h> |
|
34 #include <MPbkExtensionFactory.h> |
|
35 #include <PbkIconInfo.h> |
|
36 #include <Phonebook.rsg> |
|
37 |
|
38 // ================= MEMBER FUNCTIONS ======================= |
|
39 |
|
40 CPbkViewNavigator::~CPbkViewNavigator() |
|
41 { |
|
42 iViewTabGroups.ResetAndDestroy(); |
|
43 Release(iExtGlobals); |
|
44 } |
|
45 |
|
46 CAknNavigationDecorator* CPbkViewNavigator::TabGroupFromId(TInt aTabId) const |
|
47 { |
|
48 const TInt tabGroupCount = iViewTabGroups.Count(); |
|
49 for (TInt i=0; i < tabGroupCount; ++i) |
|
50 { |
|
51 CAknNavigationDecorator* decorator = |
|
52 CONST_CAST(CAknNavigationDecorator*, iViewTabGroups[i]); |
|
53 CAknTabGroup* tabGroup = |
|
54 static_cast<CAknTabGroup*>(decorator->DecoratedControl()); |
|
55 if (tabGroup->TabIndexFromId(aTabId) >= 0) |
|
56 { |
|
57 return decorator; |
|
58 } |
|
59 } |
|
60 return NULL; |
|
61 } |
|
62 |
|
63 void CPbkViewNavigator::BaseConstructL() |
|
64 { |
|
65 iExtGlobals = CPbkExtGlobals::InstanceL(); |
|
66 |
|
67 iNaviPane = static_cast<CAknNavigationControlContainer*> |
|
68 (iAppUi.StatusPane()->ControlL(TUid::Uid(EEikStatusPaneUidNavi))); |
|
69 |
|
70 RArray<TInt> tabGroupIds; |
|
71 CleanupClosePushL(tabGroupIds); |
|
72 const TInt nodeCount = iViewGraph.Count(); |
|
73 for (TInt i=0; i < nodeCount; ++i) |
|
74 { |
|
75 const CDigViewNode& viewNode = iViewGraph[i]; |
|
76 const TInt resId = viewNode.AdditionalResId(); |
|
77 if (resId != 0 && tabGroupIds.Find(resId) == KErrNotFound) |
|
78 { |
|
79 User::LeaveIfError(tabGroupIds.Append(resId)); |
|
80 TResourceReader resReader; |
|
81 iAppUi.ControlEnv()->CreateResourceReaderLC(resReader, resId); |
|
82 CAknNavigationDecorator* tabGroup = CreateTabGroupL(resReader); |
|
83 CleanupStack::PushL(tabGroup); |
|
84 User::LeaveIfError(iViewTabGroups.Append(tabGroup)); |
|
85 CleanupStack::Pop(tabGroup); |
|
86 CleanupStack::PopAndDestroy(); // resReader |
|
87 } |
|
88 } |
|
89 |
|
90 // Call this to skin the tab bitmaps |
|
91 HandleResourceChange(KAknsMessageSkinChange); |
|
92 |
|
93 CleanupStack::PopAndDestroy(&tabGroupIds); |
|
94 } |
|
95 |
|
96 void CPbkViewNavigator::HandleResourceChange(TInt aType) |
|
97 { |
|
98 const TInt tabGroupCount = iViewTabGroups.Count(); |
|
99 for (TInt i=0; i<tabGroupCount; ++i) |
|
100 { |
|
101 CAknTabGroup* tabGroup = TabGroupFromIndex(i); |
|
102 tabGroup->HandleResourceChange(aType); |
|
103 } |
|
104 |
|
105 if (aType == KAknsMessageSkinChange) |
|
106 { |
|
107 SkinTabBitmaps(); |
|
108 } |
|
109 } |
|
110 |
|
111 CAknTabGroup* CPbkViewNavigator::TabGroupFromIndex (TInt aIndex) const |
|
112 { |
|
113 CAknNavigationDecorator* decorator = |
|
114 CONST_CAST(CAknNavigationDecorator*, iViewTabGroups[aIndex]); |
|
115 CAknTabGroup* tabGroup = |
|
116 static_cast<CAknTabGroup*>(decorator->DecoratedControl()); |
|
117 |
|
118 return tabGroup; |
|
119 } |
|
120 |
|
121 void CPbkViewNavigator::SkinTabBitmaps() |
|
122 { |
|
123 TRAP_IGNORE(DoSkinTabBitmapsL()); |
|
124 } |
|
125 |
|
126 void CPbkViewNavigator::DoSkinTabBitmapsL() |
|
127 { |
|
128 CPbkIconInfoContainer* iconInfoContainer = |
|
129 CPbkIconInfoContainer::NewL(R_PBK_TAB_ICON_INFO_ARRAY); |
|
130 CleanupStack::PushL(iconInfoContainer); |
|
131 |
|
132 // let extensions add their own tab icons |
|
133 iExtGlobals->FactoryL().AddPbkTabIconsL(iconInfoContainer); |
|
134 |
|
135 const TInt tabGroupCount = iViewTabGroups.Count(); |
|
136 for (TInt i=0; i<tabGroupCount; ++i) |
|
137 { |
|
138 CAknTabGroup* tabGroup = TabGroupFromIndex(i); |
|
139 SkinTabGroupL(*tabGroup, *iconInfoContainer); |
|
140 } |
|
141 |
|
142 CleanupStack::PopAndDestroy(iconInfoContainer); |
|
143 } |
|
144 |
|
145 void CPbkViewNavigator::SkinTabGroupL |
|
146 (CAknTabGroup& aTabGroup, CPbkIconInfoContainer& aIconInfoContainer) |
|
147 { |
|
148 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
149 |
|
150 const TInt count = aTabGroup.TabCount(); |
|
151 for (TInt i = 0; i < count; ++i) |
|
152 { |
|
153 TInt tabId = aTabGroup.TabIdFromIndex(i); |
|
154 // tabId is used as icon id |
|
155 const TPbkIconInfo* iconInfo = |
|
156 aIconInfoContainer.Find(TPbkIconId(tabId)); |
|
157 if (iconInfo) |
|
158 { |
|
159 CFbsBitmap* bitmap = NULL; |
|
160 CFbsBitmap* mask = NULL; |
|
161 PbkIconUtils::CreateIconLC( |
|
162 skin, bitmap, mask, *iconInfo); |
|
163 |
|
164 aTabGroup.ReplaceTabL(tabId, bitmap, mask); |
|
165 |
|
166 CleanupStack::Pop(2); // mask, bitmap |
|
167 } |
|
168 } |
|
169 } |
|
170 |
|
171 // End of File |