|
1 /* |
|
2 * Copyright (c) 2007-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: Interface for controlling the universal status |
|
15 * indicator popup. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include <AknPreviewPopUpController.h> |
|
21 #include <aknlayoutscalable_avkon.cdl.h> |
|
22 #include <layoutmetadata.cdl.h> |
|
23 #include <AknUtils.h> |
|
24 #include <AknStatuspaneUtils.h> |
|
25 |
|
26 #include "aknindicatorpopup.h" |
|
27 #include "aknindicatorpopupcontent.h" |
|
28 #include "AknIndicatorPlugin.h" |
|
29 |
|
30 const TInt KDefaultPopUpShowDelay = 0; |
|
31 const TInt KDefaultPopUpHideDelay = 6000000; // 6 seconds |
|
32 |
|
33 // --------------------------------------------------------------------------- |
|
34 // CAknIndicatorPopup::NewL |
|
35 // --------------------------------------------------------------------------- |
|
36 // |
|
37 CAknIndicatorPopup* CAknIndicatorPopup::NewL() |
|
38 { |
|
39 CAknIndicatorPopup* self = CAknIndicatorPopup::NewLC(); |
|
40 CleanupStack::Pop( self ); |
|
41 return self; |
|
42 } |
|
43 |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // CAknIndicatorPopup::NewLC |
|
47 // --------------------------------------------------------------------------- |
|
48 // |
|
49 CAknIndicatorPopup* CAknIndicatorPopup::NewLC() |
|
50 { |
|
51 CAknIndicatorPopup* self = new ( ELeave ) CAknIndicatorPopup(); |
|
52 CleanupStack::PushL( self ); |
|
53 self->ConstructL(); |
|
54 return self; |
|
55 } |
|
56 |
|
57 |
|
58 // --------------------------------------------------------------------------- |
|
59 // Destructor. |
|
60 // --------------------------------------------------------------------------- |
|
61 // |
|
62 CAknIndicatorPopup::~CAknIndicatorPopup() |
|
63 { |
|
64 delete iController; |
|
65 delete iContent; |
|
66 } |
|
67 |
|
68 |
|
69 // --------------------------------------------------------------------------- |
|
70 // CAknIndicatorPopup::ShowPopup |
|
71 // --------------------------------------------------------------------------- |
|
72 // |
|
73 void CAknIndicatorPopup::ShowPopup() |
|
74 { |
|
75 if ( AknLayoutUtils::PenEnabled() ) |
|
76 { |
|
77 iController->ShowPopUp(); |
|
78 } |
|
79 } |
|
80 |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 // CAknIndicatorPopup::HidePopup |
|
84 // --------------------------------------------------------------------------- |
|
85 // |
|
86 void CAknIndicatorPopup::HidePopup() |
|
87 { |
|
88 if ( AknLayoutUtils::PenEnabled() ) |
|
89 { |
|
90 iController->HidePopUp(); |
|
91 } |
|
92 } |
|
93 |
|
94 |
|
95 // --------------------------------------------------------------------------- |
|
96 // CAknIndicatorPopup::SetPosition |
|
97 // --------------------------------------------------------------------------- |
|
98 // |
|
99 void CAknIndicatorPopup::SetPosition( const TPoint& aPoint ) |
|
100 { |
|
101 // Position is the top right corner. |
|
102 iPosition = aPoint; |
|
103 iController->SetPosition( aPoint ); |
|
104 } |
|
105 |
|
106 // --------------------------------------------------------------------------- |
|
107 // CAknIndicatorPopup::SetBottomPosition |
|
108 // --------------------------------------------------------------------------- |
|
109 // |
|
110 void CAknIndicatorPopup::SetBottomPosition( const TPoint& aPoint ) |
|
111 { |
|
112 // Position is the top right corner, so it must be calculated based |
|
113 // on the bottom right corner and the amount of items. |
|
114 TSize popupSize( iContent->MinimumSize() ); |
|
115 TPoint position( aPoint ); |
|
116 position.iY -= popupSize.iHeight; |
|
117 |
|
118 iPosition = position; |
|
119 iController->SetPosition( position ); |
|
120 } |
|
121 |
|
122 // --------------------------------------------------------------------------- |
|
123 // CAknIndicatorPopup::SetSignalStateL |
|
124 // --------------------------------------------------------------------------- |
|
125 // |
|
126 void CAknIndicatorPopup::SetSignalStateL( TInt aState ) |
|
127 { |
|
128 iContent->SetSignalStateL( aState ); |
|
129 } |
|
130 // --------------------------------------------------------------------------- |
|
131 // CAknIndicatorPopup::SetBatteryStateL |
|
132 // --------------------------------------------------------------------------- |
|
133 // |
|
134 |
|
135 void CAknIndicatorPopup::SetBatteryStateL( TInt aState ) |
|
136 { |
|
137 iContent->SetBatteryStateL( aState ); |
|
138 } |
|
139 // CAknIndicatorPopup::AddItemL |
|
140 // --------------------------------------------------------------------------- |
|
141 // |
|
142 void CAknIndicatorPopup::AddItemL( TInt aIndicatorUid, |
|
143 const TDesC& aText, |
|
144 TInt aTextType, |
|
145 const CGulIcon* aIcon, |
|
146 CAknIndicatorPlugin* aPlugin, |
|
147 TInt aPriority ) |
|
148 { |
|
149 iContent->AddItemL( aIndicatorUid, aText, aTextType, aIcon, aPlugin, aPriority ); |
|
150 iController->UpdateContentSize(); |
|
151 } |
|
152 |
|
153 |
|
154 // --------------------------------------------------------------------------- |
|
155 // CAknIndicatorPopup::RemoveItem |
|
156 // --------------------------------------------------------------------------- |
|
157 // |
|
158 void CAknIndicatorPopup::RemoveItem( TInt aIndicatorUid ) |
|
159 { |
|
160 iContent->RemoveItem( aIndicatorUid ); |
|
161 iController->UpdateContentSize(); |
|
162 } |
|
163 |
|
164 |
|
165 // --------------------------------------------------------------------------- |
|
166 // CAknIndicatorPopup::SetContentVisible |
|
167 // --------------------------------------------------------------------------- |
|
168 // |
|
169 void CAknIndicatorPopup::SetContentVisible( TBool aVisible ) |
|
170 { |
|
171 iContent->SetContentVisible( aVisible ); |
|
172 } |
|
173 |
|
174 |
|
175 // --------------------------------------------------------------------------- |
|
176 // CAknIndicatorPopup::SetObserverL |
|
177 // --------------------------------------------------------------------------- |
|
178 // |
|
179 void CAknIndicatorPopup::SetObserverL( |
|
180 const MAknPreviewPopUpObserver& aObserver ) |
|
181 { |
|
182 if ( iController ) |
|
183 { |
|
184 iController->AddObserverL( aObserver ); |
|
185 } |
|
186 } |
|
187 |
|
188 |
|
189 // --------------------------------------------------------------------------- |
|
190 // CAknIndicatorPopup::RemoveObserver |
|
191 // --------------------------------------------------------------------------- |
|
192 // |
|
193 void CAknIndicatorPopup::RemoveObserver( |
|
194 const MAknPreviewPopUpObserver& aObserver ) |
|
195 { |
|
196 if ( iController ) |
|
197 { |
|
198 iController->RemoveObserver( aObserver ); |
|
199 } |
|
200 } |
|
201 |
|
202 |
|
203 // --------------------------------------------------------------------------- |
|
204 // CAknIndicatorPopup::Controller |
|
205 // --------------------------------------------------------------------------- |
|
206 // |
|
207 const CAknPreviewPopUpController* CAknIndicatorPopup::Controller() const |
|
208 { |
|
209 return iController; |
|
210 } |
|
211 |
|
212 |
|
213 // ----------------------------------------------------------------------------- |
|
214 // CAknIndicatorPopup::UpdatePopupIndicatorL |
|
215 // ----------------------------------------------------------------------------- |
|
216 // |
|
217 void CAknIndicatorPopup::UpdatePopupIndicatorL( TInt aIndicatorUid ) |
|
218 { |
|
219 iContent->HandlePluginUpdateL( aIndicatorUid ); |
|
220 } |
|
221 |
|
222 |
|
223 // ----------------------------------------------------------------------------- |
|
224 // CAknIndicatorPopup::UpdateAllPopupIndicatorsL |
|
225 // ----------------------------------------------------------------------------- |
|
226 // |
|
227 void CAknIndicatorPopup::UpdateAllPopupIndicatorsL() |
|
228 { |
|
229 iContent->UpdateAllIndicatorsL(); |
|
230 } |
|
231 |
|
232 |
|
233 // --------------------------------------------------------------------------- |
|
234 // From base class MCoeControlObserver. |
|
235 // Handles events received from the popup content. |
|
236 // --------------------------------------------------------------------------- |
|
237 // |
|
238 void CAknIndicatorPopup::HandleControlEventL( CCoeControl* aControl, |
|
239 TCoeEvent aEventType ) |
|
240 { |
|
241 if ( aControl == iContent ) |
|
242 { |
|
243 switch ( aEventType ) |
|
244 { |
|
245 case CAknIndicatorPopupContent::EAknIndicatorPopupTapEvent: |
|
246 { |
|
247 HidePopup(); |
|
248 break; |
|
249 } |
|
250 default: |
|
251 { |
|
252 break; |
|
253 } |
|
254 } |
|
255 } |
|
256 } |
|
257 |
|
258 |
|
259 // --------------------------------------------------------------------------- |
|
260 // Default constructor. |
|
261 // --------------------------------------------------------------------------- |
|
262 // |
|
263 CAknIndicatorPopup::CAknIndicatorPopup() |
|
264 { |
|
265 } |
|
266 |
|
267 |
|
268 // --------------------------------------------------------------------------- |
|
269 // CAknIndicatorPopup::ConstructL |
|
270 // --------------------------------------------------------------------------- |
|
271 // |
|
272 void CAknIndicatorPopup::ConstructL() |
|
273 { |
|
274 iContent = CAknIndicatorPopupContent::NewL(); |
|
275 iContent->SetObserver( this ); |
|
276 |
|
277 iController = CAknPreviewPopUpController::NewL( |
|
278 *iContent, |
|
279 CAknPreviewPopUpController::ELayoutSubMenu | CAknPreviewPopUpController::EDontClose ); |
|
280 |
|
281 iController->SetPopUpShowDelay( KDefaultPopUpShowDelay ); |
|
282 iController->SetPopUpHideDelay( KDefaultPopUpHideDelay ); |
|
283 |
|
284 SetPosition( TPoint( 0, 0 ) ); |
|
285 } |