63
|
1 |
/*
|
|
2 |
* Copyright (c) 2007-10 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: Content for preview pop-up.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#ifndef CBATTERYPOPUPCONTROL_H
|
|
20 |
#define CBATTERYPOPUPCONTROL_H
|
|
21 |
|
|
22 |
#include <AknControl.h>
|
|
23 |
#include <AknUtils.h>
|
|
24 |
#include <AknPreviewPopUpController.h> // Controlling the preview pop-up component
|
|
25 |
|
|
26 |
class MEikCommandObserver;
|
|
27 |
class CEikLabel;
|
|
28 |
class CGulIcon;
|
|
29 |
|
|
30 |
|
|
31 |
/**
|
|
32 |
* Class defining stylus activated pop-up content.
|
|
33 |
*
|
|
34 |
* This content is intended to be used in connection with preview pop-up
|
|
35 |
* component. Content shows an icon, text and
|
|
36 |
* an optional stylus tappable function link. If using link, the user gives link text and
|
|
37 |
* corresponding ID for link in construction. The user must also set
|
|
38 |
* itself as an observer for this content when using function links. This
|
|
39 |
* way the user gets callbacks (with ID) for its ProcessCommandL() function
|
|
40 |
* when the link is tapped.
|
|
41 |
*
|
|
42 |
* @lib BatteryPopupControl.lib
|
|
43 |
* @since S60 5.0
|
|
44 |
*/
|
|
45 |
NONSHARABLE_CLASS( CBatteryPopupControl ) :
|
|
46 |
public CAknControl,
|
|
47 |
public MCoeControlObserver,
|
|
48 |
public MAknPreviewPopUpObserver
|
|
49 |
{
|
|
50 |
public:
|
|
51 |
|
|
52 |
/** Preview popup command ids */
|
|
53 |
enum TLinkCommandID
|
|
54 |
{
|
|
55 |
ELinkNone = 0,
|
|
56 |
ELinkFirst = 1
|
|
57 |
};
|
|
58 |
|
|
59 |
/**
|
|
60 |
* Two-phased constructor. Constructs the content
|
|
61 |
* with text and function link.
|
|
62 |
*
|
|
63 |
* @since S60 5.0
|
|
64 |
* @param aContentText Text for the popup. Mandatory.
|
|
65 |
* @param aLinkText Link text.
|
|
66 |
* @return Pointer to the created content object.
|
|
67 |
*/
|
|
68 |
|
|
69 |
IMPORT_C static CBatteryPopupControl* NewL( const TDesC& aContentText,
|
|
70 |
const TDesC& aLinkText );
|
|
71 |
|
|
72 |
/**
|
|
73 |
* Destructor.
|
|
74 |
*/
|
|
75 |
~CBatteryPopupControl();
|
|
76 |
|
|
77 |
/**
|
|
78 |
* Sets the command observer of the preview pop-up content. When
|
|
79 |
* link that is set to the content is pressed, the command
|
|
80 |
* observer's ProcessCommandL() method is called with the command ID
|
|
81 |
* of the pressed component.
|
|
82 |
*
|
|
83 |
* @since S60 5.0
|
|
84 |
* @param aCommandObserver Command observer.
|
|
85 |
*/
|
|
86 |
IMPORT_C void SetCommandObserver( MEikCommandObserver& aCommandObserver );
|
|
87 |
|
|
88 |
/**
|
|
89 |
* Shows preview popup
|
|
90 |
*
|
|
91 |
* @since S60 5.0
|
|
92 |
*/
|
|
93 |
IMPORT_C void ShowPopUpL();
|
|
94 |
|
|
95 |
private:
|
|
96 |
// from base class CCoeControl
|
|
97 |
|
|
98 |
/**
|
|
99 |
* Handles a change to the control's resources of type aType which are
|
|
100 |
* shared across the environment.
|
|
101 |
*
|
|
102 |
* @param aType The type of resource that have changed.
|
|
103 |
*/
|
|
104 |
void HandleResourceChange( TInt aType );
|
|
105 |
|
|
106 |
/**
|
|
107 |
* Sets container window.
|
|
108 |
*
|
|
109 |
* @param aContainer Container.
|
|
110 |
*/
|
|
111 |
void SetContainerWindowL( const CCoeControl& aContainer );
|
|
112 |
|
|
113 |
/**
|
|
114 |
* Handles pointer events
|
|
115 |
*
|
|
116 |
* @param aPointerEvent information about the pointer event.
|
|
117 |
*/
|
|
118 |
void HandlePointerEventL( const TPointerEvent& aPointerEvent );
|
|
119 |
|
|
120 |
|
|
121 |
// from base class MCoeControlObserver
|
|
122 |
|
|
123 |
/**
|
|
124 |
* Handles an event from an observed control.
|
|
125 |
*
|
|
126 |
* @param aControl The control that sent the event.
|
|
127 |
* @param aEventType The event type.
|
|
128 |
*/
|
|
129 |
void HandleControlEventL( CCoeControl *aControl,
|
|
130 |
TCoeEvent aEventType );
|
|
131 |
|
|
132 |
// From MAknPreviewPopUpObserver
|
|
133 |
|
|
134 |
/**
|
|
135 |
* @see MAknPreviewPopUpObserver
|
|
136 |
*/
|
|
137 |
void HandlePreviewPopUpEventL( CAknPreviewPopUpController* aController,
|
|
138 |
TPreviewPopUpEvent aEvent );
|
|
139 |
|
|
140 |
/**
|
|
141 |
* Default constructor.
|
|
142 |
*/
|
|
143 |
CBatteryPopupControl();
|
|
144 |
|
|
145 |
/**
|
|
146 |
* Symbian 2nd phase constructor.
|
|
147 |
*
|
|
148 |
* @since S60 5.0
|
|
149 |
* @param aContentText Text for the popup.
|
|
150 |
* @param aLinkText Link text.
|
|
151 |
*/
|
|
152 |
void ConstructL( const TDesC& aContentText,
|
|
153 |
const TDesC& aLinkText );
|
|
154 |
|
|
155 |
/**
|
|
156 |
* Gets rect from layout data.
|
|
157 |
*
|
|
158 |
* @since S60 5.0
|
|
159 |
* @param aParent Parent rect.
|
|
160 |
* @param aComponentLayout Layout data.
|
|
161 |
*/
|
|
162 |
TRect RectFromLayout( const TRect& aParent,
|
|
163 |
const TAknWindowComponentLayout& aComponentLayout ) const;
|
|
164 |
|
|
165 |
/**
|
|
166 |
* Gets rect from layout data.
|
|
167 |
*
|
|
168 |
* @since S60 5.0
|
|
169 |
* @param aComponentLayout Layout data.
|
|
170 |
*/
|
|
171 |
TRect PopUpWindowRectFromLayout( const TAknWindowComponentLayout&
|
|
172 |
aComponentLayout ) const;
|
|
173 |
|
|
174 |
/**
|
|
175 |
* Creates CGulIcon.
|
|
176 |
*
|
|
177 |
* @since S60 5.0
|
|
178 |
*/
|
|
179 |
void CreateIconL( );
|
|
180 |
|
|
181 |
// from base class CCoeControl
|
|
182 |
|
|
183 |
/**
|
|
184 |
* Returns a control determined by control index.
|
|
185 |
*
|
|
186 |
* @param aIndex Index of a control to be returned.
|
|
187 |
* @return Pointer to control.
|
|
188 |
*/
|
|
189 |
CCoeControl* ComponentControl( TInt aIndex ) const;
|
|
190 |
|
|
191 |
/**
|
|
192 |
* Returns the number of controls inside the control.
|
|
193 |
*
|
|
194 |
* @return The number of component controls.
|
|
195 |
*/
|
|
196 |
TInt CountComponentControls() const;
|
|
197 |
|
|
198 |
/**
|
|
199 |
* Draws the control.
|
|
200 |
*
|
|
201 |
* @param aRect The control's area.
|
|
202 |
*/
|
|
203 |
void Draw( const TRect& aRect ) const;
|
|
204 |
|
|
205 |
/**
|
|
206 |
* Returns the control's minimum required size.
|
|
207 |
*
|
|
208 |
* @return The minimum size required by the control.
|
|
209 |
*/
|
|
210 |
TSize MinimumSize();
|
|
211 |
|
|
212 |
/**
|
|
213 |
* Responds to size changes to set the size and position for
|
|
214 |
* the contents of this control.
|
|
215 |
*/
|
|
216 |
void SizeChanged();
|
|
217 |
|
|
218 |
private: // data
|
|
219 |
/** Variant ids */
|
|
220 |
enum TVariantID
|
|
221 |
{
|
|
222 |
EVariantIconText = 0,
|
|
223 |
EVariantIconTextLink = 1
|
|
224 |
};
|
|
225 |
|
|
226 |
/**
|
|
227 |
* Label for informative text.
|
|
228 |
* Own.
|
|
229 |
*/
|
|
230 |
CEikLabel* iText;
|
|
231 |
|
|
232 |
/**
|
|
233 |
* Link text.
|
|
234 |
* Own.
|
|
235 |
*/
|
|
236 |
HBufC* iLinkText;
|
|
237 |
|
|
238 |
/**
|
|
239 |
* Command observer.
|
|
240 |
* Not own.
|
|
241 |
*/
|
|
242 |
MEikCommandObserver* iCommandObserver;
|
|
243 |
|
|
244 |
/**
|
|
245 |
* Font
|
|
246 |
* Not own
|
|
247 |
*/
|
|
248 |
const CFont* iFont;
|
|
249 |
|
|
250 |
/**
|
|
251 |
* Status of highlighted item.
|
|
252 |
*/
|
|
253 |
TBool iHighlightedItem;
|
|
254 |
|
|
255 |
/**
|
|
256 |
* Id for icon bitmap
|
|
257 |
*/
|
|
258 |
TInt iIconId;
|
|
259 |
|
|
260 |
/**
|
|
261 |
* Id for icon mask
|
|
262 |
*/
|
|
263 |
TInt iMaskId;
|
|
264 |
|
|
265 |
/**
|
|
266 |
* Icon.
|
|
267 |
* Own.
|
|
268 |
*/
|
|
269 |
CGulIcon* iIcon;
|
|
270 |
|
|
271 |
/**
|
|
272 |
* Layout for icon
|
|
273 |
*/
|
|
274 |
TAknLayoutRect iBitmapLayout;
|
|
275 |
|
|
276 |
/**
|
|
277 |
* Variant,
|
|
278 |
* 0 = icon and text
|
|
279 |
* 1 = icon, text and function link
|
|
280 |
*/
|
|
281 |
TInt iVariant;
|
|
282 |
|
|
283 |
/**
|
|
284 |
* Popup controller
|
|
285 |
* Own.
|
|
286 |
*/
|
|
287 |
CAknPreviewPopUpController* iController;
|
|
288 |
|
|
289 |
/**
|
|
290 |
* Rect for link
|
|
291 |
*/
|
|
292 |
TRect iLinkRect;
|
|
293 |
|
|
294 |
/**
|
|
295 |
* Alignment of the Layout either ERight or ELeft
|
|
296 |
*/
|
|
297 |
CGraphicsContext::TTextAlign iAlign;
|
|
298 |
};
|
|
299 |
|
|
300 |
|
|
301 |
#endif // CBATTERYPOPUPCONTROL_H
|
|
302 |
|