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 request container class methods. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <akncontext.h> |
|
21 #include <aknnavide.h> |
|
22 #include <eikspane.h> |
|
23 #include <barsread.h> |
|
24 #include <akntabgrp.h> |
|
25 #include <AknIconArray.h> |
|
26 #include <gulicon.h> |
|
27 #include <StringLoader.h> |
|
28 #include <akntitle.h> |
|
29 #include <eiklbx.h> |
|
30 #include <avkon.hrh> |
|
31 #include <coehelp.h> |
|
32 #include <AknsUtils.h> |
|
33 #include <akntabgrp.h> |
|
34 #include <blid.mbg> |
|
35 #include "CBlidBaseContainer.h" |
|
36 #include "MKeyProcessor.h" |
|
37 #include "BlidUID.h" |
|
38 #include "bliduiconsts.h" |
|
39 #include "Blidutils.h" |
|
40 #include "Blid.hrh" |
|
41 #include "CBlidAppUi.h" |
|
42 |
|
43 TBool CBlidBaseContainer::iGPSAvailability = EFalse; |
|
44 // ================= MEMBER FUNCTIONS ======================= |
|
45 // ---------------------------------------------------- |
|
46 // CBlidBaseContainer::CBlidBaseContainer |
|
47 // First phase constructor, can not leave |
|
48 // ---------------------------------------------------- |
|
49 // |
|
50 CBlidBaseContainer::CBlidBaseContainer( |
|
51 MKeyProcessor& aKeyProcessor, |
|
52 const TDesC& aHelpContext ) |
|
53 :iKeyProcessor(aKeyProcessor) |
|
54 { |
|
55 iContextName = aHelpContext; |
|
56 } |
|
57 |
|
58 // ---------------------------------------------------- |
|
59 // CBlidBaseContainer::~CBlidBaseContainer |
|
60 // Destructor, frees allocated resources |
|
61 // ---------------------------------------------------- |
|
62 // |
|
63 CBlidBaseContainer::~CBlidBaseContainer() |
|
64 { |
|
65 } |
|
66 |
|
67 // ---------------------------------------------------- |
|
68 // CBlidBaseContainer::ActivateTabL |
|
69 // Activates a tab specified bt tab id |
|
70 // ---------------------------------------------------- |
|
71 // |
|
72 void CBlidBaseContainer::ActivateTabL( |
|
73 CAknNavigationDecorator& aNaviDecorator, |
|
74 TInt aTabId ) |
|
75 { |
|
76 CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane(); |
|
77 CAknNavigationControlContainer* naviPane = |
|
78 static_cast<CAknNavigationControlContainer*>( |
|
79 sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi))); |
|
80 CAknTabGroup* tabGroup = static_cast<CAknTabGroup*>( |
|
81 aNaviDecorator.DecoratedControl() ); |
|
82 tabGroup->SetActiveTabById( aTabId ); |
|
83 naviPane->PushL( aNaviDecorator ); |
|
84 } |
|
85 |
|
86 |
|
87 // ---------------------------------------------------- |
|
88 // CBlidBaseContainer::GetHelpContext |
|
89 // Get the help context for the application |
|
90 // ---------------------------------------------------- |
|
91 // |
|
92 void CBlidBaseContainer::GetHelpContext( TCoeHelpContext& aContext ) const |
|
93 { |
|
94 aContext.iContext = iContextName; |
|
95 aContext.iMajor = TUid::Uid(KBLIDUID3); |
|
96 } |
|
97 |
|
98 // ---------------------------------------------------- |
|
99 // CBlidBaseContainer::OfferKeyEventL |
|
100 // Handles the key event |
|
101 // ---------------------------------------------------- |
|
102 // |
|
103 TKeyResponse CBlidBaseContainer::OfferKeyEventL( |
|
104 const TKeyEvent& aKeyEvent, |
|
105 TEventCode aType) |
|
106 { |
|
107 CEikStatusPane* sp = StatusPane(); |
|
108 // Fetch pointer to the default navi pane control |
|
109 CAknNavigationControlContainer* naviPane = |
|
110 static_cast<CAknNavigationControlContainer*>(sp->ControlL( |
|
111 TUid::Uid(EEikStatusPaneUidNavi))); |
|
112 CAknNavigationDecorator* naviDecorator = naviPane->Top(); |
|
113 |
|
114 // Check if navigation pane controls exists, because decorator does |
|
115 // not exist in every cases. E.g. after contact fetch in "new rule" |
|
116 // command operation naviDecorator is null. |
|
117 if ( naviDecorator && naviDecorator->ControlType() == |
|
118 CAknNavigationDecorator::ETabGroup ) |
|
119 { |
|
120 if ( naviDecorator->DecoratedControl()->OfferKeyEventL( |
|
121 aKeyEvent, aType ) == EKeyWasConsumed ) |
|
122 { |
|
123 return EKeyWasConsumed; |
|
124 } |
|
125 } |
|
126 |
|
127 if ( iKeyProcessor.ProcessKeyEventL( aKeyEvent, aType ) == |
|
128 EKeyWasConsumed ) |
|
129 { |
|
130 return EKeyWasConsumed; |
|
131 } |
|
132 |
|
133 for ( TInt i = 0; i < CountComponentControls(); i++ ) |
|
134 { |
|
135 if ( ComponentControl(i)->OfferKeyEventL( aKeyEvent, aType ) == |
|
136 EKeyWasConsumed ) |
|
137 { |
|
138 return EKeyWasConsumed; |
|
139 } |
|
140 } |
|
141 |
|
142 return EKeyWasNotConsumed; |
|
143 } |
|
144 |
|
145 // ---------------------------------------------------- |
|
146 // CBlidBaseContainer::HandleResourceChange |
|
147 // Handles the change in app resource |
|
148 // ---------------------------------------------------- |
|
149 // |
|
150 void CBlidBaseContainer::HandleResourceChange(TInt aType) |
|
151 { |
|
152 CCoeControl::HandleResourceChange(aType); |
|
153 if( aType == KAknsMessageSkinChange ) |
|
154 { |
|
155 static_cast<CBlidAppUi*>(iCoeEnv->AppUi())->SkinChange(); |
|
156 } |
|
157 } |
|
158 |
|
159 // ---------------------------------------------------- |
|
160 // CBlidBaseContainer::CreateNaviPaneL |
|
161 // Creates the navigation pane |
|
162 // ---------------------------------------------------- |
|
163 // |
|
164 CAknNavigationDecorator* CBlidBaseContainer::CreateNaviPaneL( |
|
165 TBool aDefaultNaviPane ) |
|
166 { |
|
167 CEikStatusPane* sp = StatusPane(); |
|
168 if( !sp ) |
|
169 { |
|
170 User::Leave( KErrGeneral ); |
|
171 } |
|
172 // Fetch pointer to the default navi pane control |
|
173 CAknNavigationControlContainer* naviPane = |
|
174 static_cast<CAknNavigationControlContainer*>(sp->ControlL( |
|
175 TUid::Uid(EEikStatusPaneUidNavi))); |
|
176 if( !naviPane ) |
|
177 { |
|
178 User::Leave( KErrGeneral ); |
|
179 } |
|
180 CAknNavigationDecorator* decorator = NULL; |
|
181 if ( aDefaultNaviPane ) // dummy tab |
|
182 { |
|
183 naviPane->PushDefaultL(EFalse); |
|
184 } |
|
185 else |
|
186 { |
|
187 decorator = naviPane->CreateTabGroupL(iKeyProcessor.TabObserver()); |
|
188 decorator->SetControlType( CAknNavigationDecorator::ETabGroup ); |
|
189 CAknTabGroup* tabGroup = |
|
190 static_cast< CAknTabGroup* > ( decorator->DecoratedControl() ); |
|
191 AddTabsL( *tabGroup ); |
|
192 } |
|
193 return decorator; |
|
194 } |
|
195 |
|
196 // ---------------------------------------------------- |
|
197 // CBlidBaseContainer::AddIconL |
|
198 // Add icon |
|
199 // ---------------------------------------------------- |
|
200 // |
|
201 void CBlidBaseContainer::AddIconL |
|
202 ( CAknIconArray* aIcons, |
|
203 const TAknsItemID aSkinID, |
|
204 const TDesC& aIconFileWithPath, |
|
205 TInt aIconGraphicsIndex, |
|
206 TInt aIconGraphicsMaskIndex ) |
|
207 { |
|
208 CFbsBitmap *bitmap = NULL; |
|
209 CFbsBitmap* mask = NULL; |
|
210 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
211 AknsUtils::CreateIconLC( skin, |
|
212 aSkinID, |
|
213 bitmap, |
|
214 mask, |
|
215 aIconFileWithPath, |
|
216 aIconGraphicsIndex, |
|
217 aIconGraphicsMaskIndex ); |
|
218 |
|
219 // Append it to icons array |
|
220 CGulIcon* icon = CGulIcon::NewL( bitmap, mask ); |
|
221 CleanupStack::Pop( 2 ); // mask, bitmap. icon has now ownership |
|
222 CleanupStack::PushL( icon ); |
|
223 aIcons->AppendL( icon ); |
|
224 CleanupStack::Pop( ); // icon |
|
225 |
|
226 } |
|
227 |
|
228 // ---------------------------------------------------- |
|
229 // CBlidBaseContainer::MakeTitleL |
|
230 // Sets the title to text specified by a resource |
|
231 // ---------------------------------------------------- |
|
232 // |
|
233 void CBlidBaseContainer::MakeTitleL( TInt aResourceText ) |
|
234 { |
|
235 HBufC* buf = StringLoader::LoadLC(aResourceText); |
|
236 CAknTitlePane* title = static_cast<CAknTitlePane*>( StatusPane()-> |
|
237 ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
|
238 CleanupStack::Pop(); //buf |
|
239 title->SetText(buf); // Takes ownership of buf |
|
240 } |
|
241 |
|
242 // ---------------------------------------------------- |
|
243 // CBlidBaseContainer::MakeEmptyTextListBoxL |
|
244 // |
|
245 // ---------------------------------------------------- |
|
246 // |
|
247 void CBlidBaseContainer::MakeEmptyTextListBoxL( |
|
248 CEikListBox* aListBox, |
|
249 TInt aResourceText ) |
|
250 { |
|
251 HBufC* textFromResourceFile; |
|
252 textFromResourceFile = |
|
253 StringLoader::LoadLC( aResourceText, iCoeEnv ); |
|
254 aListBox->View()->SetListEmptyTextL( *textFromResourceFile ); |
|
255 CleanupStack::PopAndDestroy(); // textFromResourceFile. |
|
256 } |
|
257 |
|
258 // ---------------------------------------------------- |
|
259 // CBlidBaseContainer::StatusPane |
|
260 // Returns the status pane |
|
261 // ---------------------------------------------------- |
|
262 // |
|
263 CEikStatusPane* CBlidBaseContainer::StatusPane() |
|
264 { |
|
265 return iEikonEnv->AppUiFactory()->StatusPane(); |
|
266 } |
|
267 |
|
268 // ---------------------------------------------------- |
|
269 // CBlidBaseContainer::AddTabsL |
|
270 // Adds the tabs |
|
271 // ---------------------------------------------------- |
|
272 // |
|
273 void CBlidBaseContainer::AddTabsL(CAknTabGroup& aTabGroup) |
|
274 { |
|
275 aTabGroup.SetTabFixedWidthL(EAknTabWidthWithTwoTabs); |
|
276 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
277 HBufC* filename = BlidUtils::GetBitmapFilenameLC(); |
|
278 CFbsBitmap* bitmap = NULL; |
|
279 CFbsBitmap* bitmapMask = NULL; |
|
280 |
|
281 //Add tab icon 1 |
|
282 AknsUtils::CreateIconLC( skin, |
|
283 KAknsIIDQgnPropBlidNavigationTab3, |
|
284 bitmap, |
|
285 bitmapMask, |
|
286 *filename, |
|
287 EMbmBlidQgn_prop_blid_navigation_tab3, |
|
288 EMbmBlidQgn_prop_blid_navigation_tab3_mask ); |
|
289 aTabGroup.AddTabL( EBlidNavigationView, bitmap, bitmapMask ); |
|
290 CleanupStack::Pop(2); //bitmap, bitmapmask |
|
291 |
|
292 //Add tab icon 2 |
|
293 AknsUtils::CreateIconLC( skin, |
|
294 KAknsIIDQgnPropBlidTripTab3, |
|
295 bitmap, |
|
296 bitmapMask, |
|
297 *filename, |
|
298 EMbmBlidQgn_prop_blid_trip_tab3, |
|
299 EMbmBlidQgn_prop_blid_trip_tab3_mask ); |
|
300 aTabGroup.AddTabL( EBlidTripMeterView, bitmap, bitmapMask ); |
|
301 CleanupStack::Pop(2); //bitmap, bitmapmask |
|
302 |
|
303 |
|
304 |
|
305 CleanupStack::PopAndDestroy(); //filename |
|
306 } |
|
307 |
|
308 // --------------------------------------------------------- |
|
309 // CBlidBaseContainer::SetGPSAvailability |
|
310 // Sets the GPS availability to ETrue or EFalse |
|
311 // --------------------------------------------------------- |
|
312 // |
|
313 void CBlidBaseContainer::SetGPSAvailability(const TBool aAvailability) |
|
314 { |
|
315 iGPSAvailability = aAvailability; |
|
316 } |
|
317 |
|
318 // --------------------------------------------------------- |
|
319 // CBlidBaseContainer::IsGPSAvailable |
|
320 // Checks if GPS is available |
|
321 // --------------------------------------------------------- |
|
322 // |
|
323 TBool CBlidBaseContainer::IsGPSAvailable() |
|
324 { |
|
325 return iGPSAvailability; |
|
326 } |
|
327 |
|
328 // End of File |
|