diff -r 000000000000 -r 4e91876724a2 photosgallery/viewframework/uiutilities/src/glxtextentrypopup.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/photosgallery/viewframework/uiutilities/src/glxtextentrypopup.cpp Thu Dec 17 08:45:44 2009 +0200 @@ -0,0 +1,188 @@ +/* +* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Text entry popup class for entering textual input +* +*/ + + + + +/** + * @internal reviewed 06/06/2007 by Dave Schofield + */ + +#include "glxtextentrypopup.h" + +#include + +#include "glxuiutility.h" +#include +#include "glxsetappstate.h" +#include + +/** + * TGlxTextEntryPopupRestoreState + * Contains state information to be + * restored when CGlxTextEntryPopup is + * dismissed or if CAknTextQueryDialog::ExecuteLD + * leaves + */ +class TGlxTextEntryPopupRestoreState + { +public: + /** + * Default constructor + */ + TGlxTextEntryPopupRestoreState(); + +public: + /** Pointer to the HUI utility (not owned) */ + CGlxUiUtility* iUiUtility; + + /** Previous screen orientation */ + TGlxOrientation iPreviousOrientation; + + /** Previous application state */ + TGlxAppState iPreviousAppState; + }; + +// ----------------------------------------------------------------------------- +// Constructor +// ----------------------------------------------------------------------------- +// +TGlxTextEntryPopupRestoreState::TGlxTextEntryPopupRestoreState() + { + iUiUtility = NULL; + iPreviousOrientation = EGlxOrientationDefault; + iPreviousAppState = EGlxAppStateUndefined; + } + +// ----------------------------------------------------------------------------- +// NewL +// ----------------------------------------------------------------------------- +// +EXPORT_C CGlxTextEntryPopup* CGlxTextEntryPopup::NewL(const TDesC& aTitle, TDes& aText) + { + CGlxTextEntryPopup* self = new (ELeave) CGlxTextEntryPopup(aText); + CleanupStack::PushL(self); + self->ConstructL(aTitle); + CleanupStack::Pop(self); + return self; + } + +// ----------------------------------------------------------------------------- +// Constructor +// ----------------------------------------------------------------------------- +// +CGlxTextEntryPopup::CGlxTextEntryPopup(TDes& aText) : CAknTextQueryDialog(aText) + { + } + +// ----------------------------------------------------------------------------- +// ExecuteLD +// ----------------------------------------------------------------------------- +// +EXPORT_C TInt CGlxTextEntryPopup::ExecuteLD() + { + TRACER( "CGlxTextEntryPopup::ExecuteLD" ); + + TGlxTextEntryPopupRestoreState rollbackState; + // attempt to get current PCFW app state + rollbackState.iPreviousAppState = GlxSetAppState::AppState(); + // set app state to text entry + GlxSetAppState::SetState(EGlxInTextEntry); + + CGlxUiUtility* uiUtility = CGlxUiUtility::UtilityL(); + CleanupClosePushL( *uiUtility ); + + // create cleanup stack item to revert previous state if dlg leaves + TCleanupItem cleanupItem( RollbackState, &rollbackState ); + CleanupStack::PushL( cleanupItem ); + + rollbackState.iUiUtility = uiUtility; + rollbackState.iPreviousOrientation = uiUtility->AppOrientation(); + + // If Device supports text-entry mode only in portrait, + // then the orientation has to be forced to EGlxOrientationTextEntry here. + if(uiUtility->IsPenSupported()) + { + uiUtility->SetAppOrientationL( EGlxOrientationDefault ); + } + else + { + uiUtility->SetAppOrientationL( EGlxOrientationTextEntry ); + } + + TInt retVal = CAknTextQueryDialog::ExecuteLD(R_GLX_TEXT_ENTRY_QUERY); + + CleanupStack::PopAndDestroy( &rollbackState ); // cleanupItem + CleanupStack::PopAndDestroy( uiUtility ); + + return retVal; + } + +// ----------------------------------------------------------------------------- +// UpdateLeftSoftKeyL +// ----------------------------------------------------------------------------- +// +void CGlxTextEntryPopup::UpdateLeftSoftKeyL() + { + //Check whether the entered text length is bigger than zero + if( !CheckIfEntryTextOk () && !iAllowEmptyString) + { + MakeLeftSoftkeyVisible(EFalse); + } + else + { + MakeLeftSoftkeyVisible(ETrue); + } + } + +// ----------------------------------------------------------------------------- +// SetLeftSoftKeyL +// ----------------------------------------------------------------------------- +// +EXPORT_C void CGlxTextEntryPopup::SetLeftSoftKeyL(TBool aAllowEmptyString) + { + iAllowEmptyString = aAllowEmptyString; + } + +// ----------------------------------------------------------------------------- +// ConstructL +// ----------------------------------------------------------------------------- +// +void CGlxTextEntryPopup::ConstructL(const TDesC& aTitle) + { + SetPromptL(aTitle); + } + +// ----------------------------------------------------------------------------- +// RollbackState +// ----------------------------------------------------------------------------- +// +void CGlxTextEntryPopup::RollbackState(TAny* aParam) + { + TRACER( "CGlxTextEntryPopup::RollbackState" ); + TGlxTextEntryPopupRestoreState* restoreState + = static_cast( aParam ); + + // Rollback app state to previous state + GlxSetAppState::SetState( restoreState->iPreviousAppState ); + + if ( restoreState->iUiUtility) + { + TRAP_IGNORE( restoreState->iUiUtility->SetAppOrientationL( + restoreState->iPreviousOrientation ) ); + } + }