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

📄 smsfunctioncontainer.cpp

📁 一个比较完整的有关移动开发的例子 vc++6.0下编译通过
💻 CPP
字号:

#include <gulicon.h>
#include <aknutils.h>    // definition of AKN_LAF_COLOR()
#include <avkon.hrh>
#include <akntitle.h>
#include <aknnotewrappers.h>
#include <stringloader.h> // StringLoader
#include <eikclbd.h>
#include <eiklabel.h>
#include <FairyLand.rsg>

#include "SMSListView.h"
#include "SMSOperationView.h"
#include "SMSFunctionContainer.h"
#include "FairyLandAppUi.h"
#include <FairyLand.mbg>
#include "SMSFunctionView.h"
#include "FairyLand.hrh"


#define MEM_FREE(p) if (NULL != (p)){delete (p); (p) = NULL;}

const TInt  BoxSize_Least = 0;
const TInt	BoxSize_Max = 3 ;



//////////////////////////////////////////////////////////////////////////
CSMSFunctionContainer::CSMSFunctionContainer()
{
   n_Status=0;

   m_pLabel1=NULL;
   m_pLabel2=NULL;
   m_pLabel3=NULL;
   m_pLabel4=NULL;

}	

// EPOC default constructor can leave.
void CSMSFunctionContainer::ConstructL(const TRect& aRect)
{
    CreateWindowL();
     

    m_pLabel1 = new(ELeave) CEikLabel;
	m_pLabel1->SetContainerWindowL(*this);
	TBuf<32> sTmpTitle1;
	CEikonEnv::Static()->ReadResource(sTmpTitle1, R_QTN_WRITE_SMS);
	m_pLabel1->SetTextL(sTmpTitle1);
	m_pLabel1->SetExtent(TPoint(60,21), m_pLabel1->MinimumSize());

    m_pLabel2 = new(ELeave) CEikLabel;
	m_pLabel2->SetContainerWindowL(*this);
	TBuf<32> sTmpTitle2;
	CEikonEnv::Static()->ReadResource(sTmpTitle2, R_QTN_IN_BOX);
	m_pLabel2->SetTextL(sTmpTitle2);
	m_pLabel2->SetExtent(TPoint(60,49), m_pLabel2->MinimumSize());
    
	m_pLabel3 = new(ELeave) CEikLabel;
	m_pLabel3->SetContainerWindowL(*this);
	TBuf<32> sTmpTitle3;
	CEikonEnv::Static()->ReadResource(sTmpTitle3, R_QTN_DRAFT_BOX);
	m_pLabel3->SetTextL(sTmpTitle3);
	m_pLabel3->SetExtent(TPoint(60,77), m_pLabel3->MinimumSize());

	m_pLabel4 = new(ELeave) CEikLabel;
	m_pLabel4->SetContainerWindowL(*this);
	TBuf<32> sTmpTitle4;
	CEikonEnv::Static()->ReadResource(sTmpTitle4, R_QTN_SENT_BOX);
	m_pLabel4->SetTextL(sTmpTitle4);
	m_pLabel4->SetExtent(TPoint(60,105), m_pLabel4->MinimumSize());

	SetRect( aRect );
    ActivateL();

}

// destructor
CSMSFunctionContainer::~CSMSFunctionContainer()
{
   MEM_FREE(m_pLabel1);
   MEM_FREE(m_pLabel2);
   MEM_FREE(m_pLabel3);
   MEM_FREE(m_pLabel4);
   
}

void CSMSFunctionContainer::SizeChanged()
{

}

// ---------------------------------------------------------
// CSMSFunctionContainer::CountComponentControls() const
// return the number of controls
// ---------------------------------------------------------
//
TInt CSMSFunctionContainer::CountComponentControls() const
{
	// return number of controls inside this container
	return 4; 
}

// ---------------------------------------------------------
// CSMSFunctionContainer::ComponentControl(TInt aIndex) const
// return the pointer to specified control.
// ---------------------------------------------------------
//
CCoeControl* CSMSFunctionContainer::ComponentControl( TInt aIndex ) const
{
	switch (aIndex)
	{
	case 0:
		{
			return m_pLabel1;
			break;
		}
	case 1:
		{
			return m_pLabel2;
			break;
		}
	case 2:
		{
			return m_pLabel3;
			break;
		}
	case 3:
		{
			return m_pLabel4;
			break;
		}
	

	default:
		{
			return NULL;
			break;
		}
	}

}

