author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:24:28 +0300 | |
branch | RCL_3 |
changeset 44 | 5033d469f7c9 |
parent 37 | 870918037e16 |
permissions | -rw-r--r-- |
37 | 1 |
/* |
2 |
* Copyright (c) 2005 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: Provides blid main view's container class methods. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
// INCLUDE FILES |
|
20 |
#include <aknview.h> |
|
21 |
#include <aknnavide.h> |
|
22 |
#include <eikmenub.h> |
|
23 |
#include <aknViewAppUi.h> |
|
24 |
#include <aknlists.h> // CAknSingleLargeStyleListBox |
|
44
5033d469f7c9
Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
25 |
#include <Blid.rsg> |
37 | 26 |
#include <AknsConstants.h> |
27 |
#include <AknIconArray.h> |
|
28 |
#include <aknnavide.h> |
|
29 |
#include <AknIconUtils.h> |
|
30 |
#include <avkon.mbg> |
|
31 |
#include <avkon.hrh> |
|
32 |
#include <gulicon.h> |
|
33 |
#include <eikclbd.h> |
|
34 |
#include <AknDef.h> |
|
35 |
#include <csxhelp/blid.hlp.hrh> |
|
36 |
||
37 |
#include "CBlidSavedWayptsContainer.h" |
|
38 |
#include "Blid.hrh" |
|
39 |
#include "CBlidSavedWayptsLBModel.h" |
|
40 |
||
41 |
// CONSTANTS |
|
42 |
#ifdef _DEBUG |
|
43 |
_LIT( KPanicText, "CBlidSavedWayptsContainer" ); |
|
44 |
||
45 |
enum TPanicCode |
|
46 |
{ |
|
47 |
KBlidNullPointer = 1 |
|
48 |
}; |
|
49 |
#endif |
|
50 |
// Unnamed namespace for local definitions |
|
51 |
namespace { |
|
52 |
const TInt KViewListboxGranularity = 2; // list box granularity |
|
53 |
} // namespace |
|
54 |
||
55 |
||
56 |
// ================= MEMBER FUNCTIONS ======================= |
|
57 |
// ---------------------------------------------------------------------------- |
|
58 |
// CBlidSavedWayptsContainer::NewL |
|
59 |
// ---------------------------------------------------------------------------- |
|
60 |
// |
|
61 |
CBlidSavedWayptsContainer* CBlidSavedWayptsContainer::NewL( |
|
62 |
MKeyProcessor& aKeyProcessor, |
|
63 |
MObjectProvider* aParent, |
|
64 |
const TRect& aRect, |
|
65 |
MBlidLocation* aLocation, |
|
66 |
MBlidSettings* aSettings, |
|
67 |
MBlidRouter* aRouter, |
|
68 |
CBlidBaseView& aView) |
|
69 |
{ |
|
70 |
CBlidSavedWayptsContainer* self = |
|
71 |
new (ELeave) CBlidSavedWayptsContainer( aKeyProcessor, aView ); |
|
72 |
CleanupStack::PushL(self); |
|
73 |
self->SetMopParent( aParent ); |
|
74 |
self->ConstructL( aRect, aLocation, aSettings,aRouter ); |
|
75 |
CleanupStack::Pop( self ); // self |
|
76 |
return self; |
|
77 |
} |
|
78 |
||
79 |
// ---------------------------------------------------------------------------- |
|
80 |
// CBlidSavedWayptsContainer::CBlidSavedWayptsContainer |
|
81 |
// ---------------------------------------------------------------------------- |
|
82 |
// |
|
83 |
CBlidSavedWayptsContainer::CBlidSavedWayptsContainer( MKeyProcessor& aKeyProcessor, |
|
84 |
CBlidBaseView& aView ) |
|
85 |
:CBlidBaseContainer( aKeyProcessor, KBLID_HLP_WAYPOINTS ), iView(aView) |
|
86 |
{ |
|
87 |
} |
|
88 |
||
89 |
// --------------------------------------------------------- |
|
90 |
// CBlidSavedWayptsContainer::ConstructL |
|
91 |
// Symbian 2nd phase constructor can leave. |
|
92 |
// --------------------------------------------------------- |
|
93 |
// |
|
94 |
void CBlidSavedWayptsContainer::ConstructL( const TRect& aRect, |
|
95 |
MBlidLocation* aLocation, |
|
96 |
MBlidSettings* aSettings,MBlidRouter* aRouter ) |
|
97 |
{ |
|
98 |
CreateWindowL(); |
|
99 |
SetBlank(); |
|
100 |
||
101 |
iDecoratedTabGroup = CreateNaviPaneL( EFalse ); |
|
102 |
ActivateTabL( *iDecoratedTabGroup, EBlidSavedWayptsView ); |
|
103 |
||
104 |
CreateListboxL(aLocation, aSettings,aRouter); |
|
105 |
||
106 |
MakeTitleL(R_BLID_TITLE_WAYPOINTS); |
|
107 |
SetRect(aRect); |
|
108 |
ActivateL(); |
|
109 |
} |
|
110 |
||
111 |
// ---------------------------------------------------------------------------- |
|
112 |
// CBlidSavedWayptsContainer::~CBlidSavedWayptsContainer |
|
113 |
// ---------------------------------------------------------------------------- |
|
114 |
// |
|
115 |
CBlidSavedWayptsContainer::~CBlidSavedWayptsContainer() |
|
116 |
{ |
|
117 |
delete iDecoratedTabGroup; |
|
118 |
delete iListBox; |
|
119 |
} |
|
120 |
||
121 |
// ---------------------------------------------------------------------------- |
|
122 |
// CBlidSavedWayptsContainer::UpdateL |
|
123 |
// ---------------------------------------------------------------------------- |
|
124 |
// |
|
125 |
void CBlidSavedWayptsContainer::UpdateL() |
|
126 |
{ |
|
127 |
__ASSERT_DEBUG( iListBox, User::Panic( KPanicText, KBlidNullPointer ) ); |
|
128 |
iListBox->DrawNow(); |
|
129 |
} |
|
130 |
||
131 |
// ---------------------------------------------------------------------------- |
|
132 |
// CBlidSavedWayptsContainer::OfferKeyEventL |
|
133 |
// ---------------------------------------------------------------------------- |
|
134 |
// |
|
135 |
TKeyResponse CBlidSavedWayptsContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
136 |
TEventCode aType) |
|
137 |
{ |
|
138 |
if ( aKeyEvent.iCode == EKeyOK ) |
|
139 |
{ |
|
140 |
TBool shiftKeyPressed = (aKeyEvent.iModifiers & EModifierShift); |
|
141 |
if(shiftKeyPressed) |
|
142 |
{ |
|
143 |
iListBox->OfferKeyEventL( aKeyEvent, aType); |
|
144 |
return EKeyWasConsumed; |
|
145 |
} |
|
146 |
CEikMenuBar* menubar = static_cast<CAknViewAppUi*> |
|
147 |
(iAvkonAppUi)->View(TUid::Uid( EBlidSavedWayptsView ))->MenuBar(); |
|
148 |
if ( menubar ) |
|
149 |
{ |
|
150 |
menubar->SetMenuTitleResourceId(R_BLID_SAVEDWAYPTS_VIEW_OK_MENUBAR); |
|
151 |
||
152 |
menubar->StopDisplayingMenuBar(); |
|
153 |
TRAPD(err,menubar->TryDisplayMenuBarL()); |
|
154 |
User::LeaveIfError(err); |
|
155 |
menubar->SetMenuTitleResourceId(R_BLID_SAVEDWAYPTS_MENUBAR); |
|
156 |
} |
|
157 |
||
158 |
return EKeyWasConsumed; |
|
159 |
} |
|
160 |
else if( aKeyEvent.iCode == EKeyBackspace ) |
|
161 |
{ |
|
162 |
static_cast<CAknViewAppUi*> |
|
163 |
(iAvkonAppUi)->View(TUid::Uid( EBlidSavedWayptsView ))->HandleCommandL(EBlidCmdDeleteWaypt); |
|
164 |
} |
|
165 |
return CBlidBaseContainer::OfferKeyEventL( aKeyEvent, aType ); |
|
166 |
} |
|
167 |
||
168 |
// --------------------------------------------------------- |
|
169 |
// CBlidSavedWayptsContainer::SizeChanged() |
|
170 |
// Called by framework when the view size is changed |
|
171 |
// --------------------------------------------------------- |
|
172 |
// |
|
173 |
void CBlidSavedWayptsContainer::SizeChanged() |
|
174 |
{ |
|
175 |
iListBox->SetRect( Rect() ); |
|
176 |
} |
|
177 |
||
178 |
// --------------------------------------------------------- |
|
179 |
// CBlidSavedWayptsContainer::CountComponentControls() const |
|
180 |
// --------------------------------------------------------- |
|
181 |
// |
|
182 |
TInt CBlidSavedWayptsContainer::CountComponentControls() const |
|
183 |
{ |
|
184 |
return 1; // return nbr of controls inside this container |
|
185 |
} |
|
186 |
||
187 |
// --------------------------------------------------------- |
|
188 |
// CBlidSavedWayptsContainer::ComponentControl(TInt aIndex) const |
|
189 |
// --------------------------------------------------------- |
|
190 |
// |
|
191 |
CCoeControl* CBlidSavedWayptsContainer::ComponentControl(TInt /*aIndex*/) const |
|
192 |
{ |
|
193 |
return iListBox; |
|
194 |
} |
|
195 |
||
196 |
// --------------------------------------------------------- |
|
197 |
// CBlidSavedWayptsContainer::CreateListboxL |
|
198 |
// --------------------------------------------------------- |
|
199 |
// |
|
200 |
void CBlidSavedWayptsContainer::CreateListboxL( MBlidLocation* aLocation, |
|
201 |
MBlidSettings* aSettings,MBlidRouter* aRouter ) |
|
202 |
{ |
|
203 |
delete iListBox; |
|
204 |
iListBox = NULL; |
|
205 |
iListBox = new(ELeave) CAknSingleGraphicStyleListBox(); |
|
206 |
iListBox->SetContainerWindowL(*this); |
|
207 |
||
208 |
#ifndef RD_SCALABLE_UI_V2 |
|
209 |
iListBox->ConstructL( this, EAknGenericListBoxFlags |
|
210 |
| EAknListBoxMarkableList); |
|
211 |
#else |
|
212 |
iListBox->ConstructL( this, EAknGenericListBoxFlags |
|
213 |
| EAknListBoxStylusMarkableList); |
|
214 |
#endif |
|
215 |
||
216 |
MDesCArray* model = CBlidSavedWayptsLBModel::NewLC( aLocation, aSettings,aRouter ); |
|
217 |
// listbox takes the ownership |
|
218 |
iListBox->Model()->SetItemTextArray( model ); |
|
219 |
iListBox->Model()->SetOwnershipType( ELbmOwnsItemArray ); |
|
220 |
CleanupStack::Pop(); // model |
|
221 |
||
222 |
UpdateIconsL(); |
|
223 |
||
224 |
// Make scroll arrows |
|
225 |
iListBox->CreateScrollBarFrameL( ETrue ); |
|
226 |
iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
227 |
CEikScrollBarFrame::EAuto,CEikScrollBarFrame::EAuto ); |
|
228 |
MakeEmptyTextListBoxL(R_BLID_NO_WAYPOINTS); |
|
229 |
||
230 |
iListBox->ActivateL(); |
|
231 |
} |
|
232 |
||
233 |
// ----------------------------------------------------------------------------- |
|
234 |
// CBlidSavedWayptsContainer::UpdateIconsL |
|
235 |
// ----------------------------------------------------------------------------- |
|
236 |
// |
|
237 |
void CBlidSavedWayptsContainer::UpdateIconsL() |
|
238 |
{ |
|
239 |
TAknsItemID skinId = KAknsIIDNone; |
|
240 |
||
241 |
CAknIconArray* icons = new( ELeave ) CAknIconArray( |
|
242 |
KViewListboxGranularity ); |
|
243 |
CleanupStack::PushL( icons ); |
|
244 |
||
245 |
TFileName* aknIconFile = new (ELeave) TFileName; |
|
246 |
CleanupStack::PushL(aknIconFile); |
|
247 |
*aknIconFile = AknIconUtils::AvkonIconFileName(); |
|
248 |
||
249 |
AddIconL( icons, skinId, *aknIconFile, EMbmAvkonQgn_indi_marked_add , |
|
250 |
EMbmAvkonQgn_indi_marked_add_mask ); |
|
251 |
AddIconL( icons, skinId, *aknIconFile, EMbmAvkonQgn_prop_empty , |
|
252 |
EMbmAvkonQgn_prop_empty_mask ); |
|
253 |
||
254 |
||
255 |
//get old icons and delete those |
|
256 |
CAknIconArray* Oldicons = static_cast<CAknIconArray*>( |
|
257 |
iListBox->ItemDrawer()->ColumnData()->IconArray() ); |
|
258 |
delete Oldicons; |
|
259 |
||
260 |
//set new icons to array |
|
261 |
iListBox->ItemDrawer()->ColumnData()->SetIconArray( icons ); |
|
262 |
CleanupStack::PopAndDestroy(aknIconFile); |
|
263 |
CleanupStack::Pop(icons); |
|
264 |
} |
|
265 |
||
266 |
// ----------------------------------------------------------------------------- |
|
267 |
// CLocMainContainer::SelectedRow |
|
268 |
// ----------------------------------------------------------------------------- |
|
269 |
// |
|
270 |
TInt CBlidSavedWayptsContainer::SelectedRow() const |
|
271 |
{ |
|
272 |
return iListBox->CurrentItemIndex(); |
|
273 |
} |
|
274 |
||
275 |
// ----------------------------------------------------------------------------- |
|
276 |
// CLocMainContainer::SetSelectedRow |
|
277 |
// ----------------------------------------------------------------------------- |
|
278 |
// |
|
279 |
void CBlidSavedWayptsContainer::SetSelectedRow(TInt aIndex) const |
|
280 |
{ |
|
281 |
iListBox->SetCurrentItemIndex(aIndex); |
|
282 |
} |
|
283 |
||
284 |
// ----------------------------------------------------------------------------- |
|
285 |
// CLocMainContainer::HandleResourceChange |
|
286 |
// ----------------------------------------------------------------------------- |
|
287 |
// |
|
288 |
void CBlidSavedWayptsContainer::HandleResourceChange(TInt aType) |
|
289 |
{ |
|
290 |
CBlidBaseContainer::HandleResourceChange( aType ); |
|
291 |
if( aType == KAknsMessageSkinChange ) |
|
292 |
{ |
|
293 |
TRAPD( error, UpdateIconsL() ); |
|
294 |
if ( error != KErrNone ) |
|
295 |
{ |
|
296 |
iCoeEnv->HandleError( error ); |
|
297 |
} |
|
298 |
iListBox->DrawDeferred(); |
|
299 |
} |
|
300 |
else if ( aType == KEikDynamicLayoutVariantSwitch ) |
|
301 |
{ |
|
302 |
iView.Update(this); |
|
303 |
} |
|
304 |
} |
|
305 |
||
306 |
// ---------------------------------------------------------------------------- |
|
307 |
// CBlidSavedWayptsContainer::FocuChanged() |
|
308 |
// ---------------------------------------------------------------------------- |
|
309 |
// |
|
310 |
void CBlidSavedWayptsContainer::FocusChanged(TDrawNow aDrawNow) |
|
311 |
{ |
|
312 |
if (iListBox) |
|
313 |
{ |
|
314 |
iListBox->SetFocus(IsFocused(), aDrawNow); |
|
315 |
} |
|
316 |
} |
|
317 |
||
318 |
// ----------------------------------------------------------------------------- |
|
319 |
// CLocMainContainer::HandleMarkCommandL |
|
320 |
// ----------------------------------------------------------------------------- |
|
321 |
// |
|
322 |
void CBlidSavedWayptsContainer::HandleMarkCommandL(TInt aCommand) |
|
323 |
{ |
|
324 |
AknSelectionService::HandleMarkableListProcessCommandL(aCommand,iListBox); |
|
325 |
} |
|
326 |
||
327 |
// ---------------------------------------------------- |
|
328 |
// CBlidSavedWayptsContainer::MakeEmptyTextListBoxL |
|
329 |
// ---------------------------------------------------- |
|
330 |
// |
|
331 |
void CBlidSavedWayptsContainer::MakeEmptyTextListBoxL( TInt aResourceText ) |
|
332 |
{ |
|
333 |
HBufC* textFromResourceFile; |
|
334 |
textFromResourceFile = iCoeEnv->AllocReadResourceLC( aResourceText ); |
|
335 |
iListBox->View()->SetListEmptyTextL( *textFromResourceFile ); |
|
336 |
CleanupStack::PopAndDestroy(); // textFromResourceFile. |
|
337 |
} |
|
338 |
||
339 |
#ifdef RD_SCALABLE_UI_V2 |
|
340 |
// --------------------------------------------------------------------------- |
|
341 |
// CBlidSavedWayptsContainer::SetListBoxObserver |
|
342 |
// --------------------------------------------------------------------------- |
|
343 |
// |
|
344 |
void CBlidSavedWayptsContainer::SetListBoxObserver( MEikListBoxObserver* aObserver ) |
|
345 |
{ |
|
346 |
iListBox->SetListBoxObserver( aObserver ); |
|
347 |
} |
|
348 |
#endif // RD_SCALABLE_UI_V2 |
|
349 |
// End of File |