|
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 ); |
|
125 } |
|
126 // Enable predictiveTextInput option in the query dialog! |
|
127 SetPredictiveTextInputPermitted( ETrue ); |
|
128 TInt retVal = CAknTextQueryDialog::ExecuteLD(R_GLX_TEXT_ENTRY_QUERY); |
|
129 |
|
130 CleanupStack::PopAndDestroy( &rollbackState ); // cleanupItem |
|
131 CleanupStack::PopAndDestroy( uiUtility ); |
|
132 |
|
133 return retVal; |
|
134 } |
|
135 |
|
136 // ----------------------------------------------------------------------------- |
|
137 // UpdateLeftSoftKeyL |
|
138 // ----------------------------------------------------------------------------- |
|
139 // |
|
140 void CGlxTextEntryPopup::UpdateLeftSoftKeyL() |
|
141 { |
|
142 //Check whether the entered text length is bigger than zero |
|
143 if( !CheckIfEntryTextOk () && !iAllowEmptyString) |
|
144 { |
|
145 MakeLeftSoftkeyVisible(EFalse); |
|
146 } |
|
147 else |
|
148 { |
|
149 MakeLeftSoftkeyVisible(ETrue); |
|
150 } |
|
151 } |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // SetLeftSoftKeyL |
|
155 // ----------------------------------------------------------------------------- |
|
156 // |
|
157 EXPORT_C void CGlxTextEntryPopup::SetLeftSoftKeyL(TBool aAllowEmptyString) |
|
158 { |
|
159 iAllowEmptyString = aAllowEmptyString; |
|
160 } |
|
161 |
|
162 // ----------------------------------------------------------------------------- |
|
163 // ConstructL |
|
164 // ----------------------------------------------------------------------------- |
|
165 // |
|
166 void CGlxTextEntryPopup::ConstructL(const TDesC& aTitle) |
|
167 { |
|
168 SetPromptL(aTitle); |
|
169 } |
|
170 |
|
171 // ----------------------------------------------------------------------------- |
|
172 // RollbackState |
|
173 // ----------------------------------------------------------------------------- |
|
174 // |
|
175 void CGlxTextEntryPopup::RollbackState(TAny* aParam) |
|
176 { |
|
177 TRACER( "CGlxTextEntryPopup::RollbackState" ); |
|
178 TGlxTextEntryPopupRestoreState* restoreState |
|
179 = static_cast<TGlxTextEntryPopupRestoreState*>( aParam ); |
|
180 |
|
181 // Rollback app state to previous state |
|
182 GlxSetAppState::SetState( restoreState->iPreviousAppState ); |
|
183 |
|
184 if ( restoreState->iUiUtility) |
|
185 { |
|
186 TRAP_IGNORE( restoreState->iUiUtility->SetAppOrientationL( |
|
187 restoreState->iPreviousOrientation ) ); |
|
188 } |
|
189 } |