|
1 /* |
|
2 * Copyright (c) 2008 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: Focus appearance drawer |
|
15 * |
|
16 */ |
|
17 |
|
18 // System includes |
|
19 #include <AknsDrawUtils.h> |
|
20 #include <AknsUtils.h> |
|
21 #include <AknsItemID.h> |
|
22 |
|
23 // User includes |
|
24 #include "xncontroladapter.h" |
|
25 #include "xnproperty.h" |
|
26 #include "xnappuiadapter.h" |
|
27 #include "xnuiengine.h" |
|
28 #include "xnnode.h" |
|
29 #include "xninactivitymonitor.h" |
|
30 |
|
31 #include "xnfocuscontrol.h" |
|
32 |
|
33 // Constants |
|
34 const TInt KSkinGfxInnerRectShrink( 5 ); |
|
35 |
|
36 // ============================ LOCAL FUNCTIONS ================================ |
|
37 |
|
38 // ============================ MEMBER FUNCTIONS =============================== |
|
39 // ----------------------------------------------------------------------------- |
|
40 // CXnFocusControl::NewL() |
|
41 // Two-phased constructor. |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 CXnFocusControl* CXnFocusControl::NewL( CXnAppUiAdapter& aAppUiAdapter ) |
|
45 { |
|
46 CXnFocusControl* self = CXnFocusControl::NewLC( aAppUiAdapter ); |
|
47 CleanupStack::Pop( self ); |
|
48 return self; |
|
49 } |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // CXnFocusControl::NewLC() |
|
53 // Two-phased constructor. |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 CXnFocusControl* CXnFocusControl::NewLC( CXnAppUiAdapter& aAppUiAdapter ) |
|
57 { |
|
58 CXnFocusControl* self = new ( ELeave ) CXnFocusControl( aAppUiAdapter ); |
|
59 CleanupStack::PushL( self ); |
|
60 self->ConstructL(); |
|
61 return self; |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CXnFocusControl::~CXnFocusControl() |
|
66 // C++ default destructor. |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 CXnFocusControl::~CXnFocusControl() |
|
70 { |
|
71 delete iMonitor; |
|
72 } |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 // CXnFocusControl::CXnFocusControl() |
|
76 // C++ default constructor. |
|
77 // ----------------------------------------------------------------------------- |
|
78 // |
|
79 CXnFocusControl::CXnFocusControl( CXnAppUiAdapter& aAppUiAdapter ) |
|
80 : iAppUiAdapter( aAppUiAdapter ) |
|
81 { |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // CXnFocusControl::ConstructL() |
|
86 // 2nd phase constructor |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 void CXnFocusControl::ConstructL() |
|
90 { |
|
91 iMonitor = CXnInactivityMonitor::NewL( *this ); |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // CXnFocusControl::InactivityTimerExpired() |
|
96 // |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 void CXnFocusControl::InactivityTimerExpired() |
|
100 { |
|
101 MakeVisible( EFalse ); |
|
102 } |
|
103 |
|
104 // ----------------------------------------------------------------------------- |
|
105 // CXnFocusControl::MakeVisible() |
|
106 // |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 void CXnFocusControl::MakeVisible( TBool aVisible ) |
|
110 { |
|
111 TRAP_IGNORE( DoMakeVisibleL( aVisible ) ); |
|
112 } |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // CXnFocusControl::DoMakeVisibleL() |
|
116 // |
|
117 // ----------------------------------------------------------------------------- |
|
118 // |
|
119 void CXnFocusControl::DoMakeVisibleL( TBool aVisible ) |
|
120 { |
|
121 if ( aVisible != iVisible ) |
|
122 { |
|
123 if ( !aVisible ) |
|
124 { |
|
125 iVisible = aVisible; |
|
126 |
|
127 iRefused = EFalse; |
|
128 |
|
129 iMonitor->Stop(); |
|
130 |
|
131 CXnNode* node( iAppUiAdapter.UiEngine().FocusedNode() ); |
|
132 |
|
133 if ( node ) |
|
134 { |
|
135 CXnControlAdapter* control( node->Control() ); |
|
136 |
|
137 if ( control && control->RefusesFocusLoss() ) |
|
138 { |
|
139 // Need to keep drawing focus appearance |
|
140 iRefused = ETrue; |
|
141 |
|
142 node->UnsetStateL( |
|
143 XnPropertyNames::style::common::KPressedDown ); |
|
144 } |
|
145 else |
|
146 { |
|
147 node->UnsetStateL( |
|
148 XnPropertyNames::style::common::KFocus ); |
|
149 } |
|
150 |
|
151 iAppUiAdapter.UiEngine().RenderUIL(); |
|
152 } |
|
153 } |
|
154 else |
|
155 { |
|
156 iRefused = EFalse; |
|
157 |
|
158 iVisible = aVisible; |
|
159 |
|
160 iMonitor->Start(); |
|
161 } |
|
162 } |
|
163 } |
|
164 |
|
165 // ----------------------------------------------------------------------------- |
|
166 // CXnFocusControl::IsVisible() |
|
167 // |
|
168 // ----------------------------------------------------------------------------- |
|
169 // |
|
170 TBool CXnFocusControl::IsVisible() const |
|
171 { |
|
172 return iVisible; |
|
173 } |
|
174 |
|
175 // ----------------------------------------------------------------------------- |
|
176 // CXnFocusControl::Draw() |
|
177 // |
|
178 // ----------------------------------------------------------------------------- |
|
179 // |
|
180 void CXnFocusControl::Draw( const TRect& aRect, CWindowGc& aGc ) const |
|
181 { |
|
182 if ( IsVisible() || iRefused ) |
|
183 { |
|
184 CXnNode* node( iAppUiAdapter.UiEngine().FocusedNode() ); |
|
185 |
|
186 if ( node ) |
|
187 { |
|
188 TRect innerRect( aRect ); |
|
189 |
|
190 innerRect.Shrink( |
|
191 KSkinGfxInnerRectShrink, KSkinGfxInnerRectShrink ); |
|
192 |
|
193 MAknsSkinInstance* skin( AknsUtils::SkinInstance() ); |
|
194 |
|
195 if ( node->IsStateSet( XnPropertyNames::style::common::KPressedDown ) ) |
|
196 { |
|
197 AknsDrawUtils::DrawFrame( skin, aGc, aRect, innerRect, |
|
198 KAknsIIDQsnFrHomePressed, KAknsIIDDefault ); |
|
199 } |
|
200 |
|
201 if ( node->IsStateSet( XnPropertyNames::style::common::KFocus ) ) |
|
202 { |
|
203 AknsDrawUtils::DrawFrame( skin, aGc, aRect, innerRect, |
|
204 KAknsIIDQsnFrHome, KAknsIIDDefault ); |
|
205 } |
|
206 } |
|
207 } |
|
208 } |
|
209 |
|
210 // End of file |
|
211 |