|
1 /* |
|
2 ============================================================================ |
|
3 Name : NPRListBoxView.cpp |
|
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 to wrap the Series60 container to show the NPR's main options |
|
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 "NPRListBoxView.h" |
|
29 #include "NPRListBox.h" |
|
30 #include "NPRAppUi.h" |
|
31 #include "NPRAppEngine.h" |
|
32 |
|
33 |
|
34 /** |
|
35 * Symbian two-phase constructor. |
|
36 * This creates an instance then calls the second-phase constructor |
|
37 * without leaving the instance on the cleanup stack. |
|
38 * @return new instance of CNPRListBoxView |
|
39 */ |
|
40 CNPRListBoxView* CNPRListBoxView::NewL() |
|
41 { |
|
42 CNPRListBoxView* self = CNPRListBoxView::NewLC(); |
|
43 CleanupStack::Pop( self ); |
|
44 return self; |
|
45 } |
|
46 |
|
47 /** |
|
48 * Symbian two-phase constructor. |
|
49 * This creates an instance, pushes it on the cleanup stack, |
|
50 * then calls the second-phase constructor. |
|
51 * @return new instance of CNPRListBoxView |
|
52 */ |
|
53 CNPRListBoxView* CNPRListBoxView::NewLC() |
|
54 { |
|
55 CNPRListBoxView* self = new ( ELeave ) CNPRListBoxView(); |
|
56 CleanupStack::PushL( self ); |
|
57 self->ConstructL(); |
|
58 return self; |
|
59 } |
|
60 |
|
61 /** |
|
62 * First phase of Symbian two-phase construction. Should not contain any |
|
63 * code that could leave. |
|
64 */ |
|
65 CNPRListBoxView::CNPRListBoxView() |
|
66 :iNPRListBox(NULL) |
|
67 { |
|
68 } |
|
69 |
|
70 /** |
|
71 * The view's destructor removes the container from the control |
|
72 * stack and destroys it. |
|
73 */ |
|
74 CNPRListBoxView::~CNPRListBoxView() |
|
75 { |
|
76 delete iNPRListBox; |
|
77 iNPRListBox = NULL; |
|
78 } |
|
79 |
|
80 |
|
81 /** |
|
82 * Second-phase constructor for view. |
|
83 * Initialize contents from resource. |
|
84 */ |
|
85 void CNPRListBoxView::ConstructL() |
|
86 { |
|
87 BaseConstructL( R_NPRLIST_BOX_NPRLIST_BOX_VIEW ); |
|
88 } |
|
89 |
|
90 /** |
|
91 * @return The UID for this view |
|
92 */ |
|
93 TUid CNPRListBoxView::Id() const |
|
94 { |
|
95 return TUid::Uid( ENPRListBoxViewId ); |
|
96 } |
|
97 |
|
98 /** |
|
99 * Handle a command for this view (override) |
|
100 * @param aCommand command id to be handled |
|
101 */ |
|
102 void CNPRListBoxView::HandleCommandL(TInt aCommand) |
|
103 { |
|
104 TBool commandHandled = EFalse; |
|
105 switch(aCommand) |
|
106 { // code to dispatch to the AknView's menu and CBA commands is generated here |
|
107 case ESelect: |
|
108 { |
|
109 commandHandled = ETrue; |
|
110 TInt index = iNPRListBox->CurrentItemIndex(); |
|
111 switch(index) |
|
112 { |
|
113 case ENews: |
|
114 { |
|
115 iNPRListBox->SendNewsQueryL(); |
|
116 break; |
|
117 } |
|
118 case EStations: |
|
119 { |
|
120 static_cast<CNPRAppUi*>(CEikonEnv::Static()->EikAppUi())->ActivateLocalViewL(TUid::Uid(ENPRSearchStationListBoxViewId)); |
|
121 break; |
|
122 } |
|
123 case EPrograms: |
|
124 break; |
|
125 default: |
|
126 break; |
|
127 } |
|
128 break; |
|
129 } |
|
130 default: |
|
131 break; |
|
132 } |
|
133 |
|
134 |
|
135 if (!commandHandled) |
|
136 { |
|
137 if ( aCommand == EAknSoftkeyExit ) |
|
138 { |
|
139 AppUi()->HandleCommandL( EEikCmdExit ); |
|
140 } |
|
141 } |
|
142 } |
|
143 |
|
144 /** |
|
145 * Handles user actions during activation of the view, |
|
146 * such as initializing the content. |
|
147 */ |
|
148 void CNPRListBoxView::DoActivateL( |
|
149 const TVwsViewId& /*aPrevViewId*/, |
|
150 TUid /*aCustomMessageId*/, |
|
151 const TDesC8& /*aCustomMessage*/ ) |
|
152 { |
|
153 SetupStatusPaneL(); |
|
154 |
|
155 if ( iNPRListBox == NULL ) |
|
156 { |
|
157 iNPRListBox = CreateContainerL(); |
|
158 iNPRListBox->SetMopParent( this ); |
|
159 AppUi()->AddToStackL( *this, iNPRListBox ); |
|
160 } |
|
161 } |
|
162 |
|
163 /** |
|
164 */ |
|
165 void CNPRListBoxView::DoDeactivate() |
|
166 { |
|
167 CleanupStatusPane(); |
|
168 |
|
169 if ( iNPRListBox != NULL ) |
|
170 { |
|
171 AppUi()->RemoveFromViewStack( *this, iNPRListBox ); |
|
172 delete iNPRListBox; |
|
173 iNPRListBox = NULL; |
|
174 } |
|
175 } |
|
176 |
|
177 /** |
|
178 * Handle status pane size change for this view (override) |
|
179 */ |
|
180 void CNPRListBoxView::HandleStatusPaneSizeChange() |
|
181 { |
|
182 CAknView::HandleStatusPaneSizeChange(); |
|
183 |
|
184 // this may fail, but we're not able to propagate exceptions here |
|
185 TVwsViewId view; |
|
186 AppUi()->GetActiveViewId( view ); |
|
187 if ( view.iViewUid == Id() ) |
|
188 { |
|
189 TInt result; |
|
190 TRAP( result, SetupStatusPaneL() ); |
|
191 } |
|
192 } |
|
193 |
|
194 void CNPRListBoxView::SetupStatusPaneL() |
|
195 { |
|
196 // reset the context pane |
|
197 TUid contextPaneUid = TUid::Uid( EEikStatusPaneUidContext ); |
|
198 CEikStatusPaneBase::TPaneCapabilities subPaneContext = |
|
199 StatusPane()->PaneCapabilities( contextPaneUid ); |
|
200 if ( subPaneContext.IsPresent() && subPaneContext.IsAppOwned() ) |
|
201 { |
|
202 CAknContextPane* context = static_cast< CAknContextPane* > ( |
|
203 StatusPane()->ControlL( contextPaneUid ) ); |
|
204 context->SetPictureToDefaultL(); |
|
205 } |
|
206 |
|
207 // setup the title pane |
|
208 TUid titlePaneUid = TUid::Uid( EEikStatusPaneUidTitle ); |
|
209 CEikStatusPaneBase::TPaneCapabilities subPaneTitle = |
|
210 StatusPane()->PaneCapabilities( titlePaneUid ); |
|
211 if ( subPaneTitle.IsPresent() && subPaneTitle.IsAppOwned() ) |
|
212 { |
|
213 CAknTitlePane* title = static_cast< CAknTitlePane* >( |
|
214 StatusPane()->ControlL( titlePaneUid ) ); |
|
215 TResourceReader reader; |
|
216 iEikonEnv->CreateResourceReaderLC( reader, R_NPRLIST_BOX_TITLE_RESOURCE ); |
|
217 title->SetFromResourceL( reader ); |
|
218 CleanupStack::PopAndDestroy(); // reader internal state |
|
219 } |
|
220 } |
|
221 |
|
222 void CNPRListBoxView::CleanupStatusPane() |
|
223 { |
|
224 } |
|
225 |
|
226 |
|
227 /** |
|
228 * Creates the top-level container for the view. You may modify this method's |
|
229 * contents and the CNPRListBox::NewL() signature as needed to initialize the |
|
230 * container, but the signature for this method is fixed. |
|
231 * @return new initialized instance of CNPRListBox |
|
232 */ |
|
233 CNPRListBox* CNPRListBoxView::CreateContainerL() |
|
234 { |
|
235 return CNPRListBox::NewL( ClientRect(), NULL, this ); |
|
236 } |