25
|
1 |
/*
|
|
2 |
* Copyright (c) 2004-2007 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: Implementation of the CVtUiNumberEntryControl control class.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include "CVtUiNumberEntryControl.h"
|
|
21 |
#include "VtUiLayout.h"
|
|
22 |
#include "VtUiUtility.h"
|
|
23 |
#include "mvtuicomponentmanager.h"
|
|
24 |
#include "tvtuistates.h"
|
|
25 |
#include "tvtuiwsevent.h"
|
|
26 |
#include "mvtuifeature.h"
|
|
27 |
#include "mvtuinumberentrycontrolobserver.h"
|
|
28 |
#include "cvtuidtmfbuffer.h"
|
|
29 |
|
|
30 |
#include <AknsUtils.h>
|
|
31 |
#include <cvtlogger.h>
|
|
32 |
#include <eikenv.h>
|
|
33 |
|
|
34 |
// CONSTANTS
|
|
35 |
|
|
36 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
37 |
|
|
38 |
// Implementation for TVtUiNumberEntryComponentState
|
|
39 |
|
|
40 |
// -----------------------------------------------------------------------------
|
|
41 |
// TVtUiNumberEntryComponentState::TVtUiNumberEntryComponentState
|
|
42 |
// -----------------------------------------------------------------------------
|
|
43 |
//
|
|
44 |
TVtUiNumberEntryComponentState::TVtUiNumberEntryComponentState(
|
|
45 |
MVtUiComponent& aComponent )
|
|
46 |
: TVtUiComponentState( aComponent,
|
|
47 |
TVtUiBlockListBitField(
|
|
48 |
MVtUiComponent::EComponentIdDialer ) )
|
|
49 |
{
|
|
50 |
}
|
|
51 |
|
|
52 |
// Implementation for CVtUiNumberEntryControl
|
|
53 |
|
|
54 |
// -----------------------------------------------------------------------------
|
|
55 |
// CVtUiNumberEntryControl::CVtUiNumberEntryControl
|
|
56 |
// C++ constructor can NOT contain any code, that
|
|
57 |
// might leave.
|
|
58 |
// -----------------------------------------------------------------------------
|
|
59 |
//
|
|
60 |
CVtUiNumberEntryControl::CVtUiNumberEntryControl(
|
|
61 |
MVtUiFeature& aFeature,
|
|
62 |
TVtUiStates& aUiStates )
|
|
63 |
: iFeature( aFeature ),
|
|
64 |
iComponentState( *this ),
|
|
65 |
iUiStates( aUiStates )
|
|
66 |
{
|
|
67 |
__VTPRINTENTER( "NECtrl.ctor" )
|
|
68 |
__VTPRINTEXIT( "NECtrl.ctor" )
|
|
69 |
}
|
|
70 |
|
|
71 |
// -----------------------------------------------------------------------------
|
|
72 |
// CVtUiNumberEntryControl::ConstructL
|
|
73 |
// Symbian 2nd phase constructor.
|
|
74 |
// -----------------------------------------------------------------------------
|
|
75 |
//
|
|
76 |
void CVtUiNumberEntryControl::ConstructL( const TRect& aRect )
|
|
77 |
{
|
|
78 |
__VTPRINTENTER( "NECtrl.ConstructL" )
|
|
79 |
CreateWindowL();
|
|
80 |
SetRect( aRect );
|
|
81 |
ActivateL();
|
|
82 |
MakeVisible( EFalse );
|
|
83 |
iInputBuffer = CVtUiDTMFBuffer::NewL( *iCoeEnv );
|
|
84 |
__VTPRINTEXIT( "NECtrl.ConstructL" )
|
|
85 |
}
|
|
86 |
|
|
87 |
// -----------------------------------------------------------------------------
|
|
88 |
// CVtUiNumberEntryControl::~CVtUiNumberEntryControl
|
|
89 |
// Destructor.
|
|
90 |
// -----------------------------------------------------------------------------
|
|
91 |
//
|
|
92 |
CVtUiNumberEntryControl::~CVtUiNumberEntryControl()
|
|
93 |
{
|
|
94 |
__VTPRINTENTER( "NECtrl.~" )
|
|
95 |
AknsUtils::DeregisterControlPosition( this );
|
|
96 |
delete iInputBuffer;
|
|
97 |
__VTPRINTEXIT( "NECtrl.~" )
|
|
98 |
}
|
|
99 |
|
|
100 |
// -----------------------------------------------------------------------------
|
|
101 |
// CVtUiNumberEntryControl::OpenNumberEntry
|
|
102 |
// -----------------------------------------------------------------------------
|
|
103 |
//
|
|
104 |
TBool CVtUiNumberEntryControl::OpenNumberEntry()
|
|
105 |
{
|
|
106 |
__VTPRINTENTER( "NECtrl.OpenNumberEntry" )
|
|
107 |
TBool result( EFalse );
|
|
108 |
if ( !iUiStates.IsNumberEntryOpen() )
|
|
109 |
{
|
|
110 |
__VTPRINT( DEBUG_GEN, "VtUiNumberEntry.OPEN" )
|
|
111 |
iInputBuffer->Activate();
|
|
112 |
iUiStates.SetIsNumberEntryOpen( ETrue );
|
|
113 |
result = ETrue;
|
|
114 |
}
|
|
115 |
__VTPRINTEXITR( "NECtrl.OpenNumberEntry %d", result )
|
|
116 |
return result;
|
|
117 |
}
|
|
118 |
|
|
119 |
// -----------------------------------------------------------------------------
|
|
120 |
// CVtUiNumberEntryControl::IsNumberEntryOpen
|
|
121 |
// -----------------------------------------------------------------------------
|
|
122 |
//
|
|
123 |
TBool CVtUiNumberEntryControl::IsNumberEntryOpen() const
|
|
124 |
{
|
|
125 |
__VTPRINTENTER( "NECtrl.IsNumberEntryOpen" )
|
|
126 |
const TBool result( iUiStates.IsNumberEntryOpen() );
|
|
127 |
__VTPRINTEXITR( "NECtrl.IsNumberEntryOpen %d",result )
|
|
128 |
return result;
|
|
129 |
}
|
|
130 |
|
|
131 |
// -----------------------------------------------------------------------------
|
|
132 |
// CVtUiNumberEntryControl::CloseNumberEntry
|
|
133 |
// -----------------------------------------------------------------------------
|
|
134 |
//
|
|
135 |
void CVtUiNumberEntryControl::CloseNumberEntry()
|
|
136 |
{
|
|
137 |
__VTPRINTENTER( "NECtrl.CloseNumberEntry" )
|
|
138 |
if ( iUiStates.IsNumberEntryOpen() )
|
|
139 |
{
|
|
140 |
__VTPRINT( DEBUG_GEN, "NECtrl.CloseNumberEntry CLOSE" )
|
|
141 |
iUiStates.SetIsNumberEntryOpen( EFalse );
|
|
142 |
iInputBuffer->Deactivate();
|
|
143 |
}
|
|
144 |
__VTPRINTEXIT( "NECtrl.CloseNumberEntry" )
|
|
145 |
}
|
|
146 |
|
|
147 |
// -----------------------------------------------------------------------------
|
|
148 |
// CVtUiNumberEntryControl::RegisterComponentL
|
|
149 |
// -----------------------------------------------------------------------------
|
|
150 |
//
|
|
151 |
void CVtUiNumberEntryControl::RegisterComponentL(
|
|
152 |
MVtUiComponentManager& aComponentManager )
|
|
153 |
{
|
|
154 |
__VTPRINTENTER( "NECtrl.RegisterComponentL" )
|
|
155 |
User::LeaveIfError( aComponentManager.ChangeComponentRegistration(
|
|
156 |
iComponentState, MVtUiComponentManager::ERegister ) );
|
|
157 |
__VTPRINTEXIT( "NECtrl.RegisterComponentL" )
|
|
158 |
}
|
|
159 |
|
|
160 |
// -----------------------------------------------------------------------------
|
|
161 |
// CVtUiNumberEntryControl::UnregisterComponent
|
|
162 |
// -----------------------------------------------------------------------------
|
|
163 |
//
|
|
164 |
void CVtUiNumberEntryControl::UnregisterComponent(
|
|
165 |
MVtUiComponentManager& aComponentManager )
|
|
166 |
{
|
|
167 |
__VTPRINTENTER( "NECtrl.UnregisterComponent" )
|
|
168 |
iInputBuffer->Reset();
|
|
169 |
aComponentManager.ChangeComponentRegistration( iComponentState,
|
|
170 |
MVtUiComponentManager::EUnregister );
|
|
171 |
__VTPRINTEXIT( "NECtrl.UnregisterComponent" )
|
|
172 |
}
|
|
173 |
|
|
174 |
// -----------------------------------------------------------------------------
|
|
175 |
// CVtUiNumberEntryControl::SetNumberEntryControlObserver
|
|
176 |
// -----------------------------------------------------------------------------
|
|
177 |
//
|
|
178 |
void CVtUiNumberEntryControl::SetNumberEntryControlObserver(
|
|
179 |
MVtUiNumberEntryControlObserver* aObserver )
|
|
180 |
{
|
|
181 |
__VTPRINTENTER( "NECtrl.SetNumberEntryControlObserver" )
|
|
182 |
iControlObserver = aObserver;
|
|
183 |
__VTPRINTEXIT( "NECtrl.SetNumberEntryControlObserver" )
|
|
184 |
}
|
|
185 |
|
|
186 |
// -----------------------------------------------------------------------------
|
|
187 |
// CVtUiNumberEntryControl::OfferKeyEventL
|
|
188 |
// -----------------------------------------------------------------------------
|
|
189 |
//
|
|
190 |
TKeyResponse CVtUiNumberEntryControl::OfferKeyEventL(
|
|
191 |
const TKeyEvent& aKeyEvent,
|
|
192 |
TEventCode )
|
|
193 |
{
|
|
194 |
__VTPRINTENTER( "NECtrl.OfferKeyEventL" )
|
|
195 |
|
|
196 |
TKeyResponse resp( EKeyWasNotConsumed );
|
|
197 |
|
|
198 |
if ( IsDisplayingMenuOrDialog() ||
|
|
199 |
aKeyEvent.iCode == EKeyLeftArrow ||
|
|
200 |
aKeyEvent.iCode == EKeyRightArrow ||
|
|
201 |
aKeyEvent.iCode == EKeyUpArrow ||
|
|
202 |
aKeyEvent.iCode == EKeyDownArrow ||
|
|
203 |
aKeyEvent.iCode == EKeyBackspace ||
|
|
204 |
aKeyEvent.iCode == EKeyZoomIn ||
|
|
205 |
aKeyEvent.iCode == EKeyZoomOut ||
|
|
206 |
aKeyEvent.iScanCode == EStdKeyUpArrow ||
|
|
207 |
aKeyEvent.iScanCode == EStdKeyDownArrow ||
|
|
208 |
aKeyEvent.iScanCode == EStdKeyLeftArrow ||
|
|
209 |
aKeyEvent.iScanCode == EStdKeyRightArrow )
|
|
210 |
{
|
|
211 |
return resp;
|
|
212 |
}
|
|
213 |
|
|
214 |
TChar dtmfTone;
|
|
215 |
if ( VtUiUtility::IsDTMFEvent( aKeyEvent, dtmfTone ) )
|
|
216 |
{
|
|
217 |
iInputBuffer->Append( dtmfTone );
|
|
218 |
}
|
|
219 |
|
|
220 |
__VTPRINTEXITR( "NECtrl.OfferKeyEvent %d", resp )
|
|
221 |
return resp;
|
|
222 |
}
|
|
223 |
|
|
224 |
// -----------------------------------------------------------------------------
|
|
225 |
// CVtUiNumberEntryControl::DoCloseNumberEntry
|
|
226 |
// -----------------------------------------------------------------------------
|
|
227 |
//
|
|
228 |
TInt CVtUiNumberEntryControl::DoCloseNumberEntry( TAny* aAny )
|
|
229 |
{
|
|
230 |
__VTPRINTENTER( "NECtrl.DoCloseNumberEntry" )
|
|
231 |
CVtUiNumberEntryControl* self =
|
|
232 |
reinterpret_cast< CVtUiNumberEntryControl* >( aAny );
|
|
233 |
self->HandleTimeoutCloseNumberEntry();
|
|
234 |
__VTPRINTEXIT( "NECtrl.DoCloseNumberEntry" )
|
|
235 |
return KErrNone;
|
|
236 |
}
|
|
237 |
|
|
238 |
// -----------------------------------------------------------------------------
|
|
239 |
// CVtUiNumberEntryControl::HandleTimeoutCloseNumberEntry
|
|
240 |
// -----------------------------------------------------------------------------
|
|
241 |
//
|
|
242 |
void CVtUiNumberEntryControl::HandleTimeoutCloseNumberEntry()
|
|
243 |
{
|
|
244 |
__VTPRINTENTER( "NECtrl.HandleTimeoutCloseNumberEntry" )
|
|
245 |
__VTPRINTEXIT( "NECtrl.HandleTimeoutCloseNumberEntry" )
|
|
246 |
iFeature.Stop();
|
|
247 |
}
|
|
248 |
|
|
249 |
// -----------------------------------------------------------------------------
|
|
250 |
// CVtUiNumberEntryControl::IsDisplayingMenuOrDialog
|
|
251 |
// -----------------------------------------------------------------------------
|
|
252 |
//
|
|
253 |
TBool CVtUiNumberEntryControl::IsDisplayingMenuOrDialog() const
|
|
254 |
{
|
|
255 |
__VTPRINTENTER( "NECtrl.IsDisplayingMenuOrDialog" )
|
|
256 |
CEikMenuBar* menuBar = iEikonEnv->AppUiFactory()->MenuBar();
|
|
257 |
const TBool result( CCoeEnv::Static()->AppUi()->IsDisplayingDialog() ||
|
|
258 |
( menuBar && menuBar->IsDisplayed() ) );
|
|
259 |
__VTPRINTEXITR( "NECtrl.IsDisplayingMenuOrDialog %d", result )
|
|
260 |
return result;
|
|
261 |
}
|
|
262 |
|
|
263 |
// -----------------------------------------------------------------------------
|
|
264 |
// CVtUiNumberEntryControl::ComponentId
|
|
265 |
// -----------------------------------------------------------------------------
|
|
266 |
//
|
|
267 |
MVtUiComponent::TComponentId CVtUiNumberEntryControl::ComponentId() const
|
|
268 |
{
|
|
269 |
__VTPRINTENTER( "NECtrl.ComponentId" )
|
|
270 |
__VTPRINTEXIT( "NECtrl.ComponentId" )
|
|
271 |
return MVtUiComponent::EComponentIdNumberEntry;
|
|
272 |
}
|
|
273 |
|
|
274 |
// -----------------------------------------------------------------------------
|
|
275 |
// CVtUiNumberEntryControl::ComponentAsControl
|
|
276 |
// -----------------------------------------------------------------------------
|
|
277 |
//
|
|
278 |
CCoeControl* CVtUiNumberEntryControl::ComponentAsControl()
|
|
279 |
{
|
|
280 |
__VTPRINTENTER( "NECtrl.ComponentAsControl" )
|
|
281 |
__VTPRINTEXIT( "NECtrl.ComponentAsControl" )
|
|
282 |
return this;
|
|
283 |
}
|
|
284 |
|
|
285 |
// -----------------------------------------------------------------------------
|
|
286 |
// CVtUiNumberEntryControl::DoActivateL
|
|
287 |
// -----------------------------------------------------------------------------
|
|
288 |
//
|
|
289 |
void CVtUiNumberEntryControl::DoActivateL()
|
|
290 |
{
|
|
291 |
__VTPRINTENTER( "NECtrl.DoActivateL" )
|
|
292 |
OpenNumberEntry();
|
|
293 |
if ( iControlObserver )
|
|
294 |
{
|
|
295 |
iControlObserver->ControlActivatedL();
|
|
296 |
}
|
|
297 |
__VTPRINTEXIT( "NECtrl.DoActivateL" )
|
|
298 |
}
|
|
299 |
|
|
300 |
// -----------------------------------------------------------------------------
|
|
301 |
// CVtUiNumberEntryControl::DoDeactivateL
|
|
302 |
// -----------------------------------------------------------------------------
|
|
303 |
//
|
|
304 |
void CVtUiNumberEntryControl::DoDeactivateL()
|
|
305 |
{
|
|
306 |
__VTPRINTENTER( "NECtrl.DoDeactivateL" )
|
|
307 |
CloseNumberEntry();
|
|
308 |
if ( iControlObserver )
|
|
309 |
{
|
|
310 |
iControlObserver->ControlDeactivated();
|
|
311 |
}
|
|
312 |
__VTPRINTEXIT( "NECtrl.DoDeactivateL" )
|
|
313 |
}
|
|
314 |
|
|
315 |
// End of File
|