|
1 /* |
|
2 * Copyright (c) 2006 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: Base view in GS Sensor Plugin. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "gssensorbaseview.h" |
|
21 #include "gssensorplugin_debug.h" |
|
22 #include "gssensormskobserver.h" |
|
23 #include "gssensorplugin.hrh" |
|
24 |
|
25 #include <aknViewAppUi.h> |
|
26 #include <gsbasecontainer.h> |
|
27 #include <StringLoader.h> |
|
28 #include <eikbtgpc.h> |
|
29 |
|
30 // CONSTANTS |
|
31 _LIT( KGSDoActivateError, "DoActivateL" ); |
|
32 |
|
33 // ========================= MEMBER FUNCTIONS ================================ |
|
34 |
|
35 // --------------------------------------------------------------------------- |
|
36 // CGSSensorBaseView::CGSSensorBaseView |
|
37 // C++ constructor |
|
38 // --------------------------------------------------------------------------- |
|
39 // |
|
40 CGSSensorBaseView::CGSSensorBaseView() |
|
41 { |
|
42 TRACE_( "[GSSensorPlugin] CGSSensorBaseView::CGSSensorBaseView()" ); |
|
43 iAppUi = iAvkonViewAppUi; |
|
44 TRACE_( "[GSSensorPlugin] CGSSensorBaseView::CGSSensorBaseView() - return" ); |
|
45 } |
|
46 |
|
47 |
|
48 // --------------------------------------------------------------------------- |
|
49 // CGSSensorBaseView::~CGSSensorBaseView |
|
50 // Destructor |
|
51 // --------------------------------------------------------------------------- |
|
52 // |
|
53 CGSSensorBaseView::~CGSSensorBaseView() |
|
54 { |
|
55 TRACE_( "[GSSensorPlugin] CGSSensorBaseView::~CGSSensorBaseView()" ); |
|
56 if ( iContainer && iAppUi ) |
|
57 { |
|
58 iAppUi->RemoveFromViewStack( *this, iContainer ); |
|
59 delete iContainer; |
|
60 } |
|
61 TRACE_( "[GSSensorPlugin] CGSSensorBaseView::~CGSSensorBaseView() - return" ); |
|
62 } |
|
63 |
|
64 // --------------------------------------------------------------------------- |
|
65 // CGSSensorBaseView::SetCurrentItem |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 void CGSSensorBaseView::SetCurrentItem( TInt aIndex ) |
|
69 { |
|
70 TRACE_1( "[GSSensorPlugin] CGSSensorBaseView::SetCurrentItem() - %i", aIndex ); |
|
71 iCurrentItem = aIndex; |
|
72 TRACE_( "[GSSensorPlugin] CGSSensorBaseView::SetCurrentItem() - return" ); |
|
73 } |
|
74 |
|
75 // --------------------------------------------------------------------------- |
|
76 // CGSSensorBaseView::HandleListBoxEventL |
|
77 // --------------------------------------------------------------------------- |
|
78 // |
|
79 void CGSSensorBaseView::HandleListBoxEventL( |
|
80 CEikListBox* /*aListBox*/, |
|
81 TListBoxEvent aEventType ) |
|
82 { |
|
83 TRACE_( "[GSSensorPlugin] CGSSensorBaseView::HandleListBoxEventL()" ); |
|
84 switch ( aEventType ) |
|
85 { |
|
86 case EEventEnterKeyPressed: |
|
87 case EEventItemSingleClicked: |
|
88 HandleListBoxSelectionL(); |
|
89 break; |
|
90 default: |
|
91 break; |
|
92 } |
|
93 TRACE_( "[GSSensorPlugin] CGSSensorBaseView::HandleListBoxEventL() - return" ); |
|
94 } |
|
95 |
|
96 // --------------------------------------------------------------------------- |
|
97 // CGSSensorBaseView::HandleClientRectChange |
|
98 // --------------------------------------------------------------------------- |
|
99 // |
|
100 void CGSSensorBaseView::HandleClientRectChange() |
|
101 { |
|
102 TRACE_( "[GSSensorPlugin] CGSSensorBaseView::HandleClientRectChange()" ); |
|
103 if ( iContainer && iContainer->iListBox ) |
|
104 { |
|
105 iContainer->SetRect( ClientRect() ); |
|
106 } |
|
107 TRACE_( "[GSSensorPlugin] CGSSensorBaseView::HandleClientRectChange() - return" ); |
|
108 } |
|
109 |
|
110 // --------------------------------------------------------------------------- |
|
111 // CGSSensorBaseView::DoActivateL |
|
112 // Activates the view. |
|
113 // --------------------------------------------------------------------------- |
|
114 // |
|
115 void CGSSensorBaseView::DoActivateL( |
|
116 const TVwsViewId& /*aPrevViewId*/, |
|
117 TUid /*aCustomMessageId*/, |
|
118 const TDesC8& /*aCustomMessage*/ ) |
|
119 { |
|
120 TRACE_( "[GSSensorPlugin] CGSSensorBaseView::DoActivateL()" ); |
|
121 if ( iContainer ) |
|
122 { |
|
123 iAppUi->RemoveFromViewStack( *this, iContainer ); |
|
124 delete iContainer; |
|
125 iContainer = NULL; |
|
126 } |
|
127 |
|
128 CreateContainerL(); |
|
129 |
|
130 iAppUi->AddToViewStackL( *this, iContainer ); |
|
131 iContainer->iListBox->SetListBoxObserver( this ); |
|
132 // Update MSK label |
|
133 CheckMiddleSoftkeyLabelL(); |
|
134 |
|
135 TRACE_( "[GSSensorPlugin] CGSSensorBaseView::DoActivateL() - return" ); |
|
136 } |
|
137 |
|
138 // --------------------------------------------------------------------------- |
|
139 // CGSSensorBaseView::DoDeactivate() |
|
140 // --------------------------------------------------------------------------- |
|
141 // |
|
142 void CGSSensorBaseView::DoDeactivate() |
|
143 { |
|
144 TRACE_( "[GSSensorPlugin] CGSSensorBaseView::DoDeactivate()" ); |
|
145 if ( iContainer ) |
|
146 { |
|
147 iAppUi->RemoveFromViewStack( *this, iContainer ); |
|
148 delete iContainer; |
|
149 iContainer = NULL; |
|
150 } |
|
151 TRACE_( "[GSSensorPlugin] CGSSensorBaseView::DoDeactivate() - return" ); |
|
152 } |
|
153 |
|
154 // --------------------------------------------------------------------------- |
|
155 // CGSSensorBaseView::CreateContainerL() |
|
156 // --------------------------------------------------------------------------- |
|
157 // |
|
158 void CGSSensorBaseView::CreateContainerL() |
|
159 { |
|
160 TRACE_( "[GSSensorPlugin] CGSSensorBaseView::CreateContainerL()" ); |
|
161 NewContainerL(); |
|
162 __ASSERT_ALWAYS( iContainer, User::Panic( KGSDoActivateError, EGSViewPanicNullPtr ) ); |
|
163 iContainer->SetMopParent( this ); |
|
164 |
|
165 TRAPD( error, iContainer->ConstructL( ClientRect() ) ); |
|
166 |
|
167 if ( error ) |
|
168 { |
|
169 TRACE_1( "[GSSensorPlugin] CGSSensorBaseView::CreateContainerL() - Error: %i", error ); |
|
170 delete iContainer; |
|
171 iContainer = NULL; |
|
172 User::Leave( error ); |
|
173 } |
|
174 TRACE_( "[GSSensorPlugin] CGSSensorBaseView::CreateContainerL() - return" ); |
|
175 } |
|
176 |
|
177 // ----------------------------------------------------------------------------- |
|
178 // CGSSensorBaseView::RemoveCommandFromMSK |
|
179 // This method should do nothing but MSK issues. |
|
180 // ----------------------------------------------------------------------------- |
|
181 // |
|
182 void CGSSensorBaseView::RemoveCommandFromMSK() |
|
183 { |
|
184 TRACE_( "[GSSensorPlugin] CGSSensorBaseView::RemoveCommandFromMSK()" ); |
|
185 CEikButtonGroupContainer* cbaGroup = Cba(); |
|
186 if ( cbaGroup ) |
|
187 { |
|
188 // Remove command from stack |
|
189 cbaGroup->RemoveCommandFromStack( KGSSenPluginMSKControlID, EGSSenMskGeneral ); |
|
190 } |
|
191 TRACE_( "[GSSensorPlugin] CGSSensorBaseView::RemoveCommandFromMSK() - return" ); |
|
192 } |
|
193 |
|
194 // ----------------------------------------------------------------------------- |
|
195 // CGSSensorBaseView::SetMiddleSoftKeyLabelL |
|
196 // Sets middle softkey label. |
|
197 // ----------------------------------------------------------------------------- |
|
198 // |
|
199 void CGSSensorBaseView::SetMiddleSoftKeyLabelL( |
|
200 const TInt aResourceId, const TInt aCommandId ) |
|
201 { |
|
202 TRACE_( "[GSSensorPlugin] CGSSensorBaseView::SetMiddleSoftKeyLabelL()" ); |
|
203 CEikButtonGroupContainer* cbaGroup = Cba(); |
|
204 if ( cbaGroup ) |
|
205 { |
|
206 HBufC* middleSKText = StringLoader::LoadLC( aResourceId ); |
|
207 TPtr mskPtr = middleSKText->Des(); |
|
208 cbaGroup->AddCommandToStackL( |
|
209 KGSSenPluginMSKControlID, |
|
210 aCommandId, |
|
211 mskPtr ); |
|
212 CleanupStack::Pop( middleSKText ); |
|
213 delete middleSKText; |
|
214 } |
|
215 TRACE_( "[GSSensorPlugin] CGSSensorBaseView::SetMiddleSoftKeyLabelL() - return" ); |
|
216 } |