epoc32/include/mw/AknUtils.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
williamr@4
     1
/*
williamr@4
     2
* Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies).
williamr@4
     3
* All rights reserved.
williamr@4
     4
* This component and the accompanying materials are made available
williamr@4
     5
* under the terms of "Eclipse Public License v1.0"
williamr@4
     6
* which accompanies this distribution, and is available
williamr@4
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
williamr@4
     8
*
williamr@4
     9
* Initial Contributors:
williamr@4
    10
* Nokia Corporation - initial contribution.
williamr@4
    11
*
williamr@4
    12
* Contributors:
williamr@4
    13
*
williamr@4
    14
* Description: 
williamr@4
    15
*     General Avkon Utilities. Includes:
williamr@4
    16
*       - listbox utilities
williamr@4
    17
*       - layout utilities
williamr@4
    18
* 
williamr@4
    19
*
williamr@4
    20
*/
williamr@4
    21
williamr@4
    22
williamr@4
    23
#ifndef __AKNUTILS_H__
williamr@4
    24
#define __AKNUTILS_H__
williamr@4
    25
williamr@4
    26
#include <eiktxlbm.h>
williamr@4
    27
#include <avkon.hrh>
williamr@4
    28
#include <avkon.rsg>
williamr@4
    29
#include <coedef.h>
williamr@4
    30
#include <coecobs.h>
williamr@4
    31
#include <w32std.h>
williamr@4
    32
#include <gulalign.h>
williamr@4
    33
#include <gulutil.h>
williamr@4
    34
#include <eikenv.h>
williamr@4
    35
#include <biditext.h>
williamr@4
    36
#include <eiksbfrm.h>
williamr@4
    37
#include <AknsConstants.h>
williamr@4
    38
#include <aknenv.h>
williamr@4
    39
#include <AknLayout.lag>
williamr@4
    40
williamr@4
    41
// These are for listbox column lengths (These are used to allocate memory from stack while drawing listboxes, they should be as small as possible, but not smaller!)
williamr@4
    42
const TInt KMaxColumnDataLength = 80; // This is maximum length of data for one listbox column -- after that the data is truncated before drawing.
williamr@4
    43
const TInt KMaxTotalDataLength = 8*KMaxColumnDataLength;  // max of 5 columns can have full 80 characters...
williamr@4
    44
williamr@4
    45
/** AVKON utility module
williamr@4
    46
 *
williamr@4
    47
 * From this file, you can find several tools for making application development easier for S60
williamr@4
    48
 *
williamr@4
    49
 * 1) Conversion modules to convert coordinate data from european LAF to usable formats
williamr@4
    50
 *     AknLayoutUtils, TAknLayoutRect, TAknLayoutText
williamr@4
    51
 * 2) Utilities to clip text
williamr@4
    52
 * 3) Part of selection service implementation
williamr@4
    53
 * 4) Different classes that help using listboxes
williamr@4
    54
 * 5) Handling colors in AKN_LAF_COLOR macro.
williamr@4
    55
 * 6) Resource readers for different purposes
williamr@4
    56
 * 7) Utility to find files without specifying the drive letter or path
williamr@4
    57
 */
williamr@4
    58
williamr@4
    59
williamr@4
    60
class CCoeControl;
williamr@4
    61
class CEikTextListBox;
williamr@4
    62
class CEikColumnListBox;
williamr@4
    63
class CEikFormattedCellListBox;
williamr@4
    64
class CGulIcon;
williamr@4
    65
class CEikSettingsListBox;
williamr@4
    66
class CAknLAF;
williamr@4
    67
class CEikImage;
williamr@4
    68
class CEikMfne;
williamr@4
    69
class CEikListBox;
williamr@4
    70
class CEikLabel;
williamr@4
    71
class CEikEdwin;
williamr@4
    72
class CEikMenuPane;
williamr@4
    73
class CAknPopupField;
williamr@4
    74
class CListBoxView;
williamr@4
    75
class CAknColumnListBox;
williamr@4
    76
class CEikSecretEditor;
williamr@4
    77
class CFindExtension;
williamr@4
    78
class CAknLayoutFont;
williamr@4
    79
class TAknFontSpecification;
williamr@4
    80
class CAknAppUiBase;
williamr@4
    81
class TAknWindowLineLayout;
williamr@4
    82
class TAknMultiLineTextLayout;
williamr@4
    83
class TAknTextLineLayout;
williamr@4
    84
williamr@4
    85
/**
williamr@4
    86
 * Egul library had methods to clip text from right side, this class includes methods to clip from both sides.
williamr@4
    87
 * It does add 3 dots to the end of the text.
williamr@4
    88
 */
williamr@4
    89
const TInt  KDefaultClipWidth = -1;
williamr@4
    90
const TUint KDefaultClipChar  = TUint(0x2026);
williamr@4
    91
williamr@4
    92
// Constant to use in AknLayoutUtils to indicate that the parameter is not to be used as a override value
williamr@4
    93
const TInt KAknLayoutUtilsDoNotOverride = -1;
williamr@4
    94
williamr@4
    95
/**
williamr@4
    96
* Text utilities.
williamr@4
    97
* Text truncating and wrapping methods in this class do not support 
williamr@4
    98
* text that requires conversion from logical to visual form,
williamr@4
    99
* e.g. Arabic/Hebrew, Thai and Hindi text. Code that needs to support that
williamr@4
   100
* kind of text should use corresponding methods in AknBidiTextUtils instead.
williamr@4
   101
*/
williamr@4
   102
class AknTextUtils 
williamr@4
   103
    {
williamr@4
   104
public:
williamr@4
   105
    enum TClipDirection
williamr@4
   106
    {
williamr@4
   107
    EDoNotClip,
williamr@4
   108
    EClipFromEnd,
williamr@4
   109
    EClipFromBeginning
williamr@4
   110
    };
williamr@4
   111
    /** ClipToFit() Generic clipping
williamr@4
   112
    
williamr@4
   113
    @param aBuffer         String that needs to be clipped. will be modified by this call
williamr@4
   114
    @param aFont           Font used in the code
williamr@4
   115
    @param aMaxWidthInPixels Maximum length of text that will not be clipped.
williamr@4
   116
    @param aDir            Where is the text clipped from. EDoNotClip, EClipFromEnd, EClipFromBeginning.
williamr@4
   117
    @param aClipWidth      The length of the text after clipping. KDefaultClipWidth will make it use aMaxWidthInPixels.
williamr@4
   118
    @param aClipString     The representation of three dots. (not really used anywhere - use the default value always or "")
williamr@4
   119
       
williamr@4
   120
    returns true if the text was clipped and 3 dots were added. 
williamr@4
   121
    */
williamr@4
   122
    
williamr@4
   123
    IMPORT_C static TBool ClipToFit(TDes& aBuffer,
williamr@4
   124
                                    const CFont& aFont, 
williamr@4
   125
                                    TInt aMaxWidthInPixels,
williamr@4
   126
                                    TClipDirection aDir=EClipFromEnd,
williamr@4
   127
                                    TInt aClipWidth = KDefaultClipWidth,
williamr@4
   128
                                    const TDesC &aClipString=_L("..."));
williamr@4
   129
williamr@4
   130
    /** ClipToFit() for clipping text inside lists
williamr@4
   131
     *
williamr@4
   132
     * NOTICE: This method cannot handle situation where the text may dynamically change its size! Especially when you have bitmaps on the right side!
williamr@4
   133
     *
williamr@4
   134
     * This needs to be done AFTER the listbox has done its SizeChanged()!
williamr@4
   135
     */
williamr@4
   136
    IMPORT_C static TBool ClipToFit(TDes& aBuffer, 
williamr@4
   137
                                    TClipDirection aDir,
williamr@4
   138
                                    CEikFormattedCellListBox *aListBox,
williamr@4
   139
                                    TInt aItemIndex,
williamr@4
   140
                                    TInt aSubCellNumber);
williamr@4
   141
williamr@4
   142
    /** ClipToFit() for clipping text inside lists
williamr@4
   143
     *
williamr@4
   144
     * NOTICE: This method cannot handle situation where the text may dynamically change its size! Especially when you have bitmaps on the right side!
williamr@4
   145
     *
williamr@4
   146
     * This needs to be done AFTER the listbox has done its SizeChanged()!
williamr@4
   147
     */
williamr@4
   148
    IMPORT_C static TBool ClipToFit(TDes& aBuffer,
williamr@4
   149
                                    TClipDirection aDir,
williamr@4
   150
                                    CEikColumnListBox *aListBox,
williamr@4
   151
                                    TInt aItemIndex,
williamr@4
   152
                                    TInt aColumnNumber);
williamr@4
   153
williamr@4
   154
    // implementation
williamr@4
   155
williamr@4
   156
    static TBool DoClipToFit(
williamr@4
   157
        TDes& aBuffer,
williamr@4
   158
        const CFont& aFont,
williamr@4
   159
        TInt aMaxWidthInPixels,
williamr@4
   160
        TClipDirection aDir,
williamr@4
   161
        TInt aClipWidth,
williamr@4
   162
        const TDesC& aClipString );
williamr@4
   163
williamr@4
   164
    /**
williamr@4
   165
    * Wraps a string to an array of pointers.
williamr@4
   166
    * The number of lines and line widths are specified by aLineWidthArray.
williamr@4
   167
    * The pointers in aWrappedArray point to positions inside aWrappedString.
williamr@4
   168
    *
williamr@4
   169
    * @param aStringToWrap      String that needs to be wrapped
williamr@4
   170
    * @param aLineWidthArray    Line widths in pixels
williamr@4
   171
    * @param aFont              Used font
williamr@4
   172
    * @param aWrappedArray      Pointers to wrapped lines
williamr@4
   173
    */
williamr@4
   174
    IMPORT_C static void WrapToArrayL( 
williamr@4
   175
        const TDesC& aStringToWrap,
williamr@4
   176
        const CArrayFix<TInt>& aLineWidthArray,
williamr@4
   177
        const CFont& aFont,
williamr@4
   178
        CArrayFix<TPtrC>& aWrappedArray);
williamr@4
   179
williamr@4
   180
    /**
williamr@4
   181
    * Wraps a string to an array of pointers.
williamr@4
   182
    * Constant line width is given.
williamr@4
   183
    * The pointers in aWrappedArray point to positions inside aWrappedString.
williamr@4
   184
    *
williamr@4
   185
    * @param aStringToWrap      String that needs to be wrapped
williamr@4
   186
    * @param aLineWidth         Constant line width in pixels
williamr@4
   187
    * @param aFont              Used font
williamr@4
   188
    * @param aWrappedArray      Pointers to wrapped lines
williamr@4
   189
    */
williamr@4
   190
    IMPORT_C static void WrapToArrayL( 
williamr@4
   191
        const TDesC& aStringToWrap,
williamr@4
   192
        TInt aLineWidth,
williamr@4
   193
        const CFont& aFont,
williamr@4
   194
        CArrayFix<TPtrC>& aWrappedArray );
williamr@4
   195
williamr@4
   196
    /**
williamr@4
   197
    * Wraps a string to an array of pointers and clips at the end
williamr@4
   198
    * of the last line if there aren't enough lines to accomodate
williamr@4
   199
    * the entire text. When clipping three dots are inserted at the
williamr@4
   200
    * end of the last line.
williamr@4
   201
    * The number of lines and line widths are specified by aLineWidthArray.
williamr@4
   202
    * The pointers in aWrappedArray point to positions inside aWrappedString.
williamr@4
   203
    *
williamr@4
   204
    * Expect the string to be modified if clipping is needed.
williamr@4
   205
    * (Clipping character KEllipsis is inserted at the ending point)
williamr@4
   206
    *
williamr@4
   207
    * @param aStringToWrap      String that needs to be wrapped
williamr@4
   208
    * @param aLineWidthArray    Line widths in pixels
williamr@4
   209
    * @param aFont              Used font
williamr@4
   210
    * @param aWrappedArray      Pointers to wrapped lines
williamr@4
   211
    */
williamr@4
   212
    IMPORT_C static void WrapToArrayAndClipL( 
williamr@4
   213
        TDes& aStringToWrap,             
williamr@4
   214
        const CArrayFix<TInt>& aLineWidthArray, 
williamr@4
   215
        const CFont& aFont,                     
williamr@4
   216
        CArrayFix<TPtrC>& aWrappedArray );       
williamr@4
   217
    
williamr@4
   218
    /**
williamr@4
   219
    * Chops a string when a line break character is encountered.
williamr@4
   220
    * Clips at the end of each line if there isn't enough space
williamr@4
   221
    * on that line.
williamr@4
   222
    * When clipping, KEllipsis (shown as 3 dots) is inserted at
williamr@4
   223
    * the end of the line.
williamr@4
   224
    * The number of lines and line widths are specified by aLineWidthArray.
williamr@4
   225
    * The pointers in aChoppedArray point to positions inside aStringToChop.
williamr@4
   226
    *
williamr@4
   227
    * Expect the string to be modified if clipping is needed
williamr@4
   228
    * (Clipping character KEllipsis is inserted in the end of the lines)
williamr@4
   229
    *
williamr@4
   230
    * @param aStringToChop      String that needs to be chopped
williamr@4
   231
    * @param aLineWidthArray    Line widths in pixels
williamr@4
   232
    * @param aFont              Used font
williamr@4
   233
    * @param aChoppedArray      Pointers to chopped lines
williamr@4
   234
    */
williamr@4
   235
    IMPORT_C static void ChopToArrayAndClipL(
williamr@4
   236
        TDes& aStringToChop,             
williamr@4
   237
        const CArrayFix<TInt>& aLineWidthArray, 
williamr@4
   238
        const CFont& aFont,                    
williamr@4
   239
        CArrayFix<TPtrC>& aChoppedArray);
williamr@4
   240
williamr@4
   241
    /**
williamr@4
   242
    * Chops a string when a line break character is encountered.
williamr@4
   243
    * Clips at the end of each line if there isn't enough space
williamr@4
   244
    * on that line.
williamr@4
   245
    * When clipping, KEllipsis (shown as 3 dots) is inserted at
williamr@4
   246
    * the end of the line.
williamr@4
   247
    * Constant line width is given.
williamr@4
   248
    * The pointers in aChoppedArray point to positions inside aStringToChop.
williamr@4
   249
    *
williamr@4
   250
    * Expect the string to be modified if clipping is needed
williamr@4
   251
    * (Clipping character KEllipsis is inserted in the end of the lines)
williamr@4
   252
    *
williamr@4
   253
    * @param aStringToChop      String that needs to be chopped
williamr@4
   254
    * @param aLineWidth         Constant line width in pixels
williamr@4
   255
    * @param aFont              Used font
williamr@4
   256
    * @param aChoppedArray      Pointers to chopped lines
williamr@4
   257
    */
williamr@4
   258
    IMPORT_C static void ChopToArrayAndClipL(
williamr@4
   259
        TDes& aStringToChop,             
williamr@4
   260
        TInt aLineWidth, 
williamr@4
   261
        const CFont& aFont,                    
williamr@4
   262
        CArrayFix<TPtrC>& aChoppedArray );
williamr@4
   263
williamr@4
   264
    /**
williamr@4
   265
    * Wraps a string (aStringToWrap) into lines according to the
williamr@4
   266
    * number of lines and line widths specified in aLineWidthArray. 
williamr@4
   267
    * Inserts '\n' at the end of lines. 
williamr@4
   268
    * Copies the result into aWrappedString.
williamr@4
   269
    * Leaves if aWrappedString isn't big enough.
williamr@4
   270
    *
williamr@4
   271
    * @param aStringToWrap      String that needs to be wrapped
williamr@4
   272
    * @param aLineWidthArray    Lines widths in pixels
williamr@4
   273
    * @param aFont              Used font
williamr@4
   274
    * @param aWrappedString     Wrapped string 
williamr@4
   275
    */
williamr@4
   276
    IMPORT_C static void WrapToStringL( 
williamr@4
   277
        const TDesC& aStringToWrap,
williamr@4
   278
        const CArrayFix<TInt>& aLineWidthArray,
williamr@4
   279
        const CFont& aFont,
williamr@4
   280
        TDes& aWrappedString );
williamr@4
   281
williamr@4
   282
   /**
williamr@4
   283
    * Wraps a string (aStringToWrap) into lines according to the
williamr@4
   284
    * number of lines and line widths specified in aLineWidthArray. 
williamr@4
   285
    * Inserts '\n' at the end of lines. 
williamr@4
   286
    * Clips the last line if there aren't enough lines to
williamr@4
   287
    * fit the entire string. 
williamr@4
   288
    * Copies the result into aWrappedString.
williamr@4
   289
    * Leaves if aWrappedString isn't big enough.
williamr@4
   290
    *
williamr@4
   291
    * @param aStringToWrap      String that needs to be wrapped
williamr@4
   292
    * @param aLineWidthArray    Width of lines in pixels
williamr@4
   293
    * @param aFont              Used font
williamr@4
   294
    * @param aWrappedString     Wrapped string 
williamr@4
   295
    */
williamr@4
   296
    IMPORT_C static void WrapToStringAndClipL(
williamr@4
   297
        const TDesC& aStringToWrap, 
williamr@4
   298
        const CArrayFix<TInt>& aLineWidthArray, 
williamr@4
   299
        const CFont& aFont, 
williamr@4
   300
        TDes& aWrappedString ); 
williamr@4
   301
williamr@4
   302
    /**
williamr@4
   303
     * This routine is used to strip away a set of characters from
williamr@4
   304
     * a descriptor.
williamr@4
   305
     *
williamr@4
   306
     * Useful for example for listboxes to make sure strings from
williamr@4
   307
     * network or typed by the end user does not have tab or linefeed
williamr@4
   308
     * characters. (as those will make listbox broken.)
williamr@4
   309
     * 
williamr@4
   310
     * @param   aDes         Parameter to change
williamr@4
   311
     * @param   aCharacters  A set of characters to remove
williamr@4
   312
     *
williamr@4
   313
     * There exists predefined character sets to remove:
williamr@4
   314
     *    KAknStripTabs
williamr@4
   315
     *    KAknStripListControlChars  (\t's and \n's and \r's)
williamr@4
   316
     */
williamr@4
   317
    IMPORT_C static void StripCharacters(TDes &aDes, const TDesC &aCharacters);
williamr@4
   318
williamr@4
   319
    /**
williamr@4
   320
     * This routine is used to replace all control chars with a single 
williamr@4
   321
     * character, usually a whitespace.
williamr@4
   322
     *
williamr@4
   323
     * @param   aDes         Parameter to change
williamr@4
   324
     * @param   aCharacters  A set of characters to remove
williamr@4
   325
     * @param   aReplacement a character used as replacement
williamr@4
   326
     *
williamr@4
   327
     *    KAknReplaceTabs
williamr@4
   328
     *    KAknReplaceListControlChars  (\t's and \n's)
williamr@4
   329
     */
williamr@4
   330
    IMPORT_C static void ReplaceCharacters(TDes &aDes, const TDesC &aChars, TChar aReplacement);
williamr@4
   331
williamr@4
   332
    /**
williamr@4
   333
     * This routine is used to remove extra whitespaces from text before 
williamr@4
   334
     * showing on screen
williamr@4
   335
     *
williamr@4
   336
     * @param   aDes                   Parameter to change
williamr@4
   337
     * @param   aWhiteSpaceCharacters  A set of whitespace characters to remove
williamr@4
   338
     */
williamr@4
   339
    IMPORT_C static void PackWhiteSpaces(TDes &aDes, const TDesC &aWhiteSpaceChars);
williamr@4
   340
    
williamr@4
   341
    // non-exported implementation
williamr@4
   342
williamr@4
   343
    static void WrapToStringL(
williamr@4
   344
        const TDesC& aStringToWrap, 
williamr@4
   345
        const CArrayFix<TInt>& aLineWidthArray, 
williamr@4
   346
        const CFont& aFont, 
williamr@4
   347
        TDes& aWrappedString,
williamr@4
   348
        TInt aFlags,
williamr@4
   349
        TInt aDirectionality );
williamr@4
   350
williamr@4
   351
    static void WrapToArrayL( 
williamr@4
   352
        TDes& aStringToWrap,
williamr@4
   353
        const CArrayFix<TInt>* aLineWidthArray, 
williamr@4
   354
        const CFont& aFont,
williamr@4
   355
        CArrayFix<TPtrC>& aWrappedArray,
williamr@4
   356
        TInt aLineWidth,
williamr@4
   357
        TInt aFlags,
williamr@4
   358
        TInt aDirectionality );
williamr@4
   359
williamr@4
   360
    static void ChopToArrayAndClipL(
williamr@4
   361
        TDes& aStringToChop,             
williamr@4
   362
        const CArrayFix<TInt>* aLineWidthArray,
williamr@4
   363
        const CFont& aFont,                 
williamr@4
   364
        CArrayFix<TPtrC>& aChoppedArray,
williamr@4
   365
        TInt aLineWidth );    
williamr@4
   366
williamr@4
   367
    /**
williamr@4
   368
    * This utility is used to see if a text is empty according to the conventions of 
williamr@4
   369
    * Avkon.
williamr@4
   370
    *
williamr@4
   371
    * @param    aTextToTest
williamr@4
   372
    * @return   ETrue if the text is empty according to Avkon
williamr@4
   373
    */
williamr@4
   374
    static TBool IsEmptyText( const TDesC& aTextToTest );
williamr@4
   375
williamr@4
   376
    /**
williamr@4
   377
     * This routine is used to convert between arabic-indic digits and european digits.
williamr@4
   378
     * based on existing language setting. So it'll convert any digit from the string
williamr@4
   379
     * to use either european digits or arabic-indic digits based on current settings.
williamr@4
   380
     *
williamr@4
   381
     * NOTE: THis method can be also called in european release. The method is required
williamr@4
   382
     * to do the correct thing with all the languages.
williamr@4
   383
     *
williamr@4
   384
     * This method should only be used just before displaying the number as unicode string.
williamr@4
   385
     * Also, never store the converted string as unicode.
williamr@4
   386
     *
williamr@4
   387
     * @since 2.0
williamr@4
   388
     * @param   aDes                    Parameter to change
williamr@4
   389
     */
williamr@4
   390
    IMPORT_C static void LanguageSpecificNumberConversion(TDes &aDes);
williamr@4
   391
williamr@4
   392
    /**
williamr@4
   393
     * This routine is used to convert digits from any digit format to another format eg. from 
williamr@4
   394
     * european digits to arabic-indic digits.
williamr@4
   395
     *
williamr@4
   396
     * @since 2.0
williamr@4
   397
     * @param aDes                      Parameter to change. It can contain digits from several digit types.
williamr@4
   398
     * @param aDigitType                Destination digit type.
williamr@4
   399
     */
williamr@4
   400
    IMPORT_C static void ConvertDigitsTo( TDes& aDes, TDigitType aDigitType );
williamr@4
   401
williamr@4
   402
    /**
williamr@4
   403
    * Convenience routine to obtain the directionality of the current input language
williamr@4
   404
    * This routine will attempt to access this information in a system-efficient way.
williamr@4
   405
    *
williamr@4
   406
    * This is not to be confused with either the directionality of the display text 
williamr@4
   407
    * language or (a closely associated concept) the layout direction of the UI 
williamr@4
   408
    * (accessed via AknLayoutUtils::LayoutMirrored() )
williamr@4
   409
    * 
williamr@4
   410
    * @since 2.0
williamr@4
   411
    * @return TBidiText::ELeftToRight if the current input language is left to right
williamr@4
   412
    *         TBidiText::ERightToLeft if the current input langauge is right to left     
williamr@4
   413
    */
williamr@4
   414
    IMPORT_C static TBidiText::TDirectionality CurrentScriptDirectionality();
williamr@4
   415
williamr@4
   416
    /**
williamr@4
   417
    * Method used to constrain the digit type to use to that consisted with the current input language
williamr@4
   418
    * 
williamr@4
   419
    * @since 2.0
williamr@4
   420
    * @returns TDigitType consistent with the current input language
williamr@4
   421
    */
williamr@4
   422
    static TDigitType InputLanguageFilteredDigitType();
williamr@4
   423
williamr@4
   424
    /**
williamr@4
   425
    * Method used to constrain the digit type to use to that consisted with the current display text language
williamr@4
   426
    * 
williamr@4
   427
    * @since 2.0
williamr@4
   428
    * @returns TDigitType consistent with the current input language
williamr@4
   429
    */
williamr@4
   430
    static TDigitType DisplayTextLanguageFilteredDigitType();
williamr@4
   431
williamr@4
   432
    /**
williamr@4
   433
    * Returns the digit type to be used for editors that are purely numeric in quality.
williamr@4
   434
    *
williamr@4
   435
    * @since 2.0
williamr@4
   436
    * @returns TDigitType to use for purely numeric editors
williamr@4
   437
    */ 
williamr@4
   438
    IMPORT_C static TDigitType NumericEditorDigitType();
williamr@4
   439
williamr@4
   440
    /**
williamr@4
   441
     * This routine is used to convert between arabic-indic digits and european digits.
williamr@4
   442
     * based on existing language setting. So it'll convert any digit from the string
williamr@4
   443
     * to use either european digits or arabic-indic digits based on current settings.
williamr@4
   444
     *
williamr@4
   445
     * This routine builds in the constraints imposed by current display text languages. 
williamr@4
   446
     *
williamr@4
   447
     * The number of characters in the buffer is not changed by this routine. It can therefore be 
williamr@4
   448
     * safely used easily with existing (modifiable) descriptors.
williamr@4
   449
     *
williamr@4
   450
     * This method should only be used just before displaying the number as unicode descriptor.
williamr@4
   451
     * Never store the converted string.
williamr@4
   452
     *
williamr@4
   453
     * @since 2.0
williamr@4
   454
     * @param   aDes                    Parameter to change
williamr@4
   455
     */
williamr@4
   456
    IMPORT_C static void DisplayTextLanguageSpecificNumberConversion(TDes &aDes);
williamr@4
   457
  
williamr@4
   458
    /**
williamr@4
   459
    * Returns the digit type to be used for editors that are alphanumeric.
williamr@4
   460
    * (Note that these editors may be configurable to be purely numeric - that is have a numeric
williamr@4
   461
    * mode, but they remain alphanumeric editors for the sake of this API.)
williamr@4
   462
    *
williamr@4
   463
    * This may be useful for instance for input processors that convert numeric key events to the 
williamr@4
   464
    * currently set input digit type.
williamr@4
   465
    *
williamr@4
   466
    * @since 2.0
williamr@4
   467
    * @returns TDigitType to editors with alphanumeric capability
williamr@4
   468
    */ 
williamr@4
   469
    IMPORT_C static TDigitType TextEditorDigitType();
williamr@4
   470
williamr@4
   471
    enum TDigitModeQueryType {
williamr@4
   472
        EDigitModeEditorDefault, // in editors by default whether western or foreign digits are used (gen.editors, both text and numbers)
williamr@4
   473
        EDigitModeUserModifiableEditor, // in editors whether user can modify digitmode with keypad
williamr@4
   474
        EDigitModeShownToUser, // in all components when displaying digits
williamr@4
   475
        EDigitModeNumberEditor, // number, time, date, notification texts (1st group of editors)
williamr@4
   476
        EDigitModeLatinNumberEditor // e-mail, password, PIN codes, etc. (3rd group, where only latin can be used)
williamr@4
   477
    };
williamr@4
   478
    /**
williamr@4
   479
     * This routine can be used to check what modes digits can be on.
williamr@4
   480
     *
williamr@4
   481
     * It uses input language, display language and the setting from general settings
williamr@4
   482
     * to calculate whether foreign digits need to be used.
williamr@4
   483
     *
williamr@4
   484
     * This is useful for editor implementation and anyone that needs to convert
williamr@4
   485
     * digits for display.
williamr@4
   486
     * 
williamr@4
   487
     * @since 2.0
williamr@4
   488
     * @param aQueryType   what is the situation where the digits are to be used.
williamr@4
   489
     * @returns ETrue to indicate whether digit conversions need to be used.
williamr@4
   490
     * @returns EFalse to indicate that no conversion is needed.
williamr@4
   491
     */
williamr@4
   492
    IMPORT_C static TBool DigitModeQuery(TDigitModeQueryType aQueryType = EDigitModeShownToUser);
williamr@4
   493
williamr@4
   494
    /** 
williamr@4
   495
     * Converts a filename ABCDE.EXT to format which is suitable for display.
williamr@4
   496
     * This method is needed for bi-directional language support.
williamr@4
   497
     * The method adds directionality markers to the filename so that the
williamr@4
   498
     * filename can correctly be rendered to screen.
williamr@4
   499
     *
williamr@4
   500
     *
williamr@4
   501
     * @since 2.6
williamr@4
   502
     * @param aDes contains the file name in logical format. 
williamr@4
   503
     * @returns file name in logical format with needed directionality markers.
williamr@4
   504
     */
williamr@4
   505
    IMPORT_C static HBufC* ConvertFileNameL(const TDesC& aDes);
williamr@4
   506
williamr@4
   507
williamr@4
   508
    /**
williamr@4
   509
    * @deprecated
williamr@4
   510
    * Do not use. This method will be removed.
williamr@4
   511
    */
williamr@4
   512
    IMPORT_C static HBufC* LoadScalableTextL(CCoeEnv& aCoe, TInt aResourceId);
williamr@4
   513
williamr@4
   514
    /**
williamr@4
   515
    * @deprecated
williamr@4
   516
    * Do not use. This method will be removed.
williamr@4
   517
    */
williamr@4
   518
    IMPORT_C static HBufC* LoadScalableTextLC(CCoeEnv& aCoe, TInt aResourceId);
williamr@4
   519
williamr@4
   520
    /**
williamr@4
   521
    * @deprecated
williamr@4
   522
    * Do not use. This method will be removed.
williamr@4
   523
    */
williamr@4
   524
    IMPORT_C static TInt LoadScalableText(CCoeEnv& aCoe, TInt aResourceId, TDes& aBuffer ); 
williamr@4
   525
williamr@4
   526
    /**
williamr@4
   527
    * @deprecated
williamr@4
   528
    * Do not use. This method will be removed.
williamr@4
   529
    */
williamr@4
   530
    IMPORT_C static HBufC* ClipAccordingScreenOrientationLC(CCoeEnv& aCoe, HBufC* aBuf); 
williamr@4
   531
williamr@4
   532
    /**
williamr@4
   533
    * Utility method used in scalable UI for choosing the longest fitting text variant.
williamr@4
   534
    * Truncating and wrapping methods in classes AknTextUtils and AknBidiTextUtils do
williamr@4
   535
    * the choice by themselves, so whenever they are used to process the text, it is not
williamr@4
   536
    * necessary to call this method.
williamr@4
   537
    *
williamr@4
   538
    * Applications do not need to call this method if they pass their localized texts
williamr@4
   539
    * to Avkon's UI components.
williamr@4
   540
    *
williamr@4
   541
    * @since 2.8
williamr@4
   542
    * 
williamr@4
   543
    * @param aText Text containing one or many variants with varying text widths,
williamr@4
   544
    * separated with the character 0x0001. The text is supposed to be 
williamr@4
   545
    * in logical order.
williamr@4
   546
    * @param aFont Font used to render the text.
williamr@4
   547
    * @param aMaxWidthInPixels Max width in pixels.
williamr@4
   548
    *
williamr@4
   549
    * @ret Longest fitting text. If none of the variants fits,
williamr@4
   550
    * the shortest one in pixels is returned.
williamr@4
   551
    */
williamr@4
   552
    IMPORT_C static TPtrC ChooseScalableText(
williamr@4
   553
        const TDesC& aText,
williamr@4
   554
        const CFont& aFont,
williamr@4
   555
        TInt aMaxWidthInPixels );
williamr@4
   556
    };
