Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
2 * Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * This is a concrete class for the handling of a grid. The class handles a
16 * rectangular grid arrangement of items held in any linear ordering i.e
17 * cells ordered top to bottom and left, left to right and down etc.
23 #if !defined(__AKNGRID_H__)
33 #include <AknGridView.h>
36 // CLASS PREDEFINITIONS
37 class CAknGridExtension;
42 * Application grid handling class from Avkon.
43 * Provides support for ordering application grids items.
45 * @since Series 60 0.9
47 class CAknGrid : public CEikListBox
59 * Base class default constructor.
60 * @return A pointer to a new @c CAknGrid object.
67 IMPORT_C virtual ~CAknGrid();
70 * This function gives @c CAknGridM class pointer to @c CAknGrid class.
71 * Usually, the @c CAknGridM class object is instantiated automatically
72 * during the construction phase of the @c CAknGrid object. If an
73 * application programmer provides their own grid model class, the
74 * application programmer must instantiate their own grid model class object
75 * and give it to the @c CAknGrid object using the @c SetModel function
76 * before calling the @c ConstructL/ConstructFromResourceL function.
77 * @param aModel Pointer to @c CAknGridM class.
79 IMPORT_C void SetModel(CAknGridM* aModel);
82 * This is Symbian default constructor. The @c ConstructL function needs to
83 * be called in case resource data is not used. If a leave occurs the
84 * framework generates a Symbian Leave code.
85 * @param aPatent A CCoeControl pointer.
86 * @param aFlags Parameter for @c CEikListBox constructor. If the
87 * parameter is missing default value is 0.
89 IMPORT_C void ConstructL(const CCoeControl* aParent, TInt aFlags = 0);
92 * The @c ConstructFromResourceL function needs to be called in case
93 * resource data is used. Usually, the @c CAknGridM class object is
94 * instantiated automatically during the construction phase of the
95 * @c CAknGrid object. If an application programmer provides their own grid
96 * model class, the application programmer must instantiate their own grid
97 * model class object and give it to the @c CAknGrid object using the
98 * @c SetModel function before calling the
99 * @c ConstructL/ConstructFromResourceL function. If a leave occurs the
100 * framework generates a Symbian Leave code.
101 * @param aReader Construct controls from resource file.
103 IMPORT_C void ConstructFromResourceL(TResourceReader& aReader);
106 * Sets the orientation of the grid, either vertical or horizontal, the
107 * ordering of the data and the size of the primary dimension of the
108 * grid. The value for the parameter @c aNumOfItemsInPrimaryOrient must be
109 * greater than zero since this determines the number of items (be it rows
110 * or columns) in the primary orientation of the grid. If a leave occurs
111 * the framework generates a Symbian Leave code.
112 * @param aVerticalOrientation Items vertical orientation.
113 * @param aLeftToRight @c ETrue left to right.
114 * @param aTopToBottom @c ETrue top to bottom.
115 * @param aNumOfItemsInPrimaryOrient Number of items in primary orient.
116 * @param aNumOfItemsInSecondaryOrient Number of items in Secondary orient.
117 * @param aSizeOfItems Item size.
118 * @param aWidthOfSpaceBetweenItems =0 Width of space between items.
119 * @param aHeightOfSpaceBetweenItems =0 Height of space between items.
121 IMPORT_C void SetLayoutL(TBool aVerticalOrientation,
124 TInt aNumOfItemsInPrimaryOrient,
125 TInt aNumOfItemsInSecondaryOrient,
127 TInt aWidthOfSpaceBetweenItems=0,
128 TInt aHeightOfSpaceBetweenItems=0);
131 * Sets the layout from a resource. Layout includes orientation (either
132 * vertical or horizontal), horizontal and vertical direction of numbering,
133 * the number of items in the primary and secondary orientation, and the
134 * primary and secondary scrolling types. If a leave occurs the framework
135 * generates a Symbian Leave code.
136 * @param aReader Constructs controls from a resource file.
138 IMPORT_C void SetLayoutFromResourceL(TResourceReader& aReader);
141 * Sets the movement of the cursor with respect to scrolling when the
142 * end item in the current row or column, whichever is the primary
143 * orientation of the data items, is encountered. The movement maybe
144 * either stop, loop back to same row or column or move onto the
145 * next logical data item in the sequence.
146 * @param aScrollingType Items scrolling type enum definition.
148 IMPORT_C void SetPrimaryScrollingType(CAknGridView::TScrollingType aScrollingType);
151 * Sets the movement of the cursor with respect to scrolling when the
152 * end item in the secondary dimension of the grid is encountered.
153 * The movement maybe either stop, loop back back to same row or column
154 * or move onto the next logical data item in the sequence.
155 * @param aSecondaryScrolling Secondary scrolling type enum definition.
157 IMPORT_C void SetSecondaryScrollingType(CAknGridView::TScrollingType aSecondaryScrolling);
160 * Sets the starting position of the data within the grid. A blank page
161 * cannot be accessed (since cannot move into empty cells) so a totally
162 * blank page is the same as if the page never existed since the user
163 * cannot scroll into it. For this reason it is suggested that the start
164 * position be no more than one page into the grid. If a leave occurs
165 * the framework generates a Symbian Leave code.
166 * @param aGridStartPosition Parameter manipulate the grid's starting
169 IMPORT_C void SetStartPositionL(TPoint aGridStartPosition);
172 * @c CurrentDataIndex retrieves the index of the selection. In grids, you
173 * should use this method instead of @c CEikListBox::CurrentItemIndex(),
174 * when you are manipulating data stored in the grid's @c ItemTextArray.
175 * While @c CurrentItemIndex() returns the same value as
176 * @c CurrentItemIndex() on most phones, there will be difference in some
177 * language variants where text reading/writing direction is different from
179 * @return A current position of highlight.
181 IMPORT_C TInt CurrentDataIndex() const;
184 * Moves the cursor to the required grid data index.
185 * @param aDataIndex Data index value.
187 IMPORT_C void SetCurrentDataIndex(TInt aDataIndex);
190 * The grid position function. Gives the data index by using grid's
191 * position. The position must be given from the top left corner. If
192 * the function returns -1 the item's position is invalid.
193 * @param aGridPosition The data item's co-ordinate values.
194 * @return Activated item's index value.
196 IMPORT_C TInt IndexOfPosition(TPoint aGridPosition) const;
199 * The grid position function. Gives the data item's co-ordinate values
200 * by using item's index value.
201 * @param aItemIndex The data item's index value.
202 * @return @c TPoint co-ordinate values of active item.
204 IMPORT_C TPoint PositionAtIndex(TInt aItemIndex) const;
207 * Item drawer. Gets the pointer to the grid class.
208 * @return A pointer to @c CFormattedCellListBoxItemDrawer object.
210 IMPORT_C CFormattedCellListBoxItemDrawer* ItemDrawer() const;
213 * Function sets a grid text to the data item. If a leave occurs the
214 * framework generates a Symbian Leave code.
215 * @since Series S60 3.0
216 * @param aText Descriptor parameter.
218 IMPORT_C void SetEmptyGridTextL(const TDesC& aText);
221 * This function sets the empty grid text.
222 * @return A pointer to the grid text descriptor.
224 inline const TDesC* EmptyGridText() const;
229 * This function creates a new object and returns pointer to it. If the
230 * leave occurs the framework generates a Symbian Leave code.
231 * @return A pointer to @c CListBoxView class.
233 IMPORT_C virtual CListBoxView* MakeViewClassInstanceL();
236 * This function sets the column width of the grid. Column width cannot be
237 * set in a horizontal grid since the number of columns in the grid is
238 * defined by the initialising call to @c SetLayoutL. The column width
239 * cannot be larger than the width of the viewing rectangle.
240 * @param aColumnWidth A parameter defines a width of the column.
242 IMPORT_C void SetColumnWidth(TInt aColumnWidth);
245 * This function gives a width of the column.
246 * @return A width of the column.
248 IMPORT_C TInt ColumnWidth() const;
250 public: //from CEikListBox
253 * This function updates the scrollbars, including item position. This
254 * function is called when the size of the scrollbars or data changes. If
255 * the leave occurs the framework generates a Symbian Leave code.
257 IMPORT_C virtual void UpdateScrollBarsL();
260 * This function should be called after one or more items have been added to
261 * the grid. If a leave occurs the framework generates a Symbian Leave
264 IMPORT_C void HandleItemAdditionL();
267 * This function should be called after one or more items have been removed
268 * from the grid. If a leave occurs the framework generates a Symbian
271 IMPORT_C void HandleItemRemovalL();
274 * This function is from @c CEikAppUi, handles key events. If a leave
275 * occurs the framework generates a Symbian Leave code.
276 * @param aKeyEvent Event to handled.
277 * @param aType of the key event.
278 * @return Response code ( @c EKeyWasConsumed, @c EKeyWasNotConsumed )
280 IMPORT_C virtual TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
283 * This function sets the row height of the grid. Row height cannot be set
284 * in a vertical grid since the number of rows in the grid is defined by
285 * the initialising call to @c SetLayoutL. The row height cannot be larger
286 * than the height of the viewing rectangle. If a leave occurs the
287 * framework generates a Symbian Leave code.
288 * @param aHeight The height of the item's rows.
290 IMPORT_C void SetItemHeightL(TInt aHeight);
293 * This function handles size changes. This routine assumes that
294 * @c SetLayoutL has been called to set up the grid.
296 IMPORT_C void SizeChanged();
299 * This function creates a new object and returns pointer to
300 * @c CTextListBoxModel class.
301 * @return A pointer to @c CTextListBoxModel object.
303 IMPORT_C CTextListBoxModel* Model() const;
306 * This function handles viewable rectangle.
307 * @param aRect Rectangle parameter.
309 IMPORT_C void SetRect(const TRect& aRect);
312 * This function is called when the grid's items, item's data and scroll
313 * bars has been changed. This implementation ensures that the current
314 * item is visible after resize. If a leave occurs the framework generates
315 * a Symbian Leave code.
317 IMPORT_C virtual void HandleViewRectSizeChangeL();
320 * This function sets top item index.
321 * @param aItemIndex Item index value.
323 IMPORT_C virtual void SetTopItemIndex(TInt aItemIndex) const;
326 * This function handles resource changes.
327 * @since Series S60 2.6.
328 * @param aType Message type.
330 IMPORT_C virtual void HandleResourceChange(TInt aType);
333 * Indicates whether the control should be redrawn now. If @c ENoDrawNow,
334 * the function has no immediately effect. EDrawNow redraw control
336 * @since Series S60 3.0.
338 IMPORT_C void FocusChanged(TDrawNow aDrawNow);
340 public: // From CCoeControl
341 IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
343 protected: // from CEikListBox
346 * This function scroll horizontal by one column when the left/right scroll
347 * arrows (i.e. the nudge buttons) are tapped.
348 * @return A nudge value when the buttons are pressed.
350 IMPORT_C virtual TInt HorizontalNudgeValue() const;
353 * This function gets the granularity for horizontal scrolls. The
354 * granularity is the minimum size of a horizontal move of the client area.
355 * @return A grain size for horizontal scrolling in pixels.
357 IMPORT_C virtual TInt HorizScrollGranularityInPixels() const;
360 * This function called by various functions of this class to ensure that
361 * the top item index is always a sane value. The implementation in
362 * @c CEikListBox tries to ensure the minimum amount of white space at the
363 * bottom of the list box. Note that this function does not affect the
364 * current item index.
366 IMPORT_C virtual void AdjustTopItemIndex() const;
369 * This function handles drag events. If a leave occurs the framework
370 * generates a Symbian Leave code.
371 * @param aPointerPos The position of the @c TPointerEvent for which this
372 * handler is invoked.
374 IMPORT_C virtual void HandleDragEventL(TPoint aPointerPos);
377 * This function calculates the client area. This method is called by
378 * various functions of this class to recalculate the extent of the client
379 * area from @c iViewRect. This implementation takes into account any
380 * rounding of the viewing rectangle made to fit a whole number of items.
381 * @param aClientRect On return contains a size for the client area in
384 IMPORT_C virtual void RestoreClientRectFromViewRect(TRect& aClientRect) const;
387 * This function rounds down the height of the rectangle (if necessary) so
388 * that only a whole number of items can be displayed inside the list box.
389 * @param aRect Rectangle parameter.
391 IMPORT_C virtual TInt AdjustRectHeightToWholeNumberOfItems(TRect& aRect) const;
394 * Updates the position of grids scroll bars’ thumbs to reflect the vertical
395 * position of selector.
397 IMPORT_C virtual void UpdateScrollBarThumbs() const;
400 * Gets a count of the component controls of this grid.
401 * @return The number of component controls.
403 IMPORT_C virtual TInt CountComponentControls() const;
408 * Moves to the next or previous item on the grid. If a leave occurs the
409 * framework generates a Symbian Leave code.
410 * @param aPoint Co-ordinate object parameter.
412 IMPORT_C void MoveToNextOrPreviousItemL(TPoint aPoint);
415 * This protected function used by functions to check/alter the dimensions
416 * of the grid as data items are added or removed or the size of the items
417 * are altered. It also assumes that @c SetLayoutL has been called.
418 * This will not leave if scrollbars have both been turned off. If a leave
419 * occurs the framework generates a Symbian Leave code.
421 IMPORT_C virtual void CalcGridSizeL();
424 * Creates a formatted list item drawer. If a leave occurs the framework
425 * generates a Symbian Leave code.
427 IMPORT_C virtual void CreateItemDrawerL();
433 inline CAknGridM* GridModel() const;
436 inline CAknGridView* GridView() const;
439 * This function sets the size and initial layout of items. If a leave
440 * occurs the framework generates a Symbian Leave code.
441 * @param aOrientation
444 * @param aNumOfItemsInPrimaryOrient
445 * @param aNumOfItemsInSecondaryOrient
446 * @param aSizeOfItems
447 * @param aWidthOfSpaceBetweenItems
448 * @param aHeightOfSpaceBetweenItems
450 void DoSetLayoutL(TInt aOrientation,
453 TInt aNumOfItemsInPrimaryOrient,
454 TInt aNumOfItemsInSecondaryOrient,
456 TInt aWidthOfSpaceBetweenItems=0,
457 TInt aHeightOfSpaceBetweenItems=0);
463 IMPORT_C void* ExtensionInterface( TUid aInterface );
464 private: // from MListBoxModel
465 IMPORT_C virtual TAny* MListBoxModel_Reserved();
469 * From @c MEikScrollBarObserver
471 * This function handles scroll events caused by scroll bar.
472 * It updates grid's view by event and new thumb position.
474 * @param aScrollBar pointer to scroll bar sent this event
475 * @param aEventType type of event
477 IMPORT_C virtual void HandleScrollEventL(CEikScrollBar* aScrollBar, TEikScrollEvent aEventType);
480 * From @c MObjectProvider.
482 * Retrieves an object of the same type as that encapsulated in aId. This
483 * function is used to allow controls to ask their owners for access to
484 * other objects that they own.
486 * @param aId An encapsulated object type ID.
487 * @return Encapsulates the pointer to the object provided.
488 * Note that the encapsulated pointer may be NULL.
490 IMPORT_C virtual TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
495 TBool iCurrentIsValid;
496 TInt iNumOfColsInView;
497 TInt iNumOfRowsInView;
498 TSize iSpaceBetweenItems;
499 TInt iSpare; // was iNumOfItemsInPrimaryOrient;
500 TBitFlags iOrientationFlags;
501 TBitFlags iHorizontalFlags;
502 TBitFlags iVerticalFlags;
503 CAknGridExtension *iExtension; // spare taken to use as extension class
509 inline CAknGridM* CAknGrid::GridModel() const
511 return STATIC_CAST(CAknGridM*,iModel);
517 inline CAknGridView* CAknGrid::GridView() const
519 return STATIC_CAST(CAknGridView*,iView);
523 * Return text currently in the empty grid text
525 inline const TDesC* CAknGrid::EmptyGridText() const
527 return STATIC_CAST(CAknGridView*,iView)->EmptyListText();
530 #endif //__AKNGRID_H__