25
|
1 |
/*
|
|
2 |
* Copyright (c) 2005-2008 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: Container for GSParentPlugin.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
// INCLUDE FILES
|
|
19 |
#include <gsparentcontainer.h>
|
|
20 |
#include <gsparentplugin.h>
|
|
21 |
#include <gsplugininterface.h>
|
|
22 |
#include "GsLogger.h"
|
|
23 |
#include <gsparentpluginrsc.rsg>
|
|
24 |
#include <gsfwviewuids.h>
|
|
25 |
#include "GSBaseDocument.h"
|
|
26 |
#include <mgswatchdog.h>
|
|
27 |
|
|
28 |
#include <AknIconArray.h> //for loading icons
|
|
29 |
#include <aknlists.h>
|
|
30 |
#include <AknsUtils.h> //for loading icons
|
|
31 |
#include <akntitle.h>
|
|
32 |
#include <akntitle.h>
|
|
33 |
#include <aknViewAppUi.h>
|
|
34 |
#include <barsread.h> // For TResourceReader
|
|
35 |
#include <bldvariant.hrh>
|
|
36 |
#include <calslbs.h>
|
|
37 |
#include <eikclbd.h>
|
|
38 |
#include "GsContainerExt.h" //For CGsContainerExt
|
|
39 |
|
|
40 |
//CONSTANTS
|
|
41 |
const TInt KGSPluginArrayInitSize = 10;
|
|
42 |
const TInt KGSCaptionBufSize = 256;
|
|
43 |
|
|
44 |
// ========================= MEMBER FUNCTIONS ================================
|
|
45 |
|
|
46 |
// ---------------------------------------------------------------------------
|
|
47 |
// CGSParentContainer::ConstructL(const TRect& aRect)
|
|
48 |
// Symbian OS two phased constructor
|
|
49 |
//
|
|
50 |
// ---------------------------------------------------------------------------
|
|
51 |
//
|
|
52 |
void CGSParentContainer::ConstructL(
|
|
53 |
const TRect& aRect,
|
|
54 |
CAknViewAppUi* aAppUi,
|
|
55 |
CArrayPtrFlat<CGSPluginInterface>* aPluginArray,
|
|
56 |
TInt aTitleRscId,
|
|
57 |
CGSParentPlugin* aParentPlugin,
|
|
58 |
TGSListboxTypes aListBoxType )
|
|
59 |
{
|
|
60 |
iAppUi = aAppUi;
|
|
61 |
iPluginArray = aPluginArray;
|
|
62 |
iListBoxType = aListBoxType;
|
|
63 |
iParentPlugin = aParentPlugin;
|
|
64 |
|
|
65 |
CGSBaseDocument* doc = static_cast< CGSBaseDocument* >( iAppUi->Document() );
|
|
66 |
iExt = CGsContainerExt::NewL();
|
|
67 |
iExt->iGSWatchDog = doc->WatchDog();
|
|
68 |
|
|
69 |
// Initialize the array containing pointers to plugins that are actually
|
|
70 |
// displayed in lbx.
|
|
71 |
iVisiblePlugins = new (ELeave) CArrayPtrFlat<CGSPluginInterface>( KGSPluginArrayInitSize );
|
|
72 |
|
|
73 |
__GSLOGSTRING( "[CGSParentContainer] ConstructL" );
|
|
74 |
|
|
75 |
// Set view title from resource:
|
|
76 |
CEikStatusPane* sp = iAppUi->StatusPane();
|
|
77 |
CAknTitlePane* title = static_cast<CAknTitlePane*>
|
|
78 |
( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
|
|
79 |
TResourceReader rReader;
|
|
80 |
iCoeEnv->CreateResourceReaderLC( rReader, aTitleRscId );
|
|
81 |
title->SetFromResourceL( rReader );
|
|
82 |
CleanupStack::PopAndDestroy(); // rReader
|
|
83 |
|
|
84 |
CreateWindowL(); //makes this control a window-owning control
|
|
85 |
|
|
86 |
CreateListBoxL( iListBoxType );
|
|
87 |
|
|
88 |
SetRect( aRect );
|
|
89 |
ActivateL();
|
|
90 |
}
|
|
91 |
|
|
92 |
|
|
93 |
// ---------------------------------------------------------------------------
|
|
94 |
// CGSParentContainer::~CGSParentContainer()
|
|
95 |
// Destructor
|
|
96 |
//
|
|
97 |
// ---------------------------------------------------------------------------
|
|
98 |
//
|
|
99 |
CGSParentContainer::~CGSParentContainer()
|
|
100 |
{
|
|
101 |
__GSLOGSTRING( "[CGSParentContainer] ~CGSParentContainer()|->" );
|
|
102 |
if ( iVisiblePlugins )
|
|
103 |
{
|
|
104 |
iVisiblePlugins->Reset();
|
|
105 |
}
|
|
106 |
delete iVisiblePlugins;
|
|
107 |
if ( iListBox )
|
|
108 |
{
|
|
109 |
delete iListBox;
|
|
110 |
}
|
|
111 |
delete iExt;
|
|
112 |
__GSLOGSTRING( "[CGSParentContainer] ~CGSParentContainer()-|" );
|
|
113 |
}
|
|
114 |
|
|
115 |
|
|
116 |
// ---------------------------------------------------------------------------
|
|
117 |
// CGSParentContainer::UpdateListboxL
|
|
118 |
//
|
|
119 |
// Updates listbox from iPluginArray. Uses switch statement to handle different
|
|
120 |
// listbox types from TGSListboxTypes because the list item format
|
|
121 |
// and icon numbers depend on the listbox type.
|
|
122 |
// ---------------------------------------------------------------------------
|
|
123 |
//
|
|
124 |
void CGSParentContainer::UpdateListBoxL()
|
|
125 |
{
|
|
126 |
__GSLOGSTRING( "[CGSParentContainer::UpdateListBoxL]" );
|
|
127 |
iItemTextArray->Reset();
|
|
128 |
|
|
129 |
// Empty the array because it will be updated.
|
|
130 |
iVisiblePlugins->Reset();
|
|
131 |
|
|
132 |
// Array for icons in the listbox. Array owns the icons.
|
|
133 |
CAknIconArray* icons = NULL;
|
|
134 |
|
|
135 |
// Create icon array if required by the listbox type:
|
|
136 |
switch( iListBoxType )
|
|
137 |
{
|
|
138 |
case EGSListBoxTypeSingleLarge:
|
|
139 |
case EGSListBoxTypeDouble2Large:
|
|
140 |
case EGSListBoxTypeDoubleLarge:
|
|
141 |
icons = new (ELeave) CAknIconArray( KGSPluginArrayInitSize );
|
|
142 |
CleanupStack::PushL( icons );
|
|
143 |
break;
|
|
144 |
|
|
145 |
default:
|
|
146 |
break;
|
|
147 |
}
|
|
148 |
|
|
149 |
// Counter for created icons. This is used to maintain corrext indexing for
|
|
150 |
// each plugin's icons in case a plugin has multiple icons and icon indexes
|
|
151 |
// can not be mapped directly to plugin index.
|
|
152 |
TInt iconCounter = 0;
|
|
153 |
|
|
154 |
// 1) Add each plugin's data to listbox if the plugin is visible.
|
|
155 |
for( TInt i = 0; i < iPluginArray->Count(); i++ )
|
|
156 |
{
|
|
157 |
CGSPluginInterface* plugin = iPluginArray->operator[]( i );
|
|
158 |
|
|
159 |
// Adding plugin data to lbx has a lot of CGSPluginInterface API calls.
|
|
160 |
// -> A good place to use quarantine to catch panicking plugins in
|
|
161 |
// any of these calls.
|
|
162 |
#ifdef GS_ENABLE_WATCH_DOG
|
|
163 |
iExt->iGSWatchDog->QuarantineL( plugin->Id() );
|
|
164 |
#endif
|
|
165 |
|
|
166 |
if( plugin->Visible() )
|
|
167 |
{
|
|
168 |
AddPluginDataToLbxL( plugin,
|
|
169 |
iItemTextArray,
|
|
170 |
icons,
|
|
171 |
iconCounter );
|
|
172 |
}
|
|
173 |
#ifdef GS_ENABLE_WATCH_DOG
|
|
174 |
iExt->iGSWatchDog->RemoveFromQuarantineL( plugin->Id() );
|
|
175 |
#endif
|
|
176 |
}
|
|
177 |
|
|
178 |
// 2) Replace old icon array if needed.
|
|
179 |
switch( iListBoxType )
|
|
180 |
{
|
|
181 |
case EGSListBoxTypeSingleLarge:
|
|
182 |
{
|
|
183 |
// Temporary variable needed to use casted lbx.
|
|
184 |
CAknSingleLargeStyleListBox* lbx =
|
|
185 |
STATIC_CAST( CAknSingleLargeStyleListBox*, iListBox );
|
|
186 |
// Destroy the old icons because SetIconArray() does not destroy them.
|
|
187 |
CArrayPtr<CGulIcon>* oldIcons
|
|
188 |
= lbx->ItemDrawer()->ColumnData()->IconArray();
|
|
189 |
if( oldIcons )
|
|
190 |
{
|
|
191 |
__GSLOGSTRING( "[CGSParentContainer] Destroying old icons." );
|
|
192 |
oldIcons->ResetAndDestroy();
|
|
193 |
delete oldIcons;
|
|
194 |
}
|
|
195 |
// Transfer ownership of icon array to the lbx.
|
|
196 |
// SetIconArray() does not delete the old icon array
|
|
197 |
lbx->ItemDrawer()->ColumnData()->SetIconArray( icons );
|
|
198 |
CleanupStack::Pop( icons );
|
|
199 |
}
|
|
200 |
break;
|
|
201 |
case EGSListBoxTypeDouble2Large:
|
|
202 |
case EGSListBoxTypeDoubleLarge:
|
|
203 |
{
|
|
204 |
// Temporary variable needed to use casted lbx.
|
|
205 |
CEikFormattedCellListBox* lbx =
|
|
206 |
STATIC_CAST( CEikFormattedCellListBox*, iListBox );
|
|
207 |
// Destroy the old icons because SetIconArray() does not destroy them.
|
|
208 |
CArrayPtr<CGulIcon>* oldIcons
|
|
209 |
= lbx->ItemDrawer()->ColumnData()->IconArray();
|
|
210 |
if( oldIcons )
|
|
211 |
{
|
|
212 |
__GSLOGSTRING( "[CGSParentContainer] Destroying old icons." );
|
|
213 |
oldIcons->ResetAndDestroy();
|
|
214 |
delete oldIcons;
|
|
215 |
}
|
|
216 |
// Transfer ownership of icon array to the lbx.
|
|
217 |
// SetIconArray() does not delete the old icon array
|
|
218 |
lbx->ItemDrawer()->ColumnData()->SetIconArray( icons );
|
|
219 |
CleanupStack::Pop( icons );
|
|
220 |
}
|
|
221 |
break;
|
|
222 |
|
|
223 |
case EGSListBoxTypeSettings:
|
|
224 |
break;
|
|
225 |
|
|
226 |
default:
|
|
227 |
break;
|
|
228 |
}
|
|
229 |
|
|
230 |
#ifdef _GS_PARENTPLUGIN_LBX_FORMAT_TRACES
|
|
231 |
#pragma message("_GS_PARENTPLUGIN_LBX_FORMAT_TRACES activated")
|
|
232 |
__GSLOGSTRING( "[CGSParentContainer::UpdateListBoxL] iItemTextArray:" );
|
|
233 |
for( TInt i = 0; i < iItemTextArray->Count(); i++ )
|
|
234 |
{
|
|
235 |
__GSLOGSTRING1( "%S", &iItemTextArray->operator[]( i ) );
|
|
236 |
}
|
|
237 |
#endif // _GS_PARENTPLUGIN_LBX_FORMAT_TRACES
|
|
238 |
|
|
239 |
// 3) Draw listbox again
|
|
240 |
iListBox->HandleItemAdditionL();
|
|
241 |
__GSLOGSTRING( "[CGSParentContainer] UpdateListBoxL()-|" );
|
|
242 |
}
|
|
243 |
|
|
244 |
|
|
245 |
// -----------------------------------------------------------------------------
|
|
246 |
// CGSParentContainer::AddPluginDataToLbxL()
|
|
247 |
//
|
|
248 |
//
|
|
249 |
// -----------------------------------------------------------------------------
|
|
250 |
//
|
|
251 |
void CGSParentContainer::AddPluginDataToLbxL( CGSPluginInterface* aPlugin,
|
|
252 |
CDesCArray* aItemTextArray,
|
|
253 |
CAknIconArray* aIconArray,
|
|
254 |
TInt& aIconCounter )
|
|
255 |
{
|
|
256 |
// Used to disable icon
|
|
257 |
const TInt KIconNotSupported = -1;
|
|
258 |
|
|
259 |
// Index of icon used in AB-column
|
|
260 |
TInt iconIndexAB = KIconNotSupported;
|
|
261 |
|
|
262 |
// Index of icon used in D-column
|
|
263 |
TInt iconIndexD = KIconNotSupported;
|
|
264 |
|
|
265 |
#pragma message("TODO: The HBufC buffer sizes could be optimized if possible:")
|
|
266 |
|
|
267 |
// First line of lbx item text (plugin caption)
|
|
268 |
HBufC* firstLabelBuf = HBufC::NewLC( KGSCaptionBufSize );
|
|
269 |
TPtr firstLabel = firstLabelBuf->Des();
|
|
270 |
|
|
271 |
// Second line of lbx item text (optional)
|
|
272 |
HBufC* secondLabelBuf = HBufC::NewLC( KGSCaptionBufSize );
|
|
273 |
TPtr secondLabel = secondLabelBuf->Des();
|
|
274 |
|
|
275 |
// The complete formatted lbx item string which is added to lbx
|
|
276 |
HBufC* lbxItemStringBuf = HBufC::NewLC( KGSCaptionBufSize * 2 );
|
|
277 |
TPtr lbxItemString = lbxItemStringBuf->Des();
|
|
278 |
|
|
279 |
// Separates lbx item elements
|
|
280 |
_LIT( KTab, "\t" );
|
|
281 |
|
|
282 |
// Normal icon in AB-Column
|
|
283 |
CGulIcon* iconAB = NULL;
|
|
284 |
|
|
285 |
// Small icon used in D-column (optional)
|
|
286 |
CGulIcon* iconD = NULL;
|
|
287 |
|
|
288 |
// Add the plugin to visible plugins array:
|
|
289 |
iVisiblePlugins->AppendL( aPlugin );
|
|
290 |
|
|
291 |
// 1) Read item descriptor from plugin:
|
|
292 |
TRAPD( captionErr,
|
|
293 |
aPlugin->GetCaptionL( firstLabel );
|
|
294 |
)
|
|
295 |
|
|
296 |
// If plugin caption fails, set caption to error string.
|
|
297 |
if( captionErr != KErrNone )
|
|
298 |
{
|
|
299 |
_LIT( KGSParentPluginCaptionErrorTxt, "Error" );
|
|
300 |
firstLabel.Append( KGSParentPluginCaptionErrorTxt );
|
|
301 |
}
|
|
302 |
else
|
|
303 |
{
|
|
304 |
__GSLOGSTRING2( "[CGSParentContainer] 0x%X::GetCaptionL Error: %d",
|
|
305 |
aPlugin->Id().iUid, captionErr );
|
|
306 |
}
|
|
307 |
|
|
308 |
// 2) Add icons if listbox uses them:
|
|
309 |
// - AB-column icon
|
|
310 |
// - D-column icon
|
|
311 |
switch( iListBoxType )
|
|
312 |
{
|
|
313 |
case EGSListBoxTypeSingleLarge:
|
|
314 |
case EGSListBoxTypeDouble2Large:
|
|
315 |
case EGSListBoxTypeDoubleLarge:
|
|
316 |
{
|
|
317 |
// This might fail because plugin implementors might do funny stuff.
|
|
318 |
// GS Must still behave well...
|
|
319 |
TRAPD( iconErr,
|
|
320 |
iconAB = aPlugin->CreateIconL( KGSIconTypeLbxItem );
|
|
321 |
)
|
|
322 |
if( iconErr != KErrNone )
|
|
323 |
{
|
|
324 |
// Use default icon because plugin implementor's CreateIconL
|
|
325 |
// failed. If this fails, everything is lost anyway so might as
|
|
326 |
// well leave (abort GS).
|
|
327 |
iconAB = aPlugin->CGSPluginInterface::CreateIconL( KGSIconTypeLbxItem );
|
|
328 |
__GSLOGSTRING2( "[CGSParentContainer] CreateIconL for 0x%X failed:%d",
|
|
329 |
aPlugin->Id().iUid,
|
|
330 |
iconErr );
|
|
331 |
}
|
|
332 |
if( iconAB ) // Append only if not NULL (not supported)
|
|
333 |
{
|
|
334 |
CleanupStack::PushL( iconAB );
|
|
335 |
aIconArray->AppendL( iconAB );
|
|
336 |
CleanupStack::Pop( iconAB );
|
|
337 |
iconIndexAB = aIconCounter;
|
|
338 |
aIconCounter++;
|
|
339 |
}
|
|
340 |
|
|
341 |
TRAPD( iconDColErr,
|
|
342 |
iconD = aPlugin->CreateIconL( KGSIconTypeDColumn );
|
|
343 |
)
|
|
344 |
if( iconDColErr != KErrNone )
|
|
345 |
{
|
|
346 |
iconD = aPlugin->CGSPluginInterface::CreateIconL( KGSIconTypeDColumn );
|
|
347 |
__GSLOGSTRING2( "[CGSParentContainer] CreateIconL for 0x%X failed:%d",
|
|
348 |
aPlugin->Id().iUid,
|
|
349 |
iconErr );
|
|
350 |
}
|
|
351 |
if( iconD ) // Append only if not NULL (not supported)
|
|
352 |
{
|
|
353 |
CleanupStack::PushL( iconD );
|
|
354 |
aIconArray->AppendL( iconD );
|
|
355 |
CleanupStack::Pop( iconD );
|
|
356 |
iconIndexD = aIconCounter;
|
|
357 |
aIconCounter++;
|
|
358 |
}
|
|
359 |
break;
|
|
360 |
}
|
|
361 |
case EGSListBoxTypeSettings:
|
|
362 |
break;
|
|
363 |
|
|
364 |
default:
|
|
365 |
break;
|
|
366 |
}
|
|
367 |
|
|
368 |
/**
|
|
369 |
* 3) Create formatted item string. Lbx item's format string depends
|
|
370 |
* on lbx type.
|
|
371 |
*/
|
|
372 |
switch( iListBoxType )
|
|
373 |
{
|
|
374 |
/**
|
|
375 |
* list_single_large_pane:
|
|
376 |
* list item string format: "1\tTextLabel\t0\t0"
|
|
377 |
* where 0 is an index to icon array
|
|
378 |
*/
|
|
379 |
case EGSListBoxTypeSingleLarge:
|
|
380 |
{
|
|
381 |
if( iconIndexAB != KIconNotSupported ) lbxItemString.AppendNum( iconIndexAB ); // AB-Column icon
|
|
382 |
lbxItemString.Append( KTab );
|
|
383 |
lbxItemString.Append( firstLabel );
|
|
384 |
break;
|
|
385 |
}
|
|
386 |
/**
|
|
387 |
* list_setting_pane and list_big_single_setting_pane:
|
|
388 |
* list item string format: "\tFirstLabel\t\tValueText"
|
|
389 |
* list item string format: "\tFirstLabel\t0\t"
|
|
390 |
* list item string format: "\tFirstLabel\t\tValueText\t*"
|
|
391 |
* list item string format: "\tFirstLabel\t\t\t\tSecondLabel"
|
|
392 |
* where 0 is an index to icon array
|
|
393 |
*/
|
|
394 |
case EGSListBoxTypeSettings:
|
|
395 |
{
|
|
396 |
aPlugin->GetValue( EGSPluginKeySettingsItemValueString, secondLabel );
|
|
397 |
|
|
398 |
lbxItemString.Append( KTab );
|
|
399 |
lbxItemString.Append( firstLabel );
|
|
400 |
lbxItemString.Append( KTab );
|
|
401 |
lbxItemString.Append( KTab );
|
|
402 |
lbxItemString.Append( secondLabel );
|
|
403 |
break;
|
|
404 |
}
|
|
405 |
/**
|
|
406 |
* list_double2_large_graphic_pane:
|
|
407 |
* list item string format: "1\tFirstLabel\tSecondLabel\t0"
|
|
408 |
* where 0 is an index of small (13x13) icon in icon array
|
|
409 |
* and 1 is an index of a thumbnail image
|
|
410 |
*/
|
|
411 |
case EGSListBoxTypeDouble2Large:
|
|
412 |
case EGSListBoxTypeDoubleLarge:
|
|
413 |
{
|
|
414 |
aPlugin->GetValue( EGSPluginKeySettingsItemValueString, secondLabel );
|
|
415 |
|
|
416 |
if( iconIndexAB != KIconNotSupported ) lbxItemString.AppendNum( iconIndexAB ); // AB-Column icon
|
|
417 |
lbxItemString.Append( KTab );
|
|
418 |
lbxItemString.Append( firstLabel ); // FirstLabel
|
|
419 |
lbxItemString.Append( KTab );
|
|
420 |
lbxItemString.Append( secondLabel ); // SecondLabel
|
|
421 |
lbxItemString.Append( KTab );
|
|
422 |
if( iconIndexD != KIconNotSupported ) lbxItemString.AppendNum( iconIndexD ); // D-Column Icon
|
|
423 |
break;
|
|
424 |
}
|
|
425 |
}
|
|
426 |
aItemTextArray->AppendL( lbxItemString );
|
|
427 |
|
|
428 |
CleanupStack::PopAndDestroy( lbxItemStringBuf );
|
|
429 |
CleanupStack::PopAndDestroy( secondLabelBuf );
|
|
430 |
CleanupStack::PopAndDestroy( firstLabelBuf );
|
|
431 |
}
|
|
432 |
|
|
433 |
|
|
434 |
// ---------------------------------------------------------------------------
|
|
435 |
// CGSParentContainer::ListBox()
|
|
436 |
//
|
|
437 |
//
|
|
438 |
// ---------------------------------------------------------------------------
|
|
439 |
//
|
|
440 |
CEikListBox* CGSParentContainer::ListBox()
|
|
441 |
{
|
|
442 |
return iListBox;
|
|
443 |
}
|
|
444 |
|
|
445 |
|
|
446 |
// ---------------------------------------------------------------------------
|
|
447 |
// CGSParentContainer::SizeChanged
|
|
448 |
// called by framework when the view size is changed
|
|
449 |
//
|
|
450 |
// ---------------------------------------------------------------------------
|
|
451 |
//
|
|
452 |
void CGSParentContainer::SizeChanged()
|
|
453 |
{
|
|
454 |
if ( iListBox )
|
|
455 |
{
|
|
456 |
iListBox->SetRect( Rect() );
|
|
457 |
}
|
|
458 |
}
|
|
459 |
|
|
460 |
|
|
461 |
// ---------------------------------------------------------------------------
|
|
462 |
// CGSParentContainer::CountComponentControls
|
|
463 |
//
|
|
464 |
//
|
|
465 |
// ---------------------------------------------------------------------------
|
|
466 |
//
|
|
467 |
TInt CGSParentContainer::CountComponentControls() const
|
|
468 |
{
|
|
469 |
return 1;
|
|
470 |
}
|
|
471 |
|
|
472 |
|
|
473 |
// ---------------------------------------------------------------------------
|
|
474 |
// CGSParentContainer::ComponentControl
|
|
475 |
//
|
|
476 |
//
|
|
477 |
// ---------------------------------------------------------------------------
|
|
478 |
//
|
|
479 |
CCoeControl* CGSParentContainer::ComponentControl(TInt /*aIndex*/) const
|
|
480 |
{
|
|
481 |
return iListBox;
|
|
482 |
}
|
|
483 |
|
|
484 |
|
|
485 |
// ---------------------------------------------------------------------------
|
|
486 |
// CGSParentContainer::TKeyResponse OfferKeyEventL
|
|
487 |
// Called when a key is pressed.
|
|
488 |
//
|
|
489 |
// ---------------------------------------------------------------------------
|
|
490 |
//
|
|
491 |
TKeyResponse CGSParentContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent,
|
|
492 |
TEventCode aType )
|
|
493 |
{
|
|
494 |
switch ( aKeyEvent.iCode )
|
|
495 |
{
|
|
496 |
case EKeyUpArrow:
|
|
497 |
case EKeyDownArrow:
|
|
498 |
{
|
|
499 |
TKeyResponse listboxResp =
|
|
500 |
iListBox->OfferKeyEventL( aKeyEvent, aType );
|
|
501 |
if ( iParentPlugin )
|
|
502 |
{
|
|
503 |
iParentPlugin->CheckMiddleSoftkeyLabelL();
|
|
504 |
}
|
|
505 |
return listboxResp;
|
|
506 |
}
|
|
507 |
case EKeyLeftArrow:
|
|
508 |
case EKeyRightArrow:
|
|
509 |
// Listbox takes all events even if it doesn't use them
|
|
510 |
return EKeyWasNotConsumed;
|
|
511 |
default:
|
|
512 |
break;
|
|
513 |
}
|
|
514 |
// now it's iListBox's job to process the key event
|
|
515 |
return iListBox->OfferKeyEventL( aKeyEvent, aType );
|
|
516 |
}
|
|
517 |
|
|
518 |
|
|
519 |
// ---------------------------------------------------------------------------
|
|
520 |
// CGSParentContainer::HandleListBoxEventL
|
|
521 |
//
|
|
522 |
//
|
|
523 |
// ---------------------------------------------------------------------------
|
|
524 |
void CGSParentContainer::HandleListBoxEventL( CEikListBox* aListBox,
|
|
525 |
TListBoxEvent aEventType )
|
|
526 |
{
|
|
527 |
__GSLOGSTRING1(
|
|
528 |
"[CGSParentContainer] HandleListBoxEventL aEventType:%d",
|
|
529 |
aEventType);
|
|
530 |
switch (aEventType)
|
|
531 |
{
|
|
532 |
case EEventEnterKeyPressed:
|
|
533 |
case EEventItemSingleClicked:
|
|
534 |
{
|
|
535 |
__GSLOGSTRING1(
|
|
536 |
"[CGSParentContainer] Activating view plugin in index[%d]",
|
|
537 |
aListBox->CurrentItemIndex() );
|
|
538 |
|
|
539 |
if( aListBox->CurrentItemIndex() < 0 )
|
|
540 |
{
|
|
541 |
// Negative listbox value -> no item selected?
|
|
542 |
break;
|
|
543 |
}
|
|
544 |
|
|
545 |
if(iExt->iDblClickPreventer->IsActive())
|
|
546 |
{
|
|
547 |
break;
|
|
548 |
}
|
|
549 |
iExt->iDblClickPreventer->Start();
|
|
550 |
CGSPluginInterface* selectedPlugin = iVisiblePlugins->operator[](
|
|
551 |
aListBox->CurrentItemIndex() );
|
|
552 |
|
|
553 |
// Different command is used depending on the plugin type.
|
|
554 |
switch( selectedPlugin->ItemType() )
|
|
555 |
{
|
|
556 |
// In these cases the plugin is a view:
|
|
557 |
case EGSItemTypeSingleLarge:
|
|
558 |
case EGSItemTypeSetting:
|
|
559 |
case EGSItemTypeSettingIcon:
|
|
560 |
iAppUi->ActivateLocalViewL( selectedPlugin->Id() );
|
|
561 |
break;
|
|
562 |
// In these cases the plugin is a dialog:
|
|
563 |
case EGSItemTypeSettingDialog:
|
|
564 |
case EGSItemTypeSingleLargeDialog:
|
|
565 |
selectedPlugin->HandleSelection(
|
|
566 |
EGSSelectionBySelectionKey );
|
|
567 |
UpdateListBoxL(); // Refrest the listbox if value changed.
|
|
568 |
break;
|
|
569 |
}
|
|
570 |
}
|
|
571 |
break;
|
|
572 |
|
|
573 |
default:
|
|
574 |
break;
|
|
575 |
}
|
|
576 |
}
|
|
577 |
|
|
578 |
|
|
579 |
// ---------------------------------------------------------------------------
|
|
580 |
// CGSParentContainer::HandleResourceChange()
|
|
581 |
//
|
|
582 |
//
|
|
583 |
// ---------------------------------------------------------------------------
|
|
584 |
//
|
|
585 |
void CGSParentContainer::HandleResourceChange( TInt aType )
|
|
586 |
{
|
|
587 |
CCoeControl::HandleResourceChange( aType );
|
|
588 |
//Handle layout orientation or skin change
|
|
589 |
if ( aType == KAknsMessageSkinChange ||
|
|
590 |
aType == KEikDynamicLayoutVariantSwitch )
|
|
591 |
{
|
|
592 |
TRect mainPaneRect;
|
|
593 |
AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane,
|
|
594 |
mainPaneRect);
|
|
595 |
SetRect( mainPaneRect );
|
|
596 |
if ( aType == KAknsMessageSkinChange )
|
|
597 |
{
|
|
598 |
TRAP_IGNORE( UpdateListBoxL() );
|
|
599 |
}
|
|
600 |
}
|
|
601 |
}
|
|
602 |
|
|
603 |
|
|
604 |
// ---------------------------------------------------------------------------
|
|
605 |
// CGSParentContainer::CreateListBoxL()
|
|
606 |
//
|
|
607 |
//
|
|
608 |
// ---------------------------------------------------------------------------
|
|
609 |
//
|
|
610 |
void CGSParentContainer::CreateListBoxL(
|
|
611 |
TGSListboxTypes aListBoxType )
|
|
612 |
{
|
|
613 |
switch( aListBoxType )
|
|
614 |
{
|
|
615 |
case EGSListBoxTypeSingleLarge:
|
|
616 |
{
|
|
617 |
CAknSingleLargeStyleListBox* lbx =
|
|
618 |
new( ELeave ) CAknSingleLargeStyleListBox;
|
|
619 |
iListBox = lbx;
|
|
620 |
lbx->ConstructL( this );
|
|
621 |
lbx->SetContainerWindowL( *this );
|
|
622 |
lbx->SetListBoxObserver( this );
|
|
623 |
lbx->CreateScrollBarFrameL( ETrue );
|
|
624 |
lbx->ScrollBarFrame()->SetScrollBarVisibilityL(
|
|
625 |
CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
|
|
626 |
// Obtain reference to listbox model's item text array:
|
|
627 |
iItemTextArray = STATIC_CAST( CDesCArray*,
|
|
628 |
lbx->Model()->ItemTextArray() );
|
|
629 |
}
|
|
630 |
break;
|
|
631 |
|
|
632 |
case EGSListBoxTypeSettings:
|
|
633 |
{
|
|
634 |
CAknSettingStyleListBox* lbx =
|
|
635 |
new( ELeave ) CAknSettingStyleListBox;
|
|
636 |
iListBox = lbx;
|
|
637 |
lbx->ConstructL( this, EAknListBoxSelectionList );
|
|
638 |
lbx->SetContainerWindowL( *this );
|
|
639 |
lbx->SetListBoxObserver( this );
|
|
640 |
lbx->CreateScrollBarFrameL( ETrue );
|
|
641 |
lbx->ScrollBarFrame()->SetScrollBarVisibilityL(
|
|
642 |
CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
|
|
643 |
// Obtain reference to listbox model's item text array:
|
|
644 |
iItemTextArray = STATIC_CAST( CDesCArray*,
|
|
645 |
lbx->Model()->ItemTextArray() );
|
|
646 |
}
|
|
647 |
break;
|
|
648 |
|
|
649 |
case EGSListBoxTypeDouble2Large:
|
|
650 |
{
|
|
651 |
TInt flags = 0;
|
|
652 |
CAknDouble2LargeStyleListBox* lbx =
|
|
653 |
new( ELeave ) CAknDouble2LargeStyleListBox;
|
|
654 |
iListBox = lbx;
|
|
655 |
lbx->ConstructL( this, flags );
|
|
656 |
lbx->SetContainerWindowL( *this );
|
|
657 |
lbx->SetListBoxObserver( this );
|
|
658 |
lbx->CreateScrollBarFrameL( ETrue );
|
|
659 |
lbx->ScrollBarFrame()->SetScrollBarVisibilityL(
|
|
660 |
CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
|
|
661 |
// Obtain reference to listbox model's item text array:
|
|
662 |
iItemTextArray = STATIC_CAST( CDesCArray*,
|
|
663 |
lbx->Model()->ItemTextArray() );
|
|
664 |
}
|
|
665 |
break;
|
|
666 |
|
|
667 |
case EGSListBoxTypeDoubleLarge:
|
|
668 |
{
|
|
669 |
TInt flags = 0;
|
|
670 |
CAknDoubleLargeStyleListBox* lbx =
|
|
671 |
new( ELeave ) CAknDoubleLargeStyleListBox;
|
|
672 |
iListBox = lbx;
|
|
673 |
lbx->ConstructL( this, flags );
|
|
674 |
lbx->SetContainerWindowL( *this );
|
|
675 |
lbx->SetListBoxObserver( this );
|
|
676 |
lbx->CreateScrollBarFrameL( ETrue );
|
|
677 |
lbx->ScrollBarFrame()->SetScrollBarVisibilityL(
|
|
678 |
CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
|
|
679 |
// Obtain reference to listbox model's item text array:
|
|
680 |
iItemTextArray = STATIC_CAST( CDesCArray*,
|
|
681 |
lbx->Model()->ItemTextArray() );
|
|
682 |
}
|
|
683 |
break;
|
|
684 |
|
|
685 |
default:
|
|
686 |
break;
|
|
687 |
}
|
|
688 |
}
|
|
689 |
|
|
690 |
|
|
691 |
// -----------------------------------------------------------------------------
|
|
692 |
// CGSParentContainer::SelectedPlugin()
|
|
693 |
//
|
|
694 |
//
|
|
695 |
// -----------------------------------------------------------------------------
|
|
696 |
//
|
|
697 |
CGSPluginInterface* CGSParentContainer::SelectedPlugin()
|
|
698 |
{
|
|
699 |
CGSPluginInterface* plugin = NULL;
|
|
700 |
const TInt index = iListBox->CurrentItemIndex();
|
|
701 |
if ( index >= 0 && index < iVisiblePlugins->Count() )
|
|
702 |
{
|
|
703 |
plugin = iVisiblePlugins->operator[]( index );
|
|
704 |
__GSLOGSTRING2( "[CGSParentContainer] SelectedPlugin 0x%X in index %d",
|
|
705 |
plugin->Id().iUid, index );
|
|
706 |
}
|
|
707 |
return plugin;
|
|
708 |
}
|
|
709 |
|
|
710 |
|
|
711 |
// -----------------------------------------------------------------------------
|
|
712 |
// CGSParentContainer::SetSelectedItem()
|
|
713 |
//
|
|
714 |
//
|
|
715 |
// -----------------------------------------------------------------------------
|
|
716 |
//
|
|
717 |
void CGSParentContainer::SetSelectedItem( TUid aSelectedItemUid )
|
|
718 |
{
|
|
719 |
__GSLOGSTRING1( "[CGSParentContainer] SetSelectedItem(0x%X)",
|
|
720 |
aSelectedItemUid.iUid );
|
|
721 |
|
|
722 |
if( aSelectedItemUid != KGSNoneSelected )
|
|
723 |
{
|
|
724 |
TInt selectedItemIndex = 0;
|
|
725 |
for( TInt i = 0; i < iVisiblePlugins->Count(); i++ )
|
|
726 |
{
|
|
727 |
CGSPluginInterface* plugin = iVisiblePlugins->operator[]( i );
|
|
728 |
__GSLOGSTRING2( "[CGSParentContainer] Checking [%d] 0x%X)",
|
|
729 |
i, plugin->Id().iUid );
|
|
730 |
// If plugin is found, select it:
|
|
731 |
if( plugin->Id() == aSelectedItemUid )
|
|
732 |
{
|
|
733 |
__GSLOGSTRING2( "[CGSParentContainer] Match 0x%X in index %d",
|
|
734 |
plugin->Id().iUid, i );
|
|
735 |
selectedItemIndex = i;
|
|
736 |
break;
|
|
737 |
}
|
|
738 |
}
|
|
739 |
iListBox->SetCurrentItemIndexAndDraw( selectedItemIndex );
|
|
740 |
}
|
|
741 |
}
|
|
742 |
|
|
743 |
|
|
744 |
// -----------------------------------------------------------------------------
|
|
745 |
// CGSParentContainer::GetHelpContext()
|
|
746 |
//
|
|
747 |
//
|
|
748 |
// -----------------------------------------------------------------------------
|
|
749 |
//
|
|
750 |
void CGSParentContainer::GetHelpContext( TCoeHelpContext& aContext ) const
|
|
751 |
{
|
|
752 |
// This is forwarded to the CGSParentPlugin type class that actually knows
|
|
753 |
// the help context but does not have its own CCoeControl class.
|
|
754 |
iParentPlugin->GetHelpContext( aContext );
|
|
755 |
}
|
|
756 |
|
|
757 |
|
|
758 |
// ---------------------------------------------------------------------------
|
|
759 |
// CGSParentContainer::FocusChanged
|
|
760 |
//
|
|
761 |
// Set focus on the selected listbox. For animated skins feature.
|
|
762 |
// ---------------------------------------------------------------------------
|
|
763 |
EXPORT_C void CGSParentContainer::FocusChanged( TDrawNow /*aDrawNow*/ )
|
|
764 |
{
|
|
765 |
if( iListBox )
|
|
766 |
{
|
|
767 |
iListBox->SetFocus( IsFocused() );
|
|
768 |
}
|
|
769 |
}
|
|
770 |
|
|
771 |
|
|
772 |
// ---------------------------------------------------------------------------
|
|
773 |
// CGSParentContainer::HandleSelectionKeyL
|
|
774 |
//
|
|
775 |
// Behaves like a selection key.
|
|
776 |
// ---------------------------------------------------------------------------
|
|
777 |
void CGSParentContainer::HandleSelectionKeyL()
|
|
778 |
{
|
|
779 |
HandleListBoxEventL( iListBox,EEventEnterKeyPressed );
|
|
780 |
}
|
|
781 |
|
|
782 |
|
|
783 |
// -----------------------------------------------------------------------------
|
|
784 |
// CGSParentContainer::TopPlugin()
|
|
785 |
//
|
|
786 |
//
|
|
787 |
// -----------------------------------------------------------------------------
|
|
788 |
//
|
|
789 |
CGSPluginInterface* CGSParentContainer::TopPlugin()
|
|
790 |
{
|
|
791 |
CGSPluginInterface* plugin = NULL;
|
|
792 |
const TInt index = iListBox->TopItemIndex();
|
|
793 |
if ( index >= 0 && index < iVisiblePlugins->Count() )
|
|
794 |
{
|
|
795 |
plugin = iVisiblePlugins->operator[]( index );
|
|
796 |
__GSLOGSTRING2( "[CGSParentContainer] TopPlugin 0x%X in index %d",
|
|
797 |
plugin->Id().iUid, index );
|
|
798 |
}
|
|
799 |
return plugin;
|
|
800 |
}
|
|
801 |
|
|
802 |
|
|
803 |
// -----------------------------------------------------------------------------
|
|
804 |
// CGSParentContainer::SetSelectedItem()
|
|
805 |
//
|
|
806 |
//
|
|
807 |
// -----------------------------------------------------------------------------
|
|
808 |
//
|
|
809 |
void CGSParentContainer::SetTopItem( TUid aTopItemUid )
|
|
810 |
{
|
|
811 |
__GSLOGSTRING1( "[CGSParentContainer] SetTopItem(0x%X)",
|
|
812 |
aTopItemUid.iUid );
|
|
813 |
|
|
814 |
if( aTopItemUid != KGSNoneSelected )
|
|
815 |
{
|
|
816 |
TInt topItemIndex = 0;
|
|
817 |
for( TInt i = 0; i < iVisiblePlugins->Count(); i++ )
|
|
818 |
{
|
|
819 |
CGSPluginInterface* plugin = iVisiblePlugins->operator[]( i );
|
|
820 |
__GSLOGSTRING2( "[CGSParentContainer] Checking [%d] 0x%X)",
|
|
821 |
i, plugin->Id().iUid );
|
|
822 |
// If plugin is found, select it:
|
|
823 |
if( plugin->Id() == aTopItemUid )
|
|
824 |
{
|
|
825 |
__GSLOGSTRING2( "[CGSParentContainer] Match 0x%X in index %d",
|
|
826 |
plugin->Id().iUid, i );
|
|
827 |
topItemIndex = i;
|
|
828 |
break;
|
|
829 |
}
|
|
830 |
}
|
|
831 |
iListBox->SetTopItemIndex( topItemIndex );
|
|
832 |
}
|
|
833 |
}
|
|
834 |
|
|
835 |
// -----------------------------------------------------------------------------
|
|
836 |
// CGSParentContainer::SetListBoxEmptyTextL()
|
|
837 |
//
|
|
838 |
//Set the empty text of list box.
|
|
839 |
// -----------------------------------------------------------------------------
|
|
840 |
//
|
|
841 |
void CGSParentContainer::SetListBoxEmptyTextL(const TDes& aEmpty )
|
|
842 |
{
|
|
843 |
if ( iListBox )
|
|
844 |
{
|
|
845 |
iListBox->View()->SetListEmptyTextL( aEmpty );
|
|
846 |
}
|
|
847 |
}
|
|
848 |
|
|
849 |
// -----------------------------------------------------------------------------
|
|
850 |
// CGSParentContainer::StoreListBoxPositionL
|
|
851 |
//
|
|
852 |
//Store the exact position of listbox.
|
|
853 |
// -----------------------------------------------------------------------------
|
|
854 |
//
|
|
855 |
void CGSParentContainer::StoreListBoxPositionL( CGSParentPlugin::TListBoxPosition& aPosition )
|
|
856 |
{
|
|
857 |
aPosition.iCurrentItemIndex = iListBox->CurrentItemIndex();
|
|
858 |
aPosition.iItemOffsetInPixels = iListBox->View()->ItemOffsetInPixels();
|
|
859 |
aPosition.iTopItemIndex = iListBox->View()->TopItemIndex();
|
|
860 |
}
|
|
861 |
|
|
862 |
// -----------------------------------------------------------------------------
|
|
863 |
// CGSParentContainer::RestoreListBoxPositionL
|
|
864 |
//
|
|
865 |
//Restore the exact position of listbox.
|
|
866 |
// -----------------------------------------------------------------------------
|
|
867 |
//
|
|
868 |
void CGSParentContainer::RestoreListBoxPositionL( const CGSParentPlugin::TListBoxPosition& aPosition, TBool aScreenModeChanged )
|
|
869 |
{
|
|
870 |
if( iListBox->View()->BottomItemIndex()>= aPosition.iCurrentItemIndex )
|
|
871 |
|
|
872 |
{
|
|
873 |
|
|
874 |
if ( aPosition.iCurrentItemIndex >= 0 )
|
|
875 |
{
|
|
876 |
iListBox->SetCurrentItemIndex( aPosition.iCurrentItemIndex );
|
|
877 |
}
|
|
878 |
|
|
879 |
if ( aScreenModeChanged )
|
|
880 |
{
|
|
881 |
iListBox->View()->VerticalMoveToItemL( aPosition.iCurrentItemIndex,
|
|
882 |
CListBoxView::ESingleSelection );
|
|
883 |
}
|
|
884 |
else
|
|
885 |
{
|
|
886 |
iListBox->View()->SetItemOffsetInPixels( aPosition.iItemOffsetInPixels );
|
|
887 |
iListBox->View()->SetTopItemIndex( aPosition.iTopItemIndex );
|
|
888 |
}
|
|
889 |
}
|
|
890 |
}
|
|
891 |
//End of File
|