williamr@4
   557
williamr@4
   558
_LIT(KAknStripTabs, "\t");
williamr@4
   559
_LIT(KAknStripListControlChars, "\t\n");
williamr@4
   560
_LIT(KAknReplaceTabs, "\t");
williamr@4
   561
_LIT(KAknReplaceListControlChars, "\t\n");
williamr@4
   562
_LIT(KAknCommonWhiteSpaceCharacters, " \n\t\r");
williamr@4
   563
williamr@4
   564
/**
williamr@4
   565
 * These are part of Selection service and they should be called by application's HandleCommandL() to get
williamr@4
   566
 * menus and cba's handled automatically for selection service.
williamr@4
   567
 *
williamr@4
   568
 * The right way to implement these would be to have dialogs with names "Selection List", "MultiSelection List"
williamr@4
   569
 * and "Markable list" and make them keep a listbox inside it. (look at CAknPopupList, it does similar things)
williamr@4
   570
 *
williamr@4
   571
 * See CAknSelectionListDialog and CAknMarkableListDialog from aknselectionlist.h, they provide better
williamr@4
   572
 * interface for applications.
williamr@4
   573
 */
williamr@4
   574
class AknSelectionService
williamr@4
   575
    {
williamr@4
   576
public:
williamr@4
   577
    /** Helper function to implement ProcessCommandL() for selection list dialogs
williamr@4
   578
     */
williamr@4
   579
    IMPORT_C static void HandleSelectionListProcessCommandL(
williamr@4
   580
        TInt aCommand,
williamr@4
   581
        CEikListBox* aListBox);
williamr@4
   582
williamr@4
   583
    /** Helper function to implement ProcessCommandL() for selection list dialogs
williamr@4
   584
     */
williamr@4
   585
    IMPORT_C static void HandleMultiselectionListProcessCommandL(
williamr@4
   586
        TInt aCommand,
williamr@4
   587
        CEikListBox* aListBox);
williamr@4
   588
williamr@4
   589
    /** Helper function to implement ProcessCommandL() for markable list dialogs
williamr@4
   590
     */
williamr@4
   591
    IMPORT_C static void HandleMarkableListProcessCommandL(
williamr@4
   592
        TInt aCommand,
williamr@4
   593
        CEikListBox* aListBox);
williamr@4
   594
williamr@4
   595
    /** Helper function to implement ProcessCommandL() for menu lists
williamr@4
   596
     */
williamr@4
   597
    IMPORT_C static TKeyResponse HandleMenuListOfferKeyEventL(
williamr@4
   598
        const TKeyEvent& aKeyEvent,
williamr@4
   599
        TEventCode aType,
williamr@4
   600
        CEikListBox* aListBox);
williamr@4
   601
williamr@4
   602
    /** Helper function to implement DynInitMenuPaneL() for markable list dialogs
williamr@4
   603
     */
williamr@4
   604
    IMPORT_C static void HandleMarkableListDynInitMenuPane(
williamr@4
   605
        TInt aResourceId,
williamr@4
   606
        CEikMenuPane *aMenu,
williamr@4
   607
        CEikListBox *aListBox);
williamr@4
   608
williamr@4
   609
    /** Helper function to implement DynInitMenuPaneL() for markable list dialogs
williamr@4
   610
     */
williamr@4
   611
    IMPORT_C static void HandleMarkableListDynInitMenuItem(
williamr@4
   612
        CEikMenuPane *aMenu,
williamr@4
   613
        CEikListBox *aListBox,
williamr@4
   614
        TInt aCommandId,
williamr@4
   615
        TBool aCanBeAppliedToMultipleItems);
williamr@4
   616
williamr@4
   617
    /** Helper function to implement command handling for markable list dialogs
williamr@4
   618
     */
williamr@4
   619
    IMPORT_C static void HandleMarkableListUpdateAfterCommandExecution(
williamr@4
   620
        CEikListBox *aListBox);
williamr@4
   621
williamr@4
   622
    /** Helper function to position list highlight correctly after item removal
williamr@4
   623
     */
williamr@4
   624
    IMPORT_C static void HandleItemRemovalAndPositionHighlightL(
williamr@4
   625
        CEikListBox *aListBox,
williamr@4
   626
        TInt aValueOfCurrentItemIndexBeforeRemoval,
williamr@4
   627
        TBool aCurrentItemWasRemoved);
williamr@4
   628
williamr@4
   629
    // This one updates selectionindexes too.
williamr@4
   630
    /** Helper function to position list highlight correctly after item removal
williamr@4
   631
     *
williamr@4
   632
     * It also updates selection index array based on information about which
williamr@4
   633
     * items were removed.
williamr@4
   634
     */
williamr@4
   635
    IMPORT_C static void HandleItemRemovalAndPositionHighlightL(
williamr@4
   636
        CEikListBox *aListBox,
williamr@4
   637
        TInt aValueOfCurrentItemIndexBeforeRemoval,
williamr@4
   638
        CArrayFix<TInt> &aIndexesOfRemovedItemsBeforeRemoval);
williamr@4
   639
    };
williamr@4
   640
williamr@4
   641
williamr@4
   642
williamr@4
   643
class CAknSearchField;
williamr@4
   644
williamr@4
   645
/** 
williamr@4
   646
 * This class implements find requirements from component specifications. This
williamr@4
   647
 * class works also as documentation of how to use different find components.
williamr@4
   648
 * (The implementation has been copied from the example application which 
williamr@4
   649
 * implements find and replaced the code with calls to these static functions).
williamr@4
   650
 *
williamr@4
   651
 * There is no reason for an application to use this class directly. 
williamr@4
   652
 * Application should use CAknSelectionListDialog instead. This class is public
williamr@4
   653
 * only because sometimes it is necessary to access the low level behaviour of
williamr@4
   654
 * find to implement similar functionality in places independent of find; or if
williamr@4
   655
 * @c CAknSelectionListDialog is not used for some reason.
williamr@4
   656
 */
williamr@4
   657
