Symbian Learning Notes (8)--try to do a Sudoku game again

Source: Internet
Author: User
Tags printf

Still do a Sudoku game with the same function as the interface, but it took much more time than I did with Android or J2ME, and of course it was pretty obvious (I ran the J2ME implementation on N73 because the code for redrawing the screen wasn't optimized, so it didn't work. But the same algorithm runs quite smoothly on brew or Symbian.

This time I'm going to talk about some of the problems I've encountered in the Symbian version, and I hope I don't make the same mistake again.

1, multi-view application framework Issues

I am using the carbide C + + IDE environment, I do not know why can not generate a multi-view shelf, so only in the HelloWorld framework of the code on their own manual rewrite, the result is a panic toss me for a long time, The problem is that you do not delete the created caknview in the destructor, the following code (note is correct, otherwise it will go wrong when exiting the application):

CSuDoScAppUi::~CSuDoScAppUi()
...{
// if(iAppCtrol!=NULL){
// this->RemoveView(iAppCtrol->Id());
// delete iAppCtrol;
// iAppCtrol=NULL;
//
// RDebug::Printf("delete iAppCtrol");
// }
// RDebug::Printf("delete Ui");
}

The place where we need to clear the object is to delete the Ccoecontrol in the Caknview because it is responsible for creating and deleting Coecontrol in its Doactivatel/dodeactivatel two functions, However, if this dodeactivatel is not invoked when exiting, it can be invoked at the time of the destructor:

CSuDoScAppCtrol::~CSuDoScAppCtrol()
...{
iFs.Close();
iList.Close();

DoDeactivate();

RDebug::Printf("delete Ctrol");
}

2, about the problem of displaying fonts

When calling CWINDOWGC's DrawText method, you must set the font otherwise there will be no display, and there is a standard code for the font to refer to (from the Internet):

CWindowGc& gc = SystemGc();
CFont *font = NULL;
TFontSpec fontSpec = iEikonEnv->LegendFont()->FontSpecInTwips();
fontSpec.iHeight -= fontSpec.iHeight / 6;

iCoeEnv->ScreenDevice()->GetNearestFontInTwips( font, fontSpec );
gc.UseFont( font );

// do sth.

gc.DiscardFont();
iCoeEnv->ScreenDevice()->ReleaseFont( font );

3, on the SVG image display

I have all the digital images in the SVG format, the SVG image must be set when the size, otherwise it can not be displayed. In addition, because its background color is white at the time of manufacture, it needs to be mask to display it as transparent.

for(TInt i=0,j=0;i<9;i++,j+=2)...{
CFbsBitmap * b=NULL;
CFbsBitmap * c=NULL;
AknIconUtils::CreateIconL(b,c,iMFileName,EMbmSudoscY1+j,EMbmSudoscY1+j+1);
AknIconUtils::SetSize(b, TSize(22, 22));
AknIconUtils::SetSize(c, TSize(22, 22));
iThumbNormal.AppendL(b);
iThumbNormalMask.AppendL(c);
}

Ithumbnormal and Ithumbnormalmask are two Rpointerarray objects, where I load all the digital graphs when I contructl, which can effectively mitigate the splash screen that was loaded when redrawing. And then when it's displayed, you can:

if( CSuDoScHelper::CheckGrid(iGrid,i%9,i/9,iGrid[i].value) )
gc.BitBltMasked(TPoint(xx,yy),iThumbNormal[iGrid[i].value-1],r,iThumbNormalMask[iGrid[i].value-1], EFalse);
else
gc.BitBltMasked(TPoint(xx,yy),iThumbError[iGrid[i].value-1],r,iThumbErrorMask[iGrid[i].value-1], EFalse);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.