|
1 /* |
|
2 * Copyright (c) 2007 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: CFsTreeControl is a HUI control that handles UI events for |
|
15 * tree list. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 //////TOOLKIT INCLUDES |
|
21 // <cmail> SF |
|
22 #include "emailtrace.h" |
|
23 #include <alf/alfevent.h> |
|
24 // </cmail> |
|
25 |
|
26 |
|
27 // <cmail> Needed for pointer events. "Base class modifications for using touch" |
|
28 #include <alf/alfdisplay.h> |
|
29 #include <alf/alfroster.h> |
|
30 // </cmail> |
|
31 |
|
32 |
|
33 //////PROJECT INCLUDES |
|
34 //<cmail> removed __FS_ALFRED_SUPPORT flag |
|
35 //#include <fsconfig.h> |
|
36 //</cmail> removed __FS_ALFRED_SUPPORT flag |
|
37 #include "fstreecontrol.h" |
|
38 #include "fstreevisualizer.h" |
|
39 |
|
40 // ======== MEMBER FUNCTIONS ======== |
|
41 |
|
42 // --------------------------------------------------------------------------- |
|
43 // Two-phased constructor. |
|
44 // --------------------------------------------------------------------------- |
|
45 // |
|
46 EXPORT_C CFsTreeControl* CFsTreeControl::NewL( CAlfEnv& aEnv, |
|
47 CFsTree& aTree, |
|
48 MFsTreeVisualizer& aVisualizer ) |
|
49 { |
|
50 FUNC_LOG; |
|
51 CFsTreeControl* self = new( ELeave ) CFsTreeControl( //aEnv, |
|
52 aTree, |
|
53 aVisualizer ); |
|
54 CleanupStack::PushL( self ); |
|
55 self->ConstructL( aEnv ); |
|
56 CleanupStack::Pop( self ); |
|
57 return self; |
|
58 } |
|
59 |
|
60 // --------------------------------------------------------------------------- |
|
61 // C++ destructor. |
|
62 // --------------------------------------------------------------------------- |
|
63 // |
|
64 CFsTreeControl::~CFsTreeControl() |
|
65 { |
|
66 FUNC_LOG; |
|
67 |
|
68 } |
|
69 |
|
70 // --------------------------------------------------------------------------- |
|
71 // From class CHuiControl. |
|
72 // Called when an input event is being offered to the control. |
|
73 // --------------------------------------------------------------------------- |
|
74 // |
|
75 EXPORT_C TBool CFsTreeControl::OfferEventL(const TAlfEvent& aEvent) |
|
76 { |
|
77 FUNC_LOG; |
|
78 TBool eventHandled = EFalse; |
|
79 |
|
80 //Handle pointer events |
|
81 if ( aEvent.IsPointerEvent() ) |
|
82 { |
|
83 if (aEvent.PointerEvent().iType == TPointerEvent::EButton1Down) |
|
84 { |
|
85 SetDragEvents(ETrue); |
|
86 } |
|
87 if (aEvent.PointerEvent().iType == TPointerEvent::EButton1Up) |
|
88 { |
|
89 SetDragEvents(EFalse); |
|
90 } |
|
91 eventHandled = iTreeVisualizer.HandlePointerEventL( aEvent ); |
|
92 } |
|
93 else if( iFocused && aEvent.IsKeyEvent() && aEvent.Code() == EEventKey) |
|
94 { |
|
95 eventHandled = iTreeVisualizer.HandleKeyEventL( aEvent ); |
|
96 } |
|
97 return eventHandled; |
|
98 } |
|
99 |
|
100 //--------------------------------------------------------------------------- |
|
101 // Sets focus state of list component |
|
102 //--------------------------------------------------------------------------- |
|
103 void CFsTreeControl::SetFocused( const TBool aFocused ) |
|
104 { |
|
105 FUNC_LOG; |
|
106 iFocused = aFocused; |
|
107 } |
|
108 //--------------------------------------------------------------------------- |
|
109 // Returns state of the focus |
|
110 //--------------------------------------------------------------------------- |
|
111 TBool CFsTreeControl::IsFocused() const |
|
112 { |
|
113 FUNC_LOG; |
|
114 return iFocused; |
|
115 } |
|
116 |
|
117 // --------------------------------------------------------------------------- |
|
118 // |
|
119 // --------------------------------------------------------------------------- |
|
120 // |
|
121 void CFsTreeControl::VisualPrepareDrawFailed(CAlfVisual& /*aVisual*/, |
|
122 TInt /*aErrorCode*/) |
|
123 { |
|
124 FUNC_LOG; |
|
125 |
|
126 } |
|
127 |
|
128 // <cmail> "Base class modifications for using touch" |
|
129 // --------------------------------------------------------------------------- |
|
130 // C++ constructor. |
|
131 // --------------------------------------------------------------------------- |
|
132 // |
|
133 CFsTreeControl::CFsTreeControl( /*CAlfEnv& aEnv,*/ CFsTree& aTree, MFsTreeVisualizer& aVisualizer ) |
|
134 : //CHuiControl( aEnv ), |
|
135 iTree(aTree), |
|
136 iTreeVisualizer( aVisualizer ), |
|
137 iFocused( ETrue ), |
|
138 iGetExtraPointerEvents(EFalse) |
|
139 { |
|
140 FUNC_LOG; |
|
141 |
|
142 } |
|
143 // </cmail> |
|
144 |
|
145 |
|
146 // --------------------------------------------------------------------------- |
|
147 // Second phase constructor. |
|
148 // --------------------------------------------------------------------------- |
|
149 // |
|
150 void CFsTreeControl::ConstructL( CAlfEnv& aEnv ) |
|
151 { |
|
152 FUNC_LOG; |
|
153 CAlfControl::ConstructL( aEnv ); |
|
154 } |
|
155 |
|
156 // <cmail> |
|
157 void CFsTreeControl::NotifyControlVisibility( TBool aIsVisible, CAlfDisplay& /*aDisplay*/ ) |
|
158 { |
|
159 iTreeVisualizer.NotifyControlVisibilityChange(aIsVisible); |
|
160 if (!aIsVisible) |
|
161 { |
|
162 SetDragEvents(EFalse); |
|
163 } |
|
164 } |
|
165 |
|
166 |
|
167 void CFsTreeControl::SetDragEvents(TBool aEnable) |
|
168 { |
|
169 //Add & remove extra touch events. |
|
170 if (Display()) |
|
171 { |
|
172 if(aEnable && !iGetExtraPointerEvents) |
|
173 { |
|
174 Display()->Roster().AddPointerEventObserver(EAlfPointerEventReportDrag, *this); |
|
175 Display()->Roster().AddPointerEventObserver(EAlfPointerEventReportLongTap, *this); |
|
176 Display()->Roster().AddPointerEventObserver(EAlfPointerEventReportUnhandled, *this); |
|
177 //aDisplay.Roster().DisableLongTapEventsWhenDragging(*this); |
|
178 iGetExtraPointerEvents = ETrue; |
|
179 } |
|
180 else if(!aEnable && iGetExtraPointerEvents ) |
|
181 { |
|
182 Display()->Roster().RemovePointerEventObserver(EAlfPointerEventReportDrag, *this); |
|
183 Display()->Roster().RemovePointerEventObserver(EAlfPointerEventReportLongTap, *this); |
|
184 Display()->Roster().RemovePointerEventObserver(EAlfPointerEventReportUnhandled, *this); |
|
185 iGetExtraPointerEvents = EFalse; |
|
186 } |
|
187 } |
|
188 } |
|
189 // </cmail> |
|
190 |