|
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: Popup adaptive search grid component |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __AKNADAPTIVESEARCHGRID_H__ |
|
20 #define __AKNADAPTIVESEARCHGRID_H__ |
|
21 |
|
22 // INCLUDES |
|
23 #include <AknControl.h> // CCoeControl |
|
24 #include <aknbutton.h> // CAknbutton |
|
25 #include <eiklabel.h> |
|
26 #include "AknAdaptiveSearchGridObserver.h" |
|
27 #include <AknWsEventObserver.h> |
|
28 |
|
29 // FORWARD DECLARATIONS |
|
30 class CAknsBasicBackgroundControlContext; |
|
31 class CAknsFrameBackgroundControlContext; |
|
32 class CAknsListBoxBackgroundControlContext; |
|
33 class CAknInputFrame; |
|
34 class CEikEdwin; |
|
35 |
|
36 // CLASS DECLARATION |
|
37 /** |
|
38 * The class to provide adaptive search grid for the application |
|
39 * |
|
40 * @lib avkon.lib |
|
41 * @since Series 60 5.0 |
|
42 */ |
|
43 |
|
44 class CAknAdaptiveSearchGrid : public CAknControl, |
|
45 public MCoeControlObserver, |
|
46 public MCoeControlBackground, |
|
47 public MAknWsEventObserver |
|
48 { |
|
49 public: // Constructors and destructor |
|
50 |
|
51 /** |
|
52 * Two-phased constructor. |
|
53 * |
|
54 * @param aTextLimit text limit for the findpane. |
|
55 * @param aFieldStyle The same flag as search field |
|
56 * @return Pointer to the created adaptive search grid object |
|
57 */ |
|
58 static CAknAdaptiveSearchGrid* NewL( const TInt aTextLimit, |
|
59 TInt aFieldStyle ); |
|
60 |
|
61 /** |
|
62 * Two-phased constructor. |
|
63 * |
|
64 * @param aTextLimit text limit for the findpane. |
|
65 * @param aFieldStyle The same flag as search field |
|
66 * @return Pointer to the created adaptive search grid object |
|
67 */ |
|
68 static CAknAdaptiveSearchGrid* NewLC( const TInt aTextLimit, |
|
69 TInt aFieldStyle ); |
|
70 |
|
71 /** |
|
72 * Destructor. |
|
73 */ |
|
74 ~CAknAdaptiveSearchGrid(); |
|
75 |
|
76 public: // From base classes |
|
77 |
|
78 /** |
|
79 * From CCoeControl. |
|
80 * Gets the number of controls contained in a compound control. |
|
81 * |
|
82 * @return The number of component controls contained by this control. |
|
83 */ |
|
84 TInt CountComponentControls() const; |
|
85 |
|
86 /** |
|
87 * From CCoeControl. |
|
88 * Gets the specified component of a compound control. |
|
89 * |
|
90 * @param aIndex The index of the control to get |
|
91 * @return The component control with an index of aIndex. |
|
92 */ |
|
93 CCoeControl* ComponentControl( TInt aIndex ) const ; |
|
94 |
|
95 /** |
|
96 * From CCoeControl. |
|
97 * Handles a change to the control's resources. |
|
98 * |
|
99 * @param aType A message UID value. |
|
100 */ |
|
101 void HandleResourceChange( TInt aType ); |
|
102 |
|
103 /** |
|
104 * From CCoeControl. |
|
105 * Retrieves an object of the same type as that encapsulated in aId. |
|
106 * |
|
107 * @param aId An encapsulated object type ID. |
|
108 * @return Encapsulated pointer to the object provided. |
|
109 * Note that the encapsulated pointer may be NULL. |
|
110 */ |
|
111 TTypeUid::Ptr MopSupplyObject( TTypeUid aId ); |
|
112 |
|
113 /** |
|
114 * From MCoeControlObserver. |
|
115 * Handles an event from an observed adaptive search grid item. |
|
116 * |
|
117 * @param aControl The control which sent the event |
|
118 * @param aEventType The event type |
|
119 */ |
|
120 void HandleControlEventL( CCoeControl* aControl, TCoeEvent aEventType ); |
|
121 |
|
122 /** |
|
123 * From CCoeControl |
|
124 * |
|
125 * @param aRect the rectangle of this view that needs updating |
|
126 */ |
|
127 void Draw( const TRect& aRect ) const; |
|
128 |
|
129 /** |
|
130 * From CCoeControl. |
|
131 * This function is called whenever a control gains or loses focus. |
|
132 * |
|
133 * @param aDrawNow Contains the value that was passed to it by SetFocus(). |
|
134 */ |
|
135 void FocusChanged( TDrawNow aDrawNow ); |
|
136 |
|
137 /** |
|
138 * From MAknWsEventObserver. Handles window server events. |
|
139 * |
|
140 * @param The event that occurred. |
|
141 * @param The control that the event occurred in. |
|
142 */ |
|
143 void HandleWsEventL( const TWsEvent& aEvent, CCoeControl* aDestination ); |
|
144 |
|
145 /** |
|
146 * From MCoeControlBackground. |
|
147 * Draw the background for a given control. |
|
148 * The text drawer that shall be used to draw text on the specific |
|
149 * background can be fetched through the GetTextDrawer() method. |
|
150 * |
|
151 * @param aGc Graphics context used for drawing. |
|
152 * @param aControl The control being drawn (may be a child of the drawer). |
|
153 * @param aRect The area to be redrawn. |
|
154 */ |
|
155 void Draw( CWindowGc& aGc, const CCoeControl& aControl, const TRect& aRect ) const; |
|
156 |
|
157 public: // New functions |
|
158 |
|
159 /** |
|
160 * Sets the observer for the adaptive search grid. |
|
161 * |
|
162 * @param aObserver A pointer to the observer. Ownership is not changed. |
|
163 */ |
|
164 void SetAdaptiveSearchGridObserver( MAknAdaptiveSearchGridObserver* aObserver ); |
|
165 |
|
166 /** |
|
167 * Returns a pointer to the adaptive search grid observer. |
|
168 * |
|
169 * @return Pointer to the adaptive search grid observer. |
|
170 */ |
|
171 MAknAdaptiveSearchGridObserver* AdaptiveSearchGridObserver(); |
|
172 |
|
173 /** |
|
174 * Shows or hides adaptive search grid. |
|
175 * Position of the top left corner should be set in advance. |
|
176 * Adaptive search grid set visible with this method is by default focusing. |
|
177 * Does nothing if adaptive search grid is disabled. |
|
178 * |
|
179 * @param aVisible ETrue to show it, EFalse to hide it. |
|
180 * @param aSelectAll ETrue to highlight all content of editor. |
|
181 */ |
|
182 void SetVisibilityL( TBool aVisible, TBool aSelectAll ); |
|
183 |
|
184 /** |
|
185 * Show adaptive search grid button. |
|
186 */ |
|
187 void ShowL(); |
|
188 |
|
189 /** |
|
190 * Returns adaptive search grid visibility at this moment |
|
191 * |
|
192 * @return ETrue, if adaptive search grid is shown. |
|
193 */ |
|
194 TBool IsShown() const; |
|
195 |
|
196 /** |
|
197 * Set chars to button array |
|
198 * |
|
199 * @param aGridChars are the characters for adaptive search grid. |
|
200 */ |
|
201 void SetButtonGridChars( const TDesC& aGridChars ); |
|
202 |
|
203 /** |
|
204 * Sets text into search field. |
|
205 * |
|
206 * @param const aSearchTxt Reference to the text buffer. |
|
207 */ |
|
208 void SetSearchTextToFindPane( const TDesC& aSearchTxt ); |
|
209 |
|
210 /** |
|
211 * Initiates buttons for adaptive search grid |
|
212 */ |
|
213 void InitGridButtons(); |
|
214 |
|
215 /** |
|
216 * Initiates position for buttons of grid |
|
217 */ |
|
218 void GridButtonsPositions(); |
|
219 |
|
220 /** |
|
221 * Main function for initiation adaptive search grid |
|
222 */ |
|
223 void InitGrid(); |
|
224 |
|
225 /** |
|
226 * Show controls backspase, close, prev, next buttons and find pane |
|
227 */ |
|
228 void ShowControls(); |
|
229 |
|
230 /** |
|
231 * Hides adaptive search grid. |
|
232 */ |
|
233 void HideL(); |
|
234 |
|
235 static const TInt EDeleteLastCharPressed = -1; |
|
236 static const TInt ECloseGridPressed = -2; |
|
237 |
|
238 public: |
|
239 |
|
240 /** |
|
241 * When the rect of find pane is set, this functions will be notified |
|
242 * to record the size of it. |
|
243 */ |
|
244 void SaveFindPaneRect( const TRect &aRect ); |
|
245 |
|
246 protected: // From base class |
|
247 |
|
248 /** |
|
249 * From CCoeControl. |
|
250 * Responds to size changes to sets the size and position of |
|
251 * the contents of this control. |
|
252 */ |
|
253 void SizeChanged(); |
|
254 |
|
255 private: // Constructors |
|
256 |
|
257 /** |
|
258 * C++ default constructor. |
|
259 * |
|
260 * @param aTextLimit text limit for the findpane. |
|
261 */ |
|
262 CAknAdaptiveSearchGrid( const TInt aTextLimit ); |
|
263 |
|
264 /** |
|
265 * Symbian 2nd phase constructor. |
|
266 * @param aFieldStyle The same flag as search field |
|
267 */ |
|
268 void ConstructL( TInt aFieldStyle ); |
|
269 |
|
270 |
|
271 private: // New functions |
|
272 |
|
273 /** |
|
274 * Update page indicator. |
|
275 */ |
|
276 void UpdatePageIndicatorL(); |
|
277 |
|
278 /** |
|
279 * Sets the flag to be on or off and also calls |
|
280 * CCoeControl::MakeVisible(). |
|
281 * |
|
282 * @param aShown is True, if adaptive search grid is shown. |
|
283 */ |
|
284 void SetShown( const TBool aShown ); |
|
285 |
|
286 /** |
|
287 * Create and add button controlto adaptive search grid. |
|
288 * |
|
289 * @param aText text for button grid |
|
290 */ |
|
291 CAknButton* CreateButtonL(); |
|
292 |
|
293 /** |
|
294 * Show next page |
|
295 */ |
|
296 void NextPage(); |
|
297 |
|
298 /** |
|
299 * Show previous page |
|
300 */ |
|
301 void PrevPage(); |
|
302 |
|
303 /** |
|
304 * Initiate controls |
|
305 * Create control buttons: close, backspase, next, previous. |
|
306 * @param aFieldStyle The same flag as search field |
|
307 */ |
|
308 void InitControlsL( TInt aFieldStyle); |
|
309 |
|
310 /** |
|
311 * Initiate position for controls |
|
312 */ |
|
313 void ControlsPositions(); |
|
314 |
|
315 /** |
|
316 * Gets rect from layout data |
|
317 */ |
|
318 TRect RectFromLayout( const TRect& aParent, |
|
319 const TAknWindowComponentLayout& aComponentLayout ) const; |
|
320 |
|
321 /** |
|
322 * Update visibility of buttons from grid |
|
323 */ |
|
324 void UpdateVisibleButtonsL(); |
|
325 |
|
326 /** |
|
327 * Update layout option accoding to current amount of rows |
|
328 */ |
|
329 void UpdatePageAndRowCount(); |
|
330 |
|
331 /** |
|
332 * Update icon's color accoding to current theme |
|
333 */ |
|
334 CGulIcon* GetColorIconL( TInt aIndex ); |
|
335 /** |
|
336 * Update layout variant |
|
337 */ |
|
338 void UpdateLayoutVariant(); |
|
339 |
|
340 /** |
|
341 * Update adaptive search grid skin. |
|
342 */ |
|
343 void UpdateSkinL(); |
|
344 |
|
345 |
|
346 private: // Member variables |
|
347 |
|
348 // array for adaptive search grid buttons |
|
349 RPointerArray<CAknButton> iButtonArray; |
|
350 |
|
351 // control buttons |
|
352 CAknButton* iCloseButton; |
|
353 CAknButton* iDeleteButton; |
|
354 CAknButton* iPrevButton; |
|
355 CAknButton* iNextButton; |
|
356 CAknButton* iLastFocusedButton; |
|
357 |
|
358 // page indicator if several pages |
|
359 CEikLabel* iPageIndicator; |
|
360 |
|
361 // find pane for AS |
|
362 CAknInputFrame* iInputFrame; |
|
363 CEikEdwin* iEditor; |
|
364 TInt iTextLimit; |
|
365 |
|
366 // skin context for find pane |
|
367 CAknsListBoxBackgroundControlContext* iSkinContextOfFindPane; |
|
368 CAknsFrameBackgroundControlContext* iBgContextOfFindPane; |
|
369 |
|
370 // contex for control pane |
|
371 CAknsBasicBackgroundControlContext* iBgContextOfControlPane; |
|
372 |
|
373 // whether adaptive search grid is shown right now |
|
374 // IsVisible() is not safe enough because can be |
|
375 // changed from outside with MakeVisible() |
|
376 TBool iShown; |
|
377 |
|
378 // number of grid rows and cols |
|
379 TInt iNumOfRows; |
|
380 TInt iNumOfCols; |
|
381 |
|
382 // number of grid pages |
|
383 TInt iNumOfPages; |
|
384 |
|
385 // current page which shown on screen |
|
386 TInt iCurrentPage; |
|
387 |
|
388 // current amount of total grid button |
|
389 TInt iTotalGridButtons; |
|
390 |
|
391 // max amount of total grid button |
|
392 TInt iMaxAmountOfButtons; |
|
393 |
|
394 // current button icon size |
|
395 TSize iButtonIconSize; |
|
396 |
|
397 // chars of grid |
|
398 HBufC* iGridChars; |
|
399 |
|
400 // region which AS cover currently |
|
401 RRegion iCurrentRegion; |
|
402 |
|
403 // current layout option |
|
404 // 0 portrait with pages |
|
405 // 1 landscape with pages |
|
406 // 2 portrait with no pages |
|
407 // 3 landscape with no pages |
|
408 TInt iLayoutOption; |
|
409 |
|
410 TBool iToolbarShown; |
|
411 |
|
412 // not owned |
|
413 CAknAppUi* iAppUi; |
|
414 |
|
415 // observer to report adaptive search grid item events |
|
416 // not owned |
|
417 MAknAdaptiveSearchGridObserver* iAdaptiveSearchGridObserver; |
|
418 |
|
419 //Reset grids position when layout is changed. |
|
420 TBool iLayoutChanged; |
|
421 |
|
422 |
|
423 // For ELJG-7VC8Q2: popup find pane overlap with Adaptive Search grid |
|
424 TBool iPopupFindpane; |
|
425 // The length of overlap section |
|
426 TInt iOverlapLength; |
|
427 |
|
428 TRect iFindpaneRect; |
|
429 |
|
430 TBool iFindPaneSizeChanged; |
|
431 |
|
432 }; |
|
433 |
|
434 #endif // __AKNADAPTIVESEARCHGRID_H__ |
|
435 |
|
436 // End of File |
|
437 |