applications/Symbian_MiniGUI_TestApp/grid.cpp
changeset 46 b6935a90ca64
child 67 57a5a30dc911
equal deleted inserted replaced
45:01c1ffcc4fca 46:b6935a90ca64
       
     1 #include <w32std.h> 
       
     2 #include "profiler.h"
       
     3 
       
     4 const TSize KSize(64,60);
       
     5 const TInt KRow = 4;
       
     6 const TInt KCol = 5; 
       
     7 
       
     8 void MainL()	
       
     9 	{	
       
    10 	RWsSession ws;
       
    11 	ws.Connect();
       
    12  	CWsScreenDevice* scr = new(ELeave) CWsScreenDevice(ws);
       
    13 	scr->Construct();
       
    14  	CWindowGc* gc = new(ELeave) CWindowGc(scr);
       
    15 	gc->Construct();
       
    16  	RWindowGroup grp(ws);
       
    17 	grp.Construct(0xc0decafe, ETrue);
       
    18  	RWindow win(ws);
       
    19 	win.Construct(grp, 0xbeefcafe);
       
    20 	win.SetExtent(TPoint(20,160), TSize(320,240));
       
    21 	win.Activate();
       
    22  	win.Invalidate();
       
    23 	win.BeginRedraw();
       
    24 	gc->Activate(win);
       
    25  	gc->SetPenStyle(CGraphicsContext::ENullPen);
       
    26 	gc->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
    27  	TBool color = EFalse;
       
    28 
       
    29 if (Profiler::Start() == KErrNotFound)
       
    30 	{
       
    31 	_LIT(KProfiler,"profiler");
       
    32 	_LIT(KStart,"start -noui -drive=S");
       
    33 	RProcess p;
       
    34 	if (p.Create(KProfiler,KStart) == KErrNone)
       
    35 		{
       
    36 		p.Resume();
       
    37 		p.Close();
       
    38 		}
       
    39 	}
       
    40 
       
    41 	for (TInt col=0; col<KCol; ++col)
       
    42 		{
       
    43 		color = !color;		
       
    44 		for (TInt row=0; row<KRow; ++row)
       
    45 			{
       
    46 			TRect rect;
       
    47 			rect.iTl.iX = col * KSize.iWidth;
       
    48 			rect.iTl.iY = row * KSize.iHeight;
       
    49 			rect.SetSize(KSize);
       
    50 			color = !color;
       
    51 			gc->SetBrushColor(color? KRgbGray : KRgbBlack);
       
    52 			gc->DrawRect(rect);
       
    53 			}
       
    54 	}
       
    55 	gc->Deactivate();
       
    56 	win.EndRedraw();
       
    57 	ws.Flush();
       
    58  	User::After(3000000);
       
    59  	win.Close();
       
    60 	grp.Close();
       
    61 	delete gc;
       
    62 	delete scr;
       
    63 	ws.Close();
       
    64 
       
    65 	Profiler::Stop();
       
    66 	Profiler::Close();
       
    67 	Profiler::Unload();
       
    68 
       
    69 	} 
       
    70 
       
    71 
       
    72 GLDEF_C TInt E32Main()	
       
    73 {	
       
    74 
       
    75 	CTrapCleanup* tc = CTrapCleanup::New();	
       
    76 	if (!tc)
       
    77 		{		
       
    78 		return KErrNoMemory;
       
    79 		}
       
    80 	TRAPD(err, MainL());
       
    81 	delete tc;
       
    82  	return err;	
       
    83 }