20
|
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 "ccappcommlauncherpluginuids.hrh"
|
|
22 |
#include "ccappdetailsviewpluginuids.hrh"
|
|
23 |
#include <aknlayoutscalable_avkon.cdl.h>
|
|
24 |
|
|
25 |
|
|
26 |
// ======== MEMBER FUNCTIONS ========
|
|
27 |
|
|
28 |
// ---------------------------------------------------------------------------
|
|
29 |
// CCCAppStatusPaneHandler::CCCAppStatusPaneHandler
|
|
30 |
// ---------------------------------------------------------------------------
|
|
31 |
//
|
|
32 |
CCCAppStatusPaneHandler::CCCAppStatusPaneHandler( CCCAppView& aView ):
|
|
33 |
iView ( aView )
|
|
34 |
{
|
|
35 |
}
|
|
36 |
|
|
37 |
// ---------------------------------------------------------------------------
|
|
38 |
// CCCAppStatusPaneHandler::~CCCAppStatusPaneHandler
|
|
39 |
// ---------------------------------------------------------------------------
|
|
40 |
//
|
|
41 |
CCCAppStatusPaneHandler::~CCCAppStatusPaneHandler()
|
|
42 |
{
|
|
43 |
delete iDecoratedTabGroup;
|
|
44 |
}
|
|
45 |
|
|
46 |
// ---------------------------------------------------------------------------
|
|
47 |
// CCCAppStatusPaneHandler::NewL
|
|
48 |
// ---------------------------------------------------------------------------
|
|
49 |
//
|
|
50 |
CCCAppStatusPaneHandler* CCCAppStatusPaneHandler::NewL( CCCAppView& aView )
|
|
51 |
{
|
|
52 |
CCCAppStatusPaneHandler* self = new( ELeave ) CCCAppStatusPaneHandler( aView );
|
|
53 |
CleanupStack::PushL( self );
|
|
54 |
self->ConstructL();
|
|
55 |
CleanupStack::Pop( self );
|
|
56 |
return self;
|
|
57 |
}
|
|
58 |
|
|
59 |
// ---------------------------------------------------------------------------
|
|
60 |
// CCCAppStatusPaneHandler::ConstructL
|
|
61 |
// ---------------------------------------------------------------------------
|
|
62 |
//
|
|
63 |
void CCCAppStatusPaneHandler::ConstructL()
|
|
64 |
{
|
|
65 |
CCA_DP( KCCAppLogFile, CCA_L( "CCCAppStatusPaneHandler::ConstructL"));
|
|
66 |
}
|
|
67 |
|
|
68 |
// ---------------------------------------------------------------------------
|
|
69 |
// CCCAppStatusPaneHandler::CreateTabsL
|
|
70 |
// ---------------------------------------------------------------------------
|
|
71 |
//
|
|
72 |
void CCCAppStatusPaneHandler::CreateTabsL()
|
|
73 |
{
|
|
74 |
CCA_DP( KCCAppLogFile, CCA_L( "CCCAppStatusPaneHandler::CreateTabsL"));
|
|
75 |
|
|
76 |
for (TInt i = 0; i < iView.PluginLoader().PluginsCount(); i++)
|
|
77 |
{
|
|
78 |
TRAP_IGNORE(AddBitmapsL(i));
|
|
79 |
}
|
|
80 |
|
|
81 |
CreateNavipaneL();
|
|
82 |
|
|
83 |
//Prepare all plugins, incl hidden plugins
|
|
84 |
for (TInt i = 0; i < iView.PluginLoader().PluginsCount(); i++)
|
|
85 |
{
|
|
86 |
AddTabL( i );
|
|
87 |
}
|
|
88 |
|
|
89 |
CCA_DP( KCCAppLogFile, CCA_L( "CCCAppStatusPaneHandler::CreateTabsL: Done."));
|
|
90 |
}
|
|
91 |
|
|
92 |
|
|
93 |
// ---------------------------------------------------------------------------
|
|
94 |
// CCCAppStatusPaneHandler::CreateNavipaneL
|
|
95 |
// ---------------------------------------------------------------------------
|
|
96 |
//
|
|
97 |
void CCCAppStatusPaneHandler::CreateNavipaneL()
|
|
98 |
{
|
|
99 |
CCA_DP( KCCAppLogFile, CCA_L( "CCCAppStatusPaneHandler::CreateNavipaneL"));
|
|
100 |
|
|
101 |
//Reset iTabAvailability to EFalse, since tab will be reconstructed
|
|
102 |
iTabAvailability = EFalse;
|
|
103 |
const TInt pluginCount = iView.PluginLoader().PluginsCount();
|
|
104 |
const TInt visiblePluginCount = iView.PluginLoader().VisiblePluginCount();
|
|
105 |
|
|
106 |
CAknNavigationControlContainer* naviPane =
|
|
107 |
static_cast<CAknNavigationControlContainer*>(
|
|
108 |
iView.AppUi().EikonEnv().AppUiFactory()->StatusPane()->
|
|
109 |
ControlL( TUid::Uid( EEikStatusPaneUidNavi )));//not owned
|
|
110 |
|
|
111 |
//Delete tabs
|
|
112 |
if( iDecoratedTabGroup )
|
|
113 |
{
|
|
114 |
naviPane->Pop( iDecoratedTabGroup );
|
|
115 |
delete iDecoratedTabGroup;
|
|
116 |
iDecoratedTabGroup = NULL;
|
|
117 |
iTabGroupRef = NULL;
|
|
118 |
}
|
|
119 |
|
|
120 |
//(Re)create tabs if needed
|
|
121 |
if( KCCAppMinPluginCountForTabs <= visiblePluginCount )
|
|
122 |
|
|
123 |
{
|
|
124 |
iDecoratedTabGroup = naviPane->CreateTabGroupL( this );
|
|
125 |
iTabGroupRef = static_cast<CAknTabGroup*>( iDecoratedTabGroup->DecoratedControl() );
|
|
126 |
naviPane->PushL( *iDecoratedTabGroup );
|
|
127 |
iTabGroupRef->SetTabFixedWidthL(
|
|
128 |
visiblePluginCount > KCCAppMinPluginCountForTabs
|
|
129 |
? KTabWidthWithThreeTabs : KTabWidthWithTwoTabs );
|
|
130 |
iDecoratedTabGroup->ActivateL();
|
|
131 |
//Set it to ETrue, since there is atleast 2items in the tab
|
|
132 |
//and the tab will be visible
|
|
133 |
iTabAvailability = ETrue;
|
|
134 |
}
|
|
135 |
|
|
136 |
CCA_DP( KCCAppLogFile, CCA_L( "CCCAppStatusPaneHandler::CreateNavipaneL: Done."));
|
|
137 |
}
|
|
138 |
|
|
139 |
// ---------------------------------------------------------------------------
|
|
140 |
// CCCAppStatusPaneHandler::ActivateTab
|
|
141 |
// ---------------------------------------------------------------------------
|
|
142 |
//
|
|
143 |
void CCCAppStatusPaneHandler::ActivateTab( TInt aTabIndex )
|
|
144 |
{
|
|
145 |
CCA_DP( KCCAppLogFile, CCA_L( "CCCAppStatusPaneHandler::ActivateTabL"));
|
|
146 |
if( iTabGroupRef )
|
|
147 |
iTabGroupRef->SetActiveTabByIndex(aTabIndex);
|
|
148 |
}
|
|
149 |
|
|
150 |
// ---------------------------------------------------------------------------
|
|
151 |
// CCCAppStatusPaneHandler::ActivateTabL
|
|
152 |
// ---------------------------------------------------------------------------
|
|
153 |
//
|
|
154 |
void CCCAppStatusPaneHandler::ActivateTabL( TBool aForward )
|
|
155 |
{
|
|
156 |
CCA_DP( KCCAppLogFile, CCA_L( "CCCAppStatusPaneHandler::ActivateTabL"));
|
|
157 |
if( iTabGroupRef )
|
|
158 |
{
|
|
159 |
// Since CCApp supports variation of keys for switching the plugins
|
|
160 |
// but CAknTabGroup doesn't, some tweaking is needed.
|
|
161 |
TKeyEvent keyEvent;
|
|
162 |
keyEvent.iCode = aForward ? EKeyRightArrow : EKeyLeftArrow;
|
|
163 |
iTabGroupRef->OfferKeyEventL( keyEvent, EEventKey );
|
|
164 |
}
|
|
165 |
}
|
|
166 |
|
|
167 |
// ---------------------------------------------------------------------------
|
|
168 |
// CCCAppStatusPaneHandler::ActiveTabIndex
|
|
169 |
// ---------------------------------------------------------------------------
|
|
170 |
//
|
|
171 |
TInt CCCAppStatusPaneHandler::ActiveTabIndex()
|
|
172 |
{
|
|
173 |
CCA_DP( KCCAppLogFile, CCA_L( "CCCAppStatusPaneHandler::ActiveTabIndex"));
|
|
174 |
return iTabGroupRef ? iTabGroupRef->ActiveTabIndex() : KErrNotFound;
|
|
175 |
}
|
|
176 |
|
|
177 |
// ---------------------------------------------------------------------------
|
|
178 |
// CCCAppStatusPaneHandler::TabCount
|
|
179 |
// ---------------------------------------------------------------------------
|
|
180 |
//
|
|
181 |
TInt CCCAppStatusPaneHandler::TabCount()
|
|
182 |
{
|
|
183 |
CCA_DP( KCCAppLogFile, CCA_L( "CCCAppStatusPaneHandler::TabCount"));
|
|
184 |
return iTabGroupRef ? iTabGroupRef->TabCount() : KErrNotFound;
|
|
185 |
}
|
|
186 |
|
|
187 |
// ---------------------------------------------------------------------------
|
|
188 |
// CCCAppStatusPaneHandler::ReadBitmapsL
|
|
189 |
// ---------------------------------------------------------------------------
|
|
190 |
//
|
|
191 |
void CCCAppStatusPaneHandler::AddBitmapsL( TInt aPlugin )
|
|
192 |
{
|
|
193 |
CCCAppPluginData* data = iView.PluginLoader().PluginAt( aPlugin );
|
|
194 |
//Bitmaps provided
|
|
195 |
|
|
196 |
if( !data->iPluginBitmap )
|
|
197 |
{
|
|
198 |
CAknIcon* icon = CAknIcon::NewL();
|
|
199 |
CleanupStack::PushL( icon );
|
|
200 |
iView.PluginLoader().PluginAt( aPlugin )->Plugin().ProvideBitmapL(
|
|
201 |
CCCAppViewPluginBase::ECCAppTabIcon, *icon );
|
|
202 |
data->iPluginBitmap = icon->Bitmap();
|
|
203 |
data->iPluginBitmapMask = icon->Mask();
|
|
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 |
|
|
218 |
icon->SetBitmap( NULL );
|
|
219 |
icon->SetMask( NULL );
|
|
220 |
CleanupStack::PopAndDestroy( icon );
|
|
221 |
}
|
|
222 |
|
|
223 |
CCA_DP( KCCAppLogFile, CCA_L( "CCCAppStatusPaneHandler::AddBitmapsL: Done."));
|
|
224 |
}
|
|
225 |
|
|
226 |
|
|
227 |
// ---------------------------------------------------------------------------
|
|
228 |
// CCCAppStatusPaneHandler::AddTabL
|
|
229 |
// ---------------------------------------------------------------------------
|
|
230 |
//
|
|
231 |
void CCCAppStatusPaneHandler::AddTabL( TInt aPlugin )
|
|
232 |
{
|
|
233 |
CCCAppPluginData* data = iView.PluginLoader().PluginAt( aPlugin );
|
|
234 |
|
|
235 |
if(iTabGroupRef && data->PluginVisibility() == 1)
|
|
236 |
{
|
|
237 |
if(data->iPluginBitmap)
|
|
238 |
{
|
|
239 |
//Tabgroup takes ownership of duplicated bitmap handles
|
|
240 |
CFbsBitmap* bmp = new( ELeave ) CFbsBitmap();
|
|
241 |
CleanupStack::PushL(bmp);
|
|
242 |
CFbsBitmap* bmpMask = new( ELeave ) CFbsBitmap();
|
|
243 |
CleanupStack::PushL(bmpMask);
|
|
244 |
|
|
245 |
bmp->Duplicate(data->iPluginBitmap->Handle());
|
|
246 |
bmpMask->Duplicate(data->iPluginBitmapMask->Handle());
|
|
247 |
iTabGroupRef->AddTabL( aPlugin, bmp, bmpMask );
|
|
248 |
CleanupStack::Pop(2); //bmp, bmpmask
|
|
249 |
|
|
250 |
// CCA-Launcher and Details-View icons are GrayScale, but are detected as with color.
|
|
251 |
// They shall display dark on clear background and clear on dark background.
|
|
252 |
// SetTabMultiColorMode disables color inversion therefore it does not have to be
|
|
253 |
// called for those tabs.
|
|
254 |
TUid pluginUid = data->Plugin().Id();
|
|
255 |
if (pluginUid != TUid::Uid(KCCACommLauncherPluginImplmentationUid) &&
|
|
256 |
pluginUid != TUid::Uid(KCCADetailsViewPluginImplmentationUid))
|
|
257 |
{
|
|
258 |
iTabGroupRef->SetTabMultiColorMode( aPlugin, ETrue );
|
|
259 |
}
|
|
260 |
}
|
|
261 |
else
|
|
262 |
{
|
|
263 |
iTabGroupRef->AddTabL( aPlugin, KNullDesC() );
|
|
264 |
}
|
|
265 |
}
|
|
266 |
|
|
267 |
CCA_DP( KCCAppLogFile, CCA_L( "CCCAppStatusPaneHandler::AddTabL: Done."));
|
|
268 |
}
|
|
269 |
|
|
270 |
// ---------------------------------------------------------------------------
|
|
271 |
// CCCAppStatusPaneHandler::TabChangedL
|
|
272 |
// ---------------------------------------------------------------------------
|
|
273 |
//
|
|
274 |
void CCCAppStatusPaneHandler::TabChangedL( TInt aIndex )
|
|
275 |
{
|
|
276 |
CCA_DP( KCCAppLogFile, CCA_L( "CCCAppStatusPaneHandler::TabChangedL"));
|
|
277 |
|
|
278 |
// Tab changed succesfully, forward event to view to activate
|
|
279 |
// appropriate plugin
|
|
280 |
iView.TabChangedL( aIndex );
|
|
281 |
|
|
282 |
CCA_DP( KCCAppLogFile, CCA_L( "CCCAppStatusPaneHandler::TabChangedL: Done."));
|
|
283 |
}
|
|
284 |
|
|
285 |
// ---------------------------------------------------------------------------
|
|
286 |
// CCCAppStatusPaneHandler::IsTabAvailable
|
|
287 |
// ---------------------------------------------------------------------------
|
|
288 |
//
|
|
289 |
TBool CCCAppStatusPaneHandler::IsTabAvailable()
|
|
290 |
{
|
|
291 |
CCA_DP( KCCAppLogFile, CCA_L("CCCAppStatusPaneHandler::IsTabAvailable %d"), iTabAvailability );
|
|
292 |
return iTabAvailability;
|
|
293 |
}
|
|
294 |
|
|
295 |
// End of File
|