|
1 /* |
|
2 * Copyright (c) 2002 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 the License "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: |
|
15 * Implementation of CBrowserFavouritesContainer. |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <eikimage.h> |
|
23 #include <AknAppUi.h> |
|
24 #include <AknNavi.h> |
|
25 #include <AknNaviDe.h> |
|
26 #include <AknTabGrp.h> |
|
27 #include <AknNaviLabel.h> |
|
28 #include <AknTitle.h> |
|
29 #include <aknsfld.h> |
|
30 #include <calslbs.h> |
|
31 #include <barsread.h> // for TResourceReader |
|
32 #include <EikSpane.h> |
|
33 #include <Avkon.hrh> |
|
34 #include <BrowserNG.rsg> |
|
35 #include <FavouritesDb.h> |
|
36 |
|
37 #include <aknconsts.h> |
|
38 #include <akneditstateindicator.h> |
|
39 #include <AknsListBoxBackgroundControlContext.h> |
|
40 #include <aknlayout.cdl.h> |
|
41 |
|
42 #include "Display.h" |
|
43 #include "Preferences.h" |
|
44 #include "BrowserAppUi.h" |
|
45 #include "BrowserUIVariant.hrh" |
|
46 #include "CommonConstants.h" |
|
47 #include "BrowserFavouritesView.h" |
|
48 #include "BrowserFavouritesContainer.h" |
|
49 #include "BrowserFavouritesListbox.h" |
|
50 #include "BrowserFavouritesListboxModel.h" |
|
51 #include "BrowserFavouritesListboxIconHandler.h" |
|
52 |
|
53 // CONSTANTS |
|
54 LOCAL_D const TInt KTabId = 88888; |
|
55 LOCAL_D const TInt KMaxNaviText = 25; // format is "<int>/<int>". |
|
56 _LIT( KFormat, "%d/%d" ); |
|
57 |
|
58 // ============================= LOCAL FUNCTIONS =============================== |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CBrowserFavouritesContainer::~CBrowserFavouritesContainer |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 CBrowserFavouritesContainer::~CBrowserFavouritesContainer() |
|
65 { |
|
66 delete iListbox; |
|
67 delete iIconHandler; |
|
68 delete iSkinContext; |
|
69 delete iNaviPaneTabsFolder; |
|
70 } |
|
71 |
|
72 |
|
73 // ----------------------------------------------------------------------------- |
|
74 // CBrowserFavouritesContainer::ShowRootNaviPane |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 void CBrowserFavouritesContainer::ShowRootNaviPane() |
|
78 { |
|
79 // If text is showing, destroy now - this pops off teh Navi Pane. |
|
80 delete iNaviPaneTabsFolder; |
|
81 iNaviPaneTabsFolder = NULL; |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // CBrowserFavouritesContainer::ShowFolderNaviPaneL |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 void CBrowserFavouritesContainer::ShowFolderNaviPaneL |
|
89 ( TInt aFolderIndex, TInt aFolderCount ) |
|
90 { |
|
91 CAknNavigationControlContainer* naviPane = |
|
92 iView->ApiProvider().Display().NaviPaneL(); |
|
93 if ( !iNaviPaneTabsFolder ) |
|
94 { |
|
95 // Folder's tab group not yet created. Make it now. |
|
96 iNaviPaneTabsFolder = naviPane->CreateTabGroupL(); |
|
97 iNaviPaneTabsFolder->SetNaviDecoratorObserver(this); |
|
98 } |
|
99 |
|
100 TBuf<KMaxNaviText> buf; |
|
101 // Format Navi Pane text "1/4" style. |
|
102 buf.Format( KFormat, aFolderIndex + 1, aFolderCount ); |
|
103 AknTextUtils::LanguageSpecificNumberConversion( buf ); |
|
104 |
|
105 CEikImage* folderIcon = new (ELeave) CEikImage; |
|
106 CleanupStack::PushL( folderIcon ); |
|
107 TResourceReader rr; |
|
108 iCoeEnv->CreateResourceReaderLC( rr, R_BROWSER_ICON_PROP_FOLDER ); |
|
109 folderIcon->ConstructFromResourceL( rr ); |
|
110 folderIcon->SetPictureOwnedExternally( EFalse ); // has ownership now |
|
111 CleanupStack::PopAndDestroy(); // rr |
|
112 |
|
113 CAknTabGroup* tabGroup = |
|
114 STATIC_CAST( CAknTabGroup*, iNaviPaneTabsFolder->DecoratedControl() ); |
|
115 if ( tabGroup->TabCount() ) |
|
116 { |
|
117 // Already created. Change the contents. |
|
118 tabGroup->ReplaceTabL |
|
119 ( |
|
120 KTabId, |
|
121 buf, |
|
122 folderIcon->Bitmap(), // ownership passed |
|
123 folderIcon->Mask() // ownership passed |
|
124 ); |
|
125 } |
|
126 else |
|
127 { |
|
128 // Created just now. Add the contents. |
|
129 tabGroup->AddTabL |
|
130 ( |
|
131 KTabId, |
|
132 buf, |
|
133 folderIcon->Bitmap(), // ownership passed |
|
134 folderIcon->Mask() // ownership passed |
|
135 ); |
|
136 } |
|
137 folderIcon->SetPictureOwnedExternally( ETrue ); // ownership passed |
|
138 CleanupStack::PopAndDestroy(); // folderIcon |
|
139 |
|
140 tabGroup->SetTabFixedWidthL( EAknTabWidthWithOneTab ); |
|
141 tabGroup->SetActiveTabById( KTabId ); |
|
142 |
|
143 iNaviPaneTabsFolder->SetScrollButtonDimmed |
|
144 ( CAknNavigationDecorator::ELeftButton, aFolderIndex == 0 ); |
|
145 iNaviPaneTabsFolder->SetScrollButtonDimmed |
|
146 ( |
|
147 CAknNavigationDecorator::ERightButton, |
|
148 aFolderIndex == aFolderCount - 1 |
|
149 ); |
|
150 |
|
151 // If not yet pushed, this will do the push; if already there, this brings |
|
152 // it to top and draws. |
|
153 naviPane->PushL( *iNaviPaneTabsFolder ); |
|
154 } |
|
155 |
|
156 // ----------------------------------------------------------------------------- |
|
157 // CBrowserFavouritesContainer::ComponentControl |
|
158 // ----------------------------------------------------------------------------- |
|
159 // |
|
160 CCoeControl* CBrowserFavouritesContainer::ComponentControl |
|
161 ( TInt aIndex ) const |
|
162 { |
|
163 switch (aIndex) |
|
164 { |
|
165 case 0: |
|
166 return iListbox; |
|
167 |
|
168 default: |
|
169 return 0; |
|
170 } |
|
171 } |
|
172 |
|
173 // ----------------------------------------------------------------------------- |
|
174 // CBrowserFavouritesContainer::CountComponentControls |
|
175 // ----------------------------------------------------------------------------- |
|
176 // |
|
177 TInt CBrowserFavouritesContainer::CountComponentControls() const |
|
178 { |
|
179 return (iListbox ? 1 : 0) ; |
|
180 } |
|
181 |
|
182 // ----------------------------------------------------------------------------- |
|
183 // CBrowserFavouritesContainer::SizeChanged |
|
184 // ----------------------------------------------------------------------------- |
|
185 // |
|
186 void CBrowserFavouritesContainer::SizeChanged() |
|
187 { |
|
188 // Listbox is empty; listbox takes the whole area. |
|
189 iListbox->SetRect( Rect() ); |
|
190 } |
|
191 |
|
192 // ----------------------------------------------------------------------------- |
|
193 // CBrowserFavouritesContainer::OfferKeyEventL |
|
194 // ----------------------------------------------------------------------------- |
|
195 // |
|
196 TKeyResponse CBrowserFavouritesContainer::OfferKeyEventL |
|
197 ( const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
198 { |
|
199 CBrowserAppUi* ui = CBrowserAppUi::Static(); |
|
200 TKeyResponse result = EKeyWasNotConsumed; |
|
201 |
|
202 if (ui->OfferApplicationSpecificKeyEventL(aKeyEvent, aType) == EKeyWasConsumed) |
|
203 { |
|
204 return EKeyWasConsumed; |
|
205 } |
|
206 |
|
207 |
|
208 if ( result == EKeyWasNotConsumed ) |
|
209 { |
|
210 // Otherwise, give the view a chance to handle arrow presses |
|
211 // (moving between subfolders). |
|
212 result = iView->OfferKeyEventL( aKeyEvent, aType ); |
|
213 } |
|
214 |
|
215 if ( result == EKeyWasNotConsumed && iListbox ) |
|
216 { |
|
217 // Otherwise, let the listbox fiddle with it. This will NOT consume |
|
218 // arrow presses (base class overridden). |
|
219 result = iListbox->OfferKeyEventL( aKeyEvent, aType ); |
|
220 } |
|
221 |
|
222 return result; |
|
223 } |
|
224 |
|
225 // ----------------------------------------------------------------------------- |
|
226 // CBrowserFavouritesContainer::HandleCursorChangedL |
|
227 // ----------------------------------------------------------------------------- |
|
228 // |
|
229 void CBrowserFavouritesContainer::HandleCursorChangedL |
|
230 ( CEikListBox* /*aListBox*/ ) |
|
231 { |
|
232 } |
|
233 |
|
234 // ----------------------------------------------------------------------------- |
|
235 // CBrowserFavouritesContainer::HandleNaviDecoratorEventL |
|
236 // |
|
237 // Called when user touches the left or right arrow in navipane |
|
238 // ----------------------------------------------------------------------------- |
|
239 // |
|
240 void CBrowserFavouritesContainer::HandleNaviDecoratorEventL( TInt aEventID ) |
|
241 { |
|
242 // used to swap the arrow key functionality for Arabic, etc... |
|
243 TBool forward(!(AknLayoutUtils::PenEnabled() && AknLayoutUtils::LayoutMirrored())); |
|
244 |
|
245 switch (aEventID) |
|
246 { |
|
247 case MAknNaviDecoratorObserver::EAknNaviDecoratorEventRightTabArrow: |
|
248 iView->ShowNextFolerL(forward); |
|
249 break; |
|
250 case MAknNaviDecoratorObserver::EAknNaviDecoratorEventLeftTabArrow: |
|
251 iView->ShowNextFolerL(!forward); |
|
252 break; |
|
253 default: |
|
254 break; |
|
255 } |
|
256 } |
|
257 |
|
258 |
|
259 // ----------------------------------------------------------------------------- |
|
260 // CBrowserFavouritesContainer::ConstructComponentControlsL |
|
261 // ----------------------------------------------------------------------------- |
|
262 // |
|
263 void CBrowserFavouritesContainer::ConstructComponentControlsL( |
|
264 const TRect& /*aRect*/, |
|
265 CBrowserFavouritesView& aView ) |
|
266 { |
|
267 // Construct listbox. |
|
268 iIconHandler = CreateListboxIconHandlerL(); |
|
269 iListbox = CBrowserFavouritesListbox::NewL( iView->ApiProvider(), this, *iIconHandler ); |
|
270 iListbox->SetListBoxObserver( &aView ); |
|
271 iListbox->SetListboxCursorObserver( this ); |
|
272 HBufC* buf = iCoeEnv->AllocReadResourceLC( ListboxEmptyTextResourceId() ); |
|
273 iListbox->View()->SetListEmptyTextL( *buf ); |
|
274 CleanupStack::PopAndDestroy(); // buf |
|
275 |
|
276 } |
|
277 |
|
278 // ----------------------------------------------------------------------------- |
|
279 // CBrowserFavouritesContainer::ConstructL |
|
280 // ----------------------------------------------------------------------------- |
|
281 // |
|
282 void CBrowserFavouritesContainer::ConstructL |
|
283 ( const TRect& aRect, CBrowserFavouritesView& aView ) |
|
284 { |
|
285 iView = &aView; |
|
286 |
|
287 CAknNavigationControlContainer* naviPane = |
|
288 iView->ApiProvider().Display().NaviPaneL(); |
|
289 |
|
290 CreateWindowL(); |
|
291 SetMopParent( iView ); |
|
292 |
|
293 ConstructComponentControlsL( aRect, *iView ); |
|
294 |
|
295 TAknsItemID tileIID = KAknsIIDSkinBmpListPaneNarrowA; |
|
296 TAknLayoutRect listGenPane; |
|
297 listGenPane.LayoutRect(iAvkonAppUi->ClientRect() , |
|
298 AknLayout::list_gen_pane( 0 )); |
|
299 |
|
300 TAknLayoutRect column; |
|
301 column.LayoutRect(iAvkonAppUi->ClientRect() , |
|
302 AknLayout::A_column()); |
|
303 |
|
304 iSkinContext = CAknsListBoxBackgroundControlContext::NewL( |
|
305 KAknsIIDSkinBmpMainPaneUsual, |
|
306 listGenPane.Rect(), //TODOVRa: Should come from LAF! |
|
307 EFalse, tileIID, |
|
308 column.Rect() ); //TODOVRa: Should come from LAF! |
|
309 SetRect( aRect ); |
|
310 ActivateL(); |
|
311 } |
|
312 |
|
313 |
|
314 // ----------------------------------------------------------------------------- |
|
315 // CBrowserFavouritesContainer::MopSupplyObject |
|
316 // ----------------------------------------------------------------------------- |
|
317 // |
|
318 TTypeUid::Ptr CBrowserFavouritesContainer::MopSupplyObject( TTypeUid aId ) |
|
319 { |
|
320 if( aId.iUid == MAknsControlContext::ETypeId ) |
|
321 { |
|
322 return MAknsControlContext::SupplyMopObject( aId, iSkinContext ); |
|
323 } |
|
324 |
|
325 return SupplyMopObject( aId, (MAknEditingStateIndicator*)NULL ); |
|
326 } |
|
327 |
|
328 // ----------------------------------------------------------------------------- |
|
329 // CBrowserFavouritesContainer::HandleResourceChange |
|
330 // ----------------------------------------------------------------------------- |
|
331 // |
|
332 void CBrowserFavouritesContainer::HandleResourceChange( TInt aType ) |
|
333 { |
|
334 // goes through all the subcomponents |
|
335 CCoeControl::HandleResourceChange( aType ); |
|
336 |
|
337 if (aType == KEikDynamicLayoutVariantSwitch) |
|
338 { |
|
339 SetRect(iView->ClientRect()); |
|
340 DrawDeferred(); |
|
341 } |
|
342 } |
|
343 |
|
344 // ----------------------------------------------------------------------------- |
|
345 // CBrowserFavouritesContainer::FocusChanged |
|
346 // ----------------------------------------------------------------------------- |
|
347 // |
|
348 void CBrowserFavouritesContainer::FocusChanged( TDrawNow aDrawNow ) |
|
349 { |
|
350 if ( iListbox && iListbox->IsVisible() ) |
|
351 { |
|
352 Listbox()->SetFocus( IsFocused(), aDrawNow ); |
|
353 } |
|
354 } |
|
355 |
|
356 // End of File |