|
1 // Copyright (c) 2005-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 /** |
|
17 @file |
|
18 @internalComponent - Internal Symbian test code |
|
19 */ |
|
20 |
|
21 |
|
22 #include "TCone7Step.h" |
|
23 |
|
24 |
|
25 CCtlSuperContainer641::CCtlSuperContainer641() |
|
26 { |
|
27 } |
|
28 |
|
29 CCtlSuperContainer641::~CCtlSuperContainer641() |
|
30 { |
|
31 // kids should be destroyed automatically |
|
32 delete iName; |
|
33 } |
|
34 |
|
35 void CCtlSuperContainer641::ConstructL( const TDesC& aName ) |
|
36 { |
|
37 CCtlBase641::ConstructL(); |
|
38 |
|
39 // construct the kids, add them to the array. |
|
40 iName = aName.AllocL(); |
|
41 CreateWindowL(); |
|
42 |
|
43 iSubContainer = new (ELeave) CCtlSubContainer641; |
|
44 InitComponentArrayL(); |
|
45 Components().AppendLC( iSubContainer, KChildOneID ) ; |
|
46 iSubContainer->ConstructL( _L("subcontainer") ); |
|
47 CleanupStack::Pop( iSubContainer ); |
|
48 |
|
49 iSubContainer->SetParent( this ); |
|
50 |
|
51 ActivateL(); |
|
52 } |
|
53 |
|
54 void CCtlSuperContainer641::SizeChanged() |
|
55 { |
|
56 // set the size of the children |
|
57 TRect rect = Rect(); |
|
58 TSize size = rect.Size(); |
|
59 TPoint tl = rect.iTl; |
|
60 |
|
61 |
|
62 TInt childCount = CountComponentControls(); |
|
63 if ( childCount > 0 ) |
|
64 { |
|
65 size.iWidth = (size.iWidth *5 )/10; |
|
66 size.iHeight = ( size.iHeight * 8 )/10; |
|
67 |
|
68 CCoeControl* child; |
|
69 for ( TInt ii = 0; ii < childCount; ++ii ) |
|
70 { |
|
71 child = ComponentControl( ii ); |
|
72 tl.iX += size.iWidth/10; |
|
73 tl.iY += size.iHeight/10; |
|
74 child->SetRect( TRect( tl, size ) ); |
|
75 } |
|
76 } |
|
77 } |
|
78 |
|
79 |
|
80 |
|
81 void CCtlSuperContainer641::Draw( const TRect& /*aRect*/ ) const |
|
82 { |
|
83 // get a graphics context - outline the control |
|
84 CWindowGc& gc=SystemGc(); |
|
85 TRect rect=Rect(); |
|
86 gc.SetBrushColor( KRgbGreen ); |
|
87 DoDraw( gc, rect ); |
|
88 |
|
89 ApplyText(); |
|
90 } |
|
91 |
|
92 |
|
93 |
|
94 /** Draw text using a text-drawer derived from the environment, |
|
95 and a text-drawer instantiated locally. |
|
96 */ |
|
97 void CCtlSuperContainer641::ApplyText() const |
|
98 { |
|
99 TInt key = 0; |
|
100 // The Inherited text drawer |
|
101 XCoeTextDrawer xTextDrawer(TextDrawer( key )); |
|
102 //Assume reusable |
|
103 |
|
104 TRect rect = Rect(); |
|
105 CCoeEnv* env = ControlEnv(); |
|
106 |
|
107 xTextDrawer.SetClipRect( rect ); |
|
108 xTextDrawer.SetAlignment( EHRightVBottom ); |
|
109 xTextDrawer.DrawDisplayOrderedText( SystemGc(), KInheritedTextDrawerText, rect, *env->NormalFont() ); |
|
110 } |
|
111 |
|
112 |
|
113 /** Child controls wanting parents' text-drawer will get this one. |
|
114 Derived from the Cone environment |
|
115 */ |
|
116 void CCtlSuperContainer641::GetTextDrawer( CCoeTextDrawerBase*& aTextDrawer, const CCoeControl* /*aDrawingControl*/, TInt /*aInt*/ ) const |
|
117 { |
|
118 aTextDrawer = &iCoeEnv->DefaultTextDrawer(); |
|
119 aTextDrawer->SetTextColor( KRgbInherited ); |
|
120 // Assume that the system text-drawer _is_ reusable. |
|
121 // See adjusted CoeEnv ConstructL() |
|
122 } |
|
123 |