|
1 /* |
|
2 ========================================================================================== |
|
3 Name : NPRStationListBoxView.h |
|
4 Author : Symsource |
|
5 |
|
6 Copyright (c) 2009 Symbian Foundation Ltd |
|
7 This component and the accompanying materials are made available |
|
8 under the terms of the License "Eclipse Public License v1.0" |
|
9 which accompanies this distribution, and is available |
|
10 at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
11 |
|
12 Initial Contributors: |
|
13 - Symsource |
|
14 |
|
15 Contributors: |
|
16 - Symsource |
|
17 |
|
18 Description : AknView for wrapping the container to show the NPR's station list |
|
19 ========================================================================================== |
|
20 */ |
|
21 |
|
22 #include <barsread.h> |
|
23 #include <akncontext.h> |
|
24 #include <akntitle.h> |
|
25 #include <NPR_0xEEB0E481.rsg> |
|
26 |
|
27 #include "NPR.hrh" |
|
28 #include "NPRStationListBoxView.h" |
|
29 #include "NPRStationListBox.h" |
|
30 #include "NPRAppUi.h" |
|
31 #include "NPRAppEngine.h" |
|
32 |
|
33 /** |
|
34 * First phase of Symbian two-phase construction. Should not contain any |
|
35 * code that could leave. |
|
36 */ |
|
37 CNPRStationListBoxView::CNPRStationListBoxView() |
|
38 { |
|
39 iNPRStationListBox = NULL; |
|
40 } |
|
41 |
|
42 /** |
|
43 * The view's destructor removes the container from the control |
|
44 * stack and destroys it. |
|
45 */ |
|
46 CNPRStationListBoxView::~CNPRStationListBoxView() |
|
47 { |
|
48 delete iNPRStationListBox; |
|
49 iNPRStationListBox = NULL; |
|
50 } |
|
51 |
|
52 /** |
|
53 * Symbian two-phase constructor. |
|
54 * This creates an instance then calls the second-phase constructor |
|
55 * without leaving the instance on the cleanup stack. |
|
56 * @return new instance of CNPRStationListBoxView |
|
57 */ |
|
58 CNPRStationListBoxView* CNPRStationListBoxView::NewL() |
|
59 { |
|
60 CNPRStationListBoxView* self = CNPRStationListBoxView::NewLC(); |
|
61 CleanupStack::Pop( self ); |
|
62 return self; |
|
63 } |
|
64 |
|
65 /** |
|
66 * Symbian two-phase constructor. |
|
67 * This creates an instance, pushes it on the cleanup stack, |
|
68 * then calls the second-phase constructor. |
|
69 * @return new instance of CNPRStationListBoxView |
|
70 */ |
|
71 CNPRStationListBoxView* CNPRStationListBoxView::NewLC() |
|
72 { |
|
73 CNPRStationListBoxView* self = new ( ELeave ) CNPRStationListBoxView(); |
|
74 CleanupStack::PushL( self ); |
|
75 self->ConstructL(); |
|
76 return self; |
|
77 } |
|
78 |
|
79 /** |
|
80 * Second-phase constructor for view. |
|
81 * Initialize contents from resource. |
|
82 */ |
|
83 void CNPRStationListBoxView::ConstructL() |
|
84 { |
|
85 BaseConstructL( R_NPRSTATION_LIST_BOX_NPRSTATION_LIST_BOX_VIEW); |
|
86 } |
|
87 |
|
88 /** |
|
89 * @return The UID for this view |
|
90 */ |
|
91 TUid CNPRStationListBoxView::Id() const |
|
92 { |
|
93 return TUid::Uid( ENPRStationListBoxViewId ); |
|
94 } |
|
95 |
|
96 /** |
|
97 * Handle a command for this view (override) |
|
98 * @param aCommand command id to be handled |
|
99 */ |
|
100 void CNPRStationListBoxView::HandleCommandL( TInt aCommand ) |
|
101 { |
|
102 TBool commandHandled = EFalse; |
|
103 switch(aCommand) |
|
104 {// code to dispatch to the AknView's menu and CBA commands is generated here |
|
105 case EListen: |
|
106 { |
|
107 iNPRStationListBox->Listen(); |
|
108 commandHandled = ETrue; |
|
109 break; |
|
110 } |
|
111 case EAknSoftkeyBack: |
|
112 { |
|
113 static_cast<CNPRAppUi*>(CEikonEnv::Static()->EikAppUi())->ActivateLocalViewL(TUid::Uid(ENPRSearchStationListBoxViewId)); |
|
114 commandHandled = ETrue; |
|
115 break; |
|
116 } |
|
117 default: |
|
118 break; |
|
119 } |
|
120 } |
|
121 |
|
122 /** |
|
123 * Handles user actions during activation of the view, |
|
124 * such as initializing the content. |
|
125 */ |
|
126 void CNPRStationListBoxView::DoActivateL( |
|
127 const TVwsViewId& /*aPrevViewId*/, |
|
128 TUid /*aCustomMessageId*/, |
|
129 const TDesC8& /*aCustomMessage*/ ) |
|
130 { |
|
131 SetupStatusPaneL(); |
|
132 if ( iNPRStationListBox == NULL ) |
|
133 { |
|
134 iNPRStationListBox = CreateContainerL(); |
|
135 iNPRStationListBox->SetMopParent( this ); |
|
136 AppUi()->AddToStackL( *this, iNPRStationListBox ); |
|
137 } |
|
138 } |
|
139 |
|
140 /** |
|
141 */ |
|
142 void CNPRStationListBoxView::DoDeactivate() |
|
143 { |
|
144 CleanupStatusPane(); |
|
145 if ( iNPRStationListBox != NULL ) |
|
146 { |
|
147 AppUi()->RemoveFromViewStack( *this, iNPRStationListBox ); |
|
148 delete iNPRStationListBox; |
|
149 iNPRStationListBox = NULL; |
|
150 } |
|
151 } |
|
152 |
|
153 /** |
|
154 * Handle status pane size change for this view (override) |
|
155 */ |
|
156 void CNPRStationListBoxView::HandleStatusPaneSizeChange() |
|
157 { |
|
158 CAknView::HandleStatusPaneSizeChange(); |
|
159 |
|
160 // this may fail, but we're not able to propagate exceptions here |
|
161 TVwsViewId view; |
|
162 AppUi()->GetActiveViewId( view ); |
|
163 if ( view.iViewUid == Id() ) |
|
164 { |
|
165 TInt result; |
|
166 TRAP( result, SetupStatusPaneL() ); |
|
167 } |
|
168 } |
|
169 |
|
170 void CNPRStationListBoxView::SetupStatusPaneL() |
|
171 { |
|
172 // reset the context pane |
|
173 TUid contextPaneUid = TUid::Uid( EEikStatusPaneUidContext ); |
|
174 CEikStatusPaneBase::TPaneCapabilities subPaneContext = |
|
175 StatusPane()->PaneCapabilities( contextPaneUid ); |
|
176 if ( subPaneContext.IsPresent() && subPaneContext.IsAppOwned() ) |
|
177 { |
|
178 CAknContextPane* context = static_cast< CAknContextPane* > ( |
|
179 StatusPane()->ControlL( contextPaneUid ) ); |
|
180 context->SetPictureToDefaultL(); |
|
181 } |
|
182 |
|
183 // setup the title pane |
|
184 TUid titlePaneUid = TUid::Uid( EEikStatusPaneUidTitle ); |
|
185 CEikStatusPaneBase::TPaneCapabilities subPaneTitle = |
|
186 StatusPane()->PaneCapabilities( titlePaneUid ); |
|
187 if ( subPaneTitle.IsPresent() && subPaneTitle.IsAppOwned() ) |
|
188 { |
|
189 CAknTitlePane* title = static_cast< CAknTitlePane* >( |
|
190 StatusPane()->ControlL( titlePaneUid ) ); |
|
191 TResourceReader reader; |
|
192 iEikonEnv->CreateResourceReaderLC( reader, R_NPRSTATION_LIST_BOX_TITLE_RESOURCE); |
|
193 title->SetFromResourceL( reader ); |
|
194 CleanupStack::PopAndDestroy(); // reader internal state |
|
195 } |
|
196 |
|
197 } |
|
198 |
|
199 void CNPRStationListBoxView::CleanupStatusPane() |
|
200 { |
|
201 } |
|
202 |
|
203 /** |
|
204 * Creates the top-level container for the view. You may modify this method's |
|
205 * contents and the CNPRStationListBox::NewL() signature as needed to initialize the |
|
206 * container, but the signature for this method is fixed. |
|
207 * @return new initialized instance of CNPRStationListBox |
|
208 */ |
|
209 CNPRStationListBox* CNPRStationListBoxView::CreateContainerL() |
|
210 { |
|
211 return CNPRStationListBox::NewL( ClientRect(), NULL, this ); |
|
212 } |