author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:32:09 +0300 | |
branch | RCL_3 |
changeset 75 | 01504893d9cb |
parent 60 | 5b3385a43d68 |
permissions | -rw-r--r-- |
60 | 1 |
/* |
2 |
* Copyright (c) 2008-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: Text entry popup class for entering textual input |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
||
20 |
||
21 |
/** |
|
22 |
* @internal reviewed 06/06/2007 by Dave Schofield |
|
23 |
*/ |
|
24 |
||
25 |
#include "glxtextentrypopup.h" |
|
26 |
||
27 |
#include <featmgr.h> |
|
28 |
||
29 |
#include "glxuiutility.h" |
|
30 |
#include <glxtracer.h> |
|
31 |
#include "glxsetappstate.h" |
|
32 |
#include <glxuiutilities.rsg> |
|
33 |
||
34 |
/** |
|
35 |
* TGlxTextEntryPopupRestoreState |
|
36 |
* Contains state information to be |
|
37 |
* restored when CGlxTextEntryPopup is |
|
38 |
* dismissed or if CAknTextQueryDialog::ExecuteLD |
|
39 |
* leaves |
|
40 |
*/ |
|
41 |
class TGlxTextEntryPopupRestoreState |
|
42 |
{ |
|
43 |
public: |
|
44 |
/** |
|
45 |
* Default constructor |
|
46 |
*/ |
|
47 |
TGlxTextEntryPopupRestoreState(); |
|
48 |
||
49 |
public: |
|
50 |
/** Pointer to the HUI utility (not owned) */ |
|
51 |
CGlxUiUtility* iUiUtility; |
|
52 |
||
53 |
/** Previous screen orientation */ |
|
54 |
TGlxOrientation iPreviousOrientation; |
|
55 |
||
56 |
/** Previous application state */ |
|
57 |
TGlxAppState iPreviousAppState; |
|
58 |
}; |
|
59 |
||
60 |
// ----------------------------------------------------------------------------- |
|
61 |
// Constructor |
|
62 |
// ----------------------------------------------------------------------------- |
|
63 |
// |
|
64 |
TGlxTextEntryPopupRestoreState::TGlxTextEntryPopupRestoreState() |
|
65 |
{ |
|
66 |
iUiUtility = NULL; |
|
67 |
iPreviousOrientation = EGlxOrientationDefault; |
|
68 |
iPreviousAppState = EGlxAppStateUndefined; |
|
69 |
} |
|
70 |
||
71 |
// ----------------------------------------------------------------------------- |
|
72 |
// NewL |
|
73 |
// ----------------------------------------------------------------------------- |
|
74 |
// |
|
75 |
EXPORT_C CGlxTextEntryPopup* CGlxTextEntryPopup::NewL(const TDesC& aTitle, TDes& aText) |
|
76 |
{ |
|
77 |
CGlxTextEntryPopup* self = new (ELeave) CGlxTextEntryPopup(aText); |
|
78 |
CleanupStack::PushL(self); |
|
79 |
self->ConstructL(aTitle); |
|
80 |
CleanupStack::Pop(self); |
|
81 |
return self; |
|
82 |
} |
|
83 |
||
84 |
// ----------------------------------------------------------------------------- |
|
85 |
// Constructor |
|
86 |
// ----------------------------------------------------------------------------- |
|
87 |
// |
|
88 |
CGlxTextEntryPopup::CGlxTextEntryPopup(TDes& aText) : CAknTextQueryDialog(aText) |
|
89 |
{ |
|
90 |
} |
|
91 |
||
92 |
// ----------------------------------------------------------------------------- |
|
93 |
// ExecuteLD |
|
94 |
// ----------------------------------------------------------------------------- |
|
95 |
// |
|
96 |
EXPORT_C TInt CGlxTextEntryPopup::ExecuteLD() |
|
97 |
{ |
|
98 |
TRACER( "CGlxTextEntryPopup::ExecuteLD" ); |
|
99 |
||
100 |
TGlxTextEntryPopupRestoreState rollbackState; |
|
101 |
// attempt to get current PCFW app state |
|
102 |
rollbackState.iPreviousAppState = GlxSetAppState::AppState(); |
|
103 |
// set app state to text entry |
|
104 |
GlxSetAppState::SetState(EGlxInTextEntry); |
|
105 |
||
106 |
CGlxUiUtility* uiUtility = CGlxUiUtility::UtilityL(); |
|
107 |
CleanupClosePushL( *uiUtility ); |
|
108 |
||
109 |
// create cleanup stack item to revert previous state if dlg leaves |
|
110 |
TCleanupItem cleanupItem( RollbackState, &rollbackState ); |
|
111 |
CleanupStack::PushL( cleanupItem ); |
|
112 |
||
113 |
rollbackState.iUiUtility = uiUtility; |
|
114 |
rollbackState.iPreviousOrientation = uiUtility->AppOrientation(); |
|
115 |
||
116 |
// If Device supports text-entry mode only in portrait, |
|
117 |
// then the orientation has to be forced to EGlxOrientationTextEntry here. |
|
118 |
if(uiUtility->IsPenSupported()) |
|
119 |
{ |
|
120 |
uiUtility->SetAppOrientationL( EGlxOrientationDefault ); |
|
121 |
} |
|
122 |
else |
|
123 |
{ |
|
124 |
uiUtility->SetAppOrientationL( EGlxOrientationTextEntry ); |
|
75
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
125 |
} |
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
126 |
|
60 | 127 |
TInt retVal = CAknTextQueryDialog::ExecuteLD(R_GLX_TEXT_ENTRY_QUERY); |
128 |
||
129 |
CleanupStack::PopAndDestroy( &rollbackState ); // cleanupItem |
|
130 |
CleanupStack::PopAndDestroy( uiUtility ); |
|
131 |
||
132 |
return retVal; |
|
133 |
} |
|
134 |
||
135 |
// ----------------------------------------------------------------------------- |
|
136 |
// UpdateLeftSoftKeyL |
|
137 |
// ----------------------------------------------------------------------------- |
|
138 |
// |
|
139 |
void CGlxTextEntryPopup::UpdateLeftSoftKeyL() |
|
140 |
{ |
|
141 |
//Check whether the entered text length is bigger than zero |
|
142 |
if( !CheckIfEntryTextOk () && !iAllowEmptyString) |
|
143 |
{ |
|
144 |
MakeLeftSoftkeyVisible(EFalse); |
|
145 |
} |
|
146 |
else |
|
147 |
{ |
|
148 |
MakeLeftSoftkeyVisible(ETrue); |
|
149 |
} |
|
150 |
} |
|
151 |
||
152 |
// ----------------------------------------------------------------------------- |
|
153 |
// SetLeftSoftKeyL |
|
154 |
// ----------------------------------------------------------------------------- |
|
155 |
// |
|
156 |
EXPORT_C void CGlxTextEntryPopup::SetLeftSoftKeyL(TBool aAllowEmptyString) |
|
157 |
{ |
|
158 |
iAllowEmptyString = aAllowEmptyString; |
|
159 |
} |
|
160 |
||
161 |
// ----------------------------------------------------------------------------- |
|
162 |
// ConstructL |
|
163 |
// ----------------------------------------------------------------------------- |
|
164 |
// |
|
165 |
void CGlxTextEntryPopup::ConstructL(const TDesC& aTitle) |
|
166 |
{ |
|
167 |
SetPromptL(aTitle); |
|
168 |
} |
|
169 |
||
170 |
// ----------------------------------------------------------------------------- |
|
171 |
// RollbackState |
|
172 |
// ----------------------------------------------------------------------------- |
|
173 |
// |
|
174 |
void CGlxTextEntryPopup::RollbackState(TAny* aParam) |
|
175 |
{ |
|
176 |
TRACER( "CGlxTextEntryPopup::RollbackState" ); |
|
177 |
TGlxTextEntryPopupRestoreState* restoreState |
|
178 |
= static_cast<TGlxTextEntryPopupRestoreState*>( aParam ); |
|
179 |
||
180 |
// Rollback app state to previous state |
|
181 |
GlxSetAppState::SetState( restoreState->iPreviousAppState ); |
|
182 |
||
183 |
if ( restoreState->iUiUtility) |
|
184 |
{ |
|
185 |
TRAP_IGNORE( restoreState->iUiUtility->SetAppOrientationL( |
|
186 |
restoreState->iPreviousOrientation ) ); |
|
187 |
} |
|
188 |
} |