|
1 /* |
|
2 * Copyright (c) 2005 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: The view part of the info pop-up note |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CAKNINFOPOPUPNOTE_H |
|
20 #define CAKNINFOPOPUPNOTE_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <AknUtils.h> |
|
24 #include <e32std.h> // RPointerArray |
|
25 #include <coecntrl.h> |
|
26 |
|
27 // FORWARD DECLARATIONS |
|
28 class CAknsFrameBackgroundControlContext; |
|
29 class CAknTextControl; |
|
30 class CAknInfoPopupNoteController; |
|
31 class TAknWindowComponentLayout; |
|
32 class TAknLayoutScalableParameterLimits; |
|
33 |
|
34 // CLASS DECLARATION |
|
35 |
|
36 /** |
|
37 * CAknInfoPopupNote is the view part of popup. |
|
38 * It draws frame, background and texts in popup. |
|
39 * @lib avkon.lib |
|
40 * @since Series 60 3.0 |
|
41 */ |
|
42 class CAknInfoPopupNote : public CCoeControl, public MCoeForegroundObserver |
|
43 { |
|
44 public: // Constructors and destructor |
|
45 |
|
46 /** |
|
47 * Two-phased constructor. |
|
48 */ |
|
49 static CAknInfoPopupNote* NewL( CAknInfoPopupNoteController& aController ); |
|
50 |
|
51 /** |
|
52 * Destructor. |
|
53 */ |
|
54 virtual ~CAknInfoPopupNote(); |
|
55 |
|
56 public: // New functions |
|
57 |
|
58 /** |
|
59 * Popup will be shown after call to this function. |
|
60 */ |
|
61 void ShowL(); |
|
62 |
|
63 /** |
|
64 * Hides popup |
|
65 */ |
|
66 void Hide(); |
|
67 |
|
68 /** |
|
69 * Set text to show in popup (setted in text control, in member data). |
|
70 * If given text is too long for popup it is truncated. |
|
71 * @param aText Text to show in popup. |
|
72 */ |
|
73 void SetTextL( const TDesC& aText ); |
|
74 |
|
75 /** |
|
76 * Return text to be show in popup. |
|
77 * @return Popup text (setted in text control, in member data). |
|
78 */ |
|
79 const TPtrC GetText() const; |
|
80 |
|
81 /** |
|
82 * Sets the position and alignment of the info pop-up note. |
|
83 * @since 3.1 |
|
84 * @param aPosition The position where pop-up note is to be displayed. |
|
85 * @param aAlignment Specifies the part of pop-up note, which will be aligned |
|
86 * with the given position. |
|
87 */ |
|
88 void SetPositionAndAlignment( const TPoint& aPosition, |
|
89 const TGulAlignmentValue& aAlignment ); |
|
90 |
|
91 /** |
|
92 * Sets the position of the info pop-up note so that it is aligned with the |
|
93 * given rectangle as specified in the LAF data. This is intented to be |
|
94 * used in conjunction with lists and grids if the application wishes to |
|
95 * implement a pop-up that follows lists/grids item highlight. |
|
96 * @since 3.1 |
|
97 * @param aHighlightRect Screen-relative rectangle used to calculate |
|
98 * pop-up's position. |
|
99 */ |
|
100 void SetPositionByHighlight( const TRect& aHighlightRect ); |
|
101 |
|
102 /** |
|
103 * Restores the info pop-up note's default position discarding previously |
|
104 * set values to position and alignment. |
|
105 * @since 3.1 |
|
106 */ |
|
107 void RestoreDefaultPosition(); |
|
108 |
|
109 /** |
|
110 * Sets the tooltip mode. When tooltip mode is on, info pop-up note is |
|
111 * displayed with only one line of text, and the width of the pop-up note |
|
112 * depends on the text lenght. |
|
113 * @since 3.1 |
|
114 * @param aTooltipMode ETrue to set tooltip mode on, EFalse to set it off. |
|
115 */ |
|
116 void SetTooltipModeL( const TBool aTooltipMode ); |
|
117 |
|
118 /** |
|
119 * Whether info popup note will be automatically hidden |
|
120 * or not when app ui is faded (true by default) |
|
121 * @since 3.1 |
|
122 * @param aHide ETrue when hidden, EFalse when shown or controlled externally |
|
123 */ |
|
124 void HideWhenAppFaded( const TBool aHide ); |
|
125 |
|
126 public: // From CCoeControl, compound control methods |
|
127 |
|
128 /** |
|
129 * Return count of used components (from CCoeControl) |
|
130 * @return Number of component controls, now returns always 1. |
|
131 */ |
|
132 TInt CountComponentControls() const; |
|
133 |
|
134 /** |
|
135 * Return pointer to used components (from CCoeControl) |
|
136 * @param aIndex |
|
137 * @return Pointer to used components, now returns always iText member variable. |
|
138 */ |
|
139 CCoeControl* ComponentControl( TInt /*aIndex*/ ) const; |
|
140 |
|
141 /** |
|
142 * Hide popup immediately and gives key event forward without consuming it. |
|
143 * @param aKeyEvent The key event. |
|
144 * @param aType The type of key event: EEventKey, EEventKeyUp or EEventKeyDown. |
|
145 * @return Indicates whether or not the key event was used by this control. |
|
146 */ |
|
147 TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ); |
|
148 |
|
149 /** |
|
150 * Sets this control as visible or invisible. |
|
151 * @param aVisible ETrue to make the control visible, EFalse to make it invisible. |
|
152 */ |
|
153 void MakeVisible( TBool aVisible ); |
|
154 |
|
155 /** |
|
156 * Handles a change to the control's resources. |
|
157 * @param aType A message UID value. |
|
158 */ |
|
159 void HandleResourceChange( TInt aType ); |
|
160 |
|
161 /** |
|
162 * Handles pointer events |
|
163 */ |
|
164 void HandlePointerEventL( const TPointerEvent& aPointerEvent ); |
|
165 |
|
166 public: // From MCoeForegroundObserver |
|
167 /** |
|
168 * Empty implementation. |
|
169 * @since S60 3.2 |
|
170 */ |
|
171 void HandleGainingForeground(); |
|
172 |
|
173 /** |
|
174 * Hides info popup note if HideWhenAppFaded is enabled. |
|
175 * @since S60 3.2 |
|
176 */ |
|
177 void HandleLosingForeground(); |
|
178 |
|
179 private: // From CCoeControl |
|
180 |
|
181 /** |
|
182 * Set some of layout things. |
|
183 */ |
|
184 void SizeChanged(); |
|
185 |
|
186 private: |
|
187 |
|
188 /** |
|
189 * C++ default constructor. |
|
190 */ |
|
191 CAknInfoPopupNote( CAknInfoPopupNoteController& aController ); |
|
192 |
|
193 /** |
|
194 * Symbian 2nd phase constructor (by default it is private). |
|
195 */ |
|
196 void ConstructL(); |
|
197 |
|
198 private: // From CCoeControl |
|
199 |
|
200 /** |
|
201 * Draw mainly the background of popup window |
|
202 * @param const TRect& aRect popup window rect |
|
203 */ |
|
204 void Draw( const TRect& aRect ) const; |
|
205 |
|
206 private: // New functions |
|
207 |
|
208 // Sets the correct layout for pop-up note. |
|
209 void SetWindowLayoutL(); |
|
210 |
|
211 // Sets the info pop-up note layout. |
|
212 void SetInfoPopupWindowLayoutL(); |
|
213 |
|
214 // Set the tooltip layout. |
|
215 void SetTooltipWindowLayoutL(); |
|
216 |
|
217 // Moves pop-up note to set floating position. |
|
218 void Relocate(); |
|
219 |
|
220 // Adjusts pop-up note's position so it will fit the screen. |
|
221 void AdjustPosition( const TPoint& aFloatingPosition ); |
|
222 |
|
223 // Gets rect from layout data. |
|
224 TRect RectFromLayout( const TRect& aParent, |
|
225 const TAknWindowComponentLayout& aComponentLayout ) const; |
|
226 |
|
227 // Selects the correct line variety depending on the number of lines. |
|
228 TInt SelectLineVariety( const TInt aNumberOfLines, |
|
229 const TAknLayoutScalableParameterLimits& aLimits ) const; |
|
230 |
|
231 // Selects the correct window variety depending on the number of lines. |
|
232 TInt SelectWindowVariety( const TInt aNumberOfLines, |
|
233 const TAknLayoutScalableParameterLimits& aLimits ) const; |
|
234 |
|
235 private: // Data |
|
236 |
|
237 // Skin context |
|
238 CAknsFrameBackgroundControlContext* iBgContext; // Own |
|
239 |
|
240 // Popoup frame rects |
|
241 TRect iOuterRect; |
|
242 TRect iInnerRect; |
|
243 |
|
244 // Used text control inside popup |
|
245 CAknTextControl* iText; |
|
246 |
|
247 // Controller of the popup |
|
248 CAknInfoPopupNoteController& iController; |
|
249 |
|
250 // Flag for toolip usage |
|
251 TBool iTooltipMode; |
|
252 |
|
253 TBool iHideWhenAppFaded; |
|
254 |
|
255 // Flag, position, and alignment for floating position usage |
|
256 TBool iFloatingPositionUsed; |
|
257 TPoint iFloatingPosition; |
|
258 TGulAlignmentValue iAlignment; |
|
259 |
|
260 }; |
|
261 |
|
262 #endif // CAKNINFOPOPUPNOTE_H |
|
263 |
|
264 // End of File |