56
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 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: Status pane's combined subpane component.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <AknsDrawUtils.h>
|
|
19 |
#include <AknIndicatorContainer.h>
|
|
20 |
#include <aknlayoutscalable_avkon.cdl.h>
|
|
21 |
#include <barsread.h>
|
|
22 |
#include <eikspane.h>
|
|
23 |
#include <avkon.hrh>
|
|
24 |
#include <AknPriv.hrh>
|
|
25 |
#include <AknSmallIndicator.h>
|
|
26 |
#include <aknappui.h>
|
|
27 |
#include <uikon/eikdefmacros.h>
|
|
28 |
#include <touchfeedback.h>
|
|
29 |
|
|
30 |
#include "akncombinedpane.h"
|
|
31 |
#include "aknstatuspanedatasubscriber.h"
|
|
32 |
|
|
33 |
// This is used to calculate the amount of pixels that the subpanes are
|
|
34 |
// shifted to bottom and right when they are "pressed down".
|
|
35 |
const TInt KPressedDownDeltaDivider( 35 ); // 0.3 units
|
|
36 |
|
|
37 |
// ======== MEMBER FUNCTIONS ========
|
|
38 |
|
|
39 |
// ----------------------------------------------------------------------------
|
|
40 |
// Two-phased constructor.
|
|
41 |
// ----------------------------------------------------------------------------
|
|
42 |
//
|
|
43 |
CAknCombinedPane* CAknCombinedPane::NewL()
|
|
44 |
{
|
|
45 |
CAknCombinedPane* self = new ( ELeave ) CAknCombinedPane();
|
|
46 |
CleanupStack::PushL( self );
|
|
47 |
self->ConstructL();
|
|
48 |
CleanupStack::Pop( self );
|
|
49 |
return self;
|
|
50 |
}
|
|
51 |
|
|
52 |
|
|
53 |
// ----------------------------------------------------------------------------
|
|
54 |
// Destructor
|
|
55 |
// ----------------------------------------------------------------------------
|
|
56 |
//
|
|
57 |
CAknCombinedPane::~CAknCombinedPane()
|
|
58 |
{
|
|
59 |
iSubPanes.Reset();
|
|
60 |
|
|
61 |
if ( iAvkonAppUi )
|
|
62 |
{
|
|
63 |
iAvkonAppUi->RemoveFromStack( this );
|
|
64 |
}
|
|
65 |
}
|
|
66 |
|
|
67 |
|
|
68 |
// ----------------------------------------------------------------------------
|
|
69 |
// Returns number of controls inside this control.
|
|
70 |
// ----------------------------------------------------------------------------
|
|
71 |
//
|
|
72 |
TInt CAknCombinedPane::CountComponentControls() const
|
|
73 |
{
|
|
74 |
return iSubPanes.Count();
|
|
75 |
}
|
|
76 |
|
|
77 |
|
|
78 |
// ----------------------------------------------------------------------------
|
|
79 |
// Returns a control determined by control index.
|
|
80 |
// ----------------------------------------------------------------------------
|
|
81 |
//
|
|
82 |
CCoeControl* CAknCombinedPane::ComponentControl( TInt aIndex ) const
|
|
83 |
{
|
|
84 |
CCoeControl* control = NULL;
|
|
85 |
|
|
86 |
if ( iStatusPane && aIndex < iSubPanes.Count() )
|
|
87 |
{
|
|
88 |
TRAP_IGNORE( control = iStatusPane->ContainerControlL(
|
|
89 |
TUid::Uid( iSubPanes[aIndex].iUid ) ) );
|
|
90 |
}
|
|
91 |
|
|
92 |
return control;
|
|
93 |
}
|
|
94 |
|
|
95 |
|
|
96 |
// ----------------------------------------------------------------------------
|
|
97 |
// Handles a change to the control's resources.
|
|
98 |
// ----------------------------------------------------------------------------
|
|
99 |
//
|
|
100 |
void CAknCombinedPane::HandleResourceChange( TInt aType )
|
|
101 |
{
|
|
102 |
CAknButton::HandleResourceChange( aType );
|
|
103 |
|
|
104 |
switch ( aType )
|
|
105 |
{
|
|
106 |
case KAknMessageFocusLost: // fallthrough
|
|
107 |
case KEikMessageFadeAllWindows:
|
|
108 |
{
|
|
109 |
SetSubPanesPressedDown( EFalse );
|
|
110 |
DrawDeferred();
|
|
111 |
break;
|
|
112 |
}
|
|
113 |
|
|
114 |
case KAknsMessageSkinChange:
|
|
115 |
{
|
|
116 |
DrawDeferred();
|
|
117 |
break;
|
|
118 |
}
|
|
119 |
|
|
120 |
case KEikDynamicLayoutVariantSwitch:
|
|
121 |
{
|
|
122 |
SetSubPanesPressedDown( EFalse );
|
|
123 |
// Recalculate the pressed down delta pixels on layout change.
|
|
124 |
TAknWindowLineLayout unitValue(
|
|
125 |
AknLayoutScalable_Avkon::aid_value_unit2().LayoutLine() );
|
|
126 |
iPressedDownDelta = unitValue.iW / KPressedDownDeltaDivider;
|
|
127 |
DrawDeferred();
|
|
128 |
break;
|
|
129 |
}
|
|
130 |
|
|
131 |
default:
|
|
132 |
{
|
|
133 |
break;
|
|
134 |
}
|
|
135 |
}
|
|
136 |
}
|
|
137 |
|
|
138 |
|
|
139 |
// ----------------------------------------------------------------------------
|
|
140 |
// Resource constructor.
|
|
141 |
// ----------------------------------------------------------------------------
|
|
142 |
//
|
|
143 |
void CAknCombinedPane::ConstructFromResourceL( TResourceReader& aReader )
|
|
144 |
{
|
|
145 |
aReader.ReadInt8(); // version
|
|
146 |
|
|
147 |
TInt count = aReader.ReadInt16(); // amount of subpanes
|
|
148 |
|
|
149 |
for ( TInt i = 0; i < count; ++i )
|
|
150 |
{
|
|
151 |
TSubPaneData subPane;
|
|
152 |
|
|
153 |
aReader.ReadInt8(); // version
|
|
154 |
subPane.iUid = aReader.ReadUint32(); // subpane UID
|
|
155 |
subPane.iPressedDown = EFalse; // Isn't specified in the resource.
|
|
156 |
aReader.ReadInt32(); // extension
|
|
157 |
|
|
158 |
iSubPanes.AppendL( subPane );
|
|
159 |
}
|
|
160 |
|
|
161 |
aReader.ReadInt32(); // extension
|
|
162 |
|
|
163 |
iStatusPane = CEikStatusPaneBase::Current();
|
|
164 |
}
|
|
165 |
|
|
166 |
|
|
167 |
// ----------------------------------------------------------------------------
|
|
168 |
// Handles pointer events inside the control.
|
|
169 |
// ----------------------------------------------------------------------------
|
|
170 |
//
|
|
171 |
void CAknCombinedPane::HandlePointerEventL(
|
|
172 |
const TPointerEvent& aPointerEvent )
|
|
173 |
{
|
|
174 |
CAknButton::HandlePointerEventL( aPointerEvent );
|
|
175 |
|
|
176 |
switch ( aPointerEvent.iType )
|
|
177 |
{
|
|
178 |
case TPointerEvent::EButton1Down:
|
|
179 |
{
|
|
180 |
SetSubPanesPressedDown( ETrue );
|
|
181 |
iPointerDownInCombinedArea = ETrue;
|
|
182 |
break;
|
|
183 |
}
|
|
184 |
|
|
185 |
case TPointerEvent::EButton1Up:
|
|
186 |
{
|
|
187 |
SetSubPanesPressedDown( EFalse );
|
|
188 |
|
|
189 |
if ( iPointerDownInCombinedArea &&
|
|
190 |
Rect().Contains( aPointerEvent.iPosition ) )
|
|
191 |
{
|
|
192 |
// Display the universal indicator popup.
|
|
193 |
CAknSmallIndicator* indicatorNotifier =
|
|
194 |
CAknSmallIndicator::NewLC( TUid::Uid( 0 ) );
|
|
195 |
indicatorNotifier->HandleIndicatorTapL();
|
|
196 |
//for indicator popup event
|
|
197 |
MTouchFeedback* feedback = MTouchFeedback::Instance();
|
|
198 |
if ( feedback )
|
|
199 |
{
|
|
200 |
feedback->InstantFeedback(
|
|
201 |
this,
|
|
202 |
ETouchFeedbackPopUp,
|
|
203 |
ETouchFeedbackVibra,
|
|
204 |
aPointerEvent );
|
|
205 |
}
|
|
206 |
CleanupStack::PopAndDestroy( indicatorNotifier );
|
|
207 |
}
|
|
208 |
|
|
209 |
iPointerDownInCombinedArea = EFalse;
|
|
210 |
break;
|
|
211 |
}
|
|
212 |
|
|
213 |
case TPointerEvent::EDrag:
|
|
214 |
{
|
|
215 |
TRect combinedRect( Rect() );
|
|
216 |
if ( !combinedRect.Contains( aPointerEvent.iPosition ) )
|
|
217 |
{
|
|
218 |
SetSubPanesPressedDown( EFalse );
|
|
219 |
}
|
|
220 |
else if ( iPointerDownInCombinedArea &&
|
|
221 |
combinedRect.Contains( aPointerEvent.iPosition ) )
|
|
222 |
{
|
|
223 |
SetSubPanesPressedDown( ETrue );
|
|
224 |
}
|
|
225 |
break;
|
|
226 |
}
|
|
227 |
|
|
228 |
default:
|
|
229 |
{
|
|
230 |
break;
|
|
231 |
}
|
|
232 |
}
|
|
233 |
|
|
234 |
DrawDeferred();
|
|
235 |
}
|
|
236 |
|
|
237 |
|
|
238 |
// ----------------------------------------------------------------------------
|
|
239 |
// Default C++ constructor.
|
|
240 |
// ----------------------------------------------------------------------------
|
|
241 |
//
|
|
242 |
CAknCombinedPane::CAknCombinedPane() : CAknButton( 0 ),
|
|
243 |
iStatusPane( NULL )
|
|
244 |
{
|
|
245 |
// Calculate the pressed down delta pixels from layout data,
|
|
246 |
// aid_value_unit2 is a 10ux10u rectangle.
|
|
247 |
TAknWindowLineLayout unitValue(
|
|
248 |
AknLayoutScalable_Avkon::aid_value_unit2().LayoutLine() );
|
|
249 |
// Move the control 0.3 units to right and down for the
|
|
250 |
// "pressed down" effect.
|
|
251 |
iPressedDownDelta = unitValue.iW / KPressedDownDeltaDivider;
|
|
252 |
}
|
|
253 |
|
|
254 |
|
|
255 |
// ----------------------------------------------------------------------------
|
|
256 |
// Second-phase constructor.
|
|
257 |
// ----------------------------------------------------------------------------
|
|
258 |
//
|
|
259 |
void CAknCombinedPane::ConstructL()
|
|
260 |
{
|
|
261 |
CAknButton::ConstructL( NULL, NULL, NULL, NULL, KNullDesC, KNullDesC, 0 );
|
|
262 |
|
|
263 |
// Use the softkey frame graphics so that the bottom area appears
|
|
264 |
// consistent.
|
|
265 |
SetFrameAndCenterIds( KAknsIIDQgnFrSctrlSkButton,
|
|
266 |
KAknsIIDQgnFrSctrlSkButtonCenter,
|
|
267 |
KAknsIIDNone,
|
|
268 |
KAknsIIDNone,
|
|
269 |
KAknsIIDNone,
|
|
270 |
KAknsIIDNone,
|
|
271 |
KAknsIIDQgnFrSctrlSkButtonPressed,
|
|
272 |
KAknsIIDQgnFrSctrlSkButtonCenterPressed,
|
|
273 |
KAknsIIDNone,
|
|
274 |
KAknsIIDNone );
|
|
275 |
|
|
276 |
// Add to the control stack in order to receive the focus lost events.
|
|
277 |
iAvkonAppUi->AddToStackL( this,
|
|
278 |
ECoeStackPriorityCba,
|
|
279 |
ECoeStackFlagRefusesAllKeys |
|
|
280 |
ECoeStackFlagRefusesFocus );
|
|
281 |
}
|
|
282 |
|
|
283 |
|
|
284 |
// ----------------------------------------------------------------------------
|
|
285 |
// Sets the pressed down state of the subpanes.
|
|
286 |
// ----------------------------------------------------------------------------
|
|
287 |
//
|
|
288 |
void CAknCombinedPane::SetSubPanesPressedDown( TBool aPressedDown )
|
|
289 |
{
|
|
290 |
TInt delta = aPressedDown ? iPressedDownDelta : -iPressedDownDelta;
|
|
291 |
|
|
292 |
for ( TInt i = 0; i < iSubPanes.Count(); ++i )
|
|
293 |
{
|
|
294 |
if ( !COMPARE_BOOLS( iSubPanes[i].iPressedDown, aPressedDown ) )
|
|
295 |
{
|
|
296 |
CCoeControl* control = ComponentControl( i );
|
|
297 |
TRect controlRect( control->Rect() );
|
|
298 |
controlRect.Move( delta, delta );
|
|
299 |
control->SetRect( controlRect );
|
|
300 |
iSubPanes[i].iPressedDown = aPressedDown;
|
|
301 |
}
|
|
302 |
}
|
|
303 |
}
|
|
304 |
|
|
305 |
// End of File
|