45
|
1 |
/*
|
|
2 |
* Copyright (c) 2006 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: Location Triggering Management Plugin View's container
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// System Includes
|
|
20 |
#include <eikspane.h> // Status pane
|
|
21 |
#include <akntitle.h> // CAknTitlePane
|
|
22 |
#include <StringLoader.h> // String Loader
|
|
23 |
#include <lbtmgmtpluginview.rsg>
|
|
24 |
#include <aknlists.h> // Settings Style list box
|
|
25 |
#include <csxhelp/lbt.hlp.hrh> // LBT Help
|
|
26 |
|
|
27 |
// User Includes
|
|
28 |
#include "lbtmgmtplugincontainer.h"
|
|
29 |
#include "lbtmgmtplugincmdhdlr.h"
|
|
30 |
#include "lbtmgmtplugin.hrh"
|
|
31 |
#include "lbtmgmtpluginuid.hrh"
|
|
32 |
#include "lbtmgmtpluginview.h"
|
|
33 |
#include "lbtmgmtpluginengine.h"
|
|
34 |
|
|
35 |
// Constant defintions
|
|
36 |
const TInt KNoofComponentControls = 1;
|
|
37 |
|
|
38 |
|
|
39 |
// ========================= MEMBER FUNCTIONS ================================
|
|
40 |
|
|
41 |
// ---------------------------------------------------------------------------
|
|
42 |
// CLbtMgmtPluginContainer::CLbtMgmtPluginContainer
|
|
43 |
// Overloaded Constructor
|
|
44 |
//
|
|
45 |
// ---------------------------------------------------------------------------
|
|
46 |
//
|
|
47 |
CLbtMgmtPluginContainer::CLbtMgmtPluginContainer(MDesCArray& aListBoxModel,
|
|
48 |
MLbtMgmtPluginCmdHdlr& aCmdHandler, CLbtMgmtPluginView* aView) :
|
|
49 |
iListBoxModel(aListBoxModel), iCmdHandler(aCmdHandler), iView(aView)
|
|
50 |
{
|
|
51 |
}
|
|
52 |
|
|
53 |
// ---------------------------------------------------------------------------
|
|
54 |
// CLbtMgmtPluginContainer::~CLbtMgmtPluginContainer
|
|
55 |
// Destructor
|
|
56 |
//
|
|
57 |
// ---------------------------------------------------------------------------
|
|
58 |
//
|
|
59 |
CLbtMgmtPluginContainer::~CLbtMgmtPluginContainer()
|
|
60 |
{
|
|
61 |
// Delete the List box model only after deleting the list box
|
|
62 |
delete iListBox;
|
|
63 |
}
|
|
64 |
|
|
65 |
// ---------------------------------------------------------------------------
|
|
66 |
// CLbtMgmtPluginContainer* CLbtMgmtPluginContainer::NewL
|
|
67 |
// Static Two phase contructor that instantiates the CLbtMgmtPluginContainer
|
|
68 |
//
|
|
69 |
// @param aRect Client rectangle
|
|
70 |
// @param aListBoxModel Model for the container's list box
|
|
71 |
// @param aCmdHandler List box command handler
|
|
72 |
// @return CLbtMgmtPluginContainer* Reference to the object created
|
|
73 |
// ---------------------------------------------------------------------------
|
|
74 |
//
|
|
75 |
CLbtMgmtPluginContainer* CLbtMgmtPluginContainer::NewL(const TRect& aRect,
|
|
76 |
MDesCArray& aListBoxModel, MLbtMgmtPluginCmdHdlr& aCmdHandler,
|
|
77 |
CLbtMgmtPluginView* aView)
|
|
78 |
{
|
|
79 |
CLbtMgmtPluginContainer* self = NewLC(aRect, aListBoxModel, aCmdHandler,
|
|
80 |
aView);
|
|
81 |
CleanupStack::Pop(self);
|
|
82 |
return self;
|
|
83 |
}
|
|
84 |
|
|
85 |
// ---------------------------------------------------------------------------
|
|
86 |
// CLbtMgmtPluginContainer* CLbtMgmtPluginContainer::NewLC
|
|
87 |
// Static Two phase contructor that instantiates the CLbtMgmtPluginContainer
|
|
88 |
//
|
|
89 |
// @param aRect Client rectangle
|
|
90 |
// @param aListBoxModel Model for the container's list box
|
|
91 |
// @param aCmdHandler List box command handler
|
|
92 |
// @return CLbtMgmtPluginContainer* Reference to the object created
|
|
93 |
// ---------------------------------------------------------------------------
|
|
94 |
//
|
|
95 |
CLbtMgmtPluginContainer* CLbtMgmtPluginContainer::NewLC(const TRect& aRect,
|
|
96 |
MDesCArray& aListBoxModel, MLbtMgmtPluginCmdHdlr& aCmdHandler,
|
|
97 |
CLbtMgmtPluginView* aView)
|
|
98 |
{
|
|
99 |
CLbtMgmtPluginContainer* self = new (ELeave) CLbtMgmtPluginContainer(
|
|
100 |
aListBoxModel, aCmdHandler, aView);
|
|
101 |
CleanupStack::PushL(self);
|
|
102 |
self->ConstructL(aRect);
|
|
103 |
return self;
|
|
104 |
}
|
|
105 |
|
|
106 |
// ---------------------------------------------------------------------------
|
|
107 |
// void CLbtMgmtPluginContainer::ConstructL
|
|
108 |
// Second phase of the two phase Construction process
|
|
109 |
//
|
|
110 |
// @param aRect Client rectangle
|
|
111 |
// ---------------------------------------------------------------------------
|
|
112 |
//
|
|
113 |
void CLbtMgmtPluginContainer::ConstructL( const TRect& aRect )
|
|
114 |
{
|
|
115 |
//Make this control a window-owning control
|
|
116 |
CreateWindowL();
|
|
117 |
|
|
118 |
// Create a New Title for the View
|
|
119 |
MakeTitleL( R_LOCTR_TITLE_TEXT_LT );
|
|
120 |
|
|
121 |
CreateListboxL();
|
|
122 |
|
|
123 |
// Get the Help context
|
|
124 |
iContextName = KLOC_HLP_LBT_SETTINGS();
|
|
125 |
|
|
126 |
SetRect( aRect );
|
|
127 |
ActivateL();
|
|
128 |
}
|
|
129 |
|
|
130 |
// ---------------------------------------------------------------------------
|
|
131 |
// CLbtMgmtPluginContainer::GetFocussedItem
|
|
132 |
// Returns the currentlt focussed element.
|
|
133 |
//
|
|
134 |
// @return TInt Index of the item selected
|
|
135 |
// ---------------------------------------------------------------------------
|
|
136 |
//
|
|
137 |
TInt CLbtMgmtPluginContainer::GetFocussedItem()
|
|
138 |
{
|
|
139 |
return iListBox->CurrentItemIndex();
|
|
140 |
}
|
|
141 |
|
|
142 |
// ---------------------------------------------------------------------------
|
|
143 |
// void CLbtMgmtPluginContainer::HandleResourceChange
|
|
144 |
//
|
|
145 |
// ---------------------------------------------------------------------------
|
|
146 |
//
|
|
147 |
void CLbtMgmtPluginContainer::HandleResourceChange(TInt aType)
|
|
148 |
{
|
|
149 |
// Pass the event to the base class
|
|
150 |
CCoeControl::HandleResourceChange( aType );
|
|
151 |
switch( aType )
|
|
152 |
{
|
|
153 |
// Dynamic Layout switch
|
|
154 |
case KEikDynamicLayoutVariantSwitch:
|
|
155 |
{
|
|
156 |
// Handle the screen change event
|
|
157 |
// Trap and Ignore the error
|
|
158 |
TRAP_IGNORE(
|
|
159 |
iCmdHandler.HandleCmdL( MLbtMgmtPluginCmdHdlr::EScreenSizeChanged ));
|
|
160 |
break;
|
|
161 |
}
|
|
162 |
default:
|
|
163 |
{
|
|
164 |
break;
|
|
165 |
}
|
|
166 |
}
|
|
167 |
}
|
|
168 |
|
|
169 |
// ---------------------------------------------------------------------------
|
|
170 |
// TInt CLbtMgmtPluginContainer::CountComponentControls
|
|
171 |
//
|
|
172 |
// ---------------------------------------------------------------------------
|
|
173 |
//
|
|
174 |
TInt CLbtMgmtPluginContainer::CountComponentControls() const
|
|
175 |
{
|
|
176 |
return KNoofComponentControls;
|
|
177 |
}
|
|
178 |
|
|
179 |
// ---------------------------------------------------------------------------
|
|
180 |
// CCoeControl* CLbtMgmtPluginContainer::ComponentControl
|
|
181 |
//
|
|
182 |
// ---------------------------------------------------------------------------
|
|
183 |
//
|
|
184 |
CCoeControl* CLbtMgmtPluginContainer::ComponentControl(TInt /*aIndex*/) const
|
|
185 |
{
|
|
186 |
return iListBox;
|
|
187 |
}
|
|
188 |
|
|
189 |
// ---------------------------------------------------------------------------
|
|
190 |
// void CLbtMgmtPluginContainer::OfferKeyEventL
|
|
191 |
//
|
|
192 |
// ---------------------------------------------------------------------------
|
|
193 |
//
|
|
194 |
TKeyResponse CLbtMgmtPluginContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent,
|
|
195 |
TEventCode aType )
|
|
196 |
{
|
|
197 |
TKeyResponse keyresponse;
|
|
198 |
switch ( aKeyEvent.iCode )
|
|
199 |
{
|
|
200 |
case EKeyLeftArrow:
|
|
201 |
case EKeyRightArrow:
|
|
202 |
{
|
|
203 |
// Listbox takes all event even if it doesn't use them
|
|
204 |
return EKeyWasNotConsumed;
|
|
205 |
}
|
|
206 |
case EKeyUpArrow:
|
|
207 |
case EKeyDownArrow:
|
|
208 |
{
|
|
209 |
keyresponse = iListBox->OfferKeyEventL( aKeyEvent, aType );
|
|
210 |
iCmdHandler.HandleCmdL( MLbtMgmtPluginCmdHdlr::EListBoxItemFocused );
|
|
211 |
return keyresponse;
|
|
212 |
}
|
|
213 |
default:
|
|
214 |
{
|
|
215 |
break;
|
|
216 |
}
|
|
217 |
}
|
|
218 |
// now it's iListBox's job to process the key event
|
|
219 |
return iListBox->OfferKeyEventL( aKeyEvent, aType );
|
|
220 |
}
|
|
221 |
|
|
222 |
// ---------------------------------------------------------------------------
|
|
223 |
// void CLbtMgmtPluginContainer::HandleListBoxEventL
|
|
224 |
//
|
|
225 |
// ---------------------------------------------------------------------------
|
|
226 |
//
|
|
227 |
void CLbtMgmtPluginContainer::HandleListBoxEventL(
|
|
228 |
CEikListBox* /* aListBox */,
|
|
229 |
MEikListBoxObserver::TListBoxEvent aEventType)
|
|
230 |
{
|
|
231 |
switch (aEventType)
|
|
232 |
{
|
|
233 |
// List box Item Selection
|
|
234 |
case EEventEnterKeyPressed:
|
|
235 |
case EEventItemSingleClicked:
|
|
236 |
{
|
|
237 |
if (iView->GetLbtMgmtPluginEngine()->ActiveTriggers())
|
|
238 |
{
|
|
239 |
iView->HandleCommandL(ELbtMgmtShowCSMenu);
|
|
240 |
}
|
|
241 |
// Settings element has been selected. Command has to be issued to
|
|
242 |
// change the settings configuration
|
|
243 |
iCmdHandler.HandleCmdL(
|
|
244 |
MLbtMgmtPluginCmdHdlr::EListBoxItemSelected);
|
|
245 |
break;
|
|
246 |
}
|
|
247 |
default:
|
|
248 |
break;
|
|
249 |
}
|
|
250 |
}
|
|
251 |
|
|
252 |
// -----------------------------------------------------------------------------
|
|
253 |
// CLocNotPrefPluginContainer::GetHelpContext
|
|
254 |
//
|
|
255 |
// -----------------------------------------------------------------------------
|
|
256 |
//
|
|
257 |
void CLbtMgmtPluginContainer::GetHelpContext( TCoeHelpContext& aContext ) const
|
|
258 |
{
|
|
259 |
aContext.iContext = iContextName;
|
|
260 |
aContext.iMajor = TUid::Uid( KLbtMgmtPluginUID3 );
|
|
261 |
}
|
|
262 |
|
|
263 |
// ---------------------------------------------------------------------------
|
|
264 |
// void CLbtMgmtPluginContainer::HandlePointerEventL
|
|
265 |
//
|
|
266 |
// ---------------------------------------------------------------------------
|
|
267 |
//
|
|
268 |
void CLbtMgmtPluginContainer::HandlePointerEventL(const TPointerEvent &aPointerEvent)
|
|
269 |
{
|
|
270 |
// Check if touch is enabled or not
|
|
271 |
if( !AknLayoutUtils::PenEnabled() || !iListBox )
|
|
272 |
{
|
|
273 |
return;
|
|
274 |
}
|
|
275 |
iListBox->HandlePointerEventL( aPointerEvent );
|
|
276 |
}
|
|
277 |
// ---------------------------------------------------------------------------
|
|
278 |
// void CLbtMgmtPluginContainer::FocusChanged
|
|
279 |
//
|
|
280 |
// ---------------------------------------------------------------------------
|
|
281 |
//
|
|
282 |
void CLbtMgmtPluginContainer::FocusChanged( TDrawNow aDrawNow )
|
|
283 |
{
|
|
284 |
CCoeControl::FocusChanged( aDrawNow );
|
|
285 |
// The focus event has to be explicitly handed over to all the compound
|
|
286 |
// controls since CCoeControl does not do that implicitly
|
|
287 |
iListBox->SetFocus( IsFocused(), aDrawNow );
|
|
288 |
}
|
|
289 |
|
|
290 |
// ---------------------------------------------------------------------------
|
|
291 |
// CLbtMgmtPluginContainer::SizeChanged
|
|
292 |
//
|
|
293 |
// ---------------------------------------------------------------------------
|
|
294 |
//
|
|
295 |
void CLbtMgmtPluginContainer::SizeChanged()
|
|
296 |
{
|
|
297 |
iListBox->SetRect( Rect() );
|
|
298 |
}
|
|
299 |
|
|
300 |
// ---------------------------------------------------------------------------
|
|
301 |
// void CLbtMgmtPluginContainer::CreateListboxL
|
|
302 |
// Creates the List box and the Listbox model. Associates the list box model
|
|
303 |
// with the list box
|
|
304 |
//
|
|
305 |
// ---------------------------------------------------------------------------
|
|
306 |
//
|
|
307 |
void CLbtMgmtPluginContainer::CreateListboxL()
|
|
308 |
{
|
|
309 |
|
|
310 |
// Create the List box
|
|
311 |
iListBox = new ( ELeave ) CAknSettingStyleListBox;
|
|
312 |
iListBox->ConstructL( this, EAknListBoxSelectionList );
|
|
313 |
iListBox->SetContainerWindowL( *this );
|
|
314 |
iListBox->SetListBoxObserver( this );
|
|
315 |
iListBox->CreateScrollBarFrameL( ETrue );
|
|
316 |
iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff,
|
|
317 |
CEikScrollBarFrame::EAuto );
|
|
318 |
|
|
319 |
// The ownership of the list box model is retained with the Container.
|
|
320 |
// This is because the model contains the additional functionality of
|
|
321 |
// changing the settings values in addition to retreiving it.
|
|
322 |
iListBox->Model()->SetItemTextArray( &iListBoxModel );
|
|
323 |
iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
|
|
324 |
iListBox->ItemDrawer()->ColumnData()->EnableMarqueeL( ETrue );
|
|
325 |
iListBox->ActivateL();
|
|
326 |
}
|
|
327 |
|
|
328 |
// ---------------------------------------------------------------------------
|
|
329 |
// void CLbtMgmtPluginContainer::MakeTitleL
|
|
330 |
// Sets the Title text
|
|
331 |
//
|
|
332 |
// @param aResourceText Resource to create title
|
|
333 |
// ---------------------------------------------------------------------------
|
|
334 |
//
|
|
335 |
void CLbtMgmtPluginContainer::MakeTitleL( TInt aResourceText )
|
|
336 |
{
|
|
337 |
// Obtain the title from the Status Pane
|
|
338 |
CAknTitlePane* title = static_cast<CAknTitlePane*>( StatusPane()->
|
|
339 |
ControlL( TUid::Uid( EEikStatusPaneUidTitle )));
|
|
340 |
|
|
341 |
// Set the Title's buffer
|
|
342 |
HBufC* buf = StringLoader::LoadL( aResourceText );
|
|
343 |
title->SetText( buf ); // Takes ownership of buf
|
|
344 |
}
|
|
345 |
|
|
346 |
// ---------------------------------------------------------------------------
|
|
347 |
// void CLbtMgmtPluginContainer::StatusPane
|
|
348 |
// Returns the Appui's status pane
|
|
349 |
//
|
|
350 |
// @return CEikStatusPane* Statuspane pointer
|
|
351 |
// ---------------------------------------------------------------------------
|
|
352 |
//
|
|
353 |
CEikStatusPane* CLbtMgmtPluginContainer::StatusPane()
|
|
354 |
{
|
|
355 |
return iEikonEnv->AppUiFactory()->StatusPane();
|
|
356 |
}
|
|
357 |
|
|
358 |
// ---------------------------------------------------------------------------
|
|
359 |
// void CLbtMgmtPluginContainer::Update
|
|
360 |
// It will updates listbox model
|
|
361 |
// ---------------------------------------------------------------------------
|
|
362 |
//
|
|
363 |
void CLbtMgmtPluginContainer::Update()
|
|
364 |
{
|
|
365 |
if(iListBox)
|
|
366 |
{
|
|
367 |
iListBox->DrawDeferred();
|
|
368 |
}
|
|
369 |
}
|
|
370 |
|
|
371 |
// ---------------------------------------------------------------------------
|
|
372 |
// void CLbtMgmtPluginContainer::ShowContextMenuL
|
|
373 |
// Shows context specific menu items
|
|
374 |
// ---------------------------------------------------------------------------
|
|
375 |
//
|
|
376 |
void CLbtMgmtPluginContainer::ShowContextMenuL()
|
|
377 |
{
|
|
378 |
// Switch to Context specific options menu,
|
|
379 |
// Show it and switch back to main options menu.
|
|
380 |
CEikMenuBar* menuBar = iView->MenuBar();
|
|
381 |
// TRAP displaying of menu bar.
|
|
382 |
// If it fails, the correct resource is set back before leave.
|
|
383 |
TRAPD( err, menuBar->TryDisplayContextMenuBarL() );
|
|
384 |
User::LeaveIfError(err);
|
|
385 |
|
|
386 |
}
|
|
387 |
|