williamr@2: /* williamr@2: * Copyright (c) 1998-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@4: * under the terms of "Eclipse Public License v1.0" williamr@2: * which accompanies this distribution, and is available williamr@4: * at the URL "http://www.eclipse.org/legal/epl-v10.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: williamr@2: #if !defined(__EIKLBD_H__) williamr@2: #define __EIKLBD_H__ williamr@2: williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: williamr@2: class TListItemProperties; williamr@2: class CListBoxDataExtension; williamr@2: class MAknsControlContext; williamr@2: williamr@2: /** williamr@2: * The data container class @c TListFontBoundValues class holds size williamr@2: * properties of the fonts used in list boxes. williamr@2: * williamr@2: * @since ER5U williamr@2: */ williamr@2: class TListFontBoundValues williamr@2: { williamr@2: public: // Constructors and destructor williamr@2: williamr@2: /** williamr@2: * Default C++ constructor williamr@2: */ williamr@2: IMPORT_C TListFontBoundValues(); williamr@2: williamr@2: public: // Data williamr@2: williamr@2: /** williamr@2: * The maximum permitted width of list box characters in pixels. williamr@2: */ williamr@2: TInt iMaxNormalCharWidthInPixels; williamr@2: williamr@2: /** williamr@2: * The list box height in pixels. williamr@2: */ williamr@2: TInt iHeightInPixels; williamr@2: }; williamr@2: williamr@2: /** williamr@2: * The @c CListBoxData class is the base class for list box data classes. williamr@2: * It stores one or more instances of fonts in normal, bold and italic styles. williamr@2: * williamr@2: * @since ER5U williamr@2: */ williamr@2: class CListBoxData : public CBase williamr@2: { williamr@2: williamr@2: // friend classes williamr@2: friend class CListItemDrawer; williamr@2: williamr@2: public: // Constructors and destructor williamr@2: williamr@2: /** williamr@2: * C++ default constructor. williamr@2: */ williamr@2: IMPORT_C CListBoxData(); williamr@2: williamr@2: /** williamr@2: * Destructor williamr@2: */ williamr@2: IMPORT_C ~CListBoxData(); williamr@2: williamr@2: public: // New functions williamr@2: williamr@2: /** williamr@2: * By default Symbian 2nd phase constructor is private. williamr@2: * This one is public. williamr@2: * williamr@2: * @param aBaseFont Parameter not used in the code. williamr@2: */ williamr@2: IMPORT_C void ConstructL(const CFont* aBaseFont); williamr@2: williamr@2: /** williamr@2: * Returns a pointer to the type of font wanted. williamr@2: * williamr@2: * @param aItemProperties Definition of font type wanted. williamr@2: * @return CFont* Handle to the font or NULL. williamr@2: */ williamr@2: IMPORT_C virtual CFont* williamr@2: Font(const TListItemProperties& aItemProperties) const; williamr@2: williamr@2: /** williamr@2: * Sets properties (underlining on / off, pen colorm and font) of williamr@2: * graphical context. williamr@2: * williamr@2: * @param aItemProperties Contains properties to set. williamr@2: * @param aGc Target of settings. williamr@2: */ williamr@2: IMPORT_C void SetupGc(const TListItemProperties& aItemProperties, williamr@2: CWindowGc& aGc) const; williamr@2: williamr@2: /** williamr@2: * Queries boundary values of font size. williamr@2: * williamr@2: * @retun TListFontBoundValues& Reference to boundary value object. williamr@2: */ williamr@2: IMPORT_C const TListFontBoundValues& FontBoundValues() const; williamr@2: williamr@2: /** williamr@2: * Sets a new height of fonts williamr@2: * williamr@2: * @param aFontHeightInTwips New height for fonts. williamr@2: * @return TInt Symbian error code, @c KErrNone if success. williamr@2: */ williamr@2: IMPORT_C TInt SetFontHeight(TInt aFontHeightInTwips); williamr@2: williamr@2: /** williamr@2: * Setter for a search string used for viewing search results williamr@2: * williamr@2: * @param aSearchString The search string. williamr@2: */ williamr@2: IMPORT_C void SetSearchStringL(const TDesC* aSearchString); williamr@2: williamr@2: /** williamr@2: * Query is search string set williamr@2: * williamr@2: * @return TBool @c ETrue if search string set and has non zero length. williamr@2: * @c EFalse if no search string set or length is 0. williamr@2: */ williamr@2: IMPORT_C TBool IsSearchString() const; williamr@2: williamr@2: /** williamr@2: * Draws list item text. Supports different drawing for the search string. williamr@2: * williamr@2: * @param aGc Graphics context used. williamr@2: * @param aItemTextRect The item's text rectangle. williamr@2: * @param aItemText Text of the item. williamr@2: * @param aItemFont Used font. williamr@2: * @param aBaseLineOffset Item's base line offset. williamr@2: * @param aAlign Text alignment. williamr@2: * Default alignment is @c CGraphicsContext::ELeft williamr@2: */ williamr@2: IMPORT_C void DrawItem(CWindowGc& aGc, williamr@2: const TRect& aItemTextRect, williamr@2: const TDesC& aItemText, williamr@2: const CFont& aItemFont, williamr@2: const TInt aBaseLineOffset, williamr@2: const CGraphicsContext::TTextAlign aAlign = williamr@2: CGraphicsContext::ELeft) const; williamr@2: williamr@2: /** williamr@2: * Sets list item's text alignment. williamr@2: * williamr@2: * @param aAlign Text alignment to use. williamr@2: */ williamr@2: inline void SetAlignmentL(CGraphicsContext::TTextAlign aAlign); williamr@2: williamr@2: /** williamr@2: * Queries used text alignment. williamr@2: * williamr@2: * @return CGraphicsContext::TTextAlign The text alignment. williamr@2: */ williamr@2: inline CGraphicsContext::TTextAlign Alignment() const; williamr@2: williamr@2: /** williamr@2: * Access to skin contexts from plain listboxes. williamr@2: * williamr@2: * @since Series 60 2.0 williamr@2: * @return MAknsControlContext* Used skin context williamr@2: */ williamr@2: IMPORT_C MAknsControlContext* SkinBackgroundControlContext() const; williamr@2: williamr@2: protected: williamr@2: williamr@2: /** williamr@2: * Sets a background skinning context. Set @c NULL to disable background williamr@2: * skinning. williamr@2: * williamr@2: * @since Series 60 2.0 williamr@2: * @param aContext Background skinning context. williamr@2: */ williamr@2: IMPORT_C void williamr@2: SetSkinBackgroundControlContextL(MAknsControlContext* aContext); williamr@2: williamr@2: /** williamr@2: * Sets whether skins are enabled. williamr@2: * williamr@2: * @param aEnabled @c EFalse disable skinning, @c ETrue enable williamr@2: */ williamr@2: IMPORT_C void SetSkinEnabledL(TBool aEnabled); williamr@2: williamr@2: protected: williamr@2: williamr@2: NONSHARABLE_CLASS(CFontsWithStyle) : public CBase williamr@2: { williamr@2: williamr@2: public: // Constructors and destructor williamr@2: williamr@2: /** williamr@2: * C++ default constructor. williamr@2: */ williamr@2: CFontsWithStyle(); williamr@2: williamr@2: /** williamr@2: * Destructor. williamr@2: */ williamr@2: ~CFontsWithStyle(); williamr@2: williamr@2: public: // new functions williamr@2: williamr@2: /** williamr@2: * Releases fonts when they are no longer required. williamr@2: */ williamr@2: IMPORT_C void ReleaseFonts(); williamr@2: williamr@2: /** williamr@2: * Getter for used font style williamr@2: * williamr@2: * @return TFontStyle Used font style williamr@2: */ williamr@2: IMPORT_C TFontStyle FontStyle(); williamr@2: williamr@2: /** williamr@2: * Setter for used font style williamr@2: * williamr@2: * @return aFontStyle Font style to use. williamr@2: */ williamr@2: IMPORT_C void SetFontStyle(TFontStyle aFontStyle); williamr@2: williamr@2: public: // data williamr@2: williamr@2: /** williamr@2: * @c CArrayPtrFlat is used instead of @c CFont*, williamr@2: * because in some subclasses this structure williamr@2: * can contain more than 1 font. williamr@2: */ williamr@2: CArrayPtrFlat* iFonts; williamr@2: williamr@2: private: // data williamr@2: williamr@2: /** williamr@2: * Font style in use williamr@2: */ williamr@2: TFontStyle iFontStyle; williamr@2: }; williamr@2: williamr@2: /** williamr@2: * Constructs a new font based on the base font and font style given. williamr@2: * Constructed font is added to @c CFontsWithStyle. williamr@2: * williamr@2: * @param aBaseFont Base fontused in construction williamr@2: * @param aFontStyle A new font's style williamr@2: * @param aFonts New font is added to this font container. williamr@2: */ williamr@2: IMPORT_C void ConstructFontL(const CFont* aBaseFont, williamr@2: TFontStyle aFontStyle, williamr@2: CFontsWithStyle& aFonts); williamr@2: williamr@2: /** williamr@2: * Updates width and heigh information. Used when font is changed. williamr@2: * williamr@2: * @param aFont A font from which bound values are taken. williamr@2: */ williamr@2: IMPORT_C void UpdateFontBoundValues(const CFont& aFont); williamr@2: williamr@2: /** williamr@2: * Changes fonts' height. Takes new height as argument and regenerates williamr@2: * font set so that height is modified. williamr@2: * williamr@2: * @param aFonts Font set to modify williamr@2: * @param aFontHeightInTwips New font height williamr@2: */ williamr@2: IMPORT_C TInt RegenerateFonts(CFontsWithStyle& aFonts, williamr@2: TInt aFontHeightInTwips); williamr@2: williamr@2: protected: williamr@2: williamr@2: /** williamr@2: * Normal style font williamr@2: */ williamr@2: CFontsWithStyle iNormalFont; williamr@2: williamr@2: /** williamr@2: * Bold style font williamr@2: */ williamr@2: CFontsWithStyle iBoldFont; williamr@2: williamr@2: /** williamr@2: * Italic style font williamr@2: */ williamr@2: CFontsWithStyle iItalicFont; williamr@2: williamr@2: /** williamr@2: * Font with normal and italic styles williamr@2: */ williamr@2: CFontsWithStyle iBoldItalicFont; williamr@2: williamr@2: /** williamr@2: * String used in list box search field. williamr@2: */ williamr@2: HBufC* iSearchString; williamr@2: williamr@2: private: williamr@2: williamr@2: IMPORT_C virtual void Reserved_1(); williamr@2: IMPORT_C virtual void Reserved_2(); williamr@2: williamr@2: private: williamr@2: williamr@2: TListFontBoundValues iFontBoundValues; williamr@2: CGraphicsContext::TTextAlign iAlign; williamr@2: williamr@2: private: williamr@2: williamr@2: CListBoxDataExtension* iLBDExtension; williamr@2: }; williamr@2: williamr@2: // Inline functions williamr@2: inline void CListBoxData::SetAlignmentL(CGraphicsContext::TTextAlign aAlign) williamr@2: {iAlign=aAlign;} williamr@2: williamr@2: inline CGraphicsContext::TTextAlign CListBoxData::Alignment() const williamr@2: {return iAlign;} williamr@2: williamr@2: #endif williamr@2: williamr@2: // End of File