class AknFind
williamr@4
   658
    {
williamr@4
   659
public:
williamr@4
   660
williamr@4
   661
    /*
williamr@4
   662
     * Implements the event handlers for the find pane. This method must be
williamr@4
   663
     * called when a @c ProcessCommandL event is received and a find pane is on
williamr@4
   664
     * the screen.
williamr@4
   665
     *
williamr@4
   666
     * @param aCommand Command id.
williamr@4
   667
     * @param aListBox Pointer to listbox control.
williamr@4
   668
     * @param aSearchField Pointer to search field control.
williamr@4
   669
     * @param aParentControl Parent control.
williamr@4
   670
     */
williamr@4
   671
    IMPORT_C static void HandleFindPopupProcessCommandL(
williamr@4
   672
                        TInt aCommand, 
williamr@4
   673
                        CEikListBox* aListBox, 
williamr@4
   674
                        CAknSearchField* aSearchField, 
williamr@4
   675
                        CCoeControl* aParentControl);
williamr@4
   676
    
williamr@4
   677
    /*
williamr@4
   678
     * Handles key events for the find pane. This method must be called when
williamr@4
   679
     * control receives @c OfferKeyEventL event.
williamr@4
   680
     *
williamr@4
   681
     * @param aKeyEvent The key event.
williamr@4
   682
     * @param aType The type of key event:@c TEventCode.
williamr@4
   683
     * @param aListBoxParent Pointer to the parent control.
williamr@4
   684
     * @param aListBox Pointer to listbox control.
williamr@4
   685
     * @param aSearchField Pointer to search field control.
williamr@4
   686
     * @param isFindPopup @c ETrue if popup find pane, @c EFalse if normal find
williamr@4
   687
     *        pane.
williamr@4
   688
     * @param aNeedRefresh @c ETrue when find pane is redrawn.
williamr@4
   689
     */    
williamr@4
   690
    IMPORT_C static TKeyResponse HandleFindOfferKeyEventL(
williamr@4
   691
                        const TKeyEvent& aKeyEvent, 
williamr@4
   692
                        TEventCode aType, 
williamr@4
   693
                        CCoeControl* aListBoxParent, 
williamr@4
   694
                        CEikListBox* aListBox, 
williamr@4
   695
                        CAknSearchField* aSearchField, 
williamr@4
   696
                        TBool isFindPopup, 
williamr@4
   697
                        TBool &aNeedRefresh);
williamr@4
   698
williamr@4
   699
    /*
williamr@4
   700
     * Do not use this method.
williamr@4
   701
     *
williamr@4
   702
     * @deprecated Use @c AknFind::HandleFixedFindSizeChanged() and 
williamr@4
   703
     *             @c AknFind::HandlePopupFindSizeChanged instead.
williamr@4
   704
     *        
williamr@4
   705
     */
williamr@4
   706
    IMPORT_C static void HandleFindSizeChanged(
williamr@4
   707
            CCoeControl* aParentControl, 
williamr@4
   708
            CEikListBox* aListBox, 
williamr@4
   709
            CAknSearchField* aSearchField, 
williamr@4
   710
            TBool ispopup = ETrue, 
williamr@4
   711
            TInt aFindWindowResourceId = R_AVKON_POPUP_FIND_WINDOW, 
williamr@4
   712
            TInt aListAreaId = R_AVKON_LIST_GEN_PANE, 
williamr@4
   713
            TInt aListResourceIdWithFindPopup = 
williamr@4
   714
                                R_AVKON_LIST_GEN_PANE_WITH_FIND_POPUP, 
williamr@4
   715
            TInt aFindWindowParentResourceId = 
williamr@4
   716
                                R_AVKON_MAIN_PANE_WITH_STATUS_PANE);
williamr@4
   717
williamr@4
   718
    /** 
williamr@4
   719
     * This is the new typesafe (and easier to use) version of @c
williamr@4
   720
     * HandleFindSizeChanged(). Use this instead of (deprecated) @c
williamr@4
   721
     * HandleFindSizeChanged().
williamr@4
   722
     *
williamr@4
   723
     * @param aParentControl Parent control.
williamr@4
   724
     * @param aListBox Column list, optional and available only with column 
williamr@4
   725
     *                 lists.
williamr@4
   726
     * @param aSearchField Pointer to search field control.
williamr@4
   727
     */
williamr@4
   728
    IMPORT_C static void HandleFixedFindSizeChanged(
williamr@4
   729
            CCoeControl* aParentControl,
williamr@4
   730
            CAknColumnListBox* aListBox, // only available with column lists
williamr@4
   731
            CAknSearchField* aSearchField);
williamr@4
   732
    
williamr@4
   733
    /** 
williamr@4
   734
     * This is the new typesafe(and easier to use) version of @c 
williamr@4
   735
     * HandleFindSizeChanged(). Use this instead of (deprecated) @c
williamr@4
   736
     * HandleFindSizeChanged().
williamr@4
   737
     *
williamr@4
   738
     * @param aParentControl Parent control.
williamr@4
   739
     * @param aListBox Pointer to listbox control.
williamr@4
   740
     * @param aSearchField Pointer to search field control.
williamr@4
   741
     */
williamr@4
   742
    IMPORT_C static void HandlePopupFindSizeChanged(
williamr@4
   743
                            CCoeControl* aParentControl,
williamr@4
   744
                            CEikListBox* aListBox,  //available with all lists.
williamr@4
   745
                            CAknSearchField* aSearchField);
williamr@4
   746
    
williamr@4
   747
    /**
williamr@4
   748
     * Creates layout for a find pane and for a list. This method must be called
williamr@4
   749
     * in @c SizeChanged() method of an container.
williamr@4
   750
     *
williamr@4
   751
     * @since 2.6
williamr@4
   752
     *
williamr@4
   753
     * @param aParentControl Parent control.
williamr@4
   754
     * @param aListBox Pointer to listbox control.
williamr@4
   755
     * @param aSearchField Pointer to search field control.
williamr@4
   756
     * @param aFindWindow LAF specific table line for find window.
williamr@4
   757
     * @param aListArea LAF specific table for list box area.
williamr@4
   758
     * @param aIsPopup @c ETrue if popup find pane, @c EFalse if normal find
williamr@4
   759
     *        pane.
williamr@4
   760
     * @param aFindWindowParent LAF specific table line for find parent.
williamr@4
   761
     */
williamr@4
   762
    IMPORT_C static void HandleFindSizeChangedLayouts(
williamr@4
   763
                            CCoeControl* aParentControl, 
williamr@4
   764
                            CEikListBox* aListBox, 
williamr@4
   765
                            CAknSearchField* aSearchField, 
williamr@4
   766
                            const TAknWindowLineLayout& aFindWindow,
williamr@4
   767
                            const TAknWindowLineLayout& aListArea,
williamr@4
   768
                            TBool aIsPopup,
williamr@4
   769
                            const TAknWindowLineLayout& aFindWindowParent );
williamr@4
   770
williamr@4
   771
public:
williamr@4
   772
williamr@4
   773
    /**
williamr@4
   774
     * Checks if @c aItemText matches @c aSearchText. 
williamr@4
   775
     *
williamr@4
   776
     * @param aItemText List box item text.
williamr@4
   777
     * @param aSearchText Searched text.
williamr@4
   778
     * 
williamr@4
   779
     * @return @c ETrue if list box item text @c aItemText matches @c 
williamr@4
   780
     *         aSearchText otherwise @c EFalse.
williamr@4
   781
     */
williamr@4
   782
    IMPORT_C static TBool IsFindMatch(const TDesC& aItemText, 
williamr@4
   783
                                      const TDesC& aSearchText);
williamr@4
   784
williamr@4
   785
    /**
williamr@4
   786
     * Tests if aCh is a word separator character as described in S60.
williamr@4
   787
     *
williamr@4
   788
     * @param aCh Comperative character.
williamr@4
   789
     *
williamr@4
   790
     * @return @c ETrue if aCh is a word separator character as described in
williamr@4
   791
     * S60 otherwise @c EFalse.
williamr@4
   792
     */
williamr@4
   793
    IMPORT_C static TBool IsFindWordSeparator(TChar aCh);
williamr@4
   794
williamr@4
   795
    
williamr@4
   796
    /**
williamr@4
   797
     * Checks if @c aItemText matches @c aSearchText. 
williamr@4
   798
     * Calls UpdateNextCharsL() if findutil is not supported.
williamr@4
   799
     *
williamr@4
   800
     * @since 5.0
williamr@4
   801
     * @param aItemText List box item text.
williamr@4
   802
     * @param aSearchText Searched text.
williamr@4
   803
     * @param aNextChars Reference to the next characters for the adaptive search grid
williamr@4
   804
     *        The HBufC buffer may be re-allocated by this method. 
williamr@4
   805
     *        In that case the pointer reference is modified to point to the re-allocated object.     
williamr@4
   806
     * 
williamr@4
   807
     * @return @c ETrue if list box item text @c aItemText matches @c 
williamr@4
   808
     *         aSearchText otherwise @c EFalse.
williamr@4
   809
     */
williamr@4
   810
    IMPORT_C static TBool IsAdaptiveFindMatch( const TDesC& aItemText, 
williamr@4
   811
			    		       const TDesC& aSearchText,			
williamr@4
   812
			       		       HBufC*& aNextChars );
williamr@4
   813
williamr@4
   814
    /**
williamr@4
   815
     * Update next characters if find pane state was changed.
williamr@4
   816
     *
williamr@4
   817
     * @since 5.0
williamr@4
   818
     * @param aNextChars Next characters for the adaptive search grid
williamr@4
   819
     * @param aCh Criteria from the search field.    
williamr@4
   820
     */
williamr@4
   821
    static void UpdateNextCharsL( HBufC*& aNextChars, TChar aCh );
williamr@4
   822
    
williamr@4
   823
    /**
williamr@4
   824
     * For Devanagari adaptive search     
williamr@4
   825
     * Update next characters if find pane state was changed.
williamr@4
   826
     *
williamr@4
   827
     * @since 5.0
williamr@4
   828
     * @param aNextChars reference to the next characters for the adaptive search grid
williamr@4
   829
     * @param aItemString string we are searching.    
williamr@4
   830
     */
williamr@4
   831
    static void UpdateNextCharsL( HBufC*& aNextChars, const TDesC& aItemString );
williamr@4
   832
    
williamr@4
   833
    /**
williamr@4
   834
     * Update next chars from the list box item text, when search field if empty.
williamr@4
   835
     * This need to be done for update next characters for adaptive grid
williamr@4
   836
     * works faster then calling IsAdaptiveFindMatch(). 
williamr@4
   837
     *
williamr@4
   838
     * @since 5.0
williamr@4
   839
     * @param aNextChars Reference to the next characters for the adaptive search grid
williamr@4
   840
     *        The HBufC buffer may be re-allocated by this method. 
williamr@4
   841
     *        In that case the pointer reference is modified to point to the re-allocated object.     
williamr@4
   842
     * @param aItemString List box item text.
williamr@4
   843
     */
williamr@4
   844
    IMPORT_C static void UpdateNextCharsFromString( HBufC*& aNextChars, const TDesC& aItemString );
williamr@4
   845
williamr@4
   846
    /**
williamr@4
   847
     * Update next chars from the list box item text according to the bitflag.
williamr@4
   848
     * Use to exclude columns from the listbox string. For example icon index columns. 
williamr@4
   849
     *
williamr@4
   850
     * @since 5.0
williamr@4
   851
     * @param aInputText List box item text
williamr@4
   852
     * @param aColumnFlag The bit flag shows which columns take into account
williamr@4
   853
     * @param aOutText Updated list box item text accoding to bit flag
williamr@4
   854
     */
williamr@4
   855
    IMPORT_C static void UpdateItemTextAccordingToFlag( const TDesC& aInputText, 
williamr@4
   856
		  		 			TBitFlags32 aColumnFlag, 
williamr@4
   857
							TDes& aOutText );
williamr@4
   858
williamr@4
   859
    /**
williamr@4
   860
     * Helper function to handle find pane's visibility.
williamr@4
   861
     *
williamr@4
   862
     * @param aSearchField Pointer to search field control.
williamr@4
   863
     * @param ispopup @c ETrue if popup find pane, @c EFalse if normal find 
williamr@4
   864
     *        pane.
williamr@4
   865
     * @param textchanged @c ETrue when text in @c CAknSearchField has changed.
williamr@4
   866
     * @param aNeedRefresh @c ETrue when find pane is redrawn.
williamr@4
   867
     */
williamr@4
   868
    static void HandleFindPaneVisibility(CAknSearchField* aSearchField, 
williamr@4
   869
                                         TBool ispopup, 
williamr@4
   870
                                         TBool textchanged, 
williamr@4
   871
                                         TBool &aNeedRefresh);
williamr@4
   872
    };
williamr@4
   873
williamr@4
   874
williamr@4
   875
/** 
williamr@4
   876
 * Utility class to initialize editor control. Use this in conjunction with @c
williamr@4
   877
 * AknLayoutUtils::LayoutEdwin(). The class is not fully implemented yet.
williamr@4
   878
 */
williamr@4
   879
class AknEditUtils
williamr@4
   880
    {
williamr@4
   881
    public:
williamr@4
   882
    
williamr@4
   883
    /** Basic elements that are needed for the basic editing functions. */
williamr@4
   884
    struct SAknEditorParameters 
williamr@4
   885
    {
williamr@4
   886
        /** The maximum available space that can be used for one text. */
williamr@4
   887
        TInt iEditingSpace;
williamr@4
   888
        
williamr@4
   889
        /** Size of the editing window. */
williamr@4
   890
        TInt iEditingWindow;
williamr@4
   891
        
williamr@4
   892
        /**
williamr@4
   893
         * Character case effects on the style of entering characters.
williamr@4
   894
         * Available alternatives are Upper case, Lower case and Text case.
williamr@4
   895
         */ 
williamr@4
   896
        TInt iCharacterCase;
williamr@4
   897
        
williamr@4
   898
        /** 
williamr@4
   899
         * Specifies from which edge the current line is filled with the
williamr@4
   900
         * inserted characters.
williamr@4
   901
         */
williamr@4
   902
        TInt iJustification;
williamr@4
   903
        
williamr@4
   904
        /** Is user allowed to move the insertion point. */ 
williamr@4
   905
        TBool iAllowedToMoveInsertionPoint;
williamr@4
   906
        
williamr@4
   907
        /** Is cursor blinking or not. */
williamr@4
   908
        TBool iCursorYesNo;
williamr@4
   909
        
williamr@4
   910
        /** Is overflow active or not.  */  
williamr@4
   911
        TBool iOverflowYesNo;
williamr@4
   912
    };
williamr@4
   913
williamr@4
   914
    IMPORT_C static void ConstructEditingL(CEikEdwin* aEdwin, TInt aResourceId);
williamr@4
   915
    IMPORT_C static void ConstructEditingL(CEikEdwin* aEdwin, TResourceReader& aReader);
williamr@4
   916
    IMPORT_C static void ConstructEditingL(CEikEdwin* aEdwin, const SAknEditorParameters &aParams);
williamr@4
   917
williamr@4
   918
/**
williamr@4
   919
 *  Configures edwin editor. Use AknLayoutUtils::LayoutEdwin() with this method.
williamr@4
   920
 *
williamr@4
   921
 *  @param aEdwin Edwins created with new.
williamr@4
   922
 *  @param aEditingSpace maximum number of characters for the editor
williamr@4
   923
 *  @param aEditingWindow maximum number of lines in the editor
williamr@4
   924
 *  @param aCharacterCase initial character case:
williamr@4
   925
 *          EAknEditorCharactersUpperCase = EAknEditorUpperCase,
williamr@4
   926
 *          EAknEditorCharactersLowerCase = EAknEditorLowerCase,
williamr@4
   927
 *          EAknEditorCharactersTextCase = EAknEditorTextCase,
williamr@4
   928
 *          EAknEditorCharactersTitleCase = EAknEditorTitleCase
williamr@4
   929
 *
williamr@4
   930
 *  @param aJustification alignment for the editor text ( EAknEditorAlignCenter, 
williamr@4
   931
 *         EAknEditorAlignLeft, EAknEditorAlignRight)
williamr@4
   932
 *  @param aAllowedToMoveInsertionPoint user can move cursor
williamr@4
   933
 *  @param aCursorYesNo is cursor visible or not.
williamr@4
   934
 *  @param aOverflowYesNo
williamr@4
   935
 */
williamr@4
   936
    IMPORT_C static void ConstructEditingL(CEikEdwin* aEdwin, 
williamr@4
   937
                       TInt aEditingSpace, 
williamr@4
   938
                       TInt aEditingWindow, 
williamr@4
   939
                       TInt aCharacterCase, 
williamr@4
   940
                       TInt aJustification, 
williamr@4
   941
                       TBool aAllowedToMoveInsertionPoint, 
williamr@4
   942
                       TBool aCursorYesNo, 
williamr@4
   943
                       TBool aOverflowYesNo);
williamr@4
   944
                       
williamr@4
   945
/**
williamr@4
   946
 *  Configures edwin editor. Use AknLayoutUtils::LayoutEdwin() with this method.
williamr@4
   947
 *  
williamr@4
   948
 *  @param aEdwin Edwins created with new.
williamr@4
   949
 *  @param aEditingSpace maximum number of characters for the editor
williamr@4
   950
 *  @param aEditingWindow maximum number of lines in the editor
williamr@4
   951
 *  @param aCharacterCase initial character case:
williamr@4
   952
 *          EAknEditorCharactersUpperCase = EAknEditorUpperCase,
williamr@4
   953
 *          EAknEditorCharactersLowerCase = EAknEditorLowerCase,
williamr@4
   954
 *          EAknEditorCharactersTextCase = EAknEditorTextCase,
williamr@4
   955
 *          EAknEditorCharactersTitleCase = EAknEditorTitleCase
williamr@4
   956
 *
williamr@4
   957
 *  @param aJustification alignment for the editor text ( EAknEditorAlignCenter, 
williamr@4
   958
 *         EAknEditorAlignLeft, EAknEditorAlignRight)
williamr@4
   959
 *  @param aAllowedToMoveInsertionPoint user can move cursor
williamr@4
   960
 *  @param aCursorYesNo is cursor visible or not.
williamr@4
   961
 *  @param aOverflowYesNo
williamr@4
   962
 *  @param aIsResizeable is edwin resizeable (one line editor should use EFalse, in order to have proper scrolling)
williamr@4
   963
 */
williamr@4
   964
    IMPORT_C static void ConstructEditingL(CEikEdwin* aEdwin, 
williamr@4
   965
                                              TInt aEditingSpace, 
williamr@4
   966
                                              TInt aEditingWindow, 
williamr@4
   967
                                              TInt aCharacterCase, 
williamr@4
   968
                                              TInt aJustification, 
williamr@4
   969
                                              TBool aAllowedToMoveInsertionPoint, 
williamr@4
   970
                                              TBool aCursorYesNo, 
williamr@4
   971
                                              TBool aOverflowYesNo,
williamr@4
   972
                                              TBool aIsResizable);
williamr@4
   973
williamr@4
   974
    };
williamr@4
   975
williamr@4
   976
/** Automatic numbering for list items. (DEPRECATED)
williamr@4
   977
 * Just create this kind of object and attach it to a listbox, and you'll
williamr@4
   978
 * have automatic numbering. 
williamr@4
   979
 *
williamr@4
   980
 *
williamr@4
   981
 * You'll need to call UpdateL() each time you modify the listbox's model!
williamr@4
   982
 */
williamr@4
   983
class CListBoxNumbers : public CBase
williamr@4
   984
    {
williamr@4
   985
public:
williamr@4
   986
    IMPORT_C CListBoxNumbers(CEikTextListBox* aListBox);
williamr@4
   987
    IMPORT_C void ConstructL();
williamr@4
   988
    IMPORT_C void UpdateL();
williamr@4
   989
private:
williamr@4
   990
    CEikTextListBox* iListBox;
williamr@4
   991
    };
williamr@4
   992
williamr@4
   993
class CAknListBoxFilterItems;
williamr@4
   994
williamr@4
   995
    /** 
williamr@4
   996
    * This class shows how application should build its model for filtered
williamr@4
   997
    * items. Application should not use this directly, if it has it's own model
williamr@4
   998
    * or if there's any special things needed for @c MatchableTextArray.
williamr@4
   999
    * Application can derive from this though. All listboxes use 
williamr@4
  1000
    * @c CAknFilteredTextListBoxModel by default. @c CreateFilter() call 
williamr@4
  1001
    * enables it.
williamr@4
  1002
    * @since S60 0.9
williamr@4
  1003
    */
williamr@4
  1004
class CAknFilteredTextListBoxModel : public CTextListBoxModel, public MDesCArray
williamr@4
  1005
    {
williamr@4
  1006
public: // public interface for apps
williamr@4
  1007
    /**
williamr@4
  1008
    * Creates a @c CAknListBoxFilterItems and thus enables filtering of list
williamr@4
  1009
    * items.
williamr@4
  1010
    * @param aListBox List box from which one or more items can be selected.
williamr@4
  1011
    * @param aSearchField Search field control.
williamr@4
  1012
    */
williamr@4
  1013
    IMPORT_C void CreateFilterL(CEikListBox* aListBox, CAknSearchField* aSearchField);
williamr@4
  1014
    /**
williamr@4
  1015
     * removes previously added filter from model
williamr@4
  1016
     */
williamr@4
  1017
    IMPORT_C void RemoveFilter();
williamr@4
  1018
    /**
williamr@4
  1019
    * Access function for the filter.
williamr@4
  1020
    * @return Pointer to the listbox filter.
williamr@4
  1021
    */
williamr@4
  1022
    IMPORT_C CAknListBoxFilterItems* Filter() const;
williamr@4
  1023
    /**
williamr@4
  1024
    * Destructor.
williamr@4
  1025
    */
williamr@4
  1026
    IMPORT_C ~CAknFilteredTextListBoxModel();
williamr@4
  1027
public: // from CTextListBoxMode
williamr@4
  1028
    /**
williamr@4
  1029
    * Implementation of @c CTextListBoxModel::NumberOfItems()
williamr@4
  1030
    * @return The number of items the list box has.
williamr@4
  1031
    */
williamr@4
  1032
    IMPORT_C virtual TInt NumberOfItems() const;
williamr@4
  1033
    /**
williamr@4
  1034
    * Returns the text of the specified item.
williamr@4
  1035
    * @param aItemIndex Index to the item.
williamr@4
  1036
    * @return The text of item in given index.
williamr@4
  1037
    */
williamr@4
  1038
    IMPORT_C virtual TPtrC ItemText(TInt aItemIndex) const;
williamr@4
  1039
public: // from MEikTextListBoxModel (default filtering string conversions)
williamr@4
  1040
    /**
williamr@4
  1041
    * Implementation of @c CTextListBoxModel::MatchableTextArray()
williamr@4
  1042
    * @return Pointer to the text array.
williamr@4
  1043
    */
williamr@4
  1044
    IMPORT_C const MDesCArray* MatchableTextArray() const;
williamr@4
  1045
williamr@4
  1046
private:
williamr@4
  1047
    CAknListBoxFilterItems* iFilter; // owned
williamr@4
  1048
private: // From MdesCArray (these implement default matchabletextarray for filtering.)
williamr@4
  1049
    IMPORT_C TInt MdcaCount() const;
williamr@4
  1050
    IMPORT_C TPtrC MdcaPoint(TInt aIndex) const;
williamr@4
  1051
private: // from MListBoxModel
williamr@4
  1052
    IMPORT_C virtual TAny* MListBoxModel_Reserved();
williamr@4
  1053
    };
williamr@4
  1054
williamr@4
  1055
    /** 
williamr@4
  1056
    * Listbox item filtering. This class is designed to be stored inside
williamr@4
  1057
    * a listbox model and the model should call this in its @c NumberOfItems()
williamr@4
  1058
    * and @c ItemText() implementation. The model must be given to this class
williamr@4
  1059
    * and it must have @c MatchableTextArray() implemented correctly.
williamr@4
  1060
    * @c HandleOfferKeyEvent() should be called from the same offer key event
williamr@4
  1061
    * implementation which forwards the keys to listbox and search field
williamr@4
  1062
    * 
williamr@4
  1063
    * If you have both markable list and find at the same time, you should call
williamr@4
  1064
    * @c ResetFiltering() before executing the command for marked items. This
williamr@4
  1065
    * ensures that the ListBox's @c SelectionIndexes() returns all items instead
williamr@4
  1066
    * of only those items that are visible. Selected *items can be found under
williamr@4
  1067
    * @c CAknListBoxFilterItems::SelectionIndexes().
williamr@4
  1068
    *
williamr@4
  1069
    * @since S60 0.9
williamr@4
  1070
    * 
williamr@4
  1071
    */
williamr@4
  1072
class CAknListBoxFilterItems : public CBase, public MCoeControlObserver
williamr@4
  1073
    {
williamr@4
  1074
public:
williamr@4
  1075
    /**
williamr@4
  1076
    * Base class default constructor.
williamr@4
  1077
    * @param aListBox Listbox to be filtered,
williamr@4
  1078
    * @param aSearchField Listbox search field.
williamr@4
  1079
    * @param aModel Listbox model,
williamr@4
  1080
    * @param aView A list box view that displays the list items which are
williamr@4
  1081
    * currently visible in a list box.
williamr@4
  1082
    */
williamr@4
  1083
    IMPORT_C CAknListBoxFilterItems(
williamr@4
  1084
        CEikListBox *aListBox,
williamr@4
  1085
        CAknSearchField *aSearchField,
williamr@4
  1086
        MListBoxModel *aModel,
williamr@4
  1087
        CListBoxView *aView);
williamr@4
  1088
williamr@4
  1089
    /**
williamr@4
  1090
    * This is for setting empty list text.
williamr@4
  1091
    */
williamr@4
  1092
    IMPORT_C void ConstructL(); // for setting empty list text.
williamr@4
  1093
    /** 
williamr@4
  1094
    * This function is to be called when filter is cleared.
williamr@4
  1095
    */
williamr@4
  1096
    IMPORT_C void ResetFilteringL();
williamr@4
  1097
    /** 
williamr@4
  1098
    * This function will update filter items state from the search field and
williamr@4
  1099
    * listbox. Also updates selection indexes.
williamr@4
  1100
    */
williamr@4
  1101
    IMPORT_C void UpdateCachedDataL(); // updates iOldSearchCriteria and selection indexes.
williamr@4
  1102
    /**
williamr@4
  1103
    * Destructor. Frees all resources owned by the object prior to its
williamr@4
  1104
    * destruction.
williamr@4
  1105
    */
williamr@4
  1106
    IMPORT_C ~CAknListBoxFilterItems();    
williamr@4
  1107
williamr@4
  1108
public: 
williamr@4
  1109
    /** 
williamr@4
  1110
    * This one gives all indices, not just the ones that are visible.
williamr@4
  1111
    * @return Pointer to the array that has all indices.
williamr@4
  1112
    */
williamr@4
  1113
    IMPORT_C CArrayFix<TInt> *SelectionIndexes();
williamr@4
  1114
    /** 
williamr@4
  1115
    * This will synchronise the selection indices from the listbox.
williamr@4
  1116
    * If you use @c SelectionIndexes(), call this before it.
williamr@4
  1117
    * This is heavy operation and goes through all list items.
williamr@4
  1118
    */
williamr@4
  1119
    IMPORT_C void UpdateSelectionIndexesL();
williamr@4
  1120
    /** 
williamr@4
  1121
    * This will synchronise the selected index from the listbox.
williamr@4
  1122
    * If you use @c SelectionIndexes(), call this before it.
williamr@4
  1123
    * This is heavy operation and goes through all list items. 
williamr@4
  1124
    * @param aVisibleIndex Index to be updated.
williamr@4
  1125
    */
williamr@4
  1126
    IMPORT_C void UpdateSelectionIndexL(TInt aVisibleIndex);
williamr@4
  1127
williamr@4
  1128
public: // Applications should call this in their listbox model implementation
williamr@4
  1129
    /** 
williamr@4
  1130
    * This is used to ask how many list items are available after filter has
williamr@4
  1131
    * been used. Counts visible list items.
williamr@4
  1132
    * @return Number of items visible.
williamr@4
  1133
    */
williamr@4
  1134
    IMPORT_C TInt FilteredNumberOfItems() const;
williamr@4
  1135
    /** 
williamr@4
  1136
    * This is used to fetch the content of a list item after filter has been
williamr@4
  1137
    * used.
williamr@4
  1138
    * @param aVisibleItemIndex The index of visible item.
williamr@4
  1139
    * @return Index to the original item array.
williamr@4
  1140
    */
williamr@4
  1141
    IMPORT_C TInt FilteredItemIndex(TInt aVisibleItemIndex) const;
williamr@4
  1142
williamr@4
  1143
public: // Needed to change the correct item.
williamr@4
  1144
williamr@4
  1145
    /** 
williamr@4
  1146
    * Returns number of original list items.
williamr@4
  1147
    * @return Number of all items.
williamr@4
  1148
    */
williamr@4
  1149
    IMPORT_C TInt NonFilteredNumberOfItems() const; // this always returns >= FilteredNumberOfItems()
williamr@4
  1150
    /** 
williamr@4
  1151
    * Finds the list item on the screen when the item array index is given.
williamr@4
  1152
    * @param aOriginalIndex Item index.
williamr@4
  1153
    * @return Matching index from original array. Returns -1 if the Index is
williamr@4
  1154
    * not visible.
williamr@4
  1155
    */
williamr@4
  1156
    IMPORT_C TInt VisibleItemIndex(TInt aOriginalIndex) const;
williamr@4
  1157
public: 
williamr@4
  1158
    /** 
williamr@4
  1159
    * For building @c MdcaPoint() of the model's @c MatchableTextArray.
williamr@4
  1160
    * This method builds the default value for @c MatchableTextArray.
williamr@4
  1161
    * @param aText Pointer descriptor.
williamr@4
  1162
    * @return Modified text.
williamr@4
  1163
    */
williamr@4
  1164
    IMPORT_C TPtrC DefaultMatchableItemFromItem(TPtrC aText);
williamr@4
  1165
williamr@4
  1166
public: 
williamr@4
  1167
    /** 
williamr@4
  1168
    * Applications should call this in @c OfferKeyEventL() which gives keys to
williamr@4
  1169
    * listbox and search field.
williamr@4
  1170
    */
williamr@4
  1171
    IMPORT_C void HandleOfferkeyEventL();
williamr@4
  1172
williamr@4
  1173
   
williamr@4
  1174
    /** 
williamr@4
  1175
    * When you change the list item array you should call this method.
williamr@4
  1176
    */
williamr@4
  1177
    IMPORT_C void HandleItemArrayChangeL();
williamr@4
  1178
williamr@4
  1179
public: // MCoeControlObserver
williamr@4
  1180
    /**
williamr@4
  1181
    * Sets the observer.
williamr@4
  1182
    * @param aObserver Pointer to the observer.
williamr@4
  1183
    */
williamr@4
  1184
    IMPORT_C void SetObserver(MCoeControlObserver *aObserver);
williamr@4
  1185
    /**
williamr@4
  1186
    * Editor sends messages to this object as control events.
williamr@4
  1187
    * @param aControl The control that sent the event.
williamr@4
  1188
    * @param aEventType The event type.
williamr@4
  1189
    */
williamr@4
  1190
    IMPORT_C void HandleControlEventL(CCoeControl *aControl, TCoeEvent aEventType);
williamr@4
  1191
williamr@4
  1192
public: // For FEP
williamr@4
  1193
    /**
williamr@4
  1194
    * Sends key events to FEP. This is used to resend key event to FEP if
williamr@4
  1195
    * @c AknFind's @c HandleOfferKeyEventL() gets the key while search field
williamr@4
  1196
    * has no focus. If search field has a focus, the key events go directly to
williamr@4
  1197
    * the editor and this is not called.
williamr@4
  1198
    * @param aValue The character code for an @c EEventKey.
williamr@4
  1199
    */
williamr@4
  1200
    IMPORT_C void DeferredSendKeyEventToFepL(TUint aValue);
williamr@4
  1201
    /**
williamr@4
  1202
    * This gets called from @c DeferredSendKeyEventToFepL().
williamr@4
  1203
    * This does the actual sending of a key event. Does not support more than
williamr@4
  1204
    * one event at the time.
williamr@4
  1205
    * @param aFilterItems Pointer to the @c CAknListBoxFilterItems object.
williamr@4
  1206
    * @return Always returns 0.
williamr@4
  1207
    */
williamr@4
  1208
    static TInt IdleCallBack(TAny *aFilterItems);
williamr@4
  1209
williamr@4
  1210
public: // For size changed
williamr@4
  1211
    /**
williamr@4
  1212
    * @c AknFind uses this to inform us who is the parent control owning the
williamr@4
  1213
    * listbox and search field. This control should be window-owning control and
williamr@4
  1214
    * it will be used to resize the listbox when changes to the filtering
williamr@4
  1215
    * happens.
williamr@4
  1216
    * @param aControl Pointer to the control.
williamr@4
  1217
    */
williamr@4
  1218
    IMPORT_C void SetParentControl(CCoeControl *aControl);
williamr@4
  1219
   /**
williamr@4
  1220
    * @c AknFind uses this to inform us that we have popup find. Applications 
williamr@4
  1221
    * shouldn't call this.
williamr@4
  1222
    */
williamr@4
  1223
    IMPORT_C void SetPopup();
williamr@4
  1224
williamr@4
  1225
public: // For detaching and attaching list, findbox, model and view...
williamr@4
  1226
    /**
williamr@4
  1227
    * Attaches or detaches list used by the filtering.
williamr@4
  1228
    * @since S60 2.0
williamr@4
  1229
    * @param aListBox Pointer to listbox or @c NULL.
williamr@4
  1230
    */
williamr@4
  1231
    IMPORT_C void SetListBox(CEikListBox *aListBox);
williamr@4
  1232
    /**
williamr@4
  1233
    * Attaches or detaches find pane used by the filtering.
williamr@4
  1234
    * @since S60 2.0
williamr@4
  1235
    * @param aSearchField Pointer to findbox or @c NULL.
williamr@4
  1236
    */
williamr@4
  1237
    IMPORT_C void SetSearchField(CAknSearchField *aSearchField);
williamr@4
  1238
    /**
williamr@4
  1239
    * Attaches or detaches list model used by the filtering.
williamr@4
  1240
    * @since S60 2.0
williamr@4
  1241
    * @param aModel a pointer to list model or @c NULL.
williamr@4
  1242
    */
williamr@4
  1243
    IMPORT_C void SetModel(MListBoxModel *aModel);
williamr@4
  1244
    /**
williamr@4
  1245
    * Attaches or detaches list view used by the filtering.
williamr@4
  1246
    * @since S60 2.0
williamr@4
  1247
    * @param aView a pointer to list view or @c NULL.
williamr@4
  1248
    */
williamr@4
  1249
    IMPORT_C void SetView(CListBoxView *aView);
williamr@4
  1250
    
williamr@4
  1251
public:
williamr@4
  1252
    /**
williamr@4
  1253
    * This function just returns pointer to the search field.
williamr@4
  1254
    * @return Pointer to the search field.
williamr@4
  1255
    */
williamr@4
  1256
    IMPORT_C CCoeControl *FindBox() const;
williamr@4
  1257
williamr@4
  1258
    /**
williamr@4
  1259
     * An improved version of DeferredSendKeyEventToFepL. It sends a 
williamr@4
  1260
     * @c TKeyEvent rather than just key code. Thus the correct key 
williamr@4
  1261
     * event can be send to FEP on QWERTY keyboard.
williamr@4
  1262
     * @since S60 5.0
williamr@4
  1263
     * @param aEvent Event send to FEP.
williamr@4
  1264
     */
williamr@4
  1265
    void DeferredSendFullKeyEventToFepL(const TKeyEvent& aEvent);
williamr@4
  1266
williamr@4
  1267
private:
williamr@4
  1268
    void NoCriteriaL(TBool aUpdateAS = ETrue); // remove criteria completely.
williamr@4
  1269
    void TightenCriteriaL(const TDesC& aCriteria); // slow operation (do when adding new characters to search criteria)
williamr@4
  1270
    void ReleaseCriteriaL(const TDesC& aCriteria); // very slow operation (do when removing characters from search criteria)
williamr@4
  1271
    // EmptyListText handling
williamr@4
  1272
    void InstallEmptyTextL();
williamr@4
  1273
    void UninstallEmptyTextL();
williamr@4
  1274
    // Selections -- these methods form a pair, 
williamr@4
  1275
    // you must call Fetch first and then push.
williamr@4
  1276
    void FetchSelectionIndexesFromListBoxL();
williamr@4
  1277
    void PushSelectionIndexesToListBoxL();
williamr@4
  1278
    void ClearNextChars();
williamr@4
  1279
    TBool IsAdaptiveSearch() const; 	
williamr@4
  1280
williamr@4
  1281
    // HandleItemAddition without ResetFilteringL() call
williamr@4
  1282
    void HandleItemAdditionL();
williamr@4
  1283
    void HandleItemRemovalL();
williamr@4
  1284
private:
williamr@4
  1285
    TBool IsItemVisible(const TDesC& aMatchableItemString, const TDesC& aSearchText);
williamr@4
  1286
    static TBool IsSeparatorCharacter(TChar c);
williamr@4
  1287
    TBool IsItemSelected(TInt aRealIndex) const;
williamr@4
  1288
private:
williamr@4
  1289
    CArrayFix<TInt> *iShownIndexes; // own // uses non-filtered indexes
williamr@4
  1290
    CArrayFix<TInt> *iSelectionIndexes; // own   // this uses non-filtered indexes
williamr@4
  1291
    HBufC *iOldSearchCriteria; // own
williamr@4
  1292
    MListBoxModel *iModel;
williamr@4
  1293
    CListBoxView *iView;
williamr@4
  1294
    TInt iOldItemCount;
williamr@4
  1295
    HBufC* iEmptyListText; // own
williamr@4
  1296
    CEikListBox* iListBox;
williamr@4
  1297
    CAknSearchField* iSearchField;
williamr@4
  1298
    TBuf<256> iMatchableText;
williamr@4
  1299
    MCoeControlObserver *iObserver;
williamr@4
  1300
    CFindExtension *iExtension;
williamr@4
  1301
    TUint iKeyValue;
williamr@4
  1302
    CCoeControl *iParentControl;
williamr@4
  1303
    TBool iIsPopup;
williamr@4
  1304
    TBool iDisableChangesToShownIndexes;  
williamr@4
  1305
    };
williamr@4
  1306
williamr@4
  1307
williamr@4
  1308
/** Removing optimization that breaks listbox views 
williamr@4
  1309
 * A view which removes optimization from CListBoxView which breaks with lists where all items are not
williamr@4
  1310
 * the same layout.
williamr@4
  1311
 * Use it like this: 
williamr@4
  1312
 *   CListBoxView* MakeViewClassInstanceL() { return new(ELeave) NoOptimizationView<CListBoxView>; }
williamr@4
  1313
 */
williamr@4
  1314
template<class T>
williamr@4
  1315
class NoOptimizationView : public T
williamr@4
  1316
    {
williamr@4
  1317
public:
williamr@4
  1318
    virtual void VScrollTo(TInt aNewTopItemIndex, TRect& aMinRedrawRect)
williamr@4
  1319
    {
williamr@4
  1320
    // AVKON LAF
williamr@4
  1321
    if (this->RedrawDisabled())
williamr@4
  1322
        return;
williamr@4
  1323
    if (this->iTopItemIndex == aNewTopItemIndex)
williamr@4
  1324
        return;
williamr@4
  1325
    aMinRedrawRect.SetRect(this->iViewRect.iTl,this->iViewRect.Size());
williamr@4
  1326
    this->SetTopItemIndex(aNewTopItemIndex);
williamr@4
  1327
    this->Draw(&aMinRedrawRect);
williamr@4
  1328
    // end of AVKON LAF
williamr@4
  1329
    }
williamr@4
  1330
    };
williamr@4
  1331
williamr@4
  1332
williamr@4
  1333
/** This is private class, do not use it except for drawing controls!
williamr@4
  1334
 * 
williamr@4
  1335
 * Do not use it in applications.
williamr@4
  1336
 */
williamr@4
  1337
williamr@4
  1338
williamr@4
  1339
class AknLAFUtils 
williamr@4
  1340
    {
williamr@4
  1341
public:
williamr@4
  1342
    static void DrawLines(CGraphicsContext* aGc, 
williamr@4
  1343
                  const TRect& mainpane,
williamr@4
  1344
                  TInt x);
williamr@4
  1345
    IMPORT_C static void ReplaceColumn(TPtr aTarget, TDesC* aSource,
williamr@4
  1346
                                       TDesC* aReplacement, TChar aColumnSeparator,
williamr@4
  1347
                                       TInt aColumn);
williamr@4
  1348
    };
williamr@4
  1349
williamr@4
  1350
williamr@4
  1351
/**
williamr@4
  1352
 * Resource reader class
williamr@4
  1353
 *
williamr@4
  1354
 * This is utility class for reading listbox resouces.
williamr@4
  1355
 *
williamr@4
  1356
 * This should be derived from and it reads resource file for you.
williamr@4
  1357
 *
williamr@4
  1358
 * This seems to be only used by listbox resource readers. (Do not use it in applications)
williamr@4
  1359
 */
williamr@4
  1360
struct SAknLayoutGfx;
williamr@4
  1361
struct SAknLayoutText;
williamr@4
  1362
struct SAknLayoutCmd;
williamr@4
  1363
struct SAknLayoutGfx;
williamr@4
  1364
// Not for apps
williamr@4
  1365
struct SAknLayoutPos 
williamr@4
  1366
    {
williamr@4
  1367
    TInt l, t, r, b, W, H;
williamr@4
  1368
williamr@4
  1369
    typedef SAknLayoutPos ItemType;
williamr@4
  1370
    static void ReadResource(TResourceReader& aReader, ItemType& aTarget);    
williamr@4
  1371
    };
williamr@4
  1372
template<class T> class CArrayReader;
williamr@4
  1373
class CAknGenericReader : public CBase
williamr@4
  1374
    {
williamr@4
  1375
public:
williamr@4
  1376
    IMPORT_C void ConstructL(TInt aResourceId);
williamr@4
  1377
    IMPORT_C virtual void ConstructFromResourceL(TResourceReader& aReader);
williamr@4
  1378
    IMPORT_C ~CAknGenericReader();
williamr@4
  1379
williamr@4
  1380
    IMPORT_C const SAknLayoutGfx* GfxItem(TInt aIndex) const;
williamr@4
  1381
    IMPORT_C const SAknLayoutText* TextItem(TInt aIndex) const;
williamr@4
  1382
    IMPORT_C const SAknLayoutCmd* CmdItem(TInt aIndex) const;
williamr@4
  1383
    IMPORT_C const SAknLayoutGfx* AreaItem(TInt aIndex) const;
williamr@4
  1384
williamr@4
  1385
    CArrayReader<SAknLayoutGfx>* iGfx;
williamr@4
  1386
    CArrayReader<SAknLayoutText>* iText;
williamr@4
  1387
    CArrayReader<SAknLayoutCmd>* iCmd;
williamr@4
  1388
    CArrayReader<SAknLayoutGfx>* iArea;
williamr@4
  1389
    };
williamr@4
  1390
williamr@4
  1391
williamr@4
  1392
williamr@4
  1393
williamr@4
  1394
williamr@4
  1395
// Use this to mark that the position in LAF specification is empty.
williamr@4
  1396
const TInt AknLayoutUtilsNoValue = ELayoutEmpty;
williamr@4
  1397
williamr@4
  1398
/** Utility classes to build layout based on European LAF from resource files. (can be used by applications)
williamr@4
  1399
 *
williamr@4
  1400
 * Methods in this class are designed to be called from your control's SizeChanged() method!
williamr@4
  1401
 *
williamr@4
  1402
 * This class knows the specification's coordinate data format and ensures that different types of
williamr@4
  1403
 * controls are positioned and setup correctly according to European LAF. 
williamr@4
  1404
 * 
williamr@4
  1405
 * This class helps you with positioning labels, controls, rects and other things to according to LAF specification.
williamr@4
  1406
 * (It is NOT trivial to get it correct and this adjusts easily to changes in the LAF specification - if you're not
williamr@4
  1407
 * using this, remember to read the whole LAF specification - especially the beginning and the end with color and
williamr@4
  1408
 * especially how text margins and widths interact!!)
williamr@4
  1409
 *
williamr@4
  1410
 * (idea of this class is that when specification of one component changes, only resource file needs to be changed and when you 
williamr@4
  1411
 * get new product with new specification format, only this module needs to be changed and resources rewritten from the specification. 
williamr@4
  1412
 * And when component's specification changes, only the component need to be changed (usually only change is what components are
williamr@4
  1413
 * inside it and how it calls this module.).. => all controls have common format that decides its layout!
williamr@4
  1414
 *
williamr@4
  1415
 * Parent rectangles are always coordinates of LAF specification's parent rectangle in the screen.
williamr@4
  1416
 * 
williamr@4
  1417
 * To use this, call one of the methods in your SizeChanged() and then you'll need to make sure you
williamr@4
  1418
 * draw the area between controls using ClearBetweenRects() call from egul library. (CCoeControl::Rect() helps with that...)
williamr@4
  1419
 *
williamr@4
  1420
 * A Tip: You do not want to use any dynamic calculation of layouts! It is almost always an error to do so!
williamr@4
  1421
 *        => Do not allow layouts that have not been specified!
williamr@4
  1422
 *
williamr@4
  1423
 * (If LAF spec has many numbers and you need to dynamically choose between them, then keep the numbers in
williamr@4
  1424
 * code as function-local using SAknLayoutText/SAknLayoutRect/... -structs..)
williamr@4
  1425
 *
williamr@4
  1426
 * You'll want to use TAknLayoutRect and TAknLayoutText too to build layout
williamr@4
  1427
 * for your custom controls.
williamr@4
  1428
 */
williamr@4
  1429
class AknLayoutUtils
williamr@4
  1430
    {
williamr@4
  1431
public:
williamr@4
  1432
williamr@4
  1433
    struct SAknLayoutText
williamr@4
  1434
    {
williamr@4
  1435
    TInt iFont, iC, iL, iR, iB, iW, iJ;
williamr@4
  1436
    };
williamr@4
  1437
    struct SAknLayoutTextMultiline
williamr@4
  1438
    {
williamr@4
  1439
    TInt iFont, iC, iL, iR, iB, iW, iJ, iNumberOfLinesShown, iNextLineB;
williamr@4
  1440
    };
williamr@4
  1441
    typedef SAknLayoutTextMultiline SAknLayoutLabel;
williamr@4
  1442
    typedef SAknLayoutTextMultiline SAknLayoutEdwin;
williamr@4
  1443
    typedef SAknLayoutText SAknLayoutMfne;
williamr@4
  1444
    typedef SAknLayoutText SAknLayoutSecEd;
williamr@4
  1445
    struct SAknLayoutRect
williamr@4
  1446
    {
williamr@4
  1447
    TInt iC, iL, iT, iR, iB, iW, iH;
williamr@4
  1448
    };
williamr@4
  1449
    typedef SAknLayoutRect SAknLayoutControl;
williamr@4
  1450
    typedef SAknLayoutRect SAknLayoutImage;
williamr@4
  1451
williamr@4
  1452
    /**
williamr@4
  1453
    * Deprecated! Do not use!
williamr@4
  1454
    */
williamr@4
  1455
    IMPORT_C static void LayoutLabel(CEikLabel* aLabel,
williamr@4
  1456
                                     const TRect& aLabelParent,
williamr@4
  1457
                                     TInt aResourceId,
williamr@4
  1458
                                     const CFont* aCustomFont=0);
williamr@4
  1459
williamr@4
  1460
    /**
williamr@4
  1461
    * Deprecated! Do not use!
williamr@4
  1462
    */
williamr@4
  1463
    IMPORT_C static void LayoutLabel(CEikLabel* aLabel,
williamr@4
  1464
                                     const TRect& aLabelParent,
williamr@4
  1465
                                     TResourceReader& aReader,
williamr@4
  1466
                                     const CFont* aCustomFont=0);
williamr@4
  1467
williamr@4
  1468
    /** Layouts a label via a structure of layout parameters
williamr@4
  1469
    @param aLayout   the structure
williamr@4
  1470
     */
williamr@4
  1471
    IMPORT_C static void LayoutLabel(CEikLabel* aLabel,
williamr@4
  1472
                                     const TRect& aLabelParent,
williamr@4
  1473
                                     const SAknLayoutLabel& aLayout,
williamr@4
  1474
                                     const CFont *aCustomFont=0);
williamr@4
  1475
williamr@4
  1476
    /** Layouts a label via a layout compiler output
williamr@4
  1477
    @param aLayout   a define from aknlayout.lag file
williamr@4
  1478
     */
williamr@4
  1479
    IMPORT_C static void LayoutLabel(CEikLabel* aLabel,
williamr@4
  1480
                                     const TRect& aLabelParent,
williamr@4
  1481
                                     const TAknMultiLineTextLayout& aLayout,
williamr@4
  1482
                                     const CFont *aCustomFont=0);
williamr@4
  1483
williamr@4
  1484
    /** Layouts a label via a layout compiler output
williamr@4
  1485
    @param aLayout   a define from aknlayout.lag file
williamr@4
  1486
     */
williamr@4
  1487
    IMPORT_C static void LayoutLabel(CEikLabel* aLabel,
williamr@4
  1488
                                     const TRect& aLabelParent,
williamr@4
  1489
                                     const TAknTextLineLayout& aLayout,
williamr@4
  1490
                                     const CFont *aCustomFont=0);
williamr@4
  1491
williamr@4
  1492
    /** Layouts a label via parameters from the specification
williamr@4
  1493
    @param aLayout   a define from aknlayout.lag file
williamr@4
  1494
    @param font      font id, ELatinPlain12, ELatinBold12, ELatinBold13, ELatinBold17, ELatinBold19 etc..
williamr@4
  1495
    @param C         colour index, 0..255
williamr@4
  1496
    @param l         left margin
williamr@4
  1497
    @param r         right margin
williamr@4
  1498
    @param B         Baseline from top of the parent rectangle
williamr@4
  1499
    @param W         text width in pixels
williamr@4
  1500
    @param J         justification. ELayoutAlignNone; ELayoutAlignCenter; ELayoutAlignLeft; ELayoutAlignRight; ELayoutAlignBidi
williamr@4
  1501
    @param NextLineB baseline of 2nd line for multi-line labels/editors
williamr@4
  1502
    @param aCustomFont   a font used, if resource file uses EFontCustom
williamr@4
  1503
     */
williamr@4
  1504
    IMPORT_C static void LayoutLabel(CEikLabel* aLabel,
williamr@4
  1505
                                     const TRect& aLabelParent,
williamr@4
  1506
                                     TInt font, TInt C,
williamr@4
  1507
                                     TInt l, TInt r,
williamr@4
  1508
                                     TInt B, TInt W,
williamr@4
  1509
                                     TInt J, TInt NextLineB=0,
williamr@4
  1510
                                     const CFont* aCustomFont=0);
williamr@4
  1511
williamr@4
  1512
    /**
williamr@4
  1513
    * Deprecated! Do not use!
williamr@4
  1514
    */
williamr@4
  1515
    IMPORT_C static void LayoutEdwin(CEikEdwin* aEdwin,
williamr@4
  1516
                                     const TRect& aEdwinParent,
williamr@4
  1517
                                     TInt aResourceId,
williamr@4
  1518
                                     TInt aNumberOfLines = 0,
williamr@4
  1519
                                     const CFont* aCustomFont=0,
williamr@4
  1520
                                     TBool aMinimizeEdwinView=EFalse);
williamr@4
  1521
    /**
williamr@4
  1522
    * Deprecated! Do not use!
williamr@4
  1523
    */
williamr@4
  1524
    IMPORT_C static void LayoutEdwin(CEikEdwin* aEdwin,
williamr@4
  1525
                                     const TRect& aEdwinParent,
williamr@4
  1526
                                     TResourceReader& aReader,
williamr@4
  1527
                                     TInt aNumberOfLines = 0,
williamr@4
  1528
                                     const CFont* aCustomFont=0,
williamr@4
  1529
                                     TBool aMinimizeEdwinView=EFalse);
williamr@4
  1530
williamr@4
  1531
    /** Layouts an editor via a structure of layout parameters
williamr@4
  1532
    @param aLayout   the structure
williamr@4
  1533
     */
williamr@4
  1534
    IMPORT_C static void LayoutEdwin(CEikEdwin* aEdwin,
williamr@4
  1535
                                     const TRect& aEdwinParent,
williamr@4
  1536
                                     const SAknLayoutEdwin& aLayout,
williamr@4
  1537
                                     const CFont* aCustomFont=0,
williamr@4
  1538
                                     TBool aMinimizeEdwinView=EFalse);
williamr@4
  1539
williamr@4
  1540
    /** Layouts an editor via a structure of layout parameters
williamr@4
  1541
    @param aLayout   the structure
williamr@4
  1542
     */
williamr@4
  1543
williamr@4
  1544
    IMPORT_C static void LayoutEdwin( CEikEdwin* aEdwin,
williamr@4
  1545
                                      const TRect& aEdwinParent,
williamr@4
  1546
                                      const TAknMultiLineTextLayout& aLayout,
williamr@4
  1547
                                      const CFont* aCustomFont=0,
williamr@4
  1548
                                      TBool aMinimizeEdwinView=EFalse);
williamr@4
  1549
williamr@4
  1550
    IMPORT_C static void LayoutEdwin( CEikEdwin* aEdwin,
williamr@4
  1551
                                      const TRect& aEdwinParent,
williamr@4
  1552
                                      const TAknMultiLineTextLayout& aLayout,
williamr@4
  1553
                                      TAknsQsnTextColorsIndex aOverrideColor,
williamr@4
  1554
                                      const CFont* aCustomFont=0,
williamr@4
  1555
                                      TBool aMinimizeEdwinView=EFalse ); 
williamr@4
  1556
        
williamr@4
  1557
williamr@4
  1558
williamr@4
  1559
    IMPORT_C static void LayoutEdwin( CEikEdwin* aEdwin,
williamr@4
  1560
                                      const TRect& aEdwinParent,
williamr@4
  1561
                                      const TAknTextLineLayout& aLayout,
williamr@4
  1562
                                      const CFont* aCustomFont=0,
williamr@4
  1563
                                      TBool aMinimizeEdwinView=EFalse );
williamr@4
  1564
williamr@4
  1565
    IMPORT_C static void LayoutEdwin( CEikEdwin* aEdwin,
williamr@4
  1566
                                      const TRect& aEdwinParent,
williamr@4
  1567
                                      const TAknTextLineLayout& aLayout,
williamr@4
  1568
                                      TAknsQsnTextColorsIndex aOverrideColor,
williamr@4
  1569
                                      const CFont* aCustomFont=0,
williamr@4
  1570
                                      TBool aMinimizeEdwinView=EFalse );
williamr@4
  1571
williamr@4
  1572
    /** 
williamr@4
  1573
    * Routine to perform standard layout of a CEikEdwin editor.  Two elements from the S60 layout data are required: 
williamr@4
  1574
    * The rectangle of the containing layout element, and the TAknTextLineLayout object created for the contained text pane element. 
williamr@4
  1575
    * 
williamr@4
  1576
    * Override parameters can be supplied for a different number of lines, a different baseline separation,
williamr@4
  1577
    * or substituted skin color. Various "Do Not Override" values are to be passed if the values passed in aLayout are to be used. 
williamr@4
  1578
    * Refer to the parameters' documentation.
williamr@4
  1579
    * 
williamr@4
  1580
    * The lower extent of the editor to be laid out (whether driven by the NumberOfLinesToShow() 
williamr@4
  1581
    * feature of the TAknTextLineLayout object, or overridden by aNumberOfLinesToShowOverRide)
williamr@4
  1582
    * will not extend below the lower limit of the rectangle aEdwinParent.  Thus the number of
williamr@4
  1583
    * lines formatted is limited, and is available as an output parameter.
williamr@4
  1584
    * 
williamr@4
  1585
    * The height of the editor is also restricted by any value previously set in 
williamr@4
  1586
    * CEikEdwin::SetMaximumHeightInLines().
williamr@4
  1587
    * 
williamr@4
  1588
    * @since 3.1 
williamr@4
  1589
    * 
williamr@4
  1590
    * @param aEdwin          pointer to the editor to be laid out 
williamr@4
  1591
    * @param aEdwinParent    rectangle of the containing layout element 
williamr@4
  1592
    * @param aLayout         object representing the layout of the text pane implemented by this editor 
williamr@4
  1593
    * @param aNumberOfLinesToShowOverride  number of lines overriding aLayout, if not KAknLayoutUtilsDoNotOverride 
williamr@4
  1594
    * @param aBaselineSeparationOverride   vertical separation of baselines overriding aLayout, if not KAknLayoutUtilsDoNotOverride 
williamr@4
  1595
    * @param aOverrideColor      Avkon Skins color index to override with, if 
williamr@4
  1596
    *                            not (TAknsQsnTextColorsIndex)KAknLayoutUtilsDoNotOverride 
williamr@4
  1597
    * @param aNumberOfVisibleLines  Number of lines of editor actually laid out.
williamr@4
  1598
    */ 
williamr@4
  1599
    IMPORT_C static void LayoutEdwin( CEikEdwin* aEdwin,
williamr@4
  1600
                         const TRect& aEdwinParent,
williamr@4
  1601
                         const TAknTextLineLayout& aLayout,
williamr@4
  1602
                         TInt aNumberOfLinesToShowOverRide,
williamr@4
  1603
                         TInt aBaselineSeparationOverRide,
williamr@4
  1604
                         TAknsQsnTextColorsIndex aOverrideColor, 
williamr@4
  1605
                         TInt& aNumberOfVisibleLines );
williamr@4
  1606
                                 
williamr@4
  1607
    /** Layouts an editor via parameters from the specification
williamr@4
  1608
    @param aLayout   a define from aknlayout.lag file
williamr@4
  1609
    @param font      font id, ELatinPlain12, ELatinBold12, ELatinBold13, ELatinBold17, ELatinBold19 etc..
williamr@4
  1610
    @param C         colour index, 0..255
williamr@4
  1611
    @param l         left margin
williamr@4
  1612
    @param r         right margin
williamr@4
  1613
    @param B         Baseline from top of the parent rectangle
williamr@4
  1614
    @param W         text width in pixels
williamr@4
  1615
    @param J         justification. ELayoutAlignNone; ELayoutAlignCenter; ELayoutAlignLeft; ELayoutAlignRight; ELayoutAlignBidi
williamr@4
  1616
    @param aNumberOfLinesShown number of lines visible for the editor
williamr@4
  1617
    @param NextLineB baseline of 2nd line for multi-line labels/editors
williamr@4
  1618
    @param aMinimizeEdwinView whether to use minimum size. You need to use MinimizedEdwinRect() if you use ETrue here.
williamr@4
  1619
     */
williamr@4
  1620
    IMPORT_C static void LayoutEdwin( CEikEdwin* aEdwin,
williamr@4
  1621
                                      const TRect& aEdwinParent,
williamr@4
  1622
                                      TInt font,
williamr@4
  1623
                                      TInt C,
williamr@4
  1624
                                      TInt l,
williamr@4
  1625
                                      TInt r,
williamr@4
  1626
                                      TInt B,
williamr@4
  1627
                                      TInt W,
williamr@4
  1628
                                      TInt J,
williamr@4
  1629
                                      TInt aNumberOfLinesShown,
williamr@4
  1630
                                      TInt aNextLineBaseline,
williamr@4
  1631
                                      const CFont* aCustomFont=0 ,
williamr@4
  1632
                                      TBool aMinimizeEdwinView=EFalse );
williamr@4
  1633
williamr@4
  1634
    IMPORT_C static void LayoutEdwin( CEikEdwin* aEdwin,
williamr@4
  1635
                                      const TRect& aEdwinParent,
williamr@4
  1636
                                      TInt font,
williamr@4
  1637
                                      TInt C,
williamr@4
  1638
                                      TInt l,
williamr@4
  1639
                                      TInt r,
williamr@4
  1640
                                      TInt B,
williamr@4
  1641
                                      TInt W,
williamr@4
  1642
                                      TInt J,
williamr@4
  1643
                                      TInt aNumberOfLinesShown,
williamr@4
  1644
                                      TInt aNextLineBaseline,
williamr@4
  1645
                                      TAknsQsnTextColorsIndex aOverrideColor,
williamr@4
  1646
                                      const CFont* aCustomFont=0 ,
williamr@4
  1647
                                      TBool aMinimizeEdwinView=EFalse );
williamr@4
  1648
    /** Use this, if you give aMinimizeEdwinView to LayoutEdwin as true.
williamr@4
  1649
     * The edwin will not draw the whole rectangle allocated for the control.
williamr@4
  1650
     */
williamr@4
  1651
    IMPORT_C static TRect MinimizedEdwinRect(const CEikEdwin *aEdwin);
williamr@4
  1652
williamr@4
  1653
williamr@4
  1654
    /**
williamr@4
  1655
    * Deprecated! Do not use!
williamr@4
  1656
    */
williamr@4
  1657
    IMPORT_C static void LayoutMfne(CEikMfne* aMfne,
williamr@4
  1658
                                    const TRect& aMfneParent,
williamr@4
  1659
                                    TInt aResourceId);
williamr@4
  1660
    /**
williamr@4
  1661
    * Deprecated! Do not use!
williamr@4
  1662
    */
williamr@4
  1663
    IMPORT_C static void LayoutMfne(CEikMfne* aMfne,
williamr@4
  1664
                                    const TRect& aMfneParent,
williamr@4
  1665
                                    TResourceReader& aReader);
williamr@4
  1666
williamr@4
  1667
    IMPORT_C static void LayoutMfne(CEikMfne* aMfne,
williamr@4
  1668
                                    const TRect& aMfneParent,
williamr@4
  1669
                                    const SAknLayoutMfne& aLayout);
williamr@4
  1670
williamr@4
  1671
    IMPORT_C static void LayoutMfne(CEikMfne* aMfne,
williamr@4
  1672
                                    const TRect& aMfneParent,
williamr@4
  1673
                                    const TAknTextLineLayout& aLayout);
williamr@4
  1674
williamr@4
  1675
    IMPORT_C static void LayoutMfne(CEikMfne* aMfne,
williamr@4
  1676
                                    const TRect& aMfneParent,
williamr@4
  1677
                                    TInt font, TInt C, TInt l, TInt r,
williamr@4
  1678
                                    TInt B, TInt W, TInt J);
williamr@4
  1679
williamr@4
  1680
    /**
williamr@4
  1681
    * Deprecated! Do not use!
williamr@4
  1682
    */
williamr@4
  1683
    IMPORT_C static void LayoutControl(CCoeControl* aControl, 
williamr@4
  1684
                                       const TRect& aControlParent,
williamr@4
  1685
                                       TInt aResourceId);
williamr@4
  1686
    /**
williamr@4
  1687
    * Deprecated! Do not use!
williamr@4
  1688
    */
williamr@4
  1689
    IMPORT_C static void LayoutControl(CCoeControl* aControl,
williamr@4
  1690
                                       const TRect& aControlParent,
williamr@4
  1691
                                       TResourceReader& aReader);
williamr@4
  1692
williamr@4
  1693
    IMPORT_C static void LayoutControl(CCoeControl* aControl,
williamr@4
  1694
                                       const TRect& aControlParent,
williamr@4
  1695
                                       const SAknLayoutControl& aLayout);
williamr@4
  1696
williamr@4
  1697
    IMPORT_C static void LayoutControl(CCoeControl* aControl, 
williamr@4
  1698
                                       const TRect& aControlParent,
williamr@4
  1699
                                       const TAknWindowLineLayout& aLayout);
williamr@4
  1700
williamr@4
  1701
    IMPORT_C static void LayoutControl(CCoeControl* aControl,
williamr@4
  1702
                                       const TRect& aControlParent,
williamr@4
  1703
                                       TInt /*C*/, TInt l, TInt t, TInt r, TInt b,
williamr@4
  1704
                                       TInt W, TInt H);
williamr@4
  1705
williamr@4
  1706
    /**
williamr@4
  1707
    * Deprecated! Do not use!
williamr@4
  1708
    */
williamr@4
  1709
    IMPORT_C static void LayoutImage(CEikImage* aImage,
williamr@4
  1710
                                     const TRect& aParent,
williamr@4
  1711
                                     TInt aResourceId);
williamr@4
  1712
    /**
williamr@4
  1713
    * Deprecated! Do not use!
williamr@4
  1714
    */    
williamr@4
  1715
    IMPORT_C static void LayoutImage(CEikImage* aImage, 
williamr@4
  1716
                                     const TRect& aParent,
williamr@4
  1717
                                     TResourceReader& aReader);
williamr@4
  1718
williamr@4
  1719
    IMPORT_C static void LayoutImage(CEikImage* aImage, 
williamr@4
  1720
                                     const TRect& aParent,
williamr@4
  1721
                                     const SAknLayoutControl& aLayout);
williamr@4
  1722
williamr@4
  1723
    IMPORT_C static void LayoutImage(CEikImage* aImage,
williamr@4
  1724
                                     const TRect& aParent,
williamr@4
  1725
                                     const TAknWindowLineLayout& aLayout);
williamr@4
  1726
williamr@4
  1727
    IMPORT_C static void LayoutImage(CEikImage* aImage,
williamr@4
  1728
                                     const TRect& aParent,
williamr@4
  1729
                                     TInt C, TInt l, TInt t, TInt r, TInt b,
williamr@4
  1730
                                     TInt W, TInt H);
williamr@4
  1731
williamr@4
  1732
    /** Sets CEikSecretEditor's position, colors and fonts based on LAF specification
williamr@4
  1733
     *
williamr@4
  1734
     */
williamr@4
  1735
    IMPORT_C static void LayoutSecretEditor(CEikSecretEditor* aSecEd,
williamr@4
  1736
                                            const TRect& aParent,
williamr@4
  1737
                                            const SAknLayoutText& aLayout);
williamr@4
  1738
williamr@4
  1739
    IMPORT_C static void LayoutSecretEditor(CEikSecretEditor* aSecEd,
williamr@4
  1740
                                            const TRect& aParent,
williamr@4
  1741
                                            const TAknTextLineLayout& aLayout);
williamr@4
  1742
williamr@4
  1743
public:
williamr@4
  1744
    /** Different conversions
williamr@4
  1745
     * Fonts: ELatinPlain12, ELatinBold12, ELatinBold13, ELatinBold17, ELatinBold19, ENumberPlain5, EClockBold30, ELatinClock14, EFontCustom
williamr@4
  1746
     *        EAknLogicalFontPrimaryFont, EAknLogicalFontSecondaryFont, EAknLogicalFontTitleFont,
williamr@4
  1747
     * Alignments: ELayoutAlignNone, ELayoutAlignCenter, ELayoutAlignLeft, ELayoutAlignRight, ELayoutAlignBidi with these..
williamr@4
  1748
     */
williamr@4
  1749
    IMPORT_C static TRect TextRectFromCoords(const TRect& aParent,
williamr@4
  1750
                                             const CFont* aFont,
williamr@4
  1751
                                             TInt l, TInt r,
williamr@4
  1752
                                             TInt B, TInt W,
williamr@4
  1753
                                             TInt LB = 0);
williamr@4
  1754
williamr@4
  1755
    IMPORT_C static TRect RectFromCoords(const TRect& aParent,
williamr@4
  1756
                                         TInt l, TInt t, TInt r, TInt b,
williamr@4
  1757
                                         TInt W, TInt H);
williamr@4
  1758
williamr@4
  1759
    /**
williamr@4
  1760
    * Method to return a useable system font reference from a S60 font enumeration from among
williamr@4
  1761
    * the supported list.
williamr@4
  1762
    * 
williamr@4
  1763
    * This method should only be used if application code needs to render its own graphics. That is, it
williamr@4
  1764
    * is not using S60 controls and furthermore not using the recommended methods 
williamr@4
  1765
    * AknLayoutUtils::LayoutEdwin(), AknLayoutUtils::LayoutLabel() or AknLayoutUtils::LayoutSecretEditor(). 
williamr@4
  1766
    * 
williamr@4
  1767
    * Fonts returned by this are not recommended to be stored in clients' member data, but should be
williamr@4
  1768
    * accessed when they are required for use.
williamr@4
  1769
    *
williamr@4
  1770
    * Applications that are written to run with their layout dynamically adapting to different screen sizes 
williamr@4
  1771
    * should use only the values found in the S60 logical font enumeration, TAknLogicalFontId.
williamr@4
  1772
    * 
williamr@4
  1773
    * @param aFontId        Input S60 font id.
williamr@4
  1774
    * @param aCustomFont    Font to return if aFontId is given as EFontCustom
williamr@4
  1775
    * @return               const pointer to a system font, or aCustomFont
williamr@4
  1776
    */
williamr@4
  1777
    IMPORT_C static const CFont* FontFromId(TInt aFontId, const CFont* aCustomFont=0);
williamr@4
  1778
williamr@4
  1779
    /**
williamr@4
  1780
    * Method to return a system font reference from a S60 font id. This will always conform to type CAknLayoutFont
williamr@4
  1781
    * 
williamr@4
  1782
    * This method should only be used if application code needs to render its own graphics. That is, it
williamr@4
  1783
    * is not using S60 controls and furthermore not using the recommended methods 
williamr@4
  1784
    * AknLayoutUtils::LayoutEdwin(), AknLayoutUtils::LayoutLabel() or AknLayoutUtils::LayoutSecretEditor(). 
williamr@4
  1785
    * 
williamr@4
  1786
    * Fonts returned by this are not recommended to be stored in clients' member data, but should be
williamr@4
  1787
    * accessed when they are required for use.
williamr@4
  1788
    *
williamr@4
  1789
    * Applications that are written to run with their layout dynamically adapting to different screen sizes 
williamr@4
  1790
    * should use only the values found in the S60 logical font enumeration, TAknLogicalFontId.
williamr@4
  1791
    * 
williamr@4
  1792
    * @param aFontId        Input S60 font id.
williamr@4
  1793
    * @param aCustomFont    Font to return if aFontId is given as EFontCustom
williamr@4
  1794
    * @return               const pointer to a system font, or aCustomFont
williamr@4
  1795
    */
williamr@4
  1796
    IMPORT_C static const CAknLayoutFont* LayoutFontFromId(TInt aId, 
williamr@4
  1797
                                                           const CAknLayoutFont *aCustomFont = 0);
williamr@4
  1798
williamr@4
  1799
    /**
williamr@4
  1800
    * Return a fully constructed CAknLayoutFont object based upon the specification passed in.
williamr@4
  1801
    * The Avkon font specifiation object uses TAknFontCategory to determine the font. 
williamr@4
  1802
    *
williamr@4
  1803
    * The font object is returned as non-const, since it is owned and will eventually be deleted by the client.
williamr@4
  1804
    * 
williamr@4
  1805
    * @param aSpec     S60 font specification object
williamr@4
  1806
    * @return               pointer to a CAknLayoutFont object, owned by the caller
williamr@4
  1807
    */
williamr@4
  1808
    IMPORT_C static CAknLayoutFont* CreateLayoutFontFromSpecificationL( 
williamr@4
  1809
        const TAknFontSpecification& aSpec );
williamr@4
  1810
williamr@4
  1811
    /**
williamr@4
  1812
    * Return a fully constructed CAknLayoutFont object based upon the typeface and specification passed in.
williamr@4
  1813
    * The TTypeface object contains a typeface name that is used as the primary key to select a font.  
williamr@4
  1814
    * The S60  font specifiation object is also used, but any value of TAknFontCategory passed in is reset to 
williamr@4
  1815
    * EAknFontCategoryUndefined, and is not used to select the font. 
williamr@4
  1816
    *
williamr@4
  1817
    * The font object is returned as non-const, since it is owned and will eventually be deleted by the client.
williamr@4
  1818
    * 
williamr@4
  1819
    * @param aTypeface      Symbian Typface object
williamr@4
  1820
    * @param aSpec             S60 font specification object
williamr@4
  1821
    * @return                       pointer to a CAknLayoutFont object, owned by the caller
williamr@4
  1822
    */
williamr@4
  1823
    IMPORT_C static CAknLayoutFont* CreateLayoutFontFromSpecificationL( 
williamr@4
  1824
        const TTypeface& aTypeface, 
williamr@4
  1825
        const TAknFontSpecification& aSpec);
williamr@4
  1826
williamr@4
  1827
    /**
williamr@4
  1828
    * Deprecated! Do not use!
williamr@4
  1829
    */
williamr@4
  1830
    IMPORT_C static const CFont* FontFromName(const TDesC& aName); 
williamr@4
  1831
williamr@4
  1832
    IMPORT_C static CGraphicsContext::TTextAlign TextAlignFromId(TInt aId);
williamr@4
  1833
williamr@4
  1834
    IMPORT_C static TGulAlignment GulAlignFromId(TInt aId);
williamr@4
  1835
williamr@4
  1836
    IMPORT_C static TInt CursorHeightFromFont(const TFontSpec& aFont);
williamr@4
  1837
williamr@4
  1838
    IMPORT_C static TInt CursorWidthFromFont (const TFontSpec& aFont);
williamr@4
  1839
williamr@4
  1840
    IMPORT_C static TInt CursorAscentFromFont(const TFontSpec& aFont);
williamr@4
  1841
williamr@4
  1842
    IMPORT_C static void CursorExtensionsFromFont(const TFontSpec& /*aFont*/,
williamr@4
  1843
                                                  TInt& aFirstExtension,
williamr@4
  1844
                                                  TInt& aSecondExtension);
williamr@4
  1845
williamr@4
  1846
    IMPORT_C static TInt HighlightLeftPixelsFromFont (const TFontSpec& aFont);
williamr@4
  1847
williamr@4
  1848
    IMPORT_C static TInt HighlightRightPixelsFromFont(const TFontSpec& aFont);
williamr@4
  1849
    static void HighlightExtensionsFromFont(const TInt fontid,
williamr@4
  1850
                                            TInt& aLeft, TInt& aRight,
williamr@4
  1851
                                            TInt&  aTop, TInt& aBottom);
williamr@4
  1852
williamr@4
  1853
    /**
williamr@4
  1854
    * Access the system font array to see if there is a font that matches the  
williamr@4
  1855
    * font specification presented in Twips. Device map is also passed in case the 
williamr@4
  1856
    * system font array has fonts from different devices.
williamr@4
  1857
    * 
williamr@4
  1858
    * A null return value means that the system font array is not constructed yet, or does
williamr@4
  1859
    * not contain a font that has the same TFontSpec or device map.
williamr@4
  1860
    *
williamr@4
  1861
    * @param aSpec  Symbian font specification object to match
williamr@4
  1862
    * @param aMap   Device map to disambiguate fonts on different devices
williamr@4
  1863
    * @return       NULL if no match was found; otherwise a CAknLayoutFont pointer
williamr@4
  1864
    **/
williamr@4
  1865
    static const CAknLayoutFont* MatchFontFromSystemFontArray( 
williamr@4
  1866
        const TFontSpec& aSpec, MGraphicsDeviceMap* aMap );
williamr@4
  1867
williamr@4
  1868
    IMPORT_C static TBool LayoutMirrored();
williamr@4
  1869
williamr@4
  1870
    /*
williamr@4
  1871
    * This method returns build variant based on which flag is active,
williamr@4
  1872
    * __AVKON_ELAF__ or __AVKON_APAC__.
williamr@4
  1873
    *
williamr@4
  1874
    * If you need to decide which layout to use, do not do it based on this method.
williamr@4
  1875
    * Instead, use CAknEnv::GetCurrentLayoutId().
williamr@4
  1876
    *
williamr@4
  1877
    * @return current variant
williamr@4
  1878
    */
williamr@4
  1879
    IMPORT_C static EVariantFlag Variant();
williamr@4
  1880
williamr@4
  1881
    IMPORT_C static ESubVariantFlag SubVariant();
williamr@4
  1882
williamr@4
  1883
    IMPORT_C static void OverrideControlColorL(
williamr@4
  1884
        CCoeControl& aControl,
williamr@4
  1885
        TLogicalColor aLogicalColor,
williamr@4
  1886
        TRgb aColor);
williamr@4
  1887
    
williamr@4
  1888
    /*
williamr@4
  1889
    * This method returns the default scrollbar type for the given application. 
williamr@4
  1890
    * For non-layout aware applications (e.g. legacy apps designed for 176x208 screen) 
williamr@4
  1891
    * this method returns always EArrowHead. But for layout aware apps the returned type 
williamr@4
  1892
    * may vary depending on the type of scrollbar which has been set as preferred 
williamr@4
  1893
    * scrollbar type in the device.
williamr@4
  1894
    *
williamr@4
  1895
    * Note that applications may use freely whatever scrollbartype, this method only 
williamr@4
  1896
    * returns the default scrollbartype for the application.
williamr@4
  1897
    * 
williamr@4
  1898
    * @since  2.6
williamr@4
  1899
    * @param  aApplication Application of which default scrollbar type is requested.
williamr@4
  1900
    * @return Default scrollbar type for the given application
williamr@4
  1901
    */
williamr@4
  1902
    IMPORT_C static CEikScrollBarFrame::TScrollBarType DefaultScrollBarType(CAknAppUiBase* aApplication);
williamr@4
  1903
williamr@4
  1904
    /*
williamr@4
  1905
    * This method sets the layout for vertical scrollbar of the given scrollbar frame. Layout
williamr@4
  1906
    * can freely only be set for EDoubleSpan type scrollbars.
williamr@4
  1907
    * 
williamr@4
  1908
    * @since  2.6
williamr@4
  1909
    * @param  aScrollBarFrame   Scrollbarframe of which vertical scrollbar layout will be set.
williamr@4
  1910
    * @param  aControlParent    Rect of the parent control of the scrollbarframe.
williamr@4
  1911
    * @param  aLayout           Layout for the vertical scrollbar.
williamr@4
  1912
    *
williamr@4
  1913
    *
williamr@4
  1914
    * This method can also be useful when layout of the scrollbar needs to be changed for scrollbars
williamr@4
  1915
    * which are owned by some other components such as e.g. ListBoxes, Editors or Grids.
williamr@4
  1916
    *
williamr@4
  1917
    * Example of use:
williamr@4
  1918
    *
williamr@4
  1919
    *  // Get a pointer to scrollbarframe of the listbox
williamr@4
  1920
    *  CEikScrollBarFrame* frame = iListBox->ScrollBar();
williamr@4
  1921
    *  
williamr@4
  1922
    *  // Get the layout data
williamr@4
  1923
    *  TAknWindowLineLayout layout = GetMyListBoxLayout();
williamr@4
  1924
    *  Trect parentRect = GetMyListBoxParentRect();
williamr@4
  1925
    *
williamr@4
  1926
    *  // Set the layout
williamr@4
  1927
    *  AknLayoutUtils::LayoutVerticalScrollBar(frame, parentRect, layout);
williamr@4
  1928
    *
williamr@4
  1929
    *  // The layout for scrollbar is now set.
williamr@4
  1930
    *
williamr@4
  1931
    */
williamr@4
  1932
    IMPORT_C static void LayoutVerticalScrollBar(
williamr@4
  1933
        CEikScrollBarFrame* aScrollBarFrame,
williamr@4
  1934
        const TRect& aControlParent,
williamr@4
  1935
        const TAknWindowLineLayout& aLayout);
williamr@4
  1936
williamr@4
  1937
    /*
williamr@4
  1938
    * This method sets the layout for horizontal scrollbar of the given scrollbar frame. Layout
williamr@4
  1939
    * can freely only be set for EDoubleSpan type scrollbars.
williamr@4
  1940
    * 
williamr@4
  1941
    * @since  2.6
williamr@4
  1942
    * @param  aScrollBarFrame   Scrollbarframe of which horizontal scrollbar layout will be set.
williamr@4
  1943
    * @param  aControlParent    Rect of the parent control of the scrollbarframe.
williamr@4
  1944
    * @param  aLayout           Layout for the horizontal scrollbar.
williamr@4
  1945
    *
williamr@4
  1946
    *
williamr@4
  1947
    * Usage of this method is similar as for LayoutVerticalScrollBar().
williamr@4
  1948
    *
williamr@4
  1949
    */
williamr@4
  1950
    IMPORT_C static void LayoutHorizontalScrollBar(
williamr@4
  1951
        CEikScrollBarFrame* aScrollBarFrame,
williamr@4
  1952
        const TRect& aControlParent,
williamr@4
  1953
        const TAknWindowLineLayout& aLayout);
williamr@4
  1954
williamr@4
  1955
public:   // Metrics API
williamr@4
  1956
williamr@4
  1957
    /**
williamr@4
  1958
    * Layout Metrics.
williamr@4
  1959
    */
williamr@4
  1960
    enum TAknLayoutMetrics
williamr@4
  1961
    {
williamr@4
  1962
        /** Screen. */
williamr@4
  1963
        EScreen,
williamr@4
  1964
        
williamr@4
  1965
        /** Window that fills the entire screen. */
williamr@4
  1966
        EApplicationWindow,
williamr@4
  1967
        
williamr@4
  1968
        /** Indicates common components for most of the applications. */
williamr@4
  1969
        EStatusPane,
williamr@4
  1970
        
williamr@4
  1971
        /** The application main pane is used in all the applications */
williamr@4
  1972
        EMainPane,
williamr@4
  1973
        
williamr@4
  1974
        /** Control pane. */
williamr@4
  1975
        EControlPane,   
williamr@4
  1976
        
williamr@4
  1977
        /** The signal pane is used to indicate signal strength. */
williamr@4
  1978
        ESignalPane,
williamr@4
  1979
        
williamr@4
  1980
        /** The context pane is used to indicate an active application. */
williamr@4
  1981
        EContextPane,
williamr@4
  1982
        
williamr@4
  1983
        /** Used to indicate the subject or the name of the main pane content.*/
williamr@4
  1984
        ETitlePane,
williamr@4
  1985
        
williamr@4
  1986
        /** The battery pane is used to indicate battery strength. */
williamr@4
  1987
        EBatteryPane,
williamr@4
  1988
        
williamr@4
  1989
        /** 
williamr@4
  1990
         * The universal indicator pane is used to indicate items that require
williamr@4
  1991
         * the user's attention while browsing applications.
williamr@4
  1992
         */
williamr@4
  1993
        EUniversalIndicatorPane,
williamr@4
  1994
        
williamr@4
  1995
        /** 
williamr@4
  1996
         * The navi pane is used to indicate navigation within an application,
williamr@4
  1997
         * to provide context sensitive information to the user while entering
williamr@4
  1998
         * or editing data, or to show additional information.
williamr@4
  1999
         */
williamr@4
  2000
        ENaviPane,
williamr@4
  2001
        
williamr@4
  2002
        /** 
williamr@4
  2003
         * A fixed find pane is used with lists instead of the find pop-up
williamr@4
  2004
         * window. */
williamr@4
  2005
        EFindPane,
williamr@4
  2006
        
williamr@4
  2007
        /** Wallpaper pane. */
williamr@4
  2008
        EWallpaperPane,
williamr@4
  2009
        
williamr@4
  2010
        /** 
williamr@4
  2011
         * The universal indicator pane is used to indicate items that require
williamr@4
  2012
         * the user's attention while browsing applications.
williamr@4
  2013
         */
williamr@4
  2014
        EIndicatorPane,
williamr@4
  2015
        
williamr@4
  2016
        /** Used generally to display small sized graphics or heading texts. */
williamr@4
  2017
        EAColunm,
williamr@4
  2018
        
williamr@4
  2019
        /** Used generally to display large sized icons or heading texts. */
williamr@4
  2020
        EBColunm,
williamr@4
  2021
        
williamr@4
  2022
        /** 
williamr@4
  2023
         * Used generally to display data entered by the user. Overlaps with
williamr@4
  2024
         * the D column.
williamr@4
  2025
         */
williamr@4
  2026
        ECColunm,
williamr@4
  2027
        
williamr@4
  2028
        /** 
williamr@4
  2029
         * Used generally to display additional icons. Overlaps with
williamr@4
  2030
         * the C column.
williamr@4
  2031
         */
williamr@4
  2032
        EDColunm,
williamr@4
  2033
        
williamr@4
  2034
        /** @deprecated, do not use */
williamr@4
  2035
        EStatusPaneSecondary,
williamr@4
  2036
        
williamr@4
  2037
        /** deprecated, do not use */
williamr@4
  2038
        EControlPaneSecondary,
williamr@4
  2039
        
williamr@4
  2040
        /** Top part of status and control panes in landscape layout. */
williamr@4
  2041
        EStaconTop,
williamr@4
  2042
        
williamr@4
  2043
        /** Bottom part of status and control panes in landscape layout. */
williamr@4
  2044
        EStaconBottom,
williamr@4
  2045
williamr@4
  2046
        /** */
williamr@4
  2047
        EPopupParent,
williamr@4
  2048
        
williamr@4
  2049
        /** Bottom part of status pane in landscape layout. */
williamr@4
  2050
        EStatusPaneBottom = EStatusPaneSecondary,
williamr@4
  2051
        
williamr@4
  2052
        /** Bottom part of control pane in landscape layout. */
williamr@4
  2053
        EControlPaneBottom = EControlPaneSecondary,
williamr@4
  2054
        
williamr@4
  2055
        /** Top part of control pane in landscape layout. */
williamr@4
  2056
        EControlPaneTop = EControlPane,
williamr@4
  2057
        
williamr@4
  2058
        /** Top part of status pane in landscape layout. */
williamr@4
  2059
        EStatusPaneTop = EStatusPane
williamr@4
  2060
    };
williamr@4
  2061
williamr@4
  2062
williamr@4
  2063
    /**
williamr@4
  2064
    * Fills given TRect with rectangle for given layout component. 
williamr@4
  2065
    * Returns EFalse for status pane descendants if requested
williamr@4
  2066
    * layout component is not available in current layout. For
williamr@4
  2067
    * other components returns always ETrue (returned rectangle is
williamr@4
  2068
    * from layout definition).
williamr@4
  2069
    *
williamr@4
  2070
    * @since  2.8
williamr@4
  2071
    * @param  aParam   Layout component to be queried. 
williamr@4
  2072
    * @param  aRect    Resulting rectangle.
williamr@4
  2073
    * @param  ETrue    If requested value was available.
williamr@4
  2074
    *         EFalse   Otherwise.
williamr@4
  2075
    */
williamr@4
  2076
    IMPORT_C static TBool LayoutMetricsRect(TAknLayoutMetrics aParam, TRect& aRect);
williamr@4
  2077
williamr@4
  2078
    /**
williamr@4
  2079
    * This method returns size of rectangle for given layout component.
williamr@4
  2080
    * Returns EFalse for status pane descendants if requested
williamr@4
  2081
    * layout component is not available in current layout. For
williamr@4
  2082
    * other components returns always ETrue (returned size is
williamr@4
  2083
    * from layout definition).
williamr@4
  2084
    *
williamr@4
  2085
    * @since  2.8
williamr@4
  2086
    * @param  aParam   Layout component to be queried. 
williamr@4
  2087
    * @param  aSize    Resulting size.
williamr@4
  2088
    * @param  ETrue    If requested value was available.
williamr@4
  2089
    *         EFalse   Otherwise.
williamr@4
  2090
    */
williamr@4
  2091
    IMPORT_C static TBool LayoutMetricsSize(TAknLayoutMetrics aParam, TSize& aSize);
williamr@4
  2092
williamr@4
  2093
    /**
williamr@4
  2094
    * This method returns position of top left corner for given layout component.
williamr@4
  2095
    * Returns EFalse for status pane descendants if requested
williamr@4
  2096
    * layout component is not available in current layout. For
williamr@4
  2097
    * other components returns always ETrue (returned position is
williamr@4
  2098
    * from layout definition).
williamr@4
  2099
    *
williamr@4
  2100
    * @since  2.8
williamr@4
  2101
    * @param  aParam   Layout component to be queried. 
williamr@4
  2102
    * @param  aPos     Resulting position.
williamr@4
  2103
    * @param  ETrue    If requested value was available.
williamr@4
  2104
    *         EFalse   Otherwise.
williamr@4
  2105
    */
williamr@4
  2106
    IMPORT_C static TBool LayoutMetricsPosition(TAknLayoutMetrics aParan, TPoint& aPos);
williamr@4
  2107
public:
williamr@4
  2108
    /**
williamr@4
  2109
    * This method returns a new value for a baseline, based upon a value for bottom and 
williamr@4
  2110
    * a value for height. For legacy layout data, the baseline will be correct, and this
williamr@4
  2111
    * method will detect that it is a legacy font id and just return aBottom. 
williamr@4
  2112
    * However, for scalable layout data, the bottom value will be hidden inside 
williamr@4
  2113
    * the old baseline variable, so call this method passing in 'iB', NOT passing in 'ib'
williamr@4
  2114
    * ... e.g.: (the following line is an example, so is ok to have commented out code)
williamr@4
  2115
    * TInt newbaseline = CorrectBaseline(myLayoutLine.iB, myLayoutLine.iFont);
williamr@4
  2116
    *
williamr@4
  2117
    * @since  2.8
williamr@4
  2118
    * @param  aBottom  Baseline or Bottom value of text pane (found in TAknTextLineLayout.iB)
williamr@4
  2119
    * @param  aFontId     FontId of text pane (for scalable layouts, this will encode the height)
williamr@4
  2120
    * @return   new Baseline value
williamr@4
  2121
    */
williamr@4
  2122
    static TInt CorrectBaseline(TInt aParentHeight, TInt aBaseline, TInt aFontId);
williamr@4
  2123
williamr@4
  2124
    /**
williamr@4
  2125
    * This method updates fontid if it has ELayoutEmpty or parent relative values
williamr@4
  2126
    */
williamr@4
  2127
    static void CorrectFontId(TRect aParent, TInt at, TInt aH, TInt ab, TInt &aFontId);
williamr@4
  2128
williamr@4
  2129
    /**
williamr@4
  2130
    * This method tells if the scalable layout interface is available.
williamr@4
  2131
    * 
williamr@4
  2132
    * @internal
williamr@4
  2133
    * @return ETrue if scalable layout interface can be used, otherwise EFalse.
williamr@4
  2134
    */
williamr@4
  2135
    IMPORT_C static TBool ScalableLayoutInterfaceAvailable();
williamr@4
  2136
    
williamr@4
  2137
    /*
williamr@4
  2138
    * Enumeration of CBA's possible locations.
williamr@4
  2139
    * @since 3.0
williamr@4
  2140
    */
williamr@4
  2141
    enum TAknCbaLocation
williamr@4
  2142
        {
williamr@4
  2143
        EAknCbaLocationBottom, //landscape and portrait
williamr@4
  2144
        EAknCbaLocationRight,  //only landscape
williamr@4
  2145
        EAknCbaLocationLeft    //only landscape
williamr@4
  2146
        };
williamr@4
  2147
    
williamr@4
  2148
    /**
williamr@4
  2149
    * This method tells location of softkeys (CBA) field in current running application. 
williamr@4
  2150
    * Possible location of softkeys are bottom (portrait and landscape), left and right 
williamr@4
  2151
    * (only landscape).
williamr@4
  2152
    *
williamr@4
  2153
    * @since 3.0
williamr@4
  2154
    * @return TAknCbaLocation
williamr@4
  2155
    */
williamr@4
  2156
    IMPORT_C static TAknCbaLocation CbaLocation();
williamr@4
  2157
williamr@4
  2158
    /**
williamr@4
  2159
    * Used by pop-ups to align themselves around the given highlighted area.
williamr@4
  2160
    * @param aHighlightRect Highlighted area.
williamr@4
  2161
    * @param aControl Control whose position should be calculated,
williamr@4
  2162
    * @return TRect Size and position of pop-up.
williamr@4
  2163
    */
williamr@4
  2164
    static TRect HighlightBasedRect( const TRect& aHighlightRect, CCoeControl* aControl );
williamr@4
  2165
williamr@4
  2166
    /**
williamr@4
  2167
     * Flags for main_pane status
williamr@4
  2168
     */
williamr@4
  2169
    enum TAknMainPaneState 
williamr@4
  2170
        {
williamr@4
  2171
        EAknMainPaneForTinyStatusPane = 0x0001  // for 3x4 grid or app shell list views
williamr@4
  2172
        };
williamr@4
  2173
    IMPORT_C static TAknMainPaneState MainPaneState();
williamr@4
  2174
williamr@4
  2175
    /**
williamr@4
  2176
    * This method can be used to check whether pen support is enabled.
williamr@4
  2177
    * @return ETrue if pen support is enabled, otherwise EFalse.
williamr@4
  2178
    */
williamr@4
  2179
    IMPORT_C static TBool PenEnabled();
williamr@4
  2180
    
williamr@4
  2181
    /**
williamr@4
  2182
    * This method can be used to check whether MSK support is enabled.
williamr@4
  2183
    * @return ETrue if MSK support is enabled, otherwise EFalse.
williamr@4
  2184
    */
williamr@4
  2185
    IMPORT_C static TBool MSKEnabled();
williamr@4
  2186
williamr@4
  2187
    /**
williamr@4
  2188
    * Utility method to be used along side LayoutEdwin methods that take number of lines or 
williamr@4
  2189
    * baseline separation overrides. 
williamr@4
  2190
    * 
williamr@4
  2191
    * This routine returns the edwin height in pixels required to fit exactly the passed-in layout,
williamr@4
  2192
    * or the layout with overridden baseline separation and/or number of lines.
williamr@4
  2193
    * 
williamr@4
  2194
    * The vertical position of the editor is also returned. Note that the correct
williamr@4
  2195
    * height of the parent layout item is needed in order for this to be calculated properly.
williamr@4
  2196
    *
williamr@4
  2197
    * Note that this API does not cause a layout of the editor.
williamr@4
  2198
    * 
williamr@4
  2199
    * @since 3.1
williamr@4
  2200
    *
williamr@4
  2201
    * @param aParentHeight  Height of the parent layout item
williamr@4
  2202
    * @param aLayout        S60 layout object for the text to be laid out in the editor
williamr@4
  2203
    * @param aBaselineSeparationOverride   vertical separation of baselines overriding aLayout, if not KAknLayoutUtilsDoNotOverride 
williamr@4
  2204
    *                                       aLayout, if not KAknLayoutUtilsDoNotOverride 
williamr@4
  2205
    * @param aNumberOfLinesToShowOverride   number of lines overriding aLayout, 
williamr@4
  2206
    *                                       if not KAknLayoutUtilsDoNotOverride 
williamr@4
  2207
    * @param aEdwinVerticalPositionRelativeToParent     Returns the vertical postion of the editor 
williamr@4
  2208
    *                                                   relative to its parent when laid out.
williamr@4
  2209
    * @param aEdwinHeight   The height required in pixels to fit the required number of laid 
williamr@4
  2210
    *                       out lines plus highlights.
williamr@4
  2211
    */
williamr@4
  2212
    IMPORT_C static void GetEdwinVerticalPositionAndHeightFromLines(
williamr@4
  2213
        TInt aParentHeight,
williamr@4
  2214
        const TAknTextLineLayout& aLayout,
williamr@4
  2215
        TInt aBaselineSeparationOverRide,
williamr@4
  2216
        TInt aNumberOfLinesToShowOverRide,
williamr@4
  2217
        TInt& aEdwinVerticalPositionRelativeToParent,
williamr@4
  2218
        TInt& aEdwinHeight
williamr@4
  2219
        );
williamr@4
  2220
       
williamr@4
  2221
    /**
williamr@4
  2222
    * Utility routine to give the number of text lines that will completely fit, 
williamr@4
  2223
    * including room for highlights, within the given height, when the passed in layout is
williamr@4
  2224
    * being used. 
williamr@4
  2225
    *
williamr@4
  2226
    * Note that the NumberOfLinesShown() value from the TAknTextLineLayout object is not taken into
williamr@4
  2227
    * consideration. This routine ignores it, and returns number of lines based upon the font metrics,
williamr@4
  2228
    * hightlight specification, and the passed in maximum height.
williamr@4
  2229
    * 
williamr@4
  2230
    * Note that this API does not cause a layout of the editor.
williamr@4
  2231
    *
williamr@4
  2232
    * @since 3.1
williamr@4
  2233
    *
williamr@4
  2234
    * @param aLayout    S60 layout object for the text to be laid out in the editor    
williamr@4
  2235
    * @param aBaselineSeparationOverride   vertical separation of baselines 
williamr@4
  2236
    *       overriding aLayout, if not KAknLayoutUtilsDoNotOverride 
williamr@4
  2237
    * @param aMaxHeight     Input maximum height to use for the editor.
williamr@4
  2238
    * @param aUsedHeight    Returns the number of pixels required for the lines that fit
williamr@4
  2239
    * @return The number of lines which completely fit
williamr@4
  2240
    */
williamr@4
  2241
    IMPORT_C static TInt EdwinLinesWithinHeight (
williamr@4
  2242
        const TAknTextLineLayout& aLayout,
williamr@4
  2243
        TInt aBaselineSeparationOverride,
williamr@4
  2244
        TInt aMaxHeight,
williamr@4
  2245
        TInt& aUsedHeight
williamr@4
  2246
        );
williamr@4
  2247
};
williamr@4
  2248
williamr@4
  2249
/** Low level drawing based on European LAF document (can be used by application's custom controls)
williamr@4
  2250
 *
williamr@4
  2251
 * This class reads AVKON_LAYOUT_TEXT resources
williamr@4
  2252
 */
williamr@4
  2253
class TAknLayoutText
williamr@4
  2254
    {
williamr@4
  2255
public:
williamr@4
  2256
    IMPORT_C TAknLayoutText();
williamr@4
  2257
    /** Read resources and calculate information needed to draw text.
williamr@4
  2258
     *
williamr@4
  2259
     * LayoutText() call should be placed to control's SizeChanged() method.
williamr@4
  2260
     */
williamr@4
  2261
    IMPORT_C void LayoutText(const TRect& aParent, TInt aResourceId,
williamr@4
  2262
                             const CFont* aCustomFont=0);
williamr@4
  2263
williamr@4
  2264
    IMPORT_C void LayoutText(const TRect& aParent, TResourceReader& aReader,
williamr@4
  2265
                             const CFont* aCustomFont=0);
williamr@4
  2266
williamr@4
  2267
    IMPORT_C void LayoutText(const TRect& aParent, 
williamr@4
  2268
                             const AknLayoutUtils::SAknLayoutText& aLayout,
williamr@4
  2269
                             const CFont* aCustomFont=0);
williamr@4
  2270
williamr@4
  2271
    IMPORT_C void LayoutText(const TRect& aParent,
williamr@4
  2272
                             const TAknTextLineLayout& aLayout,
williamr@4
  2273
                             const CFont* aCustomFont=0);
williamr@4
  2274
williamr@4
  2275
    IMPORT_C void LayoutText(const TRect& aParent, TInt fontid, 
williamr@4
  2276
                             TInt C, TInt l, TInt r, TInt B, TInt W, TInt J,
williamr@4
  2277
                             const CFont* aCustomFont=0);
williamr@4
  2278
williamr@4
  2279
    /** Do the actual drawing, should be placed to control's Draw() method.
williamr@4
  2280
     */
williamr@4
  2281
    IMPORT_C void DrawText(CGraphicsContext& aGc, const TDesC& aText) const;
williamr@4
  2282
    
williamr@4
  2283
    /**
williamr@4
  2284
    * In case of bidirectional text, which is already converted from logical to
williamr@4
  2285
    * visual order, use this method with parameter 
williamr@4
  2286
    * aUseLogicalToVisualConversion EFalse.
williamr@4
  2287
    */
williamr@4
  2288
    IMPORT_C void DrawText(
williamr@4
  2289
        CGraphicsContext& aGc,
williamr@4
  2290
        const TDesC& aText,
williamr@4
  2291
        TBool aUseLogicalToVisualConversion ) const;
williamr@4
  2292
williamr@4
  2293
    IMPORT_C void DrawText(
williamr@4
  2294
        CGraphicsContext& aGc,
williamr@4
  2295
        const TDesC& aText,
williamr@4
  2296
        TBool aUseLogicalToVisualConversion,
williamr@4
  2297
        const TRgb &aColor) const;
williamr@4
  2298
                           
williamr@4
  2299
williamr@4
  2300
public:
williamr@4
  2301
    /** This returns rectangle that is used to draw the text.
williamr@4
  2302
     *
williamr@4
  2303
     * This allows you to divide screen space for egul's TextUtils::ClearBetweenRect()
williamr@4
  2304
     * without knowing exact coordinates => when coordinates change, your code 
williamr@4
  2305
     * does not need to change.
williamr@4
  2306
     */
williamr@4
  2307
    IMPORT_C TRect TextRect() const;
williamr@4
  2308
    const CFont *Font() const { return iFont; }
williamr@4
  2309
    TRgb Color() const { return AKN_LAF_COLOR_STATIC(iColor); }
williamr@4
  2310
    CGraphicsContext::TTextAlign Align() const { return iAlign; }
williamr@4
  2311
    /**
williamr@4
  2312
    * Returns the baseline position for the font set in this object.
williamr@4
  2313
    * This value, together with TextRect(), are the metrics that are used to 
williamr@4
  2314
    * parametrise a call to DrawText, for example:
williamr@4
  2315
    *      void CGraphicsContext::DrawText( 
williamr@4
  2316
    *            const TDesC& aText, 
williamr@4
  2317
    *            const TRect& aBox, 
williamr@4
  2318
    *            TInt aBaselineOffset, 
williamr@4
  2319
    *            TTextAlign aAlignment = ELeft,
williamr@4
  2320
    *            TInt aLeftMargin = 0);
williamr@4
  2321
    * 
williamr@4
  2322
    *  TAknLayoutText's own DrawText methods are recommended, however.
williamr@4
  2323
    * 
williamr@4
  2324
    *  Notice that this value is relative to the top of the TextRect() rectangle, 
williamr@4
  2325
    *  which is generally made to bound all accents. Thus this offset value 
williamr@4
  2326
    *  is usually larger than the CFont::AscentInPixels value.
williamr@4
  2327
    * 
williamr@4
  2328
    * @since 3.1 
williamr@4
  2329
    * @return   distance in pixels measured from the top of the textpane down to the baseline
williamr@4
  2330
    */
williamr@4
  2331
    TInt BaselineOffset() const;
williamr@4
  2332
private:
williamr@4
  2333
    TRect iTextRect;
williamr@4
  2334
    const CFont *iFont; // not owned..
williamr@4
  2335
    TInt iColor;
williamr@4
  2336
    TInt iOffset;
williamr@4
  2337
    CGraphicsContext::TTextAlign iAlign;
williamr@4
  2338
    friend class CBubbleOutlookNumberEntry;
williamr@4
  2339
    };
williamr@4
  2340
williamr@4
  2341
/** Low level rectangle management based on European LAF document (can be used by application's custom controls)
williamr@4
  2342
 * 
williamr@4
  2343
 * This allows you to draw images, rectangles, lines or just calculate rectangles based on LAF spec.
williamr@4
  2344
 *
williamr@4
  2345
 * This class reads AVKON_LAYOUT_RECT resources.
williamr@4
  2346
 *
williamr@4
  2347
 * Instances of this class should be placed inside controls for reading low level layout from resources.
williamr@4
  2348
 */
williamr@4
  2349
