diff -r 000000000000 -r f979ecb2b13e notepad/notepad1/ViewerSrc/NpdViewerAppUi.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/notepad/notepad1/ViewerSrc/NpdViewerAppUi.cpp Tue Feb 02 10:12:19 2010 +0200 @@ -0,0 +1,119 @@ +/* +* Copyright (c) 2002 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: Implementation of Notepad Viewer Application UI class. +* +*/ + + +// INCLUDE FILES +#include +#include +#include +#include +#include "NpdViewerAppUi.h" +#include "NpdViewerDialog.h" + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CNotepadViewerAppUi::ConstructL +// ----------------------------------------------------------------------------- +// +void CNotepadViewerAppUi::ConstructL() + { + iCurrentFileOpened = EFalse; + BaseConstructL(EAknEnableSkin | EAknEnableMSK | EAknSingleClickCompatible); + iApi = CNotepadApi::NewL(); // AddResouceFile NpdLib.rsc + iApi->CreateViewerDialogL(EFalse); // create non-wait viewerdialog + iApi->Dialog()->SetMopParent(this); + STATIC_CAST(CNotepadViewerDialog*, iApi->Dialog())->ExecuteLD(); //non-wait + } + +// ----------------------------------------------------------------------------- +// CNotepadViewerAppUi::~CNotepadViewerAppUi +// Destructor. +// ----------------------------------------------------------------------------- +// +CNotepadViewerAppUi::~CNotepadViewerAppUi() + { + delete iApi; // Release Resource, delete dialog + if ( iDoorObserver ) + { + iDoorObserver->NotifyExit(MApaEmbeddedDocObserver::EEmpty); + } + } + +// ----------------------------------------------------------------------------- +// CNotepadViewerAppUi::HandleCommandL +// ----------------------------------------------------------------------------- +// +void CNotepadViewerAppUi::HandleCommandL(TInt aCommand) + { + switch ( aCommand ) + { + case EEikCmdExit: + { + Exit(); + } + break; + default: + break; + } + } + +// ----------------------------------------------------------------------------- +// CNotepadViewerAppUi::ProcessCommandParametersL +// From CEikAppUi +// ----------------------------------------------------------------------------- +// +TBool CNotepadViewerAppUi::ProcessCommandParametersL( + TApaCommand /*aCommand*/, + TFileName& aDocumentName, + const TDesC8& /*aTail*/ ) + { + // never call CEikAppUi::ProcessCommandParametersL(..) because + // it is so harmfull to overwrite and destroy aDocumentName. + // + return ConeUtils::FileExists(aDocumentName); + } + +// ----------------------------------------------------------------------------- +// CNotepadViewerAppUi::OpenFileL +// ----------------------------------------------------------------------------- +// +void CNotepadViewerAppUi::OpenFileL(const TDesC& aFilename) + { + if( !iCurrentFileOpened ) + { + iCurrentFileOpened = ETrue; + STATIC_CAST(CNotepadViewerDialog*, iApi->Dialog())->OpenFileL( + aFilename, NULL, ETrue ); // auto-detect encoding + } + } + +// ----------------------------------------------------------------------------- +// CNotepadViewerAppUi::OpenFileL(RFile& aFile) +// ----------------------------------------------------------------------------- +// +void CNotepadViewerAppUi::OpenFileL(RFile& aFile) + { + if( !iCurrentFileOpened ) + { + iCurrentFileOpened = ETrue; + STATIC_CAST(CNotepadViewerDialog*, iApi->Dialog())->OpenFileL( + aFile, NULL, ETrue ); // auto-detect encoding + } + } + +// End of File