|
1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Handling status pane. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "ccappheaders.h" |
|
21 #include <aknlayoutscalable_avkon.cdl.h> |
|
22 |
|
23 // ======== MEMBER FUNCTIONS ======== |
|
24 |
|
25 // --------------------------------------------------------------------------- |
|
26 // CCCAppStatusPaneHandler::CCCAppStatusPaneHandler |
|
27 // --------------------------------------------------------------------------- |
|
28 // |
|
29 CCCAppStatusPaneHandler::CCCAppStatusPaneHandler( CCCAppView& aView ): |
|
30 iView ( aView ) |
|
31 { |
|
32 } |
|
33 |
|
34 // --------------------------------------------------------------------------- |
|
35 // CCCAppStatusPaneHandler::~CCCAppStatusPaneHandler |
|
36 // --------------------------------------------------------------------------- |
|
37 // |
|
38 CCCAppStatusPaneHandler::~CCCAppStatusPaneHandler() |
|
39 { |
|
40 delete iDecoratedTabGroup; |
|
41 } |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // CCCAppStatusPaneHandler::NewL |
|
45 // --------------------------------------------------------------------------- |
|
46 // |
|
47 CCCAppStatusPaneHandler* CCCAppStatusPaneHandler::NewL( CCCAppView& aView ) |
|
48 { |
|
49 CCCAppStatusPaneHandler* self = new( ELeave ) CCCAppStatusPaneHandler( aView ); |
|
50 CleanupStack::PushL( self ); |
|
51 self->ConstructL(); |
|
52 CleanupStack::Pop( self ); |
|
53 return self; |
|
54 } |
|
55 |
|
56 // --------------------------------------------------------------------------- |
|
57 // CCCAppStatusPaneHandler::ConstructL |
|
58 // --------------------------------------------------------------------------- |
|
59 // |
|
60 void CCCAppStatusPaneHandler::ConstructL() |
|
61 { |
|
62 CCA_DP( KCCAppLogFile, CCA_L( "CCCAppStatusPaneHandler::ConstructL")); |
|
63 } |
|
64 |
|
65 // --------------------------------------------------------------------------- |
|
66 // CCCAppStatusPaneHandler::CreateTabsL |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 void CCCAppStatusPaneHandler::CreateTabsL() |
|
70 { |
|
71 CCA_DP( KCCAppLogFile, CCA_L( "CCCAppStatusPaneHandler::CreateTabsL")); |
|
72 |
|
73 for (TInt i = 0; i < iView.PluginLoader().PluginsCount(); i++) |
|
74 { |
|
75 TRAP_IGNORE(AddBitmapsL(i)); |
|
76 } |
|
77 |
|
78 CreateNavipaneL(); |
|
79 |
|
80 //Prepare all plugins, incl hidden plugins |
|
81 for (TInt i = 0; i < iView.PluginLoader().PluginsCount(); i++) |
|
82 { |
|
83 AddTabL( i ); |
|
84 } |
|
85 |
|
86 CCA_DP( KCCAppLogFile, CCA_L( "CCCAppStatusPaneHandler::CreateTabsL: Done.")); |
|
87 } |
|
88 |
|
89 |
|
90 // --------------------------------------------------------------------------- |
|
91 // CCCAppStatusPaneHandler::CreateNavipaneL |
|
92 // --------------------------------------------------------------------------- |
|
93 // |
|
94 void CCCAppStatusPaneHandler::CreateNavipaneL() |
|
95 { |
|
96 CCA_DP( KCCAppLogFile, CCA_L( "CCCAppStatusPaneHandler::CreateNavipaneL")); |
|
97 |
|
98 //Reset iTabAvailability to EFalse, since tab will be reconstructed |
|
99 iTabAvailability = EFalse; |
|
100 const TInt pluginCount = iView.PluginLoader().PluginsCount(); |
|
101 const TInt visiblePluginCount = iView.PluginLoader().VisiblePluginCount(); |
|
102 |
|
103 CAknNavigationControlContainer* naviPane = |
|
104 static_cast<CAknNavigationControlContainer*>( |
|
105 iView.AppUi().EikonEnv().AppUiFactory()->StatusPane()-> |
|
106 ControlL( TUid::Uid( EEikStatusPaneUidNavi )));//not owned |
|
107 |
|
108 //Delete tabs |
|
109 if( iDecoratedTabGroup ) |
|
110 { |
|
111 naviPane->Pop( iDecoratedTabGroup ); |
|
112 delete iDecoratedTabGroup; |
|
113 iDecoratedTabGroup = NULL; |
|
114 iTabGroupRef = NULL; |
|
115 } |
|
116 |
|
117 //(Re)create tabs if needed |
|
118 if( KCCAppMinPluginCountForTabs <= visiblePluginCount ) |
|
119 |
|
120 { |
|
121 iDecoratedTabGroup = naviPane->CreateTabGroupL( this ); |
|
122 iTabGroupRef = static_cast<CAknTabGroup*>( iDecoratedTabGroup->DecoratedControl() ); |
|
123 naviPane->PushL( *iDecoratedTabGroup ); |
|
124 iTabGroupRef->SetTabFixedWidthL( |
|
125 visiblePluginCount > KCCAppMinPluginCountForTabs |
|
126 ? KTabWidthWithThreeTabs : KTabWidthWithTwoTabs ); |
|
127 iDecoratedTabGroup->ActivateL(); |
|
128 //Set it to ETrue, since there is atleast 2items in the tab |
|
129 //and the tab will be visible |
|
130 iTabAvailability = ETrue; |
|
131 } |
|
132 |
|
133 CCA_DP( KCCAppLogFile, CCA_L( "CCCAppStatusPaneHandler::CreateNavipaneL: Done.")); |
|
134 } |
|
135 |
|
136 // --------------------------------------------------------------------------- |
|
137 // CCCAppStatusPaneHandler::ActivateTab |
|
138 // --------------------------------------------------------------------------- |
|
139 // |
|
140 void CCCAppStatusPaneHandler::ActivateTab( TInt aTabIndex ) |
|
141 { |
|
142 CCA_DP( KCCAppLogFile, CCA_L( "CCCAppStatusPaneHandler::ActivateTabL")); |
|
143 if( iTabGroupRef ) |
|
144 iTabGroupRef->SetActiveTabByIndex(aTabIndex); |
|
145 } |
|
146 |
|
147 // --------------------------------------------------------------------------- |
|
148 // CCCAppStatusPaneHandler::ActivateTabL |
|
149 // --------------------------------------------------------------------------- |
|
150 // |
|
151 void CCCAppStatusPaneHandler::ActivateTabL( TBool aForward ) |
|
152 { |
|
153 CCA_DP( KCCAppLogFile, CCA_L( "CCCAppStatusPaneHandler::ActivateTabL")); |
|
154 if( iTabGroupRef ) |
|
155 { |
|
156 // Since CCApp supports variation of keys for switching the plugins |
|
157 // but CAknTabGroup doesn't, some tweaking is needed. |
|
158 TKeyEvent keyEvent; |
|
159 keyEvent.iCode = aForward ? EKeyRightArrow : EKeyLeftArrow; |
|
160 iTabGroupRef->OfferKeyEventL( keyEvent, EEventKey ); |
|
161 } |
|
162 } |
|
163 |
|
164 // --------------------------------------------------------------------------- |
|
165 // CCCAppStatusPaneHandler::ActiveTabIndex |
|
166 // --------------------------------------------------------------------------- |
|
167 // |
|
168 TInt CCCAppStatusPaneHandler::ActiveTabIndex() |
|
169 { |
|
170 CCA_DP( KCCAppLogFile, CCA_L( "CCCAppStatusPaneHandler::ActiveTabIndex")); |
|
171 return iTabGroupRef ? iTabGroupRef->ActiveTabIndex() : KErrNotFound; |
|
172 } |
|
173 |
|
174 // --------------------------------------------------------------------------- |
|
175 // CCCAppStatusPaneHandler::TabCount |
|
176 // --------------------------------------------------------------------------- |
|
177 // |
|
178 TInt CCCAppStatusPaneHandler::TabCount() |
|
179 { |
|
180 CCA_DP( KCCAppLogFile, CCA_L( "CCCAppStatusPaneHandler::TabCount")); |
|
181 return iTabGroupRef ? iTabGroupRef->TabCount() : KErrNotFound; |
|
182 } |
|
183 |
|
184 // --------------------------------------------------------------------------- |
|
185 // CCCAppStatusPaneHandler::ReadBitmapsL |
|
186 // --------------------------------------------------------------------------- |
|
187 // |
|
188 void CCCAppStatusPaneHandler::AddBitmapsL( TInt aPlugin ) |
|
189 { |
|
190 CCCAppPluginData* data = iView.PluginLoader().PluginAt( aPlugin ); |
|
191 //Bitmaps provided |
|
192 |
|
193 if( !iView.PluginLoader().PluginAt( aPlugin )->iPluginBitmap ) |
|
194 { |
|
195 CAknIcon* icon = CAknIcon::NewL(); |
|
196 CleanupStack::PushL( icon ); |
|
197 iView.PluginLoader().PluginAt( aPlugin )->Plugin().ProvideBitmapL( |
|
198 CCCAppViewPluginBase::ECCAppTabIcon, *icon ); |
|
199 data->iPluginBitmap = icon->Bitmap(); |
|
200 data->iPluginBitmapMask = icon->Mask(); |
|
201 |
|
202 // Disable compression to check icon color scheme later |
|
203 AknIconUtils::DisableCompression( data->iPluginBitmap ); |
|
204 |
|
205 //Calculate preferred size for icons |
|
206 TRect mainPane; |
|
207 AknLayoutUtils::LayoutMetricsRect( |
|
208 AknLayoutUtils::EMainPane, mainPane ); |
|
209 TAknLayoutRect naviIconRect; |
|
210 naviIconRect.LayoutRect( |
|
211 mainPane, |
|
212 AknLayoutScalable_Avkon::navi_navi_icon_text_pane_g1() ); |
|
213 TSize size(naviIconRect.Rect().Size()); |
|
214 |
|
215 AknIconUtils::SetSize( data->iPluginBitmap, size ); |
|
216 AknIconUtils::SetSize( data->iPluginBitmapMask, size ); |
|
217 icon->SetBitmap( NULL ); |
|
218 icon->SetMask( NULL ); |
|
219 CleanupStack::PopAndDestroy( icon ); |
|
220 } |
|
221 |
|
222 CCA_DP( KCCAppLogFile, CCA_L( "CCCAppStatusPaneHandler::AddBitmapsL: Done.")); |
|
223 } |
|
224 |
|
225 |
|
226 // --------------------------------------------------------------------------- |
|
227 // CCCAppStatusPaneHandler::AddTabL |
|
228 // --------------------------------------------------------------------------- |
|
229 // |
|
230 void CCCAppStatusPaneHandler::AddTabL( TInt aPlugin ) |
|
231 { |
|
232 CCCAppPluginData* data = iView.PluginLoader().PluginAt( aPlugin ); |
|
233 |
|
234 if(iTabGroupRef && iView.PluginLoader().PluginAt( aPlugin )->PluginVisibility() == 1) |
|
235 { |
|
236 if(data->iPluginBitmap) |
|
237 { |
|
238 //Tabgroup takes ownership of duplicated bitmap handles |
|
239 CFbsBitmap* bmp = new( ELeave ) CFbsBitmap(); |
|
240 CleanupStack::PushL(bmp); |
|
241 CFbsBitmap* bmpMask = new( ELeave ) CFbsBitmap(); |
|
242 CleanupStack::PushL(bmpMask); |
|
243 |
|
244 bmp->Duplicate(data->iPluginBitmap->Handle()); |
|
245 bmpMask->Duplicate(data->iPluginBitmapMask->Handle()); |
|
246 iTabGroupRef->AddTabL( aPlugin, bmp, bmpMask ); |
|
247 CleanupStack::Pop(2); //bmp, bmpmask |
|
248 |
|
249 SEpocBitmapHeader header = bmp->Header(); |
|
250 if ( SEpocBitmapHeader::ENoColor != header.iColor ) |
|
251 { |
|
252 iTabGroupRef->SetTabMultiColorMode( aPlugin, ETrue ); |
|
253 } |
|
254 } |
|
255 else |
|
256 { |
|
257 iTabGroupRef->AddTabL( aPlugin, KNullDesC() ); |
|
258 } |
|
259 } |
|
260 |
|
261 CCA_DP( KCCAppLogFile, CCA_L( "CCCAppStatusPaneHandler::AddTabL: Done.")); |
|
262 } |
|
263 |
|
264 // --------------------------------------------------------------------------- |
|
265 // CCCAppStatusPaneHandler::TabChangedL |
|
266 // --------------------------------------------------------------------------- |
|
267 // |
|
268 void CCCAppStatusPaneHandler::TabChangedL( TInt aIndex ) |
|
269 { |
|
270 CCA_DP( KCCAppLogFile, CCA_L( "CCCAppStatusPaneHandler::TabChangedL")); |
|
271 |
|
272 // Tab changed succesfully, forward event to view to activate |
|
273 // appropriate plugin |
|
274 iView.TabChangedL( aIndex ); |
|
275 |
|
276 CCA_DP( KCCAppLogFile, CCA_L( "CCCAppStatusPaneHandler::TabChangedL: Done.")); |
|
277 } |
|
278 |
|
279 // --------------------------------------------------------------------------- |
|
280 // CCCAppStatusPaneHandler::IsTabAvailable |
|
281 // --------------------------------------------------------------------------- |
|
282 // |
|
283 TBool CCCAppStatusPaneHandler::IsTabAvailable() |
|
284 { |
|
285 CCA_DP( KCCAppLogFile, CCA_L("CCCAppStatusPaneHandler::IsTabAvailable %d"), iTabAvailability ); |
|
286 return iTabAvailability; |
|
287 } |
|
288 |
|
289 // End of File |