|
1 /* |
|
2 ========================================================================================== |
|
3 Name : NPRStoryListBoxView.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 story list |
|
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 "NPRStoryListBoxView.h" |
|
30 #include "NPRStoryListBox.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 CNPRStoryListBoxView::CNPRStoryListBoxView() |
|
39 { |
|
40 iNPRStoryListBox = NULL; |
|
41 } |
|
42 |
|
43 /** |
|
44 * The view's destructor removes the container from the control |
|
45 * stack and destroys it. |
|
46 */ |
|
47 CNPRStoryListBoxView::~CNPRStoryListBoxView() |
|
48 { |
|
49 delete iNPRStoryListBox; |
|
50 iNPRStoryListBox = 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 CNPRStoryListBoxView |
|
58 */ |
|
59 CNPRStoryListBoxView* CNPRStoryListBoxView::NewL() |
|
60 { |
|
61 CNPRStoryListBoxView* self = CNPRStoryListBoxView::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 CNPRStoryListBoxView |
|
71 */ |
|
72 CNPRStoryListBoxView* CNPRStoryListBoxView::NewLC() |
|
73 { |
|
74 CNPRStoryListBoxView* self = new ( ELeave ) CNPRStoryListBoxView(); |
|
75 CleanupStack::PushL( self ); |
|
76 self->ConstructL(); |
|
77 return self; |
|
78 } |
|
79 |
|
80 /** |
|
81 * Second-phase constructor for view. |
|
82 * Initialize contents from resource. |
|
83 */ |
|
84 void CNPRStoryListBoxView::ConstructL() |
|
85 { |
|
86 BaseConstructL( R_NPRSTORY_LIST_BOX_NPRSTORY_LIST_BOX_VIEW ); |
|
87 } |
|
88 |
|
89 /** |
|
90 * @return The UID for this view |
|
91 */ |
|
92 TUid CNPRStoryListBoxView::Id() const |
|
93 { |
|
94 return TUid::Uid(ENPRStoryListBoxViewId); |
|
95 } |
|
96 |
|
97 /** |
|
98 * Handle a command for this view (override) |
|
99 * @param aCommand command id to be handled |
|
100 */ |
|
101 void CNPRStoryListBoxView::HandleCommandL( TInt aCommand ) |
|
102 { |
|
103 switch ( aCommand ) |
|
104 { // code to dispatch to the AknView's menu and CBA commands is generated here |
|
105 case ESelect: |
|
106 { |
|
107 iNPRStoryListBox->ShowSelectedStoryL(); |
|
108 break; |
|
109 } |
|
110 case EAknSoftkeyBack: |
|
111 { |
|
112 static_cast<CNPRAppUi*>(CEikonEnv::Static()->EikAppUi())->ActivateLocalViewL(TUid::Uid(ENPRListBoxViewId)); |
|
113 break; |
|
114 } |
|
115 default: |
|
116 break; |
|
117 } |
|
118 } |
|
119 |
|
120 /** |
|
121 * Handles user actions during activation of the view, |
|
122 * such as initializing the content. |
|
123 */ |
|
124 void CNPRStoryListBoxView::DoActivateL( |
|
125 const TVwsViewId& /*aPrevViewId*/, |
|
126 TUid /*aCustomMessageId*/, |
|
127 const TDesC8& /*aCustomMessage*/ ) |
|
128 { |
|
129 SetupStatusPaneL(); |
|
130 if ( iNPRStoryListBox == NULL ) |
|
131 { |
|
132 iNPRStoryListBox = CreateContainerL(); |
|
133 iNPRStoryListBox->SetMopParent( this ); |
|
134 AppUi()->AddToStackL( *this, iNPRStoryListBox ); |
|
135 } |
|
136 } |
|
137 |
|
138 /** |
|
139 */ |
|
140 void CNPRStoryListBoxView::DoDeactivate() |
|
141 { |
|
142 CleanupStatusPane(); |
|
143 |
|
144 if ( iNPRStoryListBox != NULL ) |
|
145 { |
|
146 AppUi()->RemoveFromViewStack( *this, iNPRStoryListBox ); |
|
147 delete iNPRStoryListBox; |
|
148 iNPRStoryListBox = NULL; |
|
149 } |
|
150 } |
|
151 |
|
152 /** |
|
153 * Handle status pane size change for this view (override) |
|
154 */ |
|
155 void CNPRStoryListBoxView::HandleStatusPaneSizeChange() |
|
156 { |
|
157 CAknView::HandleStatusPaneSizeChange(); |
|
158 |
|
159 // this may fail, but we're not able to propagate exceptions here |
|
160 TVwsViewId view; |
|
161 AppUi()->GetActiveViewId( view ); |
|
162 if ( view.iViewUid == Id() ) |
|
163 { |
|
164 TInt result; |
|
165 TRAP( result, SetupStatusPaneL() ); |
|
166 } |
|
167 } |
|
168 |
|
169 void CNPRStoryListBoxView::SetupStatusPaneL() |
|
170 { |
|
171 // reset the context pane |
|
172 TUid contextPaneUid = TUid::Uid( EEikStatusPaneUidContext ); |
|
173 CEikStatusPaneBase::TPaneCapabilities subPaneContext = |
|
174 StatusPane()->PaneCapabilities( contextPaneUid ); |
|
175 if ( subPaneContext.IsPresent() && subPaneContext.IsAppOwned() ) |
|
176 { |
|
177 CAknContextPane* context = static_cast< CAknContextPane* > ( |
|
178 StatusPane()->ControlL( contextPaneUid ) ); |
|
179 context->SetPictureToDefaultL(); |
|
180 } |
|
181 |
|
182 // setup the title pane |
|
183 TUid titlePaneUid = TUid::Uid( EEikStatusPaneUidTitle ); |
|
184 CEikStatusPaneBase::TPaneCapabilities subPaneTitle = |
|
185 StatusPane()->PaneCapabilities( titlePaneUid ); |
|
186 if ( subPaneTitle.IsPresent() && subPaneTitle.IsAppOwned() ) |
|
187 { |
|
188 CAknTitlePane* title = static_cast< CAknTitlePane* >( |
|
189 StatusPane()->ControlL( titlePaneUid ) ); |
|
190 TResourceReader reader; |
|
191 iEikonEnv->CreateResourceReaderLC( reader, R_NPRSTORY_LIST_BOX_TITLE_RESOURCE ); |
|
192 title->SetFromResourceL( reader ); |
|
193 CleanupStack::PopAndDestroy(); // reader internal state |
|
194 } |
|
195 } |
|
196 |
|
197 void CNPRStoryListBoxView::CleanupStatusPane() |
|
198 { |
|
199 } |
|
200 |
|
201 /** |
|
202 * Creates the top-level container for the view. You may modify this method's |
|
203 * contents and the CNPRStoryListBox::NewL() signature as needed to initialize the |
|
204 * container, but the signature for this method is fixed. |
|
205 * @return new initialized instance of CNPRStoryListBox |
|
206 */ |
|
207 CNPRStoryListBox* CNPRStoryListBoxView::CreateContainerL() |
|
208 { |
|
209 return CNPRStoryListBox::NewL( ClientRect(), NULL, this ); |
|
210 } |
|
211 |