|
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: Data class to hold widget info |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDES |
|
19 #include <e32base.h> |
|
20 |
|
21 #include "xncontroladapter.h" |
|
22 #include "xnhittest.h" |
|
23 |
|
24 // ============================ MEMBER FUNCTIONS =============================== |
|
25 |
|
26 // ----------------------------------------------------------------------------- |
|
27 // CXnHitTest::NewL() |
|
28 // Two-phased constructor. |
|
29 // ----------------------------------------------------------------------------- |
|
30 // |
|
31 CXnHitTest* CXnHitTest::NewL() |
|
32 { |
|
33 CXnHitTest* self = CXnHitTest::NewLC(); |
|
34 CleanupStack::Pop( self ); |
|
35 return self; |
|
36 } |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // CXnHitTest::NewLC() |
|
40 // Two-phased constructor. |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 CXnHitTest* CXnHitTest::NewLC() |
|
44 { |
|
45 CXnHitTest* self = new ( ELeave ) CXnHitTest; |
|
46 CleanupStack::PushL( self ); |
|
47 self->ConstructL(); |
|
48 return self; |
|
49 } |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // CXnHitTest::CXnHitTest() |
|
53 // C++ default constructor |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 CXnHitTest::CXnHitTest() |
|
57 { |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CXnHitTest::~CXnHitTest() |
|
62 // C++ default destructor. |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 CXnHitTest::~CXnHitTest() |
|
66 { |
|
67 CCoeEnv::Static()->RemoveMessageMonitorObserver( *this ); |
|
68 iHitRegion.Reset(); |
|
69 } |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // CXnHitTest::ConstructL() |
|
73 // Two-phased constructor. |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 void CXnHitTest::ConstructL() |
|
77 { |
|
78 CCoeEnv::Static()->AddMessageMonitorObserverL( *this ); |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // CXnHitTest::MonitorWsMessage() |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 void CXnHitTest::MonitorWsMessage( const TWsEvent& aEvent ) |
|
86 { |
|
87 TInt type( aEvent.Type() ); |
|
88 |
|
89 if ( type == EEventPointer ) |
|
90 { |
|
91 iPointerEvent = *aEvent.Pointer(); |
|
92 } |
|
93 } |
|
94 |
|
95 // ----------------------------------------------------------------------------- |
|
96 // CXnHitTest::AddControl() |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 void CXnHitTest::AddControl( CXnControlAdapter* aControl ) |
|
100 { |
|
101 if ( iHitRegion.Find( aControl ) == KErrNotFound ) |
|
102 { |
|
103 iHitRegion.Append( aControl ); |
|
104 } |
|
105 } |
|
106 |
|
107 // ----------------------------------------------------------------------------- |
|
108 // CXnHitTest::RemoveControl() |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 void CXnHitTest::RemoveControl( CXnControlAdapter* aControl ) |
|
112 { |
|
113 TInt index( iHitRegion.Find( aControl ) ); |
|
114 |
|
115 if ( index != KErrNotFound ) |
|
116 { |
|
117 iHitRegion.Remove( index ); |
|
118 } |
|
119 } |
|
120 |
|
121 // ----------------------------------------------------------------------------- |
|
122 // CXnHitTest::SetFlags() |
|
123 // ----------------------------------------------------------------------------- |
|
124 // |
|
125 void CXnHitTest::SetFlags( const TInt aFlags ) |
|
126 { |
|
127 iFlags |= aFlags; |
|
128 } |
|
129 |
|
130 // ----------------------------------------------------------------------------- |
|
131 // CXnHitTest::ClearFlags() |
|
132 // ----------------------------------------------------------------------------- |
|
133 // |
|
134 void CXnHitTest::ClearFlags( const TInt aFlags ) |
|
135 { |
|
136 iFlags &= ~aFlags; |
|
137 } |
|
138 |
|
139 // ----------------------------------------------------------------------------- |
|
140 // CXnHitTest::Flags() |
|
141 // ----------------------------------------------------------------------------- |
|
142 // |
|
143 TInt CXnHitTest::Flags() const |
|
144 { |
|
145 return iFlags; |
|
146 } |
|
147 |
|
148 // ----------------------------------------------------------------------------- |
|
149 // CXnHitTest::Flush() |
|
150 // ----------------------------------------------------------------------------- |
|
151 // |
|
152 void CXnHitTest::Flush() |
|
153 { |
|
154 iFlags = 0; |
|
155 |
|
156 iHitRegion.Reset(); |
|
157 } |
|
158 |
|
159 // ----------------------------------------------------------------------------- |
|
160 // CXnHitTest::HitRegionCount() |
|
161 // ----------------------------------------------------------------------------- |
|
162 // |
|
163 TInt CXnHitTest::HitRegionCount() const |
|
164 { |
|
165 return iHitRegion.Count(); |
|
166 } |
|
167 |
|
168 // ----------------------------------------------------------------------------- |
|
169 // CXnHitTest::HitRegion() |
|
170 // ----------------------------------------------------------------------------- |
|
171 // |
|
172 CXnControlAdapter* CXnHitTest::HitRegion() const |
|
173 { |
|
174 TInt count( HitRegionCount() ); |
|
175 |
|
176 if ( count > 0 ) |
|
177 { |
|
178 return iHitRegion[count - 1]; |
|
179 } |
|
180 |
|
181 return NULL; |
|
182 } |
|
183 |
|
184 // ----------------------------------------------------------------------------- |
|
185 // CXnHitTest::PointerEvent() |
|
186 // ----------------------------------------------------------------------------- |
|
187 // |
|
188 const TPointerEvent& CXnHitTest::PointerEvent() const |
|
189 { |
|
190 return iPointerEvent; |
|
191 } |
|
192 |
|
193 // End of file |