|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "MCETestUI.hrh" |
|
21 #include "CMCETestUIEventView.h" |
|
22 #include "CMCETestUIAppUi.h" |
|
23 #include "CMCETestUIEngineOutEvent.h" |
|
24 #include "CMCETestUIENgineInEvent.h" |
|
25 |
|
26 #include <e32def.h> |
|
27 #include <barsread.h> |
|
28 #include <AknNoteWrappers.h> |
|
29 #include <aknviewappui.h> |
|
30 #include <eikbtgpc.h> |
|
31 #include <akntitle.h> // for CAknTitlePane |
|
32 #include <aknnavi.h> // for CAknNavigationControlContainer |
|
33 #include <aknnavide.h> // for CAknNavigationDecorator |
|
34 |
|
35 // CONSTANTS |
|
36 |
|
37 _LIT( KEvent, "Event" ); |
|
38 _LIT( KOutEvent, "OutEvent: " ); |
|
39 _LIT( KInEvent, "InEvent: " ); |
|
40 _LIT( KLeftParenthesis, " (" ); |
|
41 _LIT( KRightParenthesis, ")" ); |
|
42 |
|
43 CMCETestUIEventView* CMCETestUIEventView::NewL( CMCETestUIEngine& aEngine ) |
|
44 { |
|
45 CMCETestUIEventView* self = new(ELeave) CMCETestUIEventView( aEngine ); |
|
46 CleanupStack::PushL(self); |
|
47 self->ConstructL(); |
|
48 CleanupStack::Pop(self); |
|
49 return self; |
|
50 } |
|
51 |
|
52 CMCETestUIEventView::CMCETestUIEventView( CMCETestUIEngine& aEngine ) |
|
53 : iEngine( aEngine ) |
|
54 { |
|
55 } |
|
56 |
|
57 // |
|
58 // Destructor for the view. |
|
59 // |
|
60 CMCETestUIEventView::~CMCETestUIEventView() |
|
61 { |
|
62 if (iContainer) |
|
63 { |
|
64 AppUi()->RemoveFromViewStack( *this, iContainer); |
|
65 delete iContainer; |
|
66 iContainer = NULL; |
|
67 } |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // CMCETestUIEventView::EngineStateChangedL() |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 void CMCETestUIEventView::EngineStateChangedL() |
|
75 { |
|
76 if ( iContainer ) |
|
77 { |
|
78 iContainer->ConstructModelL(); |
|
79 iContainer->DrawNow(); |
|
80 |
|
81 ConstructStatusPaneL(); |
|
82 } |
|
83 } |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // CMCETestUIEventView::ChangeToMainViewL() |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 void CMCETestUIEventView::ChangeToMainViewL() |
|
90 { |
|
91 TUid viewId = TUid::Uid( EMCETestUIAppViewId ); |
|
92 TRAPD( err, AppUi()->ActivateLocalViewL( viewId ) ); |
|
93 if ( err != KErrNone ) |
|
94 { |
|
95 User::InfoPrint( _L("Error") ); |
|
96 } |
|
97 |
|
98 } |
|
99 |
|
100 /** |
|
101 * Called by the framework |
|
102 * @return The Uid for this view |
|
103 */ |
|
104 TUid CMCETestUIEventView::Id() const |
|
105 { |
|
106 return TUid::Uid( EMCETestUIEventViewId ); |
|
107 } |
|
108 |
|
109 |
|
110 /** |
|
111 * From CEikAppUi, takes care of command handling for this view. |
|
112 * |
|
113 * @param aCommand command to be handled |
|
114 */ |
|
115 void CMCETestUIEventView::HandleCommandL( TInt aCommand ) |
|
116 { |
|
117 switch ( aCommand ) |
|
118 { |
|
119 case EAknSoftkeyBack: |
|
120 { |
|
121 ChangeToMainViewL(); |
|
122 break; |
|
123 } |
|
124 default: |
|
125 { |
|
126 } |
|
127 } |
|
128 } |
|
129 |
|
130 |
|
131 // ----------------------------------------------------------------------------- |
|
132 // CMCETestUIEventView::DoActivateL |
|
133 // |
|
134 // Called by the framework when the view is activated. Constructs the |
|
135 // container if necessary, setting this view as its MOP parent, and |
|
136 // adding it to the control stack. |
|
137 // |
|
138 // ----------------------------------------------------------------------------- |
|
139 |
|
140 void CMCETestUIEventView::DoActivateL( |
|
141 const TVwsViewId& /*aPrevViewId*/, |
|
142 TUid /*aCustomMessageId*/, |
|
143 const TDesC8& aCustomMessage ) |
|
144 { |
|
145 if (!iContainer) |
|
146 { |
|
147 // Solve event to be shown |
|
148 TLex8 lex( aCustomMessage ); |
|
149 TInt eventIndex = -1; |
|
150 User::LeaveIfError( lex.Val( eventIndex ) ); |
|
151 |
|
152 const RPointerArray<CMCETestUIEngineOutEvent>& outEvents = |
|
153 iEngine.OutEvents(); |
|
154 |
|
155 const RPointerArray<CMCETestUIEngineInEvent>& inEvents = |
|
156 iEngine.InEvents(); |
|
157 |
|
158 if ( eventIndex < outEvents .Count() ) |
|
159 { |
|
160 iEvent = outEvents[eventIndex ]; |
|
161 } |
|
162 else |
|
163 { |
|
164 eventIndex -= outEvents.Count(); |
|
165 if ( eventIndex < inEvents.Count() ) |
|
166 { |
|
167 iEvent = inEvents[eventIndex]; |
|
168 } |
|
169 else |
|
170 { |
|
171 User::Leave( KErrArgument ); |
|
172 } |
|
173 } |
|
174 |
|
175 iContainer = CMCETestUIEventViewContainer::NewL( |
|
176 AppUi()->ClientRect(), *this, iEngine, *iEvent ); |
|
177 iContainer->SetMopParent(this); |
|
178 //iContainer->ConstructL(AppUi()->ClientRect()); |
|
179 AppUi()->AddToViewStackL( *this, iContainer ); |
|
180 } |
|
181 |
|
182 |
|
183 Cba()->SetCommandSetL( R_AVKON_SOFTKEYS_OPTIONS_BACK ); |
|
184 Cba()->DrawNow(); |
|
185 |
|
186 ConstructStatusPaneL(); |
|
187 |
|
188 } |
|
189 |
|
190 |
|
191 // ----------------------------------------------------------------------------- |
|
192 // CMCETestUIEventView::DoDeactivate |
|
193 // |
|
194 // Called by the framework when the view is deactivated. |
|
195 // Removes the container from the control stack and deletes it. |
|
196 // |
|
197 // ----------------------------------------------------------------------------- |
|
198 void CMCETestUIEventView::DoDeactivate() |
|
199 { |
|
200 if (iContainer) |
|
201 { |
|
202 // TODO: This should not leave |
|
203 CAknNavigationControlContainer* navi = |
|
204 static_cast<CAknNavigationControlContainer*> |
|
205 (StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) )); |
|
206 navi->Pop( iNaviLabel ); |
|
207 delete iNaviLabel; |
|
208 iNaviLabel = NULL; |
|
209 |
|
210 AppUi()->RemoveFromViewStack( *this, iContainer ); |
|
211 delete iContainer; |
|
212 iContainer = NULL; |
|
213 } |
|
214 } |
|
215 |
|
216 // ----------------------------------------------------------------------------- |
|
217 // CMCETestUIEventView::ConstructStatusPaneL |
|
218 // ----------------------------------------------------------------------------- |
|
219 // |
|
220 void CMCETestUIEventView::ConstructStatusPaneL() |
|
221 { |
|
222 CAknTitlePane* titlePane = static_cast<CAknTitlePane*> |
|
223 (StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) )); |
|
224 titlePane->SetTextL( iTitlePaneText ); |
|
225 |
|
226 CAknNavigationControlContainer* navi = |
|
227 static_cast<CAknNavigationControlContainer*> |
|
228 (StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) )); |
|
229 navi->Pop( iNaviLabel ); |
|
230 delete iNaviLabel; |
|
231 iNaviLabel = NULL; |
|
232 iNaviLabel = navi->CreateNavigationLabelL( iEvent->State() ); |
|
233 navi->PushL( *iNaviLabel ); |
|
234 } |
|
235 |
|
236 // ----------------------------------------------------------------------------- |
|
237 // CMCETestUIEventView::ConstructL |
|
238 // ----------------------------------------------------------------------------- |
|
239 // |
|
240 void CMCETestUIEventView::ConstructL() |
|
241 { |
|
242 BaseConstructL(); |
|
243 } |