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

📄 mementomainview.cpp

📁 symbian手机加密记事本
💻 CPP
字号:
/*
* ============================================================================
*  Name     : CMementoMainView from CAknView
*  Part of  : MementoMain
*  Copyright (c) 2003 Nokia. All rights reserved.
* ============================================================================
*/

// INCLUDE FILES
#include <aknviewappui.h>
#include <avkon.hrh>
#include <aknnotewrappers.h> 
#include <Memento.rsg>
#include "Memento.hrh"
#include "MementoAppUi.h"
#include "MementoMainView.h"
#include "MementoMainContainer.h" 
#include "DirView.h"

// ================= MEMBER FUNCTIONS =======================

// C++ default constructor can NOT contain any code, that
// might leave.
//
CMementoMainView* CMementoMainView::NewL()
{
    CMementoMainView* self = NewLC();
    CleanupStack::Pop(self);
    return self;
}

CMementoMainView* CMementoMainView::NewLC()
{
    CMementoMainView* self = new (ELeave) CMementoMainView;
    CleanupStack::PushL(self);
    self->ConstructL();
    return self;
}

CMementoMainView::CMementoMainView()
    {
    }

// EPOC default constructor can leave.
void CMementoMainView::ConstructL()
    {
    BaseConstructL(R_ONE_VIEW);
    }

// Destructor
CMementoMainView::~CMementoMainView()
    {
    }

// ---------------------------------------------------------
// TUid CMementoMainView::Id()
// Returns Id of the view.
// ---------------------------------------------------------
TUid CMementoMainView::Id() const
    {
    return KViewId3;
    }

// ---------------------------------------------------------
// CMementoMainView::HandleCommandL(TInt aCommand)
// Handles commands
// ---------------------------------------------------------
void CMementoMainView::HandleCommandL(TInt aCommand)
    {
		switch(aCommand)
		{
		case EMazhiminDakai2:
			{	
			if (iContainer->GetItem() == 0)
			{
//				((CMementoAppUi*)CEikonEnv::Static()->AppUi())->GetDirPtr()->changeMenu();
				AppUi()->ActivateLocalViewL(KViewId2);		//调用UI中的View切换函数 
			}
			else
			{
			TBuf<32> chinese;
			CEikonEnv::Static()->ReadResource(chinese, R_QTN_MH_GRID_HEPL_TXT2);
 //           _LIT(message,"building..");
            CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
            informationNote->ExecuteLD(chinese);
			}
			break;
			}

		case EMazhiminBangzhu3:
			{	
			iContainer->setHelp(ETrue);

			HBufC* Helppath = HBufC::NewLC(KMaxPath);
			TPtr PtrHelp(Helppath->Des());
			_LIT(KMainHelp,"MainHelp.txt");
			_LIT(KFilePath,"C:\\system\\apps\\Memento\\");
			PtrHelp.Copy(KFilePath);
			PtrHelp.Append(KMainHelp);

			RFs fs;
			RFile file;
			User::LeaveIfError(fs.Connect());
			
			if( file.Open(fs,PtrHelp,EFileRead) != KErrNone)
			{
				fs.Close();
				CleanupStack::PopAndDestroy(Helppath);
				return;
			}
			TInt filesize = 0;
			file.Size(filesize);
			
			HBufC* Text = HBufC::NewL(filesize);

			TPtr8 ptrText((TUint8*)Text->Ptr(),filesize);
			file.Read(ptrText,filesize);
			
			HBufC16* buf16 = HBufC16::New(filesize);
			buf16->Des().Copy(ptrText);
			iContainer->GetEditHelpPtr()->SetTextL(&(buf16->Des()));
			CleanupStack::PopAndDestroy(Helppath);
			file.Close();
			fs.Close();

			Cba()->SetCommandSetL(R_CBA_HELP);
			Cba()->DrawNow();
			break;
			}
		case EMementoReturn:
			{
				iContainer->setHelp(EFalse);
				Cba()->SetCommandSetL(R_LOG_CBA);
				Cba()->DrawNow();
				break;
			}
		default:
			{
				AppUi()->HandleCommandL(aCommand);
				break;
			}
		}
	}

// ---------------------------------------------------------
// CMementoMainView::HandleClientRectChange()
// Handles client rect change.
// ---------------------------------------------------------
void CMementoMainView::HandleClientRectChange()
    {
    if (iContainer)
        {
        iContainer->SetRect(ClientRect());
        }
    }

// ---------------------------------------------------------
// CMementoMainView::DoActivateL(...)
// Creates the Container class object.
// ---------------------------------------------------------
void CMementoMainView::DoActivateL(const TVwsViewId& /*aPrevViewId*/,
                                    TUid /*aCustomMessageId*/,
                                    const TDesC8& /*aCustomMessage*/)
    {
    iContainer = new (ELeave) CMementoMainContainer;
    iContainer->SetMopParent(this);

	TRect rc;
	rc.SetRect(ClientRect().iTl, TSize(176, 144));
    iContainer->ConstructL(rc);
    AppUi()->AddToStackL(*this, iContainer);
    }

// ---------------------------------------------------------
// CMementoMainView::DoDeactivate()
// Deletes the Container class object.
// ---------------------------------------------------------
void CMementoMainView::DoDeactivate()
    {
    if (iContainer)
        {
		AppUi()->RemoveFromStack(iContainer);
		delete iContainer;
		iContainer = NULL;
        }
    }

// End of File

⌨️ 快捷键说明

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