📄 liancontainer.cpp
字号:
/*
* ============================================================================
* Name : CLianContainer from LianContainer.h
* Part of : Lian
* Created : 2006-3-15 by
* Implementation notes:
* Initial content was generated by Series 60 AppWizard.
* Version :
* Copyright:
* ============================================================================
*/
#include "LianContainer.h"
#include "fbs.h"
#include "Sound.h"
void CLianContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
beStart=EFalse;
iX=0;
iY=0;
iOldX=-1; //用于记录选定的单元格的位置
iOldY=-1;
iNum=30; //头像的个数
iLen=20; //单元格的大小
iW=6;
iH=8;
iCData=new(ELeave)CData(iW,iH,iNum);
iCMap=new(ELeave)CMap(iCData,iW,iH,_L("llk.mbm"),iNum,iLen);
iWelcome=new(ELeave)CFbsBitmap();
User::LeaveIfError( iWelcome->Load( _L("Z:\\SYSTEM\\apps\\LIAN\\llk2.mbm"),0 ) );
iSound1=CSound::NewL( _L("Z:\\SYSTEM\\apps\\LIAN\\move.wav") );
iSound2=CSound::NewL( _L("Z:\\SYSTEM\\apps\\LIAN\\clear.wav") );
SetRect(aRect);
ActivateL();
}
CLianContainer::~CLianContainer()
{
delete iCMap;
delete iCData;
delete iWelcome;
delete iSound1;
delete iSound2;
}
void CLianContainer::SizeChanged()
{
}
TInt CLianContainer::CountComponentControls() const
{
return 0; // return nbr of controls inside this container
}
CCoeControl* CLianContainer::ComponentControl(TInt aIndex) const
{
return NULL;
}
void CLianContainer::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
/**/if(!beStart )
{
gc.BitBlt(TPoint(0,0), iWelcome);
return;
}
gc.SetPenStyle(CGraphicsContext::ENullPen);
gc.SetBrushColor(KRgbGray);
gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
gc.DrawRect(aRect);
gc.BitBlt(TPoint(0,0),iCMap->iMap);
gc.SetPenStyle(CGraphicsContext::ESolidPen);
gc.SetBrushStyle(CGraphicsContext::ENullBrush);
if(iOldX>=0)
{
gc.SetPenColor(KRgbBlack);
gc.DrawRect(TRect(iOldX*iLen,iOldY*iLen,iOldX*iLen+iLen,iOldY*iLen+iLen));
}
gc.SetPenColor(KRgbRed);
gc.DrawRect(TRect(iX*iLen,iY*iLen,iX*iLen+iLen,iY*iLen+iLen));
}
void CLianContainer::HandleControlEventL(
CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
{
}
TKeyResponse CLianContainer::OfferKeyEventL(const TKeyEvent& aEvent,TEventCode aCode)
{
if(aCode!=EEventKey)
return EKeyWasNotConsumed;
switch(aEvent.iScanCode)
{
case 53:
case EStdKeyDevice3:
{
if(iOldX>=0) //第二次选中
{
if(iCData->UpdateGrid(iOldX,iOldY,iX,iY))
{
iCData->iData[iOldX][iOldY]=0;
iCData->iData[iX][iY]=0;
iCMap->UpdateGc();
iSound2->Play();
}
iOldX=-1;
iOldY=-1;
}
else //第一次选中
{
iOldX=iX;
iOldY=iY;
}
DrawDeferred();
break;
}
case EStdKeyUpArrow:
{
iSound1->Play();
if(iY>0)
iY--;
DrawDeferred();
break;
}
case EStdKeyDownArrow:
{
iSound1->Play();
if(iY<iH-1)
iY++;
DrawDeferred();
break;
}
case EStdKeyLeftArrow:
{
iSound1->Play();
if(iX>0)
iX--;
DrawDeferred();
break;
}
case EStdKeyRightArrow:
{
iSound1->Play();
if(iX<iW-1)
iX++;
DrawDeferred();
break;
}
default:
return EKeyWasNotConsumed;
}
return EKeyWasConsumed;
}
// End of File
void CLianContainer::StartGame(TInt iW, TInt iH)
{
if(iCData)
{
delete iCData;
iCData=new(ELeave)CData(iW,iH,iNum);
}
if(iCMap)
{
delete iCMap;
iCMap=new(ELeave)CMap(iCData,iW,iH,_L("llk.mbm"),iNum,iLen);
}
this->iW=iW;
this->iH=iH;
beStart=ETrue;
DrawDeferred();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -