epoc32/include/mw/eiklbd.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
parent 1 666f914201fb
child 4 837f303aceeb
permissions -rw-r--r--
Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
     1 /*
     2 * Copyright (c) 1998-1999 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 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".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description:
    15 *
    16 */
    17 
    18 
    19 
    20 #if !defined(__EIKLBD_H__)
    21 #define __EIKLBD_H__
    22 
    23 #include <e32base.h>
    24 #include <gdi.h>
    25 #include <w32std.h>
    26 #include <eiklbx.h>
    27 
    28 class TListItemProperties;
    29 class CListBoxDataExtension;
    30 class MAknsControlContext;
    31 
    32 /**
    33  * The data container class @c TListFontBoundValues class holds size
    34  * properties of the fonts used in list boxes.
    35  *
    36  * @since ER5U
    37  */
    38 class TListFontBoundValues
    39     {
    40 public:  // Constructors and destructor
    41 
    42         /**
    43         * Default C++ constructor
    44         */
    45         IMPORT_C TListFontBoundValues();
    46 
    47 public:     // Data
    48 
    49         /**
    50          * The maximum permitted width of list box characters in pixels.
    51          */
    52         TInt iMaxNormalCharWidthInPixels;
    53 
    54         /**
    55          * The list box height in pixels.
    56          */
    57         TInt iHeightInPixels;
    58     };
    59 
    60 /**
    61  * The @c CListBoxData class is the base class for list box data classes.
    62  * It stores one or more instances of fonts in normal, bold and italic styles.
    63  *
    64  * @since ER5U
    65  */
    66 class CListBoxData : public CBase
    67     {
    68 
    69     // friend classes
    70     friend class CListItemDrawer;
    71 
    72 public:  // Constructors and destructor
    73 
    74     /**
    75      * C++ default constructor.
    76      */
    77     IMPORT_C CListBoxData();
    78     
    79     /**
    80      * Destructor
    81      */
    82     IMPORT_C ~CListBoxData();
    83 
    84 public: // New functions
    85 
    86     /**
    87      * By default Symbian 2nd phase constructor is private. 
    88      * This one is public.
    89      *
    90      * @param aBaseFont Parameter not used in the code.
    91      */
    92     IMPORT_C void ConstructL(const CFont* aBaseFont);
    93     
    94     /**
    95      * Returns a pointer to the type of font wanted.
    96      *
    97      * @param aItemProperties Definition of font type wanted.
    98      * @return CFont* Handle to the font or NULL.
    99      */
   100      IMPORT_C virtual CFont* 
   101             Font(const TListItemProperties& aItemProperties) const;
   102 
   103     /**
   104      * Sets properties (underlining on / off, pen colorm and font) of
   105      * graphical context.
   106      *
   107      * @param aItemProperties Contains properties to set.
   108      * @param aGc Target of settings.
   109      */
   110     IMPORT_C void SetupGc(const TListItemProperties& aItemProperties,
   111                           CWindowGc& aGc) const;
   112 
   113     /**
   114      * Queries boundary values of font size.
   115      *
   116      * @retun TListFontBoundValues& Reference to boundary value object.
   117      */
   118     IMPORT_C const TListFontBoundValues& FontBoundValues() const;
   119 
   120     /**
   121      * Sets a new height of fonts
   122      *
   123      * @param aFontHeightInTwips New height for fonts.
   124      * @return TInt Symbian error code, @c KErrNone if success.
   125      */
   126      IMPORT_C TInt SetFontHeight(TInt aFontHeightInTwips);
   127 
   128     /**
   129      * Setter for a search string used for viewing search results
   130      *
   131      * @param aSearchString The search string.
   132      */
   133     IMPORT_C void SetSearchStringL(const TDesC* aSearchString);
   134 
   135     /**
   136      * Query is search string set
   137      *
   138      * @return TBool @c ETrue if search string set and has non zero length.
   139      *         @c EFalse if no search string set or length is 0.
   140      */
   141     IMPORT_C TBool IsSearchString() const;
   142     
   143     /**
   144      * Draws list item text. Supports different drawing for the search string.
   145      *
   146      * @param aGc Graphics context used.
   147      * @param aItemTextRect The item's text rectangle.
   148      * @param aItemText Text of the item.
   149      * @param aItemFont Used font.
   150      * @param aBaseLineOffset Item's base line offset.
   151      * @param aAlign Text alignment. 
   152      *        Default alignment is @c CGraphicsContext::ELeft
   153      */
   154     IMPORT_C void DrawItem(CWindowGc& aGc,
   155                            const TRect& aItemTextRect,
   156                            const TDesC& aItemText,
   157                            const CFont& aItemFont,
   158                            const TInt aBaseLineOffset,
   159                            const CGraphicsContext::TTextAlign aAlign = 
   160                                  CGraphicsContext::ELeft) const;
   161 
   162     /**
   163      * Sets list item's text alignment.
   164      *
   165      * @param aAlign Text alignment to use.
   166      */
   167     inline void SetAlignmentL(CGraphicsContext::TTextAlign aAlign);
   168 
   169     /**
   170      * Queries used text alignment.
   171      *
   172      * @return CGraphicsContext::TTextAlign The text alignment.
   173      */
   174     inline CGraphicsContext::TTextAlign Alignment() const;
   175 
   176     /**
   177      * Access to skin contexts from plain listboxes.
   178      *
   179      * @since Series 60 2.0
   180      * @return MAknsControlContext* Used skin context
   181      */
   182     IMPORT_C MAknsControlContext* SkinBackgroundControlContext() const;
   183 
   184     protected:
   185 
   186     /**
   187      * Sets a background skinning context. Set @c NULL to disable background
   188      * skinning.
   189      *
   190      * @since Series 60 2.0
   191      * @param aContext Background skinning context.
   192      */
   193     IMPORT_C void 
   194         SetSkinBackgroundControlContextL(MAknsControlContext* aContext);
   195     
   196     /**
   197      * Sets whether skins are enabled.
   198      *
   199      * @param aEnabled @c EFalse disable skinning, @c ETrue enable
   200      */
   201 	IMPORT_C void SetSkinEnabledL(TBool aEnabled);
   202 
   203 protected:
   204 
   205     NONSHARABLE_CLASS(CFontsWithStyle) : public CBase
   206         {
   207 
   208     public:  // Constructors and destructor
   209         
   210         /**
   211          * C++ default constructor.
   212          */
   213         CFontsWithStyle();
   214         
   215         /**
   216          * Destructor.
   217          */
   218         ~CFontsWithStyle();
   219 
   220 	public: // new functions
   221 
   222         /**
   223          * Releases fonts when they are no longer required.
   224          */
   225 		IMPORT_C void ReleaseFonts();
   226 
   227         /**
   228          * Getter for used font style
   229          * 
   230          * @return TFontStyle Used font style
   231          */
   232 		IMPORT_C TFontStyle FontStyle();
   233 
   234         /**
   235          * Setter for used font style
   236          *
   237          * @return aFontStyle Font style to use.
   238          */
   239 		IMPORT_C void SetFontStyle(TFontStyle aFontStyle);
   240 
   241     public: // data 
   242 
   243         /**
   244          * @c CArrayPtrFlat<CFont> is used instead of @c CFont*,
   245          * because in some subclasses this structure
   246          * can contain more than 1 font.
   247          */
   248         CArrayPtrFlat<CFont>* iFonts;
   249 
   250     private: // data
   251 
   252         /**
   253          * Font style in use
   254          */
   255         TFontStyle iFontStyle;
   256         };
   257 
   258     /**
   259      * Constructs a new font based on the base font and font style given.
   260      * Constructed font is added to @c CFontsWithStyle.
   261      *
   262      * @param aBaseFont Base fontused in construction
   263      * @param aFontStyle A new font's style
   264      * @param aFonts New font is added to this font container.
   265      */
   266     IMPORT_C void ConstructFontL(const CFont* aBaseFont, 
   267                                  TFontStyle aFontStyle, 
   268                                  CFontsWithStyle& aFonts);
   269 
   270     /**
   271      * Updates width and heigh information. Used when font is changed. 
   272      *
   273      * @param aFont A font from which bound values are taken.
   274      */
   275     IMPORT_C void UpdateFontBoundValues(const CFont& aFont);
   276     
   277     /**
   278      * Changes fonts' height. Takes new height as argument and regenerates 
   279      * font set so that height is modified.
   280      *
   281      * @param aFonts Font set to modify
   282      * @param aFontHeightInTwips New font height
   283      */
   284     IMPORT_C TInt RegenerateFonts(CFontsWithStyle& aFonts,
   285                                   TInt aFontHeightInTwips);
   286 
   287 protected:
   288 
   289     /**
   290      * Normal style font
   291      */
   292     CFontsWithStyle iNormalFont;
   293     
   294     /**
   295      * Bold style font
   296      */
   297     CFontsWithStyle iBoldFont;
   298     
   299     /**
   300      * Italic style font
   301      */
   302     CFontsWithStyle iItalicFont;
   303     
   304     /**
   305      * Font with normal and italic styles
   306      */
   307     CFontsWithStyle iBoldItalicFont;
   308     
   309     /**
   310      * String used in list box search field.
   311      */
   312     HBufC* iSearchString;
   313 
   314 private:
   315 
   316     IMPORT_C virtual void Reserved_1();
   317 	IMPORT_C virtual void Reserved_2();
   318 
   319 private:
   320 
   321     TListFontBoundValues iFontBoundValues;
   322 	CGraphicsContext::TTextAlign iAlign;
   323 
   324 private:
   325 
   326     CListBoxDataExtension* iLBDExtension;
   327     };
   328 
   329 // Inline functions 
   330 inline void CListBoxData::SetAlignmentL(CGraphicsContext::TTextAlign aAlign)
   331 	{iAlign=aAlign;}
   332 
   333 inline CGraphicsContext::TTextAlign CListBoxData::Alignment() const
   334 	{return iAlign;}
   335 
   336 #endif
   337 
   338 // End of File