2 ========================================================================
3 Name : ComingNext_SkinFetcherContainerView.cpp
4 Author : Michael Prager
5 Copyright : Licensed under GPLv3
7 ========================================================================
9 // [[[ begin generated region: do not modify [Generated System Includes]
10 #include <aknviewappui.h>
14 #include <stringloader.h>
17 #include <akncontext.h>
20 #include <aknlistquerydialog.h>
21 #include <akniconarray.h>
22 #include <aknnotewrappers.h>
23 #include <ComingNext_SkinFetcher.rsg>
24 // ]]] end generated region [Generated System Includes]
26 // [[[ begin generated region: do not modify [Generated User Includes]
28 #include "ComingNext_SkinFetcher.hrh"
29 #include "ComingNext_SkinFetcherContainerView.h"
30 #include "ComingNext_SkinFetcherContainer.hrh"
31 #include "ComingNext_SkinFetcherContainer.h"
32 // ]]] end generated region [Generated User Includes]
34 // [[[ begin generated region: do not modify [Generated Constants]
35 // ]]] end generated region [Generated Constants]
37 #include "SkinFetcher.h"
40 * First phase of Symbian two-phase construction. Should not contain any
41 * code that could leave.
43 CComingNext_SkinFetcherContainerView::CComingNext_SkinFetcherContainerView()
45 // [[[ begin generated region: do not modify [Generated Contents]
46 iComingNext_SkinFetcherContainer
= NULL
;
47 // ]]] end generated region [Generated Contents]
52 * The view's destructor removes the container from the control
53 * stack and destroys it.
55 CComingNext_SkinFetcherContainerView::~CComingNext_SkinFetcherContainerView()
57 // [[[ begin generated region: do not modify [Generated Contents]
58 delete iComingNext_SkinFetcherContainer
;
59 iComingNext_SkinFetcherContainer
= NULL
;
60 // ]]] end generated region [Generated Contents]
65 * Symbian two-phase constructor.
66 * This creates an instance then calls the second-phase constructor
67 * without leaving the instance on the cleanup stack.
68 * @return new instance of CComingNext_SkinFetcherContainerView
70 CComingNext_SkinFetcherContainerView
* CComingNext_SkinFetcherContainerView::NewL()
72 CComingNext_SkinFetcherContainerView
* self
=
73 CComingNext_SkinFetcherContainerView::NewLC();
74 CleanupStack::Pop(self
);
79 * Symbian two-phase constructor.
80 * This creates an instance, pushes it on the cleanup stack,
81 * then calls the second-phase constructor.
82 * @return new instance of CComingNext_SkinFetcherContainerView
84 CComingNext_SkinFetcherContainerView
* CComingNext_SkinFetcherContainerView::NewLC()
86 CComingNext_SkinFetcherContainerView
* self
=
87 new (ELeave
) CComingNext_SkinFetcherContainerView();
88 CleanupStack::PushL(self
);
94 * Second-phase constructor for view.
95 * Initialize contents from resource.
97 void CComingNext_SkinFetcherContainerView::ConstructL()
99 // [[[ begin generated region: do not modify [Generated Code]
100 BaseConstructL( R_COMING_NEXT_SKIN_FETCHER_CONTAINER_COMING_NEXT_SKIN_FETCHER_CONTAINER_VIEW_2
);
102 // ]]] end generated region [Generated Code]
104 // add your own initialization code here
109 * @return The UID for this view
111 TUid
CComingNext_SkinFetcherContainerView::Id() const
113 return TUid::Uid(EComingNext_SkinFetcherContainerViewId
);
117 * Handle a command for this view (override)
118 * @param aCommand command id to be handled
120 void CComingNext_SkinFetcherContainerView::HandleCommandL(TInt aCommand
)
122 // [[[ begin generated region: do not modify [Generated Code]
123 TBool commandHandled
= EFalse
;
125 { // code to dispatch to the AknView's menu and CBA commands is generated here
127 case EComingNext_SkinFetcherContainerViewControlPaneLeftId
:
128 commandHandled
= HandleControlPaneLeftSoftKeyPressedL( aCommand
);
131 case EAknSoftkeyExit
:
132 commandHandled
= HandleControlPaneRightSoftKeyPressedL( aCommand
);
139 if ( !commandHandled
)
142 if ( aCommand
== EAknSoftkeyExit
)
144 AppUi()->HandleCommandL( EEikCmdExit
);
148 // ]]] end generated region [Generated Code]
153 * Handles user actions during activation of the view,
154 * such as initializing the content.
156 void CComingNext_SkinFetcherContainerView::DoActivateL(
157 const TVwsViewId
& /*aPrevViewId*/, TUid
/*aCustomMessageId*/,
158 const TDesC8
& /*aCustomMessage*/)
160 // [[[ begin generated region: do not modify [Generated Contents]
166 if ( iComingNext_SkinFetcherContainer
== NULL
)
168 iComingNext_SkinFetcherContainer
= CreateContainerL();
169 iComingNext_SkinFetcherContainer
->SetMopParent( this );
170 AppUi()->AddToStackL( *this, iComingNext_SkinFetcherContainer
);
172 // ]]] end generated region [Generated Contents]
178 void CComingNext_SkinFetcherContainerView::DoDeactivate()
180 // [[[ begin generated region: do not modify [Generated Contents]
183 if ( iComingNext_SkinFetcherContainer
!= NULL
)
185 AppUi()->RemoveFromViewStack( *this, iComingNext_SkinFetcherContainer
);
186 delete iComingNext_SkinFetcherContainer
;
187 iComingNext_SkinFetcherContainer
= NULL
;
189 // ]]] end generated region [Generated Contents]
194 * Handle status pane size change for this view (override)
196 void CComingNext_SkinFetcherContainerView::HandleStatusPaneSizeChange()
198 CAknView::HandleStatusPaneSizeChange();
200 // this may fail, but we're not able to propagate exceptions here
202 AppUi()->GetActiveViewId(view
);
203 if (view
.iViewUid
== Id())
206 TRAP( result
, SetupStatusPaneL() );
209 // [[[ begin generated region: do not modify [Generated Code]
210 // ]]] end generated region [Generated Code]
214 // [[[ begin generated function: do not modify
215 void CComingNext_SkinFetcherContainerView::SetupStatusPaneL()
217 // reset the context pane
218 TUid contextPaneUid
= TUid::Uid( EEikStatusPaneUidContext
);
219 CEikStatusPaneBase::TPaneCapabilities subPaneContext
=
220 StatusPane()->PaneCapabilities( contextPaneUid
);
221 if ( subPaneContext
.IsPresent() && subPaneContext
.IsAppOwned() )
223 CAknContextPane
* context
= static_cast< CAknContextPane
* > (
224 StatusPane()->ControlL( contextPaneUid
) );
225 context
->SetPictureToDefaultL();
228 // setup the title pane
229 TUid titlePaneUid
= TUid::Uid( EEikStatusPaneUidTitle
);
230 CEikStatusPaneBase::TPaneCapabilities subPaneTitle
=
231 StatusPane()->PaneCapabilities( titlePaneUid
);
232 if ( subPaneTitle
.IsPresent() && subPaneTitle
.IsAppOwned() )
234 CAknTitlePane
* title
= static_cast< CAknTitlePane
* >(
235 StatusPane()->ControlL( titlePaneUid
) );
236 TResourceReader reader
;
237 iEikonEnv
->CreateResourceReaderLC( reader
, R_COMING_NEXT_SKIN_FETCHER_CONTAINER_TITLE_RESOURCE_2
);
238 title
->SetFromResourceL( reader
);
239 CleanupStack::PopAndDestroy(); // reader internal state
244 // ]]] end generated function
246 // [[[ begin generated function: do not modify
247 void CComingNext_SkinFetcherContainerView::CleanupStatusPane()
251 // ]]] end generated function
254 * Creates the top-level container for the view. You may modify this method's
255 * contents and the CComingNext_SkinFetcherContainer::NewL() signature as needed to initialize the
256 * container, but the signature for this method is fixed.
257 * @return new initialized instance of CComingNext_SkinFetcherContainer
259 CComingNext_SkinFetcherContainer
* CComingNext_SkinFetcherContainerView::CreateContainerL()
261 return CComingNext_SkinFetcherContainer::NewL(ClientRect(), NULL
, this);
265 * Handle the leftSoftKeyPressed event.
266 * @return ETrue if the command was handled, EFalse if not
268 TBool
CComingNext_SkinFetcherContainerView::HandleControlPaneLeftSoftKeyPressedL(
271 TInt pos
= RunListQuery1L(NULL
, NULL
, NULL
);
274 CSkinFetcher::GenerateBackgroundImage(pos
,
275 CAknViewAppUi::EAppUiOrientationPortrait
);
276 CSkinFetcher::GenerateBackgroundImage(pos
,
277 CAknViewAppUi::EAppUiOrientationLandscape
);
284 * Handle the rightSoftKeyPressed event.
285 * @return ETrue if the command was handled, EFalse if not
287 TBool
CComingNext_SkinFetcherContainerView::HandleControlPaneRightSoftKeyPressedL(
294 // [[[ begin generated function: do not modify
296 * Create a list box item with the given column values.
298 void CComingNext_SkinFetcherContainerView::CreateListQuery1ItemL(
301 const TDesC
& aMainText
)
303 _LIT ( KStringHeader
, "%S" );
305 aBuffer
.Format( KStringHeader(), &aMainText
);
307 // ]]] end generated function
309 // [[[ begin generated function: do not modify
311 * Add an item to the list by reading the text items from resource
312 * and setting a single image property (if available) from an index
313 * in the list box's icon array.
314 * @param aResourceId id of an ARRAY resource containing the textual
315 * items in the columns
318 void CComingNext_SkinFetcherContainerView::CreateListQuery1ResourceArrayItemL(
322 CDesCArray
* array
= CCoeEnv::Static()->ReadDesCArrayResourceL( aResourceId
);
323 CleanupStack::PushL( array
);
324 CreateListQuery1ItemL( aBuffer
, ( *array
) [ 0 ] );
325 CleanupStack::PopAndDestroy( array
);
327 // ]]] end generated function
329 // [[[ begin generated function: do not modify
331 * Initialize contents of the popup item list. This constructs the array
332 * and pushes it on the cleanup stack.
333 * @return item array, never null
335 CDesCArray
* CComingNext_SkinFetcherContainerView::InitializeListQuery1LC()
337 const int KNumItems
= 5;
338 CDesCArray
* itemArray
= new ( ELeave
) CDesCArrayFlat( KNumItems
? KNumItems
: 1 );
339 CleanupStack::PushL( itemArray
);
341 // This is intended to be large enough, but if you get
342 // a USER 11 panic, consider reducing string sizes.
344 CreateListQuery1ResourceArrayItemL(
345 des
, R_COMING_NEXT_SKIN_FETCHER_CONTAINER_LISTBOX_ITEM1
);
346 itemArray
->AppendL( des
);
347 CreateListQuery1ResourceArrayItemL(
348 des
, R_COMING_NEXT_SKIN_FETCHER_CONTAINER_LISTBOX_ITEM2
);
349 itemArray
->AppendL( des
);
350 CreateListQuery1ResourceArrayItemL(
351 des
, R_COMING_NEXT_SKIN_FETCHER_CONTAINER_LISTBOX_ITEM3
);
352 itemArray
->AppendL( des
);
353 CreateListQuery1ResourceArrayItemL(
354 des
, R_COMING_NEXT_SKIN_FETCHER_CONTAINER_LISTBOX_ITEM4
);
355 itemArray
->AppendL( des
);
356 CreateListQuery1ResourceArrayItemL(
357 des
, R_COMING_NEXT_SKIN_FETCHER_CONTAINER_LISTBOX_ITEM5
);
358 itemArray
->AppendL( des
);
361 // ]]] end generated function
363 // [[[ begin generated function: do not modify
365 * Set up the list query's icon array. If any icons are used, allocates an
366 * icon array, and places it on the cleanup stack.
367 * @return icon array, or NULL
369 CArrayPtr
< CGulIcon
>* CComingNext_SkinFetcherContainerView::SetupListQuery1IconsLC()
371 CArrayPtr
< CGulIcon
>* icons
= NULL
;
375 // ]]] end generated function
377 // [[[ begin generated function: do not modify
379 * Show the popup list query dialog for listQuery1.
381 * You may override the designer-specified items or icons, though generally
382 * both should be overridden together.
383 * @param aOverrideText optional override text
384 * @param aOverrideItemArray if not NULL, the array of formatted list items to display (passes ownership)
385 * @param aOverrideIconArray if not NULL, the array of icons to display (passes ownership)
386 * @return selected index (>=0) or -1 for Cancel
388 TInt
CComingNext_SkinFetcherContainerView::RunListQuery1L(
389 const TDesC
* aOverrideText
,
390 CDesCArray
* aOverrideItemArray
,
391 CArrayPtr
< CGulIcon
>* aOverrideIconArray
)
394 CAknListQueryDialog
* queryDialog
= NULL
;
395 queryDialog
= new ( ELeave
) CAknListQueryDialog( &index
);
396 CleanupStack::PushL( queryDialog
);
398 queryDialog
->PrepareLC( R_COMING_NEXT_SKIN_FETCHER_CONTAINER_LIST_QUERY1
);
399 if ( aOverrideText
!= NULL
)
401 queryDialog
->SetHeaderTextL( *aOverrideText
);
404 // initialize list items
405 CDesCArray
* itemArray
= NULL
;
407 if ( aOverrideItemArray
!= NULL
)
409 CleanupStack::PushL( aOverrideItemArray
);
410 itemArray
= aOverrideItemArray
;
414 itemArray
= InitializeListQuery1LC();
417 queryDialog
->SetItemTextArray( itemArray
);
418 queryDialog
->SetOwnershipType( ELbmOwnsItemArray
);
419 CleanupStack::Pop( itemArray
);
421 // initialize list icons
422 CArrayPtr
< CGulIcon
>* iconArray
= NULL
;
424 if ( aOverrideIconArray
!= NULL
)
426 CleanupStack::PushL( aOverrideIconArray
);
427 iconArray
= aOverrideIconArray
;
431 iconArray
= SetupListQuery1IconsLC();
434 if ( iconArray
!= NULL
)
436 queryDialog
->SetIconArrayL( iconArray
); // passes ownership
437 CleanupStack::Pop( iconArray
);
441 TInt result
= queryDialog
->RunLD();
444 CleanupStack::Pop( queryDialog
);
446 return result
== 0 ? -1 : index
;
449 // ]]] end generated function
451 // [[[ begin generated function: do not modify
453 * Show the popup note for note1
454 * @param aOverrideText optional override text
456 void CComingNext_SkinFetcherContainerView::RunNote1L( const TDesC
* aOverrideText
)
458 CAknConfirmationNote
* note
= new ( ELeave
) CAknConfirmationNote();
459 if ( aOverrideText
== NULL
)
461 HBufC
* noteText
= StringLoader::LoadLC( R_COMING_NEXT_SKIN_FETCHER_CONTAINER_NOTE1
);
462 note
->ExecuteLD( *noteText
);
463 CleanupStack::PopAndDestroy( noteText
);
467 note
->ExecuteLD( *aOverrideText
);
470 // ]]] end generated function