⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 camdecode_3rdappui.cpp

📁 PartiTekSDK.chm is for windows, Unix/Linux and WinCE/WinMobile platform. SDK_Manul_Symbian.pdf i
💻 CPP
字号:
/*
============================================================================
 Name        : CamDecode_3rdAppUi.cpp
 Author      : 
 Version     :
 Copyright   : Your copyright notice
 Description : Main application UI class (controller)
============================================================================
*/

// INCLUDE FILES
#include <avkon.hrh>
#include <aknmessagequerydialog.h>
#include <aknnotewrappers.h>
#include <stringloader.h>
#include <CamDecode_3rd.rsg>
#include <f32file.h>
#include <s32file.h>
#include <bautils.h>
#include <charconv.h>
#include <hlplch.h>

#include "CamDecode_3rd.pan"
#include "CamDecode_3rdApplication.h"
#include "CamDecode_3rdAppUi.h"
#include "CamDecode_3rdAppView.h"
#include "CamDecode_3rd.hrh"

#include "CamDecode_3rd_0xe5fb49dc.hlp.hrh"
// ============================ MEMBER FUNCTIONS ===============================


// -----------------------------------------------------------------------------
// CCamDecode_3rdAppUi::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CCamDecode_3rdAppUi::ConstructL()
	{
	// Initialise app UI with standard value.
	BaseConstructL();

	// Create view object
	//iAppView = CCamDecode_3rdAppView::NewL( ClientRect() );

	iAppView = new (ELeave) CCamDecode_3rdAppView;
	iAppView->SetMopParent( this );
	iAppView->ConstructL( ClientRect() );
	AddToStackL( iAppView );
	
	PrivacyStatementL();
	}
// -----------------------------------------------------------------------------
// CCamDecode_3rdAppUi::CCamDecode_3rdAppUi()
// C++ default constructor can NOT contain any code, that might leave.
// -----------------------------------------------------------------------------
//
CCamDecode_3rdAppUi::CCamDecode_3rdAppUi()
	{
	// No implementation required
	}

// -----------------------------------------------------------------------------
// CCamDecode_3rdAppUi::~CCamDecode_3rdAppUi()
// Destructor.
// -----------------------------------------------------------------------------
//
CCamDecode_3rdAppUi::~CCamDecode_3rdAppUi()
	{
	if ( iAppView )
		{
		RemoveFromStack( iAppView );
		delete iAppView;
		iAppView = NULL;
		}
	}

// -----------------------------------------------------------------------------
// CCamDecode_3rdAppUi::HandleCommandL()
// Takes care of command handling.
// -----------------------------------------------------------------------------
//
void CCamDecode_3rdAppUi::HandleCommandL( TInt aCommand )
	{
	switch( aCommand )
		{
		case EEikCmdExit:
		case EAknSoftkeyExit:
			Exit();
			break;
		case ECamDecode_3rdCommand1:
			{
			// Load a string from the resource file and display it
			//HBufC* textResource = StringLoader::LoadLC( R_HEWB_COMMAND1_TEXT );
			//
			//// Show the information Note with
			//// textResource loaded with StringLoader.
			//CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote;
			//informationNote->ExecuteLD( *textResource );

			//// Pop HBuf from CleanUpStack and Destroy it.
			//CleanupStack::PopAndDestroy( textResource );

				iAppView->StartFromMenu();
			}
			break;
		case EHelp:
			{
			CArrayFix<TCoeHelpContext>* buf = CCoeAppUi::AppHelpContextL();
			HlpLauncher::LaunchHelpApplicationL(iEikonEnv->WsSession(), buf);
			}
			break;
		case EAbout:
			{
			CAknMessageQueryDialog* dlg = new (ELeave)CAknMessageQueryDialog(); 
			dlg->PrepareLC(R_ABOUT_QUERY_DIALOG);
			HBufC* title = iEikonEnv->AllocReadResourceLC(R_ABOUT_DIALOG_TITLE);
			dlg->QueryHeading()->SetTextL(*title);
			CleanupStack::PopAndDestroy(); //title
			HBufC* msg = iEikonEnv->AllocReadResourceLC(R_ABOUT_DIALOG_TEXT);
			dlg->SetMessageTextL(*msg);
			CleanupStack::PopAndDestroy(); //msg
			dlg->RunLD(); 
			}
			break;

		default:
			Panic( ECamDecode_3rdUi );
			break;
		}
	}