// ---------------------------------------------------------
// CSMSFunctionContainer::Draw(const TRect& aRect) const
// handle the message when client region must be redrawn.
// ---------------------------------------------------------
//
void CSMSFunctionContainer::Draw( const TRect& /*aRect*/ ) const
{
	CWindowGc& gc = SystemGc();
 //	gc.DrawRect(Rect());  
	gc.Clear();
	gc.SetBrushStyle(CGraphicsContext::ESolidBrush);  
 	gc.SetBrushColor(KRgbWhite);

	gc.DrawLine(TPoint(53,0),TPoint(53,142));  
	gc.DrawLine(TPoint(53,142),TPoint(174,142));
	////////////////////////////////////////////////////

//	const CFont* iFontTemp = iEikonEnv->LegendFont();
//	gc.UseFont(iFontTemp);
//	TBuf<32> sBuf;
//	CEikonEnv::Static()->ReadResource(sBuf, R_QTN_TEAM1_WRITEMESSAGE);
//	gc.DrawText(sBuf, TPoint(50,21));
//	CEikonEnv::Static()->ReadResource(sBuf, R_QTN_TEAM1_OUTBOX);
//	gc.DrawText(sBuf, TPoint(50,49));
//	CEikonEnv::Static()->ReadResource(sBuf, R_QTN_TEAM1_INBOX);
//	gc.DrawText(sBuf, TPoint(50,77));	
//	CEikonEnv::Static()->ReadResource(sBuf, R_QTN_TEAM1_DRAFT);
//	gc.DrawText(sBuf, TPoint(50,105));



	TBuf<KMaxPath> pathMbm;
    #ifdef __WINS__
	pathMbm.Copy(_L("z:\\system\\apps\\fairyland\\fairyland.mbm"));
#else
	CFairyLandAppUi* pApp = (CFairyLandAppUi*)CEikonEnv::Static()->AppUi();
	pApp->GetAppPath(pathMbm);
	pathMbm.Append(_L("fairyland.mbm"));
#endif                                                          
	CFbsBitmap* bitleftmap1 = iEikonEnv->CreateBitmapL(pathMbm, EMbmFairylandSmsfunction1); 
	//CFbsBitmap* bitmapMask1 = iEikonEnv->CreateBitmapL(pathMbm, EMbmFairylandSMSFunction1_mask);
    gc.BitBlt(TPoint(10,15), bitleftmap1);
  
	CFbsBitmap* bitleftmap2 = iEikonEnv->CreateBitmapL(pathMbm, EMbmFairylandSmsfunction2);
	//CFbsBitmap* bitmapMask2 = iEikonEnv->CreateBitmapL(pathMbm, EMbmFairylandSMSFunction2_mask);
    gc.BitBlt(TPoint(12,43), bitleftmap2);
  
	CFbsBitmap* bitleftmap3 = iEikonEnv->CreateBitmapL(pathMbm, EMbmFairylandSmsfunction3);
	//CFbsBitmap* bitmapMask3 = iEikonEnv->CreateBitmapL(pathMbm, EMbmFairylandSMSFunction3_mask);
  gc.BitBlt(TPoint(12,71), bitleftmap3);
  
	CFbsBitmap* bitleftmap4 = iEikonEnv->CreateBitmapL(pathMbm, EMbmFairylandSmsfunction4);
	//CFbsBitmap* bitmapMask4 = iEikonEnv->CreateBitmapL(pathMbm, EMbmFairylandSMSFunction4_mask);
  gc.BitBlt(TPoint(10,99), bitleftmap4);
  
  CFbsBitmap* bitmap1 = iEikonEnv->CreateBitmapL(pathMbm, EMbmFairylandSmsfunction5);

	
	switch (n_Status)
	{
	case 0:
		{
			
		    gc.BitBlt(TPoint(56,15), bitmap1);
			
			break;
		}
	case 1:
		{
			
			gc.BitBlt(TPoint(56, 43), bitmap1);
			break;
		}
	case 2:
		{  
			gc.BitBlt(TPoint(56, 71), bitmap1);
			break;

		}
	case 3:
		{
            gc.BitBlt(TPoint(56, 99), bitmap1);
			break;
		}
	}
	MEM_FREE(bitleftmap1);
	MEM_FREE(bitleftmap2);
	MEM_FREE(bitleftmap3);
	MEM_FREE(bitleftmap4);
	MEM_FREE(bitmap1);
}

// ---------------------------------------------------------
// CAknExGridContainer::OfferKeyEventL(
//           const TKeyEvent& aKeyEvent, TEventCode aType )
// Handles the key events.
// ---------------------------------------------------------
//
TKeyResponse CSMSFunctionContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType )
{

	if( (aKeyEvent.iCode == EKeyUpArrow) && (aType == EEventKey))
	{
		if(n_Status == BoxSize_Least)
		{
			n_Status = BoxSize_Max;
			DrawNow();
		}
		else
		{
			n_Status--;
			DrawNow();

		}
	
		DrawDeferred();
	
       
	}
	
	else if( (aKeyEvent.iCode == EKeyDownArrow) && (aType == EEventKey))
	{
		if(n_Status == BoxSize_Max)
		{
			n_Status = BoxSize_Least;
			DrawNow();
		}
		else
		{
			n_Status++;
			DrawNow();
		}
	
		DrawDeferred();
	}
	else if ((aKeyEvent.iCode == EKeyDevice3) && (aType == EEventKey))
	{
		CFairyLandAppUi* pApp=(CFairyLandAppUi*)CEikonEnv::Static()->AppUi();
		if (n_Status==0)
		{
			pApp->ActivateLocalViewL(KViewId14);
		}
		else if (n_Status==1)
		{
			pApp->ActivateLocalViewL(KViewId13,KViewId12,_L8("1"));
		}
		else if (n_Status==2)
		{
			pApp->ActivateLocalViewL(KViewId13,KViewId12,_L8("2"));
		}
		else if (n_Status==3)
		{
			pApp->ActivateLocalViewL(KViewId13,KViewId12,_L8("3"));
		}
	}

	return EKeyWasConsumed;

}



TInt CSMSFunctionContainer::GetIndex()
{
	return n_Status;
}

⌨️ 快捷键说明

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