williamr@2: /* williamr@2: * Copyright (c) 1997-1999 Nokia Corporation and/or its subsidiary(-ies). williamr@2: * All rights reserved. williamr@2: * This component and the accompanying materials are made available williamr@2: * 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 williamr@2: * which accompanies this distribution, and is available williamr@2: * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". williamr@2: * williamr@2: * Initial Contributors: williamr@2: * Nokia Corporation - initial contribution. williamr@2: * williamr@2: * Contributors: williamr@2: * williamr@2: * Description: williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: #if !defined(__EIKCLB_H__) williamr@2: #define __EIKCLB_H__ williamr@2: williamr@2: williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: williamr@2: class CColumnListBoxData; williamr@2: williamr@2: williamr@2: /** williamr@2: * Draws the contents of list box items. williamr@2: * williamr@2: * @since 5.0 williamr@2: */ williamr@2: class CColumnListBoxItemDrawer : public CTextListItemDrawer williamr@2: { williamr@2: williamr@2: public: williamr@2: /* C++ default constructor. williamr@2: * williamr@2: * @since 3.2 williamr@2: */ williamr@2: williamr@2: IMPORT_C CColumnListBoxItemDrawer(); williamr@2: williamr@2: /** williamr@2: * C++ default constructor. williamr@2: * williamr@2: * Initialises the list box item drawer with the specified model, williamr@2: * font and data. williamr@2: * williamr@2: * @param aTextListBoxModel The model whose items will be drawn. williamr@2: * This provides the item text that is drawn using williamr@2: * @c DrawItemText(). williamr@2: * @param aFont The font in which the items will be drawn. williamr@2: * @param aColumnData The column list box data. This comprises: williamr@2: * the column widths, gaps, fonts, aligments and bitmaps. williamr@2: */ williamr@2: williamr@2: IMPORT_C CColumnListBoxItemDrawer(MTextListBoxModel* aTextListBoxModel, williamr@2: const CFont* aFont, williamr@2: CColumnListBoxData* aColumnData); williamr@2: williamr@2: /** williamr@2: * Destructor. williamr@2: */ williamr@2: IMPORT_C ~CColumnListBoxItemDrawer(); williamr@2: williamr@2: /** williamr@2: * Gets a pointer to the column list box data as set during construction. williamr@2: * Does not transfer ownership. williamr@2: * williamr@2: * @return The column list box data. williamr@2: */ williamr@2: IMPORT_C CColumnListBoxData* ColumnData() const; williamr@2: williamr@2: public: williamr@2: williamr@2: williamr@2: /** williamr@2: * The structure holding given item properties. williamr@2: * williamr@2: * Used for storing information given through @c SetProperties() method. williamr@2: */ williamr@2: struct SListProperties williamr@2: { williamr@2: /** Item identifier. */ williamr@2: TInt iItem; // must be first williamr@2: williamr@2: /** Properties of the item. */ williamr@2: TListItemProperties iProperties; williamr@2: }; williamr@2: williamr@2: /** williamr@2: * Clears all properties from the @c CColumnListBoxItemDrawer. williamr@2: */ williamr@2: IMPORT_C void ClearAllPropertiesL(); williamr@2: williamr@2: williamr@2: /** williamr@2: * Set the property for an item with @c aItemIndex williamr@2: * williamr@2: * @param aItemIndex Item index williamr@2: * @param aProperty The new property setting williamr@2: * The SetProperties is convinience method for normal cases. williamr@2: * NOTE that it does NOT work correctly if you can insert/delete williamr@2: * items from the list -- You need to update all properties if williamr@2: * any changes to the item text array happen! Often it is convinient williamr@2: * to override the Properties() method. Further, use this only williamr@2: * for small lists as it causes O(n) time if you need to set williamr@2: * all properties. williamr@2: */ williamr@2: IMPORT_C void SetPropertiesL(TInt aItemIndex, williamr@2: TListItemProperties aProperty); williamr@2: williamr@2: /** williamr@2: * Get properties for an item. williamr@2: * williamr@2: * @param aItemIndex Item's index for identifying. williamr@2: * @return Wanted property set. williamr@2: */ williamr@2: IMPORT_C virtual TListItemProperties Properties(TInt aItemIndex) const; williamr@2: williamr@2: public: // from CTextListItemDrawer williamr@2: williamr@2: /** williamr@2: * From @c CTextListItemDrawer. williamr@2: * williamr@2: * Draw item text. williamr@2: * williamr@2: * @param aItemIndex Index of the item to draw. williamr@2: * @param aItemTextRect Area to draw into. williamr@2: * @param aItemIsCurrent @c ETrue if the item is current. williamr@2: * @param aViewIsEmphasized @c ETrue if the view is emphasised. williamr@2: * @param aItemIsSelected @c ETrue if the item is selected. williamr@2: */ williamr@2: IMPORT_C void DrawItemText(TInt aItemIndex, williamr@2: const TRect& aItemTextRect, williamr@2: TBool aItemIsCurrent, williamr@2: TBool aViewIsEmphasized, williamr@2: TBool aItemIsSelected) const; williamr@2: // the next one is for avkon williamr@2: williamr@2: /** williamr@2: * Not used in S60. williamr@2: */ williamr@2: IMPORT_C void DrawItemMark(TBool aItemIsSelected, williamr@2: TBool aViewIsDimmed, williamr@2: const TPoint& aMarkPos) const; williamr@2: williamr@2: public: // from CListItemDrawer williamr@2: williamr@2: /** williamr@2: * From @c CListItemDrawer. williamr@2: * williamr@2: * Gets the minimum cell size. williamr@2: * williamr@2: * @return The minimum size for a cell. This is williamr@2: * TSize(0, 0) in @c CListItemDrawer. williamr@2: */ williamr@2: IMPORT_C TSize MinimumCellSize() const; williamr@2: williamr@2: /** williamr@2: * From @c CListItemDrawer. williamr@2: * williamr@2: * Gets the width of the specified item. williamr@2: * williamr@2: * @param aItemIndex The index of the item whose width is to be returned. williamr@2: * @return The width of the item. This is 0 in @c CListItemDrawer williamr@2: */ williamr@2: IMPORT_C TInt ItemWidthInPixels(TInt aItemIndex) const; williamr@2: williamr@2: /** williamr@2: * From @c CListItemDrawer. williamr@2: * williamr@2: * Sets the item cell size. williamr@2: * williamr@2: * The cell size is the on-screen size of the entire item, including its williamr@2: * text and its item mark. williamr@2: * williamr@2: * @param aSizeInPixels New size for the item cell. williamr@2: */ williamr@2: IMPORT_C void SetItemCellSize(const TSize& aSizeInPixels); williamr@2: williamr@2: /** williamr@2: * Get Item Cell Size. williamr@2: * williamr@2: * @return Cell size of an item. williamr@2: */ williamr@2: TSize LafItemSize() { return iItemCellSize; } williamr@2: williamr@2: private: // from CListItemDrawer williamr@2: williamr@2: IMPORT_C TAny* Reserved_1(); williamr@2: williamr@2: private: // defining reserved method. williamr@2: williamr@2: IMPORT_C void CColumnListBoxItemDrawer_Reserved(); williamr@2: williamr@2: protected: williamr@2: williamr@2: /** williamr@2: * Draw the item background. williamr@2: * williamr@2: * Internal member, not intended for use. williamr@2: * williamr@2: * @param aRect Drawing area. williamr@2: */ williamr@2: void DrawCurrentItemRect(const TRect& aRect) const; williamr@2: williamr@2: /** williamr@2: * Array of properties. williamr@2: */ williamr@2: CArrayFix* iPropertyArray; williamr@2: williamr@2: /** williamr@2: * Not used. williamr@2: */ williamr@2: TInt iSpare; williamr@2: }; williamr@2: williamr@2: williamr@2: /** williamr@2: * Column list box control. williamr@2: * williamr@2: * This is a list box whose lines consist of cells that are grouped vertically williamr@2: * into columns. The columns can be either textual or graphical, and column williamr@2: * widths and fonts can be set explicitly through @c CColumnListBoxData. williamr@2: * williamr@2: * Starting from 3.0 listbox uses highlight animations. Starting and stopping williamr@2: * animation is connected to focus events. To support highlight animations williamr@2: * properly you have to make sure that the list has focus when it has 'visual williamr@2: * focus'. Common issues: williamr@2: * - In many cases list is in a container which sits on top of the control williamr@2: * stack. The container receives all focus events and should hand them to the williamr@2: * list too. E.g. williamr@2: * void CContainer::FocusChanged( TDrawNow aDrawNow ) williamr@2: * { williamr@2: * ... some code ... williamr@2: * if( iListBox ) williamr@2: * iListBox->SetFocus( IsFocused(), aDrawNow ); williamr@2: * } williamr@2: * - When switching components programmatically, e.g. from one list to another williamr@2: * in the same view, make sure that you remove focus from the other williamr@2: * component. williamr@2: * - In more complex cases you may have to add a dummy interceptor control to williamr@2: * the top of control stack to hand focus events to list. williamr@2: * - Make sure you handle resource changes correctly. If resource handle chain williamr@2: * is solid it should reach CCoeControl::HandleResourceChange, which informs williamr@2: */ williamr@2: class CEikColumnListBox : public CEikTextListBox williamr@2: { williamr@2: public: williamr@2: /** williamr@2: * C++ default constructor. williamr@2: */ williamr@2: IMPORT_C CEikColumnListBox(); williamr@2: williamr@2: /** williamr@2: * Second-phase construction from a resource. williamr@2: * williamr@2: * This function completes the construction of a column list box, williamr@2: * initialising any members from the specified resource reader. williamr@2: * williamr@2: * @param aReader A resource file reader williamr@2: */ williamr@2: IMPORT_C void ConstructFromResourceL( TResourceReader& aReader ); williamr@2: williamr@2: /** williamr@2: * By default Symbian 2nd phase constructor is private. williamr@2: * williamr@2: * This function completes the construction of a column list box. williamr@2: * williamr@2: * @param aParent Parent control for the column list box. williamr@2: * @param aFlags Flags for the column list box. williamr@2: */ williamr@2: IMPORT_C void ConstructL( const CCoeControl* aParent,TInt aFlags=0); williamr@2: /** williamr@2: * Not supported in S60. williamr@2: */ williamr@2: IMPORT_C void EditItemL(TInt aColumn, TInt aMaxLength); williamr@2: protected: williamr@2: williamr@2: /** williamr@2: * This member is internal and not intended for use. williamr@2: */ williamr@2: IMPORT_C virtual void CreateItemDrawerL(); williamr@2: williamr@2: /** williamr@2: * Creates a new @c CTextListBoxModel williamr@2: */ williamr@2: IMPORT_C virtual void CreateModelL(); williamr@2: williamr@2: public: williamr@2: williamr@2: /** williamr@2: * Gets the list box model. williamr@2: * williamr@2: * @return Pointer to the model used by this list box williamr@2: */ williamr@2: IMPORT_C CTextListBoxModel* Model() const; williamr@2: williamr@2: /** williamr@2: * Gets the object used by this list box to draw its items. williamr@2: * williamr@2: * @return A pointer to the list box drawer. williamr@2: */ williamr@2: IMPORT_C CColumnListBoxItemDrawer* ItemDrawer() const; williamr@2: williamr@2: /** williamr@2: * This method needs to be called to enable extended drawing features williamr@2: * such as skinning, pictograph drawing and marquee text in the listbox williamr@2: * draw routine. williamr@2: * williamr@2: * Methods @c CEikFormattedCellListBox::ConstructL and williamr@2: * @c CEikFormattedCellListBox::ConstructFromResourceL call this method. williamr@2: * So, you only need to call this if your listbox implementation does not williamr@2: * call either of those. williamr@2: * williamr@2: * This method can be safely called more than once. williamr@2: * Item drawer must be created before calling this method, or a williamr@2: * panic is raised. williamr@2: * williamr@2: * @since S60 2.6 williamr@2: */ williamr@2: IMPORT_C void EnableExtendedDrawingL(); williamr@2: williamr@2: /** williamr@2: * Helper function that setst icon sizes for visible list items williamr@2: */ williamr@2: void SetIconSizes(); williamr@2: williamr@2: /** williamr@2: * Enables/disables list stretching. When a column list is stretched its williamr@2: * layout is optimized to take advantage of the extra screen space. williamr@2: * This is intented for devices with a large screen. This feature might be williamr@2: * set as default by a product specific flag. williamr@2: * williamr@2: * Item drawer must be created before calling this method. williamr@2: * williamr@2: * @since S60 3.1 williamr@2: * @param aEnabled ETrue to enable list stretching. williamr@2: */ williamr@2: IMPORT_C void EnableStretching( const TBool aEnabled ); williamr@2: public: // from CEikListBox williamr@2: williamr@2: /** williamr@2: * From @c CEikListBox. williamr@2: * williamr@2: * Creates the list box view. williamr@2: * The function is called by @ ConstructL() to create an instance of williamr@2: * the appropriate list box view class for this list box. The returned williamr@2: * instance is owned by this object, and does not have to have its williamr@2: * second-phase constructor run. This function is called by williamr@2: * @c CreateViewL(). williamr@2: * williamr@2: * @return Pointer to a newly constructed list box williamr@2: * view for this object. williamr@2: */ williamr@2: IMPORT_C CListBoxView* MakeViewClassInstanceL(); williamr@2: williamr@2: /** williamr@2: * From @c CEikListBox williamr@2: * williamr@2: * Handles focus changes. williamr@2: * williamr@2: * The function emphasises or de-emphasises the view as needed, and williamr@2: * shows or hides the matcher cursor. williamr@2: * williamr@2: * @param aDrawNow If @c EDrawNow, a redraw is performed immediately williamr@2: */ williamr@2: IMPORT_C void FocusChanged(TDrawNow aDrawNow); williamr@2: williamr@2: public: // from CCoeControl williamr@2: williamr@2: /** williamr@2: * From @c CCoeControl. williamr@2: * williamr@2: * Not used in S60 williamr@2: * @param aColorUseList The colour list williamr@2: */ williamr@2: IMPORT_C void GetColorUseListL( williamr@2: CArrayFix& aColorUseList) const; williamr@2: williamr@2: /** williamr@2: * From @c CCoeControl. williamr@2: * williamr@2: * Handles a change to the control's resources. williamr@2: * williamr@2: * The types of resources handled are those which are shared across williamr@2: * the environment, e.g. colours or fonts. For colour scheme changes, williamr@2: * @c DrawDeferred() is called in order to redraw the control. williamr@2: * williamr@2: * If overriding @c HandleResourceChange(), the implementation must williamr@2: * include a base call to @c CCoeControl's @c HandleResourceChange(). williamr@2: * williamr@2: * @param aType A message UID value williamr@2: */ williamr@2: IMPORT_C void HandleResourceChange(TInt aType); williamr@2: williamr@2: /** williamr@2: * From @c CCoeControl. williamr@2: * williamr@2: * Retrieves an object of the same type as that encapsulated in @c aId. williamr@2: * williamr@2: * This function is used to allow controls to ask their owners for williamr@2: * access to other objects that they own. williamr@2: * williamr@2: * Other than in the case where NULL is returned, the object returned williamr@2: * must be of the same object type - that is, the @c ETypeId member of the williamr@2: * object pointed to by the pointer returned by this function must be williamr@2: * equal to the @c iUid member of @c aUid. williamr@2: * williamr@2: * @param aUid An encapsulated object type ID. williamr@2: * @return Pointer to the type UID of the wanted object. williamr@2: */ williamr@2: IMPORT_C TTypeUid::Ptr MopSupplyObject(TTypeUid aUid); williamr@2: williamr@2: /** williamr@2: * From @c CCoeControl. williamr@2: * williamr@2: * Handles pointer events. williamr@2: * williamr@2: * This function gets called whenever a pointer event occurs in the williamr@2: * control, i.e. when the pointer is within the control's extent, or when williamr@2: * the control has grabbed the pointer. The control should implement this williamr@2: * function to handle pointer events. williamr@2: * williamr@2: * Note: events of type @c EButton1Down are processed before williamr@2: * @c HandlePointerEventL() is called, in order to transfer keyboard williamr@2: * focus to the control in which the @c EButton1Down event occurred. williamr@2: * williamr@2: * If overriding @c HandlePointerEventL(), the implementation must williamr@2: * include a base call to @c CCoeControl's @c HandlePointerEventL(). williamr@2: * williamr@2: * @param aPointerEvent The pointer event williamr@2: */ williamr@2: IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent); williamr@2: private: williamr@2: /** williamr@2: * From CAknControl williamr@2: */ williamr@2: IMPORT_C void* ExtensionInterface( TUid aInterface ); williamr@2: private: williamr@2: IMPORT_C virtual void CEikListBox_Reserved(); // listbox use only williamr@2: private: // data williamr@2: TInt iSpare; williamr@2: }; williamr@2: williamr@2: /** williamr@2: * The @c CEikColumnListBoxEditor class implements an item editor for williamr@2: * column list boxes. williamr@2: * Not supported in S60 williamr@2: * @since ER5U williamr@2: */ williamr@2: class CEikColumnListBoxEditor : public CEikListBoxTextEditor williamr@2: { williamr@2: public: williamr@2: IMPORT_C CEikColumnListBoxEditor(MListBoxModel* aModel); williamr@2: IMPORT_C ~CEikColumnListBoxEditor(); williamr@2: IMPORT_C void ConstructL(TInt aColumn); // just set column index williamr@2: public: // from MEikListBoxEditor williamr@2: IMPORT_C TPtrC ItemText(); williamr@2: IMPORT_C TBool UpdateModelL(); williamr@2: public: // From CCoeControl williamr@2: IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent); williamr@2: protected: williamr@2: IMPORT_C TInt Column() const; williamr@2: private: williamr@2: /** williamr@2: * From CAknControl williamr@2: */ williamr@2: IMPORT_C void* ExtensionInterface( TUid aInterface ); williamr@2: private: williamr@2: TInt iColumnIndex; // refers to list box column williamr@2: }; williamr@2: williamr@2: class CColumnListBoxView : public CListBoxView williamr@2: { williamr@2: public: // from CListBoxView williamr@2: williamr@2: /** williamr@2: * From @c CListBoxView williamr@2: * Draws every visible item into the specified rectangle. williamr@2: * williamr@2: * As implemented in @c CListBoxView, this function's argument is williamr@2: * ignored and the internal viewing rectangle is used. See @c SetViewRect(). williamr@2: * williamr@2: * @param aClipRect = NULL The rectangle to draw into, this is ignored williamr@2: */ williamr@2: IMPORT_C void Draw(const TRect* aClipRect = NULL) const; williamr@2: williamr@2: /** williamr@2: * From @c CListBoxView williamr@2: * Recalculates the index of the bottom item in the list from the top item williamr@2: * index and the size of the display. williamr@2: * williamr@2: * This function is called by the owning list box control when either the williamr@2: * size of the list box or the number of items in its model changes. williamr@2: */ williamr@2: IMPORT_C virtual void CalcBottomItemIndex(); williamr@2: williamr@2: private: // overridden from CListBoxView williamr@2: williamr@2: IMPORT_C virtual TAny* Reserved_1(); williamr@2: williamr@2: private: // data williamr@2: TInt iSpare; williamr@2: }; williamr@2: williamr@2: #endif // __EIKCLB_H__ williamr@2: williamr@2: // End of File