author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:18:30 +0300 | |
branch | RCL_3 |
changeset 102 | ba63c83f4716 |
parent 88 | 3321d3e205b6 |
permissions | -rw-r--r-- |
83 | 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 "xneditmode.h" |
|
29 |
#include "xnnode.h" |
|
30 |
#include "xninactivitymonitor.h" |
|
31 |
||
32 |
#include "xnfocuscontrol.h" |
|
33 |
||
34 |
// Constants |
|
35 |
const TInt KSkinGfxInnerRectShrink( 5 ); |
|
36 |
||
37 |
// ============================ LOCAL FUNCTIONS ================================ |
|
38 |
||
39 |
// ============================ MEMBER FUNCTIONS =============================== |
|
40 |
// ----------------------------------------------------------------------------- |
|
41 |
// CXnFocusControl::NewL() |
|
42 |
// Two-phased constructor. |
|
43 |
// ----------------------------------------------------------------------------- |
|
44 |
// |
|
45 |
CXnFocusControl* CXnFocusControl::NewL( CXnAppUiAdapter& aAppUiAdapter ) |
|
46 |
{ |
|
47 |
CXnFocusControl* self = CXnFocusControl::NewLC( aAppUiAdapter ); |
|
48 |
CleanupStack::Pop( self ); |
|
49 |
return self; |
|
50 |
} |
|
51 |
||
52 |
// ----------------------------------------------------------------------------- |
|
53 |
// CXnFocusControl::NewLC() |
|
54 |
// Two-phased constructor. |
|
55 |
// ----------------------------------------------------------------------------- |
|
56 |
// |
|
57 |
CXnFocusControl* CXnFocusControl::NewLC( CXnAppUiAdapter& aAppUiAdapter ) |
|
58 |
{ |
|
59 |
CXnFocusControl* self = new ( ELeave ) CXnFocusControl( aAppUiAdapter ); |
|
60 |
CleanupStack::PushL( self ); |
|
61 |
self->ConstructL(); |
|
62 |
return self; |
|
63 |
} |
|
64 |
||
65 |
// ----------------------------------------------------------------------------- |
|
66 |
// CXnFocusControl::~CXnFocusControl() |
|
67 |
// C++ default destructor. |
|
68 |
// ----------------------------------------------------------------------------- |
|
69 |
// |
|
70 |
CXnFocusControl::~CXnFocusControl() |
|
71 |
{ |
|
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 |
} |
|
92 |
||
93 |
// ----------------------------------------------------------------------------- |
|
94 |
// CXnFocusControl::MakeVisible() |
|
95 |
// |
|
96 |
// ----------------------------------------------------------------------------- |
|
97 |
// |
|
98 |
void CXnFocusControl::MakeVisible( TBool aVisible ) |
|
99 |
{ |
|
100 |
TRAP_IGNORE( DoMakeVisibleL( aVisible ) ); |
|
101 |
} |
|
102 |
||
103 |
// ----------------------------------------------------------------------------- |
|
104 |
// CXnFocusControl::DoMakeVisibleL() |
|
105 |
// |
|
106 |
// ----------------------------------------------------------------------------- |
|
107 |
// |
|
108 |
void CXnFocusControl::DoMakeVisibleL( TBool aVisible ) |
|
109 |
{ |
|
110 |
if ( aVisible != iVisible ) |
|
111 |
{ |
|
112 |
if ( !aVisible ) |
|
113 |
{ |
|
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
114 |
iVisible = aVisible; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
115 |
|
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
116 |
iRefused = EFalse; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
117 |
|
83 | 118 |
CXnNode* node( iAppUiAdapter.UiEngine().FocusedNode() ); |
119 |
||
120 |
if ( node ) |
|
121 |
{ |
|
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
122 |
node->HideTooltipsL(); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
123 |
|
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
124 |
CXnControlAdapter* control( node->Control() ); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
125 |
|
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
126 |
if ( control && control->RefusesFocusLoss() ) |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
127 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
128 |
// Need to keep drawing focus appearance |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
129 |
iRefused = ETrue; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
130 |
|
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
131 |
node->UnsetStateL( |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
132 |
XnPropertyNames::style::common::KPressedDown ); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
133 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
134 |
else |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
135 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
136 |
node->UnsetStateL( |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
137 |
XnPropertyNames::style::common::KFocus ); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
138 |
} |
83 | 139 |
|
140 |
iAppUiAdapter.UiEngine().RenderUIL(); |
|
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
141 |
} |
83 | 142 |
} |
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
143 |
else |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
144 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
145 |
iRefused = EFalse; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
146 |
|
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
147 |
iVisible = aVisible; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
148 |
} |
83 | 149 |
} |
150 |
} |
|
151 |
||
152 |
// ----------------------------------------------------------------------------- |
|
153 |
// CXnFocusControl::IsVisible() |
|
154 |
// |
|
155 |
// ----------------------------------------------------------------------------- |
|
156 |
// |
|
157 |
TBool CXnFocusControl::IsVisible() const |
|
158 |
{ |
|
159 |
return iVisible; |
|
160 |
} |
|
161 |
||
162 |
// ----------------------------------------------------------------------------- |
|
163 |
// CXnFocusControl::Draw() |
|
164 |
// |
|
165 |
// ----------------------------------------------------------------------------- |
|
166 |
// |
|
167 |
void CXnFocusControl::Draw( const TRect& aRect, CWindowGc& aGc ) const |
|
168 |
{ |
|
169 |
TInt state( iAppUiAdapter.UiEngine().EditMode()->EditState() ); |
|
170 |
||
171 |
// Don't draw focus appearance when shooting dragging widget in edit mode |
|
172 |
if ( state == CXnEditMode::EShootContent ) |
|
173 |
{ |
|
174 |
return; |
|
175 |
} |
|
176 |
||
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
177 |
if ( IsVisible() || iRefused ) |
83 | 178 |
{ |
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
179 |
CXnNode* node( iAppUiAdapter.UiEngine().FocusedNode() ); |
83 | 180 |
|
102
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
181 |
if ( node ) |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
182 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
183 |
CXnProperty* prop( NULL ); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
184 |
|
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
185 |
TRAP_IGNORE( prop = node->GetPropertyL( |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
186 |
XnPropertyNames::common::KFocusAppearance ) ); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
187 |
|
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
188 |
if ( prop && prop->StringValue() == XnPropertyNames::KNone ) |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
189 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
190 |
// Current element refuses to draw focus appearance |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
191 |
return; |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
192 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
193 |
|
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
194 |
TRect innerRect( aRect ); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
195 |
|
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
196 |
innerRect.Shrink( |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
197 |
KSkinGfxInnerRectShrink, KSkinGfxInnerRectShrink ); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
198 |
|
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
199 |
MAknsSkinInstance* skin( AknsUtils::SkinInstance() ); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
200 |
|
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
201 |
if ( node->IsStateSet( XnPropertyNames::style::common::KPressedDown ) ) |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
202 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
203 |
AknsDrawUtils::DrawFrame( skin, aGc, aRect, innerRect, |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
204 |
KAknsIIDQsnFrHomePressed, KAknsIIDDefault ); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
205 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
206 |
|
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
207 |
if ( node->IsStateSet( XnPropertyNames::style::common::KFocus ) ) |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
208 |
{ |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
209 |
AknsDrawUtils::DrawFrame( skin, aGc, aRect, innerRect, |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
210 |
KAknsIIDQsnFrHome, KAknsIIDDefault ); |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
211 |
} |
ba63c83f4716
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
88
diff
changeset
|
212 |
} |
83 | 213 |
} |
214 |
} |
|
215 |
||
216 |
// End of file |
|
217 |