TKeyResponse CCamDecode_3rdAppUi::HandleKeyEventL(
	const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
	{
		if( iAppView->iCamStart )
		{
			switch ( aKeyEvent.iCode )
			{
			case EKeyUpArrow:  
					{
						iAppView->SetZoomL( ETrue );

					return EKeyWasConsumed;
					break;
					}
				
			case EKeyDownArrow:  
					{
						iAppView->SetZoomL( EFalse );

					return EKeyWasConsumed;
					break;
					}
			default:
					{
					 return EKeyWasNotConsumed;
					}
			}
		}
		return EKeyWasNotConsumed;
	}

// -----------------------------------------------------------------------------
//  Called by the framework when the application status pane
//  size is changed.  Passes the new client rectangle to the
//  AppView
// -----------------------------------------------------------------------------
//
void CCamDecode_3rdAppUi::HandleStatusPaneSizeChange()
	{
	iAppView->SetRect( ClientRect() );
	
	}

CArrayFix<TCoeHelpContext>* CCamDecode_3rdAppUi::HelpContextL() const
	{
	// Note: help will not work if the application uid3 is not in the
	// protected range.  The default uid3 range for projects created
	// from this template (0xE0000000 - 0xEFFFFFFF) are not in the protected range so they
	// can be self signed and installed on the device during testing.
	// Once you get your official uid3 from Symbian Ltd. and find/replace
	// all occurrences of uid3 in your project, the context help will
	// work.
	CArrayFixFlat<TCoeHelpContext>* ctxs = new(ELeave)CArrayFixFlat<TCoeHelpContext>(1);
	CleanupStack::PushL(ctxs);
	ctxs->AppendL(TCoeHelpContext(KUidCamDecode_3rdApp, KGeneral_Information));
	CleanupStack::Pop(ctxs);
	return ctxs;
	}
	
void CCamDecode_3rdAppUi::PrivacyStatementL() 
	{
	// Note: to see privacy statement in emulator, copy
	// PrivacyStatement.txt from group/ directory to 
	// %EPOCROOT%\Epoc32\release\winscw\udeb\z\private\e5fb49dc\
	// Also note that on emulator you can't modify files on Z: drive,
	// so even if you answer Yes to privacy statement, it will popup
	// dialog every time you launch application. But on device it will work
	// as expected.
	HBufC * fileName = StringLoader::LoadLC(R_PRIVACY_STATEMENT_FILENAME);
	RFs &fs= iCoeEnv->FsSession();
	
	// Make full path to privacy statement
	TFileName fullFileName;
	TFileName privatePath;
	fs.PrivatePath(privatePath);
	TParse parser;
	TFileName processFileName(RProcess().FileName());
	User::LeaveIfError(parser.Set(*fileName, &privatePath, &processFileName));
	fullFileName = parser.FullName();
	CleanupStack::PopAndDestroy(fileName);
	
	if(BaflUtils::FileExists(fs, fullFileName)) 
		{
		RBuf text(CCamDecode_3rdAppUi::ReadUnicodeFileL(fs, fullFileName));
		CleanupClosePushL(text);
		CAknMessageQueryDialog *dialog = CAknMessageQueryDialog::NewL(text);
		if(dialog->ExecuteLD(R_PRIVSTMT_DIALOG) == EAknSoftkeyYes) 
			{
			BaflUtils::DeleteFile(fs, fullFileName);
			}
		CleanupStack::PopAndDestroy(&text);
		}
	}

HBufC * CCamDecode_3rdAppUi::ReadUnicodeFileL(RFs& aFs, const TDesC& aFileName)
	{
	RFile file;
	User::LeaveIfError(file.Open(aFs, aFileName, EFileShareReadersOnly | EFileStreamText | EFileRead));
	CleanupClosePushL(file);

	TInt size;
	User::LeaveIfError(file.Size(size));

	RBuf8 tmp;
	tmp.CreateL(size);
	CleanupClosePushL(tmp);
	User::LeaveIfError(file.Read(tmp));

	CCnvCharacterSetConverter * converter = CCnvCharacterSetConverter::NewLC();
	converter->PrepareToConvertToOrFromL(KCharacterSetIdentifierUtf8, aFs);

	HBufC *text = HBufC::NewL(size);

	TInt state = CCnvCharacterSetConverter::KStateDefault;
	TPtrC8 remainderOfForeignText(tmp);
	for(;;)
		{
		TPtr textPtr(text->Des());
		TInt retValue = converter->ConvertToUnicode(textPtr, remainderOfForeignText, state);
		if(retValue == CCnvCharacterSetConverter::EErrorIllFormedInput)
			User::Leave(KErrCorrupt);
		else if(retValue < 0)
			User::Leave(KErrGeneral);
		
		if(retValue == 0)
			break;
			
		remainderOfForeignText.Set(remainderOfForeignText.Right(retValue));
		}	
	
	CleanupStack::PopAndDestroy(converter);
	CleanupStack::PopAndDestroy(2);
	return text;
	}
		
void CCamDecode_3rdAppUi::Setmenu()	
{
	CEikButtonGroupContainer   *cba   =   CEikButtonGroupContainer::Current();  
	cba-> MakeCommandVisible(EAknSoftkeyOptions,false); 

}
// End of File

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -