|
1 /* |
|
2 =================================================================================================== |
|
3 Name : NPRSearchStationListBoxView.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 search options |
|
19 =================================================================================================== |
|
20 */ |
|
21 |
|
22 #include <barsread.h> |
|
23 #include <aknlists.h> |
|
24 #include <akncontext.h> |
|
25 #include <akntitle.h> |
|
26 #include <NPR_0xEEB0E481.rsg> |
|
27 |
|
28 #include "NPR.hrh" |
|
29 #include "NPRSearchStationListBoxView.h" |
|
30 #include "NPRSearchStationListBox.h" |
|
31 #include "NPRAppUi.h" |
|
32 #include "NPRAppEngine.h" |
|
33 |
|
34 /** |
|
35 * First phase of Symbian two-phase construction. Should not contain any |
|
36 * code that could leave. |
|
37 */ |
|
38 CNPRSearchStationListBoxView::CNPRSearchStationListBoxView() |
|
39 { |
|
40 iNPRSearchStationListBox = NULL; |
|
41 } |
|
42 |
|
43 /** |
|
44 * The view's destructor removes the container from the control |
|
45 * stack and destroys it. |
|
46 */ |
|
47 CNPRSearchStationListBoxView::~CNPRSearchStationListBoxView() |
|
48 { |
|
49 delete iNPRSearchStationListBox; |
|
50 iNPRSearchStationListBox = NULL; |
|
51 } |
|
52 |
|
53 /** |
|
54 * Symbian two-phase constructor. |
|
55 * This creates an instance then calls the second-phase constructor |
|
56 * without leaving the instance on the cleanup stack. |
|
57 * @return new instance of CNPRSearchStationListBoxView |
|
58 */ |
|
59 CNPRSearchStationListBoxView* CNPRSearchStationListBoxView::NewL() |
|
60 { |
|
61 CNPRSearchStationListBoxView* self = CNPRSearchStationListBoxView::NewLC(); |
|
62 CleanupStack::Pop( self ); |
|
63 return self; |
|
64 } |
|
65 |
|
66 /** |
|
67 * Symbian two-phase constructor. |
|
68 * This creates an instance, pushes it on the cleanup stack, |
|
69 * then calls the second-phase constructor. |
|
70 * @return new instance of CNPRSearchStationListBoxView |
|
71 */ |
|
72 CNPRSearchStationListBoxView* CNPRSearchStationListBoxView::NewLC() |
|
73 { |
|
74 CNPRSearchStationListBoxView* self = new ( ELeave ) CNPRSearchStationListBoxView(); |
|
75 CleanupStack::PushL( self ); |
|
76 self->ConstructL(); |
|
77 return self; |
|
78 } |
|
79 |
|
80 |
|
81 /** |
|
82 * Second-phase constructor for view. |
|
83 * Initialize contents from resource. |
|
84 */ |
|
85 void CNPRSearchStationListBoxView::ConstructL() |
|
86 { |
|
87 BaseConstructL( R_NPRSEARCH_STATION_LIST_BOX_NPRSEARCH_STATION_LIST_BOX_VIEW ); |
|
88 } |
|
89 |
|
90 /** |
|
91 * @return The UID for this view |
|
92 */ |
|
93 TUid CNPRSearchStationListBoxView::Id() const |
|
94 { |
|
95 return TUid::Uid( ENPRSearchStationListBoxViewId ); |
|
96 } |
|
97 |
|
98 /** |
|
99 * Handle a command for this view (override) |
|
100 * @param aCommand command id to be handled |
|
101 */ |
|
102 void CNPRSearchStationListBoxView::HandleCommandL( TInt aCommand ) |
|
103 { |
|
104 switch(aCommand) |
|
105 { // code to dispatch to the AknView's menu and CBA commands is generated here |
|
106 case ESelect: |
|
107 { |
|
108 iNPRSearchStationListBox->SendStationQueryL(); |
|
109 break; |
|
110 } |
|
111 case EAknSoftkeyBack: |
|
112 { |
|
113 static_cast<CNPRAppUi*>(CEikonEnv::Static()->EikAppUi())->ActivateLocalViewL(TUid::Uid(ENPRListBoxViewId)); |
|
114 break; |
|
115 } |
|
116 default: |
|
117 break; |
|
118 } |
|
119 } |
|
120 |
|
121 /** |
|
122 * Handles user actions during activation of the view, |
|
123 * such as initializing the content. |
|
124 */ |
|
125 void CNPRSearchStationListBoxView::DoActivateL( |
|
126 const TVwsViewId& /*aPrevViewId*/, |
|
127 TUid /*aCustomMessageId*/, |
|
128 const TDesC8& /*aCustomMessage*/ ) |
|
129 { |
|
130 SetupStatusPaneL(); |
|
131 if ( iNPRSearchStationListBox == NULL ) |
|
132 { |
|
133 iNPRSearchStationListBox = CreateContainerL(); |
|
134 iNPRSearchStationListBox->SetMopParent( this ); |
|
135 AppUi()->AddToStackL( *this, iNPRSearchStationListBox ); |
|
136 } |
|
137 } |
|
138 |
|
139 /** |
|
140 */ |
|
141 void CNPRSearchStationListBoxView::DoDeactivate() |
|
142 { |
|
143 CleanupStatusPane(); |
|
144 |
|
145 if ( iNPRSearchStationListBox != NULL ) |
|
146 { |
|
147 AppUi()->RemoveFromViewStack( *this, iNPRSearchStationListBox ); |
|
148 delete iNPRSearchStationListBox; |
|
149 iNPRSearchStationListBox = NULL; |
|
150 } |
|
151 } |
|
152 |
|
153 /** |
|
154 * Handle status pane size change for this view (override) |
|
155 */ |
|
156 void CNPRSearchStationListBoxView::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 CNPRSearchStationListBoxView::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_NPRSEARCH_STATION_LIST_BOX_TITLE_RESOURCE ); |
|
193 title->SetFromResourceL( reader ); |
|
194 CleanupStack::PopAndDestroy(); // reader internal state |
|
195 } |
|
196 } |
|
197 |
|
198 void CNPRSearchStationListBoxView::CleanupStatusPane() |
|
199 { |
|
200 } |
|
201 |
|
202 /** |
|
203 * Creates the top-level container for the view. You may modify this method's |
|
204 * contents and the CNPRSearchStationListBox::NewL() signature as needed to initialize the |
|
205 * container, but the signature for this method is fixed. |
|
206 * @return new initialized instance of CNPRSearchStationListBox |
|
207 */ |
|
208 CNPRSearchStationListBox* CNPRSearchStationListBoxView::CreateContainerL() |
|
209 { |
|
210 return CNPRSearchStationListBox::NewL( ClientRect(), NULL, this ); |
|
211 } |