class TAknLayoutRect
williamr@4
  2350
    {    
williamr@4
  2351
public:
williamr@4
  2352
    IMPORT_C TAknLayoutRect();
williamr@4
  2353
    /** LayoutRect should be called from control's SizeChanged() method.
williamr@4
  2354
     */
williamr@4
  2355
    IMPORT_C void LayoutRect(const TRect &aParent, TInt aResourceId);
williamr@4
  2356
    IMPORT_C void LayoutRect(const TRect &aParent, TResourceReader &aReader);
williamr@4
  2357
    IMPORT_C void LayoutRect(const TRect &aParent, 
williamr@4
  2358
                             const AknLayoutUtils::SAknLayoutRect &aLayout);
williamr@4
  2359
williamr@4
  2360
    IMPORT_C void LayoutRect(const TRect &aParent,
williamr@4
  2361
                             const TAknWindowLineLayout &aLayout);
williamr@4
  2362
williamr@4
  2363
    IMPORT_C void LayoutRect(const TRect &aParent, 
williamr@4
  2364
                             TInt C, TInt l, TInt t, TInt r, TInt b,
williamr@4
  2365
                             TInt W, TInt H);
williamr@4
  2366
    
williamr@4
  2367
    /** Color() can be called from control's Draw() method. 
williamr@4
  2368
    
williamr@4
  2369
    DO NOT CALL it in SizeChanged(), ConstructL() or ActivateL() method, because 
williamr@4
  2370
    it messes up color scheme changes. Especially if you're using colors 226-248.
williamr@4
  2371
    If you store color values, be prepared to update TRgb's you store when color
williamr@4
  2372
    palette is changed! Best thing to do is to make your Draw() methods call
williamr@4
  2373
    AKN_LAF_COLOR().
williamr@4
  2374
     */    
williamr@4
  2375
    IMPORT_C TRgb Color() const;
williamr@4
  2376
    /** Rect() can be called from control's Draw() or in SizeChanged() as input for some other table's layout code.
williamr@4
  2377
     */
williamr@4
  2378
    IMPORT_C TRect Rect() const;
williamr@4
  2379
    TBool Valid() const;
williamr@4
  2380
williamr@4
  2381
    /** DrawRect() and DrawImage() should be called from control's Draw() method.
williamr@4
  2382
     */
williamr@4
  2383
    IMPORT_C void DrawRect(CWindowGc& aGc) const;
williamr@4
  2384
    IMPORT_C void DrawOutLineRect(CWindowGc& aGc) const;
williamr@4
  2385
    IMPORT_C void DrawImage(CBitmapContext& aGc, CFbsBitmap* aBitmap, CFbsBitmap* aMask) const;
williamr@4
  2386
private:
williamr@4
  2387
    TInt iColor;
williamr@4
  2388
    TRect iRect;
williamr@4
  2389
    };
williamr@4
  2390
williamr@4
  2391
/**
williamr@4
  2392
 * Helper functions for drawing empty lists and window shadows
williamr@4
  2393
 */
williamr@4
  2394
class AknDraw 
williamr@4
  2395
    {
williamr@4
  2396
public:
williamr@4
  2397
    /** 
williamr@4
  2398
    Draws standard empty list
williamr@4
  2399
    @param aRect the client rectangle
williamr@4
  2400
    @param aGc   the graphics context
williamr@4
  2401
    @param aText text for empty list in format "Line1\nLine2"
williamr@4
  2402
     */
williamr@4
  2403
    IMPORT_C static void DrawEmptyList(
williamr@4
  2404
        const TRect& aRect,
williamr@4
  2405
        CWindowGc& aGc,
williamr@4
  2406
        TPtrC aText);
williamr@4
  2407
williamr@4
  2408
    /** 
williamr@4
  2409
    Draws empty list for setting item editing
williamr@4
  2410
    @param aRect the rectangle of setting page's content
williamr@4
  2411
    @param aGc   the graphics context
williamr@4
  2412
    @param aText text for empty list in format "Line1\nLine2"
williamr@4
  2413
     */
williamr@4
  2414
    IMPORT_C static void DrawEmptyListForSettingPage(
williamr@4
  2415
        const TRect &aRect,
williamr@4
  2416
        CWindowGc &aGc,
williamr@4
  2417
        TPtrC text); // only for setting page with empty layout.
williamr@4
  2418
williamr@4
  2419
    /** 
williamr@4
  2420
    Draws empty list for lists with find
williamr@4
  2421
    @param aRect the client rectangle
williamr@4
  2422
    @param aGc   the graphics context
williamr@4
  2423
    @param aText text for empty list in format "Line1\nLine2"
williamr@4
  2424
     */
williamr@4
  2425
    IMPORT_C static void DrawEmptyListWithFind(
williamr@4
  2426
        const TRect& aClientRect,
williamr@4
  2427
        CWindowGc& aGc,
williamr@4
  2428
        TPtrC aText); // only for fixed find pane used with single graphics listbox.
williamr@4
  2429
williamr@4
  2430
    /** 
williamr@4
  2431
    Draws empty list for lists with heading
williamr@4
  2432
    @param aRect the client rectangle
williamr@4
  2433
    @param aGc   the graphics context
williamr@4
  2434
    @param aText text for empty list in format "Line1\nLine2"
williamr@4
  2435
     */
williamr@4
  2436
    IMPORT_C static void DrawEmptyListHeading(
williamr@4
  2437
        const TRect &aClientRect,
williamr@4
  2438
        CWindowGc& aGc,
williamr@4
  2439
        TPtrC aText); // only heading style lists.
williamr@4
  2440
williamr@4
  2441
    // The following is optimization for drawing window shadows.
williamr@4
  2442
    /** 
williamr@4
  2443
    Draws a window shadow
williamr@4
  2444
    @param aCoverRect the area covered by the shadow
williamr@4
  2445
    @param aSecondShadowRect the area used for second shadow
williamr@4
  2446
    @param aFirstShadowRect  the area of first shadow
williamr@4
  2447
    @param aOutliineFrameRect the area of black outline frame
williamr@4
  2448
    @param aInsideAreaRect   the area of content inside the window
williamr@4
  2449
     */
williamr@4
  2450
    IMPORT_C static void DrawWindowShadow(
williamr@4
  2451
        CWindowGc& aGc,
williamr@4
  2452
        const TAknLayoutRect& aCoverRect,
williamr@4
  2453
        const TAknLayoutRect& aSecondShadowRect,
williamr@4
  2454
        const TAknLayoutRect& aFirstShadowRect,
williamr@4
  2455
        const TAknLayoutRect& aOutlineFrameRect,
williamr@4
  2456
        const TAknLayoutRect& aInsideAreaRect);
williamr@4
  2457
williamr@4
  2458
public:
williamr@4
  2459
williamr@4
  2460
    /** 
williamr@4
  2461
    * The main implementation routine for empty list drawing.
williamr@4
  2462
    * @param aRect the client rectangle
williamr@4
  2463
    * @param aGc   the graphics context
williamr@4
  2464
    * @param aText text for empty list in one of following formats:
williamr@4
  2465
    *
williamr@4
  2466
    * layouts with large font:
williamr@4
  2467
    * "Line 1"
williamr@4
  2468
    * "Long line. This will be wrapped to 2 lines and 2nd will be trunca..."
williamr@4
  2469
    * "Line 1\nLine 2"
williamr@4
  2470
    *
williamr@4
  2471
    * layout with 1 line of large font and up to 3 lines with small font:
williamr@4
  2472
    * "Line 1\nLong line, will be wrapped up to 3 lines with small font and..."
williamr@4
  2473
    *
williamr@4
  2474
    *
williamr@4
  2475
    * @param aLayoutLine1 Resource id of AVKON_LAYOUT_TEXT for first line layout 
williamr@4
  2476
    * @param aLayoutLine2 Resource id of AVKON_LAYOUT_TEXT for second line layout 
williamr@4
  2477
     */
williamr@4
  2478
    IMPORT_C static void DrawEmptyListImpl( const TRect& aRect,
williamr@4
  2479
                                            CWindowGc& aGc,
williamr@4
  2480
                                            TPtrC aText,
williamr@4
  2481
                                            TInt aLayoutLine1,
williamr@4
  2482
                                            TInt aLayoutLine2 );
williamr@4
  2483
    
williamr@4
  2484
    };
williamr@4
  2485
williamr@4
  2486
/**
williamr@4
  2487
 * Helper functions for drawing empty lists and window shadows
williamr@4
  2488
 */
williamr@4
  2489
class AknDrawWithSkins
williamr@4
  2490
    {
williamr@4
  2491
public:
williamr@4
  2492
    /** 
williamr@4
  2493
    Draws standard empty list
williamr@4
  2494
    @param aRect the client rectangle
williamr@4
  2495
    @param aGc   the graphics context
williamr@4
  2496
    @param aText text for empty list in format "Line1\nLine2"
williamr@4
  2497
     */
williamr@4
  2498
    IMPORT_C static void DrawEmptyList(
williamr@4
  2499
        const TRect& aRect,
williamr@4
  2500
        CWindowGc& aGc,
williamr@4
  2501
        TPtrC aText,
williamr@4
  2502
        CCoeControl *aControl);
williamr@4
  2503
williamr@4
  2504
    /** 
williamr@4
  2505
    Draws empty list for setting item editing
williamr@4
  2506
    @param aRect the rectangle of setting page's content
williamr@4
  2507
    @param aGc   the graphics context
williamr@4
  2508
    @param aText text for empty list in format "Line1\nLine2"
williamr@4
  2509
     */
williamr@4
  2510
    IMPORT_C static void DrawEmptyListForSettingPage(
williamr@4
  2511
        const TRect &aRect,
williamr@4
  2512
        CWindowGc &aGc,
williamr@4
  2513
        TPtrC text,
williamr@4
  2514
        CCoeControl *aControl); // only for setting page with empty layout.
williamr@4
  2515
williamr@4
  2516
    /** 
williamr@4
  2517
    Draws empty list for lists with find
williamr@4
  2518
    @param aRect the client rectangle
williamr@4
  2519
    @param aGc   the graphics context
williamr@4
  2520
    @param aText text for empty list in format "Line1\nLine2"
williamr@4
  2521
     */
williamr@4
  2522
    IMPORT_C static void DrawEmptyListWithFind(
williamr@4
  2523
        const TRect& aClientRect,
williamr@4
  2524
        CWindowGc& aGc,
williamr@4
  2525
        TPtrC aText,
williamr@4
  2526
        CCoeControl *aControl); // only for fixed find pane used with single graphics listbox.
williamr@4
  2527
williamr@4
  2528
    /** 
williamr@4
  2529
    Draws empty list for lists with heading
williamr@4
  2530
    @param aRect the client rectangle
williamr@4
  2531
    @param aGc   the graphics context
williamr@4
  2532
    @param aText text for empty list in format "Line1\nLine2"
williamr@4
  2533
     */
williamr@4
  2534
    IMPORT_C static void DrawEmptyListHeading(
williamr@4
  2535
        const TRect &aClientRect,
williamr@4
  2536
        CWindowGc& aGc,
williamr@4
  2537
        TPtrC aText,
williamr@4
  2538
        CCoeControl *aControl); // only heading style lists.
williamr@4
  2539
williamr@4
  2540
    // The following is optimization for drawing window shadows.
williamr@4
  2541
    /** 
williamr@4
  2542
    Draws a window shadow
williamr@4
  2543
    @param aCoverRect the area covered by the shadow
williamr@4
  2544
    @param aSecondShadowRect the area used for second shadow
williamr@4
  2545
    @param aFirstShadowRect  the area of first shadow
williamr@4
  2546
    @param aOutliineFrameRect the area of black outline frame
williamr@4
  2547
    @param aInsideAreaRect   the area of content inside the window
williamr@4
  2548
     */
williamr@4
  2549
    IMPORT_C static void DrawWindowShadow(
williamr@4
  2550
        CWindowGc& aGc,
williamr@4
  2551
        const TAknLayoutRect& aCoverRect,
williamr@4
  2552
        const TAknLayoutRect& aSecondShadowRect,
williamr@4
  2553
        const TAknLayoutRect& aFirstShadowRect,
williamr@4
  2554
        const TAknLayoutRect& aOutlineFrameRect,
williamr@4
  2555
        const TAknLayoutRect& aInsideAreaRect,
williamr@4
  2556
        CCoeControl *aControl);
williamr@4
  2557
    
williamr@4
  2558
    };
williamr@4
  2559
williamr@4
  2560
williamr@4
  2561
williamr@4
  2562
williamr@4
  2563
// Browser and calculator fonts will not be placed here. Application
williamr@4
  2564
// can use them themselves with CEikonEnv::Static()->Font() call.
williamr@4
  2565
IMPORT_C const CFont *LatinPlain12();
williamr@4
  2566
IMPORT_C const CFont *LatinBold12();
williamr@4
  2567
IMPORT_C const CFont *LatinBold13();
williamr@4
  2568
IMPORT_C const CFont *LatinBold16(); // since 2.0
williamr@4
  2569
IMPORT_C const CFont *LatinBold17();
williamr@4
  2570
IMPORT_C const CFont *LatinBold19(); 
williamr@4
  2571
IMPORT_C const CFont *NumberPlain5();
williamr@4
  2572
IMPORT_C const CFont *ClockBold30();
williamr@4
  2573
IMPORT_C const CFont *LatinClock14();
williamr@4
  2574
const CFont *CalcBold21();
williamr@4
  2575
const CFont *CalcOperBold21();
williamr@4
  2576
const CFont *CalcOperBold13();
williamr@4
  2577
williamr@4
  2578
williamr@4
  2579
williamr@4
  2580
IMPORT_C const CFont *ApacPlain12();
williamr@4
  2581
IMPORT_C const CFont *ApacPlain16();
williamr@4
  2582
williamr@4
  2583
williamr@4
  2584
/**
williamr@4
  2585
* CompletePathWithAppPath
williamr@4
  2586
*   All the components that are specified in the given descriptor (drive letter,
williamr@4
  2587
*   path and file name, including extension) are put into the result;
williamr@4
  2588
*   any missing components (path and drive letter) are taken from the app's path.
williamr@4
  2589
*
williamr@4
  2590
*   Can be used e.g. to load a bitmap file when an application don't know where
williamr@4
  2591
*   it has been installed.
williamr@4
  2592
*
williamr@4
  2593
*   Example1:
williamr@4
  2594
*        TFilename fname = _L("\testdir\pics.mbm"); // Use _LIT instead
williamr@4
  2595
*        CompletePathWithAppPath( fname );
williamr@4
  2596
*        Result:
williamr@4
  2597
*            fname == "c:\testdir\pics.mbm" if application was installed to c:
williamr@4
  2598
*
williamr@4
  2599
*   Example2:
williamr@4
  2600
*        TFilename fname = _L("pics.mbm"); // Use _LIT instead
williamr@4
  2601
*        CompletePathWithAppPath( fname );
williamr@4
  2602
*        Result:
williamr@4
  2603
*            fname == "c:\system\apps\myapp\pics.mbm" if application was 
williamr@4
  2604
*                installed to c:\system\apps\myapp
williamr@4
  2605
*
williamr@4
  2606
* @param    aFileName   FileName which will be completed with application's path
williamr@4
  2607
* @return   Error code if an error occured. In case of an error aFileName will
williamr@4
  2608
*               not be changed
williamr@4
  2609
*/
williamr@4
  2610
IMPORT_C TInt CompleteWithAppPath( TDes& aFileName );
williamr@4
  2611
williamr@4
  2612
/**
williamr@4
  2613
 * Test whether the value falls within the parent relative range
williamr@4
  2614
 * as defined in AknLayout2Def.h
williamr@4
  2615
 *
williamr@4
  2616
 * @since 2.8
williamr@4
  2617
 * @param aVal value
williamr@4
  2618
 * @return ETrue if value is within the parent relative range, EFalse otherwise
williamr@4
  2619
 */
williamr@4
  2620
TBool IsParentRelative(TInt aVal);
williamr@4
  2621
williamr@4
  2622
/**
williamr@4
  2623
 * Returns default input language that corresponds to the UI language.
williamr@4
  2624
 *
williamr@4
  2625
 * @since 3.0
williamr@4
  2626
 * @param aUiLanguage Language code of the UI language
williamr@4
  2627
 * @return Language code of the default input language
williamr@4
  2628
 */
williamr@4
  2629
IMPORT_C TInt DefaultInputLanguageFromUILanguage(const TInt aUiLanguage);
williamr@4
  2630
williamr@4
  2631
    /**
williamr@4
  2632
    * Sets the key block mode.
williamr@4
  2633
    * Has the same functionality as SetKeyBlockMode in AknAppUi,
williamr@4
  2634
    * but this can be used from a non app-framework application.
williamr@4
  2635
    * The default mode blocks simultaneous key presses.
williamr@4
  2636
    * @param aMode @c ENoKeyBlock if no key block, otherwise
williamr@4
  2637
    * @c EDefaultBlockMode
williamr@4
  2638
    */
williamr@4
  2639
IMPORT_C void SetKeyblockMode( TAknKeyBlockMode aMode );
williamr@4
  2640
williamr@4
  2641
namespace AknDateTimeUtils
williamr@4
  2642
    {
williamr@4
  2643
    /**
williamr@4
  2644
    * Converts given UTC time to home time.
williamr@4
  2645
    * This conversion is used e.g. when showing time stamps of files in UI.
williamr@4
  2646
    * In Symbian OS file system, time stamps are in UTC time, but in UI
williamr@4
  2647
    * they should be shown in home time.
williamr@4
  2648
    *
williamr@4
  2649
    * @param aTime UTC time to be converted to home time.
williamr@4
  2650
    * @since 3.1
williamr@4
  2651
    */
williamr@4
  2652
    IMPORT_C void ConvertUtcTimeToHomeTime( TTime& aTime );
williamr@4
  2653
    }
williamr@4
  2654
williamr@4
  2655
#define KAknLanguageMask 0x3FF
williamr@4
  2656
#define KAknDialectMask 0xFC00
williamr@4
  2657
williamr@4
  2658
namespace AknLangUtils
williamr@4
  2659
    {
williamr@4
  2660
    /**
williamr@4
  2661
    * Returns the RFC 3066 tag of the current display language.
williamr@4
  2662
    * @since 3.1
williamr@4
  2663
    * @ret RFC 3066 tag, ownership transferred to the caller.
williamr@4
  2664
    */
williamr@4
  2665
    IMPORT_C HBufC* DisplayLanguageTagL();
williamr@4
  2666
    
williamr@4
  2667
    TLanguage UserLanguage();
williamr@4
  2668
    
williamr@4
  2669
    }
williamr@4
  2670
williamr@4
  2671
/**
williamr@4
  2672
 * Helper functions for Popups
williamr@4
  2673
 * 
williamr@4
  2674
 * @since S60 v5.2
williamr@4
  2675
 */
williamr@4
  2676
class AknPopupUtils
williamr@4
  2677
    {
williamr@4
  2678
public:
williamr@4
  2679
    /** 
williamr@4
  2680
     * Calculates proper position for a popup control. Returned value depends
williamr@4
  2681
     * on currently active layout and softkey visibility.
williamr@4
  2682
     * 
williamr@4
  2683
     * @param aSize             The size of the popup.
williamr@4
  2684
     * @param aSoftkeysVisible  ETrue if softkeys are visible.
williamr@4
  2685
     * @return                  Corrent popup position.
williamr@4
  2686
     */
williamr@4
  2687
    IMPORT_C static TPoint Position( const TSize& aSize,
williamr@4
  2688
        TBool aSoftkeysVisible );
williamr@4
  2689
williamr@4
  2690
    /** 
williamr@4
  2691
     * Calculates proper position for a popup control. Returned value depends
williamr@4
  2692
     * on currently active layout and softkey visibility which is checked from
williamr@4
  2693
     * aControl via MOP chain.
williamr@4
  2694
     * 
williamr@4
  2695
     * @param aSize         The size of the popup.
williamr@4
  2696
     * @param aControl      Control who's position should be calculated.
williamr@4
  2697
     * @return              Corrent popup position.
williamr@4
  2698
     */
williamr@4
  2699
    IMPORT_C static TPoint Position( const TSize& aSize,
williamr@4
  2700
        CCoeControl* aControl );
williamr@4
  2701
    };
williamr@4
  2702
williamr@4
  2703
williamr@4
  2704
/**
williamr@4
  2705
 * Helper functions for Lists
williamr@4
  2706
 * 
williamr@4
  2707
 * @since S60 v5.2
williamr@4
  2708
 */
williamr@4
  2709
class AknListUtils
williamr@4
  2710
    {
williamr@4
  2711
public:
williamr@4
  2712
    /** 
williamr@4
  2713
     * Draws a separator line between list items.
williamr@4
  2714
     * 
williamr@4
  2715
     * @param aGc       Graphics context where separator is drawn to.
williamr@4
  2716
     * @param aRect     Rectangle occupied by the item that is separated.
williamr@4
  2717
     * @param aColor    Text color used in item. Separator is drawn with this
williamr@4
  2718
     *                  color and additional alpha mask.
williamr@4
  2719
     */
williamr@4
  2720
    IMPORT_C static void DrawSeparator( CGraphicsContext& aGc, 
williamr@4
  2721
        const TRect& aRect, const TRgb& aColor );
williamr@4
  2722
    };
williamr@4
  2723
williamr@4
  2724
#endif //  __AKNUTILS_H__
williamr@4
  2725
williamr@4
  2726
// End of file
williamr@4
  2727