|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: CEdwinTestControl test class for STIF Test Framework TestScripter. |
|
15 * |
|
16 */ |
|
17 #include "EdwinTestControl.h" |
|
18 #include <eikenv.h> |
|
19 #include <aknsutils.h> |
|
20 #include <aknsdrawutils.h> |
|
21 #include <aknutils.h> |
|
22 #include <aknsbasicbackgroundcontrolcontext.h> |
|
23 |
|
24 |
|
25 CEdwinTestControl::~CEdwinTestControl() |
|
26 { |
|
27 delete iEditWin; |
|
28 iEditWin = NULL; |
|
29 delete iBgContext; |
|
30 iBgContext = NULL; |
|
31 } |
|
32 |
|
33 CEdwinTestControl* CEdwinTestControl::NewL(void) |
|
34 { |
|
35 CEdwinTestControl* self = new(ELeave)CEdwinTestControl(); |
|
36 CleanupStack::PushL( self ); |
|
37 self->ConstructL(); |
|
38 CleanupStack::Pop( self ); |
|
39 return self; |
|
40 } |
|
41 |
|
42 void CEdwinTestControl::ConstructL() |
|
43 { |
|
44 CreateWindowL(); |
|
45 |
|
46 iEditWin = new (ELeave) CEikEdwin(); |
|
47 iEditWin->ConstructL( 0, 100, 100, 1 ); |
|
48 iEditWin->SetContainerWindowL( *this ); |
|
49 iEditWin->CreateTextViewL(); |
|
50 // iEditWin->SetInputCapabilitiesL( TCoeInputCapabilities::EAllText ); |
|
51 |
|
52 // make first with no size at all |
|
53 iBgContext = CAknsBasicBackgroundControlContext::NewL(KAknsIIDQsnBgScreen,TRect(0,0,1,1), ETrue ); |
|
54 // Setting rect will cause SizeChanged to be called |
|
55 // and iBgContext size & position is updated accordingly. |
|
56 SetRect( CEikonEnv::Static()->EikAppUi()->ClientRect() ); |
|
57 |
|
58 ActivateL(); |
|
59 DrawNow(); |
|
60 } |
|
61 |
|
62 void CEdwinTestControl::SizeChanged() |
|
63 { |
|
64 if ( iBgContext ) |
|
65 { |
|
66 iBgContext->SetRect(Rect()); |
|
67 |
|
68 if ( &Window() ) |
|
69 { |
|
70 iBgContext->SetParentPos( PositionRelativeToScreen() ); |
|
71 } |
|
72 } |
|
73 if ( iEditWin ) |
|
74 { |
|
75 iEditWin->SetRect(Rect()); |
|
76 } |
|
77 } |
|
78 |
|
79 |
|
80 void CEdwinTestControl::HandleResourceChange( TInt aType ) |
|
81 { |
|
82 TRect rect; |
|
83 |
|
84 if ( aType == KEikDynamicLayoutVariantSwitch ) |
|
85 { |
|
86 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect); |
|
87 SetRect(rect); |
|
88 } |
|
89 |
|
90 CCoeControl::HandleResourceChange(aType); |
|
91 } |
|
92 |
|
93 |
|
94 TTypeUid::Ptr CEdwinTestControl::MopSupplyObject(TTypeUid aId) |
|
95 { |
|
96 if ( iBgContext ) |
|
97 { |
|
98 return MAknsControlContext::SupplyMopObject( aId, iBgContext ); |
|
99 } |
|
100 |
|
101 return CCoeControl::MopSupplyObject( aId ); |
|
102 } |
|
103 |
|
104 |
|
105 void CEdwinTestControl::Draw(const TRect& aRect) const |
|
106 { |
|
107 CWindowGc& gc = SystemGc(); |
|
108 |
|
109 // draw background skin first. |
|
110 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
111 AknsDrawUtils::Background( skin, iBgContext, this, gc, aRect ); |
|
112 } |
|
113 |
|
114 TInt CEdwinTestControl::CountComponentControls() const |
|
115 { |
|
116 return 1; |
|
117 } |
|
118 |
|
119 CCoeControl* CEdwinTestControl::ComponentControl(TInt aIndex) const |
|
120 { |
|
121 switch (aIndex) |
|
122 { |
|
123 case 0: |
|
124 return iEditWin; |
|
125 default: |
|
126 return 0; |
|
127 } |
|
128 } |
|
129 |
|
130 void CEdwinTestControl::HandleControlEventL( CCoeControl* /*aControl*/, TCoeEvent /*aEventType*/) |
|
131 { |
|
132 // TODO: Add your control event handler code here |
|
133 } |
|
134 |
|
135 TKeyResponse CEdwinTestControl::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
136 { |
|
137 if ( iEditWin ) |
|
138 { |
|
139 return iEditWin->OfferKeyEventL( aKeyEvent, aType ); |
|
140 } |
|
141 else |
|
142 { |
|
143 return EKeyWasNotConsumed; |
|
144 } |
|
145 } |