lafagnosticuifoundation/cone/tef/tmultiptrtestcompoundcontrolcontainer.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <techview/eikcmbut.h>
       
    17 #include "tmultiptrtestchildcontrol.h"
       
    18 #include "tmultiptrtestcompoundcontrolcontainer.h"
       
    19 
       
    20 
       
    21 CMultPtrTestCompoundControlContainer::~CMultPtrTestCompoundControlContainer()
       
    22     {
       
    23     // Deletes the controls. 
       
    24     Components().ResetAndDestroy();
       
    25     }
       
    26 
       
    27 
       
    28 CMultPtrTestCompoundControlContainer::CMultPtrTestCompoundControlContainer()
       
    29     {
       
    30     }
       
    31 
       
    32 
       
    33 void CMultPtrTestCompoundControlContainer::ConstructL( const TRect& aRect )
       
    34     {
       
    35     CreateWindowL();
       
    36 	Window().EnableAdvancedPointers();
       
    37     SetBlank();
       
    38     
       
    39 	TRect containerRect(aRect);
       
    40 	SetRect( containerRect );
       
    41 	ActivateL();
       
    42 	//Window().PointerFilter( (EPointerFilterMove | EPointerFilterDrag), 0 );
       
    43 	InitComponentArrayL();
       
    44 	
       
    45 	TRect ourRect = Rect();
       
    46 	
       
    47 	
       
    48 	iChildOne = new(ELeave) CMultiPtrTestChildControl;
       
    49 	Components().SetControlsOwnedExternally( EFalse );
       
    50 	const TInt KChildOneID = 1;
       
    51    	Components().AppendLC( iChildOne, KChildOneID ) ;
       
    52 	iChildOne->ConstructL( _L("Child1") );
       
    53 	CleanupStack::Pop( iChildOne );
       
    54 		
       
    55 	iChildOne->SetParent( this );
       
    56 	iChildOne->SetExtent( TPoint(20,20), TSize(120,120) );
       
    57 	iChildOne->ActivateL();
       
    58 	iChildOne->DrawNow();
       
    59 
       
    60 	
       
    61 	iChildTwo = new(ELeave) CMultiPtrTestChildControl;
       
    62 	const TInt KChildTwoID = 2;
       
    63    	Components().AppendLC( iChildTwo, KChildTwoID ) ;
       
    64    	iChildTwo->ConstructL( _L("Child2") );
       
    65 	CleanupStack::Pop( iChildTwo );
       
    66 		
       
    67 	iChildTwo->SetParent( this );
       
    68 	iChildTwo->SetExtent( TPoint(80,60), TSize(120,60) );
       
    69 	iChildTwo->ActivateL();
       
    70 	iChildTwo->DrawNow();	
       
    71     }
       
    72 
       
    73 
       
    74 void CMultPtrTestCompoundControlContainer::Draw(const TRect& ) const
       
    75 	{
       
    76 	const TRect rect=Rect();
       
    77 	CWindowGc& gc=SystemGc();
       
    78 	gc.SetPenStyle(CGraphicsContext::ESolidPen );
       
    79 	gc.SetPenColor( KRgbBlack );
       
    80 	gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
       
    81 	gc.SetBrushColor(KRgbBlack);	
       
    82 	gc.DrawRect( Rect() );
       
    83 	gc.SetPenStyle(CGraphicsContext::ENullPen );
       
    84 	
       
    85 	TRect portionRect( 0,0,0,0 );
       
    86 	TInt dY = rect.Height() / 5;
       
    87 	TInt dX = rect.Width() / 10;
       
    88 	TInt diceY = 0;
       
    89 	TInt diceX = 0;
       
    90 	TBool black = ETrue;
       
    91 	TRgb colourOne( 0x0000FF00, 0x7F );
       
    92 	TRgb colourTwo( 0x000000FF, 0x7F );
       
    93 	
       
    94 	for( diceY = rect.iTl.iY; diceY < rect.Height(); diceY += dY )
       
    95 		{
       
    96 		
       
    97 		for( diceX = rect.iTl.iX; diceX < rect.Width(); diceX += dX )
       
    98 			{	
       
    99 			portionRect.iTl.iX = diceX;
       
   100 			portionRect.iTl.iY = diceY;
       
   101 			portionRect.iBr.iX = diceX + dX;
       
   102 			portionRect.iBr.iY = diceY + dY;
       
   103 			
       
   104 			if( black )	
       
   105 				{
       
   106 				gc.SetBrushColor( colourOne );
       
   107 				black = EFalse;	
       
   108 				}
       
   109 			else
       
   110 				{
       
   111 				gc.SetBrushColor( colourTwo );
       
   112 				black = ETrue;	
       
   113 				}
       
   114 				
       
   115 			gc.DrawRect( portionRect );
       
   116 			
       
   117 			}
       
   118 		
       
   119 		dX /= 2;
       
   120 		}
       
   121 	
       
   122 	}
       
   123 
       
   124 
       
   125 void CMultPtrTestCompoundControlContainer::HandlePointerEventL(const TPointerEvent& aPointerEvent)
       
   126 	{
       
   127 	CCoeControl::HandlePointerEventL( aPointerEvent );
       
   128 	}
       
   129 
       
   130