williamr@4: /* williamr@4: * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). williamr@4: * All rights reserved. williamr@4: * This component and the accompanying materials are made available williamr@4: * under the terms of "Eclipse Public License v1.0" williamr@4: * which accompanies this distribution, and is available williamr@4: * at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@4: * williamr@4: * Initial Contributors: williamr@4: * Nokia Corporation - initial contribution. williamr@4: * williamr@4: * Contributors: williamr@4: * williamr@4: * Description: williamr@4: * williamr@4: */ williamr@4: williamr@4: // EIKFRLB.H williamr@4: // williamr@4: // Copyright (c) 1997-2001 Symbian Ltd. All rights reserved. williamr@4: // williamr@4: #if !defined(__EIKFRLB_H__) williamr@4: #define __EIKFRLB_H__ williamr@4: williamr@4: #include williamr@4: #include williamr@4: #include williamr@4: #include williamr@4: williamr@4: class CFormattedCellListBoxData; williamr@4: williamr@4: /** williamr@4: * @c CFormattedCellListBoxItemDrawer draws a single list item and manages williamr@4: * list item properties. williamr@4: * williamr@4: * @lib avkon williamr@4: */ williamr@4: class CFormattedCellListBoxItemDrawer : public CTextListItemDrawer williamr@4: { williamr@4: public: williamr@4: williamr@4: /** williamr@4: * C++ default constructor. williamr@4: * williamr@4: * @param aTextListBoxModel The list box model class. williamr@4: * @param aFont Font to be used in listbox. williamr@4: * @param aFormattedCellData Pointer to the list layout drawer class. williamr@4: */ williamr@4: IMPORT_C CFormattedCellListBoxItemDrawer( williamr@4: MTextListBoxModel* aTextListBoxModel, williamr@4: const CFont* aFont, williamr@4: CFormattedCellListBoxData* aFormattedCellData); williamr@4: williamr@4: /** williamr@4: * Destructor. williamr@4: */ williamr@4: IMPORT_C ~CFormattedCellListBoxItemDrawer(); williamr@4: williamr@4: /** williamr@4: * Gets the list layout drawer. williamr@4: * williamr@4: * @return Pointer to the list layout drawer object. williamr@4: */ williamr@4: IMPORT_C CFormattedCellListBoxData* FormattedCellData() const; williamr@4: williamr@4: /** williamr@4: * Gets the list layout drawer. williamr@4: * williamr@4: * @return Pointer to the list layout drawer object. williamr@4: */ williamr@4: IMPORT_C CFormattedCellListBoxData* ColumnData() const; williamr@4: // for compability with columnlistbox itemdrawer williamr@4: williamr@4: /** williamr@4: * Draws an empty item to the list box. williamr@4: * williamr@4: * @param aItemIndex Not used. williamr@4: * @param aItemRectPos Position for the list box item rectangle. williamr@4: * @param aViewIsDimmed Not used. williamr@4: */ williamr@4: IMPORT_C virtual void DrawEmptyItem(TInt aItemIndex, TPoint aItemRectPos, williamr@4: TBool aViewIsDimmed) const; williamr@4: williamr@4: /** williamr@4: * This function sets top item index. williamr@4: * williamr@4: * @param aTop Item index value. williamr@4: */ williamr@4: IMPORT_C void SetTopItemIndex(TInt aTop); williamr@4: williamr@4: /** williamr@4: * List item index and color and style properties. williamr@4: */ williamr@4: struct SListProperties williamr@4: { williamr@4: /** List box item index. */ williamr@4: TInt iItem; // must be first williamr@4: williamr@4: /** Colour and style properties for the list item. */ williamr@4: TListItemProperties iProperties; williamr@4: }; williamr@4: williamr@4: /** williamr@4: * Clears all properties. williamr@4: */ williamr@4: IMPORT_C void ClearAllPropertiesL(); williamr@4: williamr@4: /** williamr@4: * The SetProperties is convenience method for normal cases. williamr@4: * NOTE that it does NOT work correctly if you can insert/delete williamr@4: * items from the list -- You need to update all properties if williamr@4: * any changes to the item text array happen! Often it is convenient williamr@4: * to override the @c Properties() method. Further, use this only williamr@4: * for small lists. williamr@4: * williamr@4: * It has been implemented as sorted list of (index,Property) pairs. williamr@4: * williamr@4: * If you're using find, aItemIndex for this method is the same as you give williamr@4: * in @c MdcaPoint() points the default @c Properties() does conversion williamr@4: * between indexes. williamr@4: * williamr@4: * @param aItemIndex List box item index. williamr@4: * @param properties Colour and style properties for the list box item. williamr@4: */ williamr@4: IMPORT_C void SetPropertiesL(TInt aItemIndex, TListItemProperties properties); williamr@4: williamr@4: /** williamr@4: * Function for getting properties of a certain list box item. williamr@4: * williamr@4: * @param aItemIndex The listbox item index. williamr@4: * @return Colour and style properties of wanted williamr@4: * list box item. williamr@4: */ williamr@4: IMPORT_C virtual TListItemProperties Properties(TInt aItemIndex) const; williamr@4: williamr@4: /** williamr@4: * Gets list box item cell size. williamr@4: * williamr@4: * @return The list box item cell size. williamr@4: */ williamr@4: TSize LafItemSize() { return iItemCellSize; } williamr@4: williamr@4: public: // from CTextListItemDrawer williamr@4: williamr@4: /** williamr@4: * From @c CTextListItemDrawer. williamr@4: * williamr@4: * Draw an item in a list box. williamr@4: * williamr@4: * @param aItemIndex The index into the model's item array of the item williamr@4: * to draw. williamr@4: * @param aItemTextRect The item’s text rectangle. williamr@4: * @param aItemIsCurrent @c ETrue if the item is current. @c EFalse williamr@4: * otherwise. williamr@4: * @param aViewIsEmphasized @c ETrue if the view is emphasized. @c EFalse williamr@4: * otherwise. williamr@4: * @param aItemIsSelected @c ETrue if the item is selected. @c EFalse williamr@4: * otherwise. williamr@4: */ williamr@4: IMPORT_C void DrawItemText(TInt aItemIndex,const TRect& aItemTextRect, williamr@4: TBool aItemIsCurrent, TBool aViewIsEmphasized, williamr@4: TBool aItemIsSelected) const; williamr@4: williamr@4: /** williamr@4: * From @c CTextListItemDrawer. williamr@4: * williamr@4: * Draws an item tick mark. williamr@4: * williamr@4: * A tick mark is used in multiple selection lists to indicate the item is williamr@4: * selected. williamr@4: * williamr@4: * This function is invoked by the framework to draw an item mark if williamr@4: * @c iDrawMark is set. The mark should be drawn into this list item williamr@4: * drawer's graphics context; by default, @c DrawItemMark() draws a tick williamr@4: * using the standard symbol font. williamr@4: * williamr@4: * This function does not need to be re-implemented for derived classes williamr@4: * which do not draw item marks. williamr@4: * williamr@4: * @param aItemIsSelected Whether the item to draw for is selected. williamr@4: * @param aViewIsDimmed Whether the item is dimmed. williamr@4: * @param aMarkPos Position of the mark. williamr@4: */ williamr@4: IMPORT_C void DrawItemMark(TBool aItemIsSelected, TBool aViewIsDimmed, williamr@4: const TPoint& aMarkPos) const; williamr@4: williamr@4: public: // from CListItemDrawer williamr@4: williamr@4: /** williamr@4: * From @c CListItemDrawer. williamr@4: * williamr@4: * Gets the minimum size of a cell based on the font and the number of williamr@4: * characters in the cell. williamr@4: * williamr@4: * @return The minimum size for a cell in pixels. williamr@4: */ williamr@4: IMPORT_C TSize MinimumCellSize() const; williamr@4: williamr@4: /** williamr@4: * From @c CListItemDrawer. williamr@4: * williamr@4: * Gets the width in pixels of the specified item. williamr@4: * williamr@4: * @param aItemIndex The index of the item for which the width is obtained. williamr@4: * @return The specified item's width in pixels. williamr@4: */ williamr@4: IMPORT_C TInt ItemWidthInPixels(TInt aItemIndex) const; williamr@4: williamr@4: /** williamr@4: * From @c CListItemDrawer. williamr@4: * williamr@4: * Sets the item cell size. williamr@4: * williamr@4: * The cell size is the on-screen size of the entire item, including its williamr@4: * text and its item mark. williamr@4: * williamr@4: * @param aSizeInPixels New size for the item cell. williamr@4: */ williamr@4: IMPORT_C void SetItemCellSize(const TSize& aSizeInPixels); williamr@4: williamr@4: protected: williamr@4: williamr@4: /** williamr@4: * Draws current item rectangle. williamr@4: * williamr@4: * @param aRect Current item rectangle. williamr@4: */ williamr@4: void DrawCurrentItemRect(const TRect& aRect) const; williamr@4: williamr@4: /** williamr@4: * @c WordWrapListItem is used with @c CAknDouble* style listboxes. williamr@4: * If listbox does not have 2nd line defined, @c WordWrapListItem williamr@4: * wraps 1st line to 2nd line, if text does not fit to 1st line. williamr@4: * If listbox does have 2nd line defined, this method truncates williamr@4: * both lines. williamr@4: * williamr@4: * @internal williamr@4: * @param aTarget Where to place wrapped item string williamr@4: * @param aItemString Text to be wrapped williamr@4: * @param aFirstIndex index of 1st subcell to wrap williamr@4: * @param aSecondIndex index of 2nd subcell williamr@4: */ williamr@4: void WordWrapListItem( TPtr& aTarget, williamr@4: const TDesC &aItemString, williamr@4: TInt aFirstIndex, williamr@4: TInt aSecondIndex, williamr@4: TInt aItemIndex ) const; williamr@4: /** williamr@4: * @internal williamr@4: */ williamr@4: void DrawBackgroundAndSeparatorLines( const TRect& aItemTextRect, williamr@4: TBool aDrawSeparator ) const; williamr@4: williamr@4: williamr@4: private: williamr@4: williamr@4: IMPORT_C void CFormattedCellListBoxItemDrawer_Reserved(); williamr@4: williamr@4: protected: williamr@4: williamr@4: /** williamr@4: * Top item index. williamr@4: */ williamr@4: TInt iTopItemIndex; williamr@4: williamr@4: /** williamr@4: * Array for list box item's properties. williamr@4: * Own. williamr@4: */ williamr@4: CArrayFix* iPropertyArray; williamr@4: williamr@4: private: williamr@4: williamr@4: TInt iSpare; williamr@4: }; williamr@4: williamr@4: williamr@4: /** williamr@4: * Avkon base class similar to uikon's column listbox. williamr@4: * williamr@4: * @code williamr@4: * ListBox <>--> View ---> ItemDrawer ---> Model williamr@4: * ListBox <>--> ItemDrawer <>---> Data williamr@4: * ListBox <>--> Model <>---> MDesCArray <--- Array <>---> Engine williamr@4: * @endcode williamr@4: * williamr@4: * Content for list items are tab-separated strings. williamr@4: * williamr@4: * See concrete classes derived from @c CEikFormattedCellListBox for details. williamr@4: * williamr@4: * Starting from 3.0 listbox uses highlight animations. Starting and stopping williamr@4: * animation is connected to focus events. To support highlight animations williamr@4: * properly you have to make sure that the list has focus when it has 'visual williamr@4: * focus'. Common issues: williamr@4: * - In many cases list is in a container which sits on top of the control williamr@4: * stack. The container receives all focus events and should hand them to the williamr@4: * list too. E.g. williamr@4: * @code void CContainer::FocusChanged( TDrawNow aDrawNow ) williamr@4: * { williamr@4: * ... some code ... williamr@4: * if( iListBox ) williamr@4: * iListBox->SetFocus( IsFocused(), aDrawNow ); williamr@4: * } williamr@4: * @endcode williamr@4: * - When switching components programmatically, e.g. from one list to another williamr@4: * in the same view, make sure that you remove focus from the other williamr@4: * component. williamr@4: * - In more complex cases you may have to add a dummy interceptor control to williamr@4: * the top of control stack to hand focus events to list. williamr@4: * - Make sure you handle resource changes correctly. If resource handle chain williamr@4: * is solid it should reach @c CCoeControl::HandleResourceChange, which williamr@4: * informs child components about resource change. williamr@4: * williamr@4: * See methods williamr@4: * @c CEikListBox::ConstructL() williamr@4: * @c CEikTextListBox::SetItemTextArray() williamr@4: * @c CEikFormattedCellListBoxData::SetIconArray() williamr@4: * williamr@4: * Related flags for dialogs (@c avkon.hrh) williamr@4: * @c EAknDialogSelectionList williamr@4: * @c EAknDialogMenuList williamr@4: * @c EAknDialogMultiselectionList williamr@4: * williamr@4: * Check also: williamr@4: * @c CAknSelectionListDialog (@c aknselectionlist.h) williamr@4: * @c CAknMarkableListDialog (@c aknselectionlist.h) williamr@4: * @c CAknPopupList (@c aknpopup.h) williamr@4: * @c CAknListQueryDialog (@c aknquerydialog.h) williamr@4: * @c CAknColumnListBox (@c aknlists.h) williamr@4: * williamr@4: * @lib avkon williamr@4: */ williamr@4: class CEikFormattedCellListBox : public CEikTextListBox williamr@4: { williamr@4: williamr@4: public: williamr@4: williamr@4: /** williamr@4: * C++ default constructor. williamr@4: */ williamr@4: IMPORT_C CEikFormattedCellListBox(); williamr@4: williamr@4: /** williamr@4: * Constructs list box from resource file. See @c LISTBOX resource williamr@4: * definition. williamr@4: * williamr@4: * Flags: williamr@4: * @c EAknListBoxSelectionList, williamr@4: * @c EAknListBoxMenuList, williamr@4: * @c EAknListBoxMarkableList, williamr@4: * @c EAknListBoxMultiselectionList, williamr@4: * @c EAknListBoxViewerFlags williamr@4: * williamr@4: * @param aReader Reference to resource reader @c TResourceReader object. williamr@4: */ williamr@4: IMPORT_C void ConstructFromResourceL(TResourceReader& aReader); williamr@4: williamr@4: /** williamr@4: * By default Symbian 2nd phase constructor is private. Must be called williamr@4: * if resource data is not used. williamr@4: * williamr@4: * @param aParent Pointer to @c CCoeControl class, parent control. williamr@4: * @param aFlags Flags for @c CEikListBox constructor. Possible flags : williamr@4: * @c EAknListBoxSelectionList, williamr@4: * @c EAknListBoxMenuList, williamr@4: * @c EAknListBoxMarkableList, williamr@4: * @c EAknListBoxMultiselectionList, williamr@4: * @c EAknListBoxViewerFlags williamr@4: */ williamr@4: IMPORT_C void ConstructL(const CCoeControl* aParent, TInt aFlags); williamr@4: williamr@4: public: williamr@4: williamr@4: /** williamr@4: * Gets model class of the list box. williamr@4: * williamr@4: * @return Pointer to list box model class instance. williamr@4: */ williamr@4: IMPORT_C CTextListBoxModel* Model() const; williamr@4: williamr@4: /** williamr@4: * Gets list box item drawer. williamr@4: * williamr@4: * @return Pointer to item drawer object. williamr@4: */ williamr@4: IMPORT_C CFormattedCellListBoxItemDrawer* ItemDrawer() const; williamr@4: williamr@4: /** williamr@4: * Sets icon sizes for visible list box items. williamr@4: */ williamr@4: void SetIconSizes(); williamr@4: williamr@4: public: williamr@4: williamr@4: /** williamr@4: * Enable or disable logical to visual reordering in listbox data text williamr@4: * drawing. By default, it is enabled. This has any effect only when williamr@4: * bidirectional text is rendered. williamr@4: * williamr@4: * If you convert text to visual order prior to passing it to the listbox williamr@4: * (for example by wrapping text to lines with methods in williamr@4: * @c AknBidiTextUtils), then you should disable conversion in listbox williamr@4: * by calling this method. williamr@4: * williamr@4: * @since S60 2.0 williamr@4: * @param aUseConversion If @c ETrue enable conversion. williamr@4: */ williamr@4: IMPORT_C void UseLogicalToVisualConversion( TBool aUseConversion ); williamr@4: williamr@4: public: williamr@4: williamr@4: /** williamr@4: * This method needs to be called to enable extended drawing features such williamr@4: * as skinning, pictograph drawing and marquee text in the listbox draw williamr@4: * routine. williamr@4: * williamr@4: * Methods @c CEikFormattedCellListBox::ConstructL and williamr@4: * @c CEikFormattedCellListBox::ConstructFromResourceL call this method. williamr@4: * So, you only need to call this if your listbox implementation does not williamr@4: * call either of those. williamr@4: * williamr@4: * This method can be safely called more than once. williamr@4: * Item drawer must be created before calling this method, or a panic is williamr@4: * raised. williamr@4: * williamr@4: * @since S60 2.6 williamr@4: * @panic EAknPanicListBoxItemDrawerNotCreated Panics if the item drawer williamr@4: * for the current class has not been defined. williamr@4: */ williamr@4: IMPORT_C void EnableExtendedDrawingL(); williamr@4: williamr@4: /** williamr@4: * Enables/disables list stretching. When a list is stretched its second line williamr@4: * is moved after the first line. This is intented for devices with a large williamr@4: * screen. This feature might be set as default by a product specific flag. williamr@4: * williamr@4: * Item drawer must be created before calling this method. williamr@4: * williamr@4: * @since S60 3.1 williamr@4: * @param aEnabled ETrue to enable list stretching. williamr@4: */ williamr@4: IMPORT_C void EnableStretching( const TBool aEnabled ); williamr@4: williamr@4: /** williamr@4: * Hides the second row of a double style listbox. This feature is disabled williamr@4: * by default. williamr@4: * williamr@4: * @since S60 3.1 williamr@4: * @param aHide ETrue to hide the second row. williamr@4: */ williamr@4: IMPORT_C void HideSecondRow( const TBool aHide ); williamr@4: protected: williamr@4: williamr@4: /** williamr@4: * Creates item draver for the listbox. williamr@4: */ williamr@4: IMPORT_C virtual void CreateItemDrawerL(); williamr@4: williamr@4: /** williamr@4: * From @c CEikListBox. williamr@4: * williamr@4: * Rounds down the height of the rectangle (if necessary) so that only williamr@4: * a whole number of items can be displayed inside the list box. williamr@4: * williamr@4: * @param aRect The rectangle to be modified. williamr@4: * @return The number of pixels reduced. williamr@4: */ williamr@4: IMPORT_C virtual TInt AdjustRectHeightToWholeNumberOfItems( williamr@4: TRect &aRect) const; williamr@4: williamr@4: public: // from CEikListBox williamr@4: williamr@4: /** williamr@4: * From @c CEikListBox. williamr@4: * williamr@4: * Creates the list box view. williamr@4: * williamr@4: * @return Pointer to new list box view class instance. williamr@4: */ williamr@4: IMPORT_C CListBoxView* MakeViewClassInstanceL(); williamr@4: williamr@4: /** williamr@4: * From @c CEikListBox. williamr@4: * williamr@4: * Handles focus changes. williamr@4: * williamr@4: * The function emphasizes or de-emphasizes the view as needed, williamr@4: * and shows or hides the matcher cursor. williamr@4: * williamr@4: * @param aDrawNow If @c EDrawNow, a redraw is performed immediately. williamr@4: */ williamr@4: IMPORT_C void FocusChanged(TDrawNow aDrawNow); williamr@4: williamr@4: public: // from CCoeControl williamr@4: williamr@4: /** williamr@4: * From @c CCoeControl. williamr@4: * williamr@4: * Gets the list of logical colors used to draw the control. williamr@4: * williamr@4: * @param aColorUseList The color list. williamr@4: */ williamr@4: IMPORT_C void GetColorUseListL( williamr@4: CArrayFix& aColorUseList) const; williamr@4: williamr@4: /** williamr@4: * From @c CCoeControl. williamr@4: * williamr@4: * Handles a change to the control's resources. williamr@4: * williamr@4: * @param aType A message UID value. williamr@4: */ williamr@4: IMPORT_C void HandleResourceChange(TInt aType); williamr@4: williamr@4: /** williamr@4: * From @c CCoeControl. williamr@4: * williamr@4: * Handles pointer events. williamr@4: * williamr@4: * @param aPointerEvent The pointer event. williamr@4: */ williamr@4: IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent); williamr@4: williamr@4: protected: // from MObjectProvider williamr@4: williamr@4: /** williamr@4: * From @c MObjectProvider. williamr@4: * williamr@4: * Retrieves an object of the same type as that encapsulated in aId. This williamr@4: * function is used to allow controls to ask their owners for access to williamr@4: * other objects that they own. williamr@4: * williamr@4: * @param aId An encapsulated object type ID. williamr@4: * @return Encapsulates the pointer to the object provided. williamr@4: * Note that the encapsulated pointer may be NULL. williamr@4: */ williamr@4: IMPORT_C virtual TTypeUid::Ptr MopSupplyObject(TTypeUid aId); williamr@4: williamr@4: private: williamr@4: williamr@4: /** williamr@4: * From @c CAknControl williamr@4: */ williamr@4: IMPORT_C void* ExtensionInterface( TUid aInterface ); williamr@4: williamr@4: private: // listbox use only williamr@4: williamr@4: IMPORT_C virtual void CEikListBox_Reserved(); williamr@4: williamr@4: private: // data williamr@4: williamr@4: TInt iSpare; williamr@4: }; williamr@4: williamr@4: williamr@4: /** williamr@4: * @c CFormattedCellListBoxView draws all the list items and manages williamr@4: * the area of the screen allocated for list itself. In particular, williamr@4: * this class does not handle margins of the whole list. williamr@4: * williamr@4: * @lib avkon williamr@4: */ williamr@4: class CFormattedCellListBoxView : public CListBoxView williamr@4: { williamr@4: williamr@4: public: // from CListBoxView williamr@4: williamr@4: /** williamr@4: * From @c CListBoxView. williamr@4: * williamr@4: * Draws every visible item into the specified rectangle. williamr@4: * williamr@4: * @param aClipRect The rectangle to draw into. This is not used. williamr@4: */ williamr@4: IMPORT_C void Draw(const TRect* aClipRect = NULL) const; williamr@4: williamr@4: /** williamr@4: * From @c CListBoxView. williamr@4: * williamr@4: * Draws empty list. williamr@4: * williamr@4: * @param aClientRect The rectangle to draw into. williamr@4: */ williamr@4: IMPORT_C virtual void DrawEmptyList(const TRect &aClientRect) const; williamr@4: williamr@4: /** williamr@4: * From @c CListBoxView. williamr@4: * williamr@4: * Recalculates the index of the bottom item in the list from the top item williamr@4: * index and the size of the display. This function is called by the owning williamr@4: * list box control when either the size of the list box or the number of williamr@4: * items in its model changes. williamr@4: */ williamr@4: IMPORT_C virtual void CalcBottomItemIndex(); williamr@4: williamr@4: private: // overridden from CListBoxView williamr@4: williamr@4: IMPORT_C virtual TAny* Reserved_1(); williamr@4: }; williamr@4: williamr@4: williamr@4: #endif // __EIKFRLB_H__ williamr@4: williamr@4: // End of File