epoc32/include/mw/eiklabel.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) 1997-1999 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
*
williamr@4
    16
*/
williamr@4
    17
williamr@4
    18
williamr@4
    19
#if !defined(__EIKLABEL_H__)
williamr@4
    20
#define __EIKLABEL_H__
williamr@4
    21
williamr@4
    22
williamr@4
    23
#if !defined(__EIKALIGN_H__)
williamr@4
    24
#include <eikalign.h>
williamr@4
    25
#endif
williamr@4
    26
williamr@4
    27
#if !defined(__COECCNTX_H__)
williamr@4
    28
#include <coeccntx.h>
williamr@4
    29
#endif
williamr@4
    30
williamr@4
    31
#include <bidi.h>
williamr@4
    32
williamr@4
    33
class CEikLabelExtension;
williamr@4
    34
class CAknPictographInterface;
williamr@4
    35
williamr@4
    36
/**
williamr@4
    37
 * Enables one or more lines of text to be displayed.
williamr@4
    38
 */
williamr@4
    39
class CEikLabel : public CEikAlignedControl, public MCoeControlContext
williamr@4
    40
	{
williamr@4
    41
public:  // new functions
williamr@4
    42
    /**
williamr@4
    43
     * Destructor.
williamr@4
    44
     */
williamr@4
    45
    IMPORT_C ~CEikLabel();
williamr@4
    46
    /** 
williamr@4
    47
     * C++ default constructor.
williamr@4
    48
     */
williamr@4
    49
    IMPORT_C CEikLabel();
williamr@4
    50
    /**
williamr@4
    51
     * Sets the labels alignment. Overwrites alignment set
williamr@4
    52
     * via @c CEikAlignedControl.
williamr@4
    53
     * 
williamr@4
    54
     * @param aAlignment Should be one of { @c ELayoutAlignNone, 
williamr@4
    55
     *        @c ELayoutAlignCenter, @c ELayoutAlignLeft, @c ELayoutAlignRight,
williamr@4
    56
     *        @c ELayoutAlignBidi } defined in @c Avkon.hrh.
williamr@4
    57
     */
williamr@4
    58
    IMPORT_C void SetLabelAlignment(TInt aAlignment);
williamr@4
    59
williamr@4
    60
    /**
williamr@4
    61
     * Sets the brush style to be used from @c aBrushStyle, 
williamr@4
    62
     * this overwrites the brush style set via the Control Context.
williamr@4
    63
     * 
williamr@4
    64
     * @param aBrushStyle A brush style.
williamr@4
    65
     */
williamr@4
    66
    IMPORT_C void SetBrushStyle(CWindowGc::TBrushStyle aBrushStyle);
williamr@4
    67
williamr@4
    68
    /**
williamr@4
    69
     * Sets the brush style to be used from the Control Context, 
williamr@4
    70
     * this overwrites the brush style set via the @c CEikLabel::SetBrushStyle().
williamr@4
    71
     */
williamr@4
    72
    IMPORT_C void SetBrushStyleFromContext();
williamr@4
    73
williamr@4
    74
williamr@4
    75
public:  // from CCoeControl
williamr@4
    76
    /** 
williamr@4
    77
     * From @c CCoeControl.
williamr@4
    78
     *
williamr@4
    79
     * Sets the control's minimum required size.
williamr@4
    80
     *
williamr@4
    81
     * @return Minimum size required by the control.
williamr@4
    82
     */
williamr@4
    83
    IMPORT_C TSize MinimumSize();
williamr@4
    84
    /**
williamr@4
    85
     * From @c CCoeControl.
williamr@4
    86
     * 
williamr@4
    87
     * Constructs the control from a resource file.
williamr@4
    88
     *
williamr@4
    89
     * @param aReader Interprets resource data read from a resource file.
williamr@4
    90
     */
williamr@4
    91
    IMPORT_C void ConstructFromResourceL(TResourceReader& aReader);
williamr@4
    92
    
williamr@4
    93
    /**
williamr@4
    94
     * From @c CCoeControl.
williamr@4
    95
     *
williamr@4
    96
     * Gets the list of logical colours used to draw the control.
williamr@4
    97
     *
williamr@4
    98
     * @param aColorUseList The colour list.
williamr@4
    99
     */
williamr@4
   100
    IMPORT_C void GetColorUseListL(
williamr@4
   101
                        CArrayFix<TCoeColorUse>& aColorUseList) const;
williamr@4
   102
    /**
williamr@4
   103
     * From @c CCoeControl.
williamr@4
   104
     *
williamr@4
   105
     * Handles a change to the control's resources.
williamr@4
   106
     *
williamr@4
   107
     * @param aType A message UID value.
williamr@4
   108
     */
williamr@4
   109
    IMPORT_C void HandleResourceChange(TInt aType);			// not available before Release 005u
williamr@4
   110
    /**
williamr@4
   111
     * From @c CCoeControl.
williamr@4
   112
     *
williamr@4
   113
     * Draw a control - called by window server. All controls, except blank 
williamr@4
   114
     * controls, should implement this function. The default implementation 
williamr@4
   115
     * draws a blank control.
williamr@4
   116
     *
williamr@4
   117
     * This function is used for window server-initiated redrawing of controls,
williamr@4
   118
     * and for some application-initiated drawing. It should be implemented by 
williamr@4
   119
     * each control, but is only called from within @c CCoeControl's member 
williamr@4
   120
     * functions, and not from the derived class. For this reason it is a 
williamr@4
   121
     * private member function of @c CCoeControl.
williamr@4
   122
     *
williamr@4
   123
     * @param aRect The region of the control to be redrawn. Co-ordinates are 
williamr@4
   124
     *        relative to the control's origin (top left corner).
williamr@4
   125
     * @panic EEikPanicLabelNullText Panics if label text has not been defined.
williamr@4
   126
     */
williamr@4
   127
    IMPORT_C void Draw(const TRect& aRect) const;
williamr@4
   128
williamr@4
   129
public:  
williamr@4
   130
    /**
williamr@4
   131
     * Determines text emphasis.
williamr@4
   132
     */
williamr@4
   133
    enum TTextEmphasis
williamr@4
   134
        {
williamr@4
   135
        /** No emphasis. */
williamr@4
   136
        ENoEmphasis         =0x00,
williamr@4
   137
        
williamr@4
   138
        /** Partial emphasis. */
williamr@4
   139
        EPartialEmphasis    =0x10,
williamr@4
   140
        
williamr@4
   141
        /** Full emphasis. */
williamr@4
   142
        EFullEmphasis	 =0x20
williamr@4
   143
        };
williamr@4
   144
public:  // new functions
williamr@4
   145
    
williamr@4
   146
    /**
williamr@4
   147
     * Sets the label’s text.
williamr@4
   148
     *
williamr@4
   149
     * @param aText The label’s text.
williamr@4
   150
     * @panic EEikPanicLabelNullText Panics if label text has not been defined.
williamr@4
   151
     */
williamr@4
   152
    IMPORT_C void SetTextL(const TDesC& aText);
williamr@4
   153
    
williamr@4
   154
    /**
williamr@4
   155
     * Gets the label’s text.
williamr@4
   156
     *
williamr@4
   157
     * @return The label’s text.
williamr@4
   158
     */
williamr@4
   159
    inline const TDesC* Text() const;
williamr@4
   160
    
williamr@4
   161
    /**
williamr@4
   162
     * Sets a flag to indicate that the text needs to be truncated
williamr@4
   163
     * with 3 dots.
williamr@4
   164
     */
williamr@4
   165
    IMPORT_C void CropText();
williamr@4
   166
    
williamr@4
   167
    /**
williamr@4
   168
     * Sets the buffer reserve length.
williamr@4
   169
     *
williamr@4
   170
     * @param aLength The buffer reserve length.
williamr@4
   171
     */
williamr@4
   172
    IMPORT_C void SetBufferReserveLengthL(TInt aLength);
williamr@4
   173
    
williamr@4
   174
    /**
williamr@4
   175
     * Sets the label’s font.
williamr@4
   176
     *
williamr@4
   177
     * @param aFont The label's font.
williamr@4
   178
     */
williamr@4
   179
    IMPORT_C void SetFont(const CFont* aFont);
williamr@4
   180
    
williamr@4
   181
    /**
williamr@4
   182
     * Gets the label’s font.
williamr@4
   183
     *
williamr@4
   184
     * @return The label’s font.
williamr@4
   185
     */
williamr@4
   186
    inline const CFont* Font() const;
williamr@4
   187
    
williamr@4
   188
    /**
williamr@4
   189
     * Sets the label's text emphasis.
williamr@4
   190
     *
williamr@4
   191
     * @param aEmphasis The label's text emphasis.
williamr@4
   192
     */
williamr@4
   193
    IMPORT_C void SetEmphasis(TTextEmphasis aEmphasis);
williamr@4
   194
    
williamr@4
   195
    /**
williamr@4
   196
     * Sets the gap between lines. Gap has a particular definition here.
williamr@4
   197
     * It is defined to be: "baselines separation" - @c CFont::HeightInPixels()
williamr@4
   198
     * 
williamr@4
   199
     * @param aGap Pixels gap to set between lines.
williamr@4
   200
     */
williamr@4
   201
    IMPORT_C void SetPixelGapBetweenLines(TInt aGap);
williamr@4
   202
    
williamr@4
   203
    /**
williamr@4
   204
     * Gets the number of pixels between two lines of text.
williamr@4
   205
     *
williamr@4
   206
     * @return The number of pixels between two lines of text.
williamr@4
   207
     */
williamr@4
   208
    IMPORT_C TInt PixelGapBetweenLines() const;
williamr@4
   209
williamr@4
   210
    /**
williamr@4
   211
     * Tests whether the label is underlined.
williamr@4
   212
     *
williamr@4
   213
     * @return @c ETrue if the label is set as underlined.
williamr@4
   214
     * @return @c EFalse if the label is not set as underlined.
williamr@4
   215
     */
williamr@4
   216
    inline TBool IsUnderlined() const;
williamr@4
   217
    
williamr@4
   218
    /**
williamr@4
   219
     * Sets the label underlining.
williamr@4
   220
     *
williamr@4
   221
     * @param aUnderLining @c ETrue to set the label as underlined. 
williamr@4
   222
     *        @c EFalse to set the label as not underlined.
williamr@4
   223
     */
williamr@4
   224
    IMPORT_C void SetUnderlining(TBool aUnderLining);
williamr@4
   225
    
williamr@4
   226
    /**
williamr@4
   227
     * Tests label strike-through.
williamr@4
   228
     *
williamr@4
   229
     * @return @c ETrue if the label is set to be drawn with a line through it.
williamr@4
   230
     * @return @c EFalse if the label is not set to be drawn with a line 
williamr@4
   231
     *            through it.
williamr@4
   232
     */
williamr@4
   233
    inline TBool IsStrikethrough() const;
williamr@4
   234
    
williamr@4
   235
    /**
williamr@4
   236
     * Sets the label strike-through.
williamr@4
   237
     *
williamr@4
   238
     * @param aStrikethrough @c ETrue to set the label to be drawn with a line 
williamr@4
   239
     *        through it. @c EFalse to set the label to not be drawn with a 
williamr@4
   240
     *        line through it.
williamr@4
   241
     */
williamr@4
   242
    IMPORT_C void SetStrikethrough(TBool aStrikethrough);
williamr@4
   243
    
williamr@4
   244
    /**
williamr@4
   245
     * Gets the minimum size required to draw the specified text.
williamr@4
   246
     *
williamr@4
   247
     * @param aText The text to be drawn.
williamr@4
   248
     * @return The minimum size required to draw the text.
williamr@4
   249
     */
williamr@4
   250
    IMPORT_C TSize CalcMinimumSize(TPtrC& aText) const;
williamr@4
   251
    
williamr@4
   252
    /**
williamr@4
   253
     * Gets the number of lines of text in the label.
williamr@4
   254
     *
williamr@4
   255
     * @return The number of lines of text.
williamr@4
   256
     */
williamr@4
   257
    inline TUint8 NumberOfLines();
williamr@4
   258
    
williamr@4
   259
    /**
williamr@4
   260
     * Gets the buffer reserve length.
williamr@4
   261
     *
williamr@4
   262
     * @return The buffer reserve length.
williamr@4
   263
     */
williamr@4
   264
    IMPORT_C TInt BufferReserveLength() const;
williamr@4
   265
williamr@4
   266
    /**
williamr@4
   267
     * Enables or disables logical to visual conversion when label text
williamr@4
   268
     * is drawn. By default, it is enabled.
williamr@4
   269
     * If you perform the conversion yourself and give visual text
williamr@4
   270
     * (in scrictly left-to-right order) to label, you
williamr@4
   271
     * should disable the conversion in label. Note that label does not perform
williamr@4
   272
     * cropping if logical to visual conversion is disabled.
williamr@4
   273
     *
williamr@4
   274
     * @param aUseConversion Whether label should perform logical to visual
williamr@4
   275
     *        conversion or not.
williamr@4
   276
     */
williamr@4
   277
    IMPORT_C void UseLogicalToVisualConversion( TBool aUseConversion );
williamr@4
   278
williamr@4
   279
    /**
williamr@4
   280
     * Gets information whether label is performing logical to visual
williamr@4
   281
     * conversion or not.
williamr@4
   282
     *
williamr@4
   283
     * @return @c ETrue if label does logical to visual conversion.
williamr@4
   284
     * @return @c EFalse if not.
williamr@4
   285
     */
williamr@4
   286
    IMPORT_C TBool LogicalToVisualConversionUsed() const;
williamr@4
   287
williamr@4
   288
    /**
williamr@4
   289
     * Enables pictograph drawing in the label text.
williamr@4
   290
     * Only effective in Japanese variant.
williamr@4
   291
     * By default, it is disabled.
williamr@4
   292
     *
williamr@4
   293
     * @since S60 2.6
williamr@4
   294
     * @param aInterface Used pictograph interface owned by the caller.
williamr@4
   295
     */
williamr@4
   296
    IMPORT_C void EnablePictographsL( CAknPictographInterface& aInterface );
williamr@4
   297
williamr@4
   298
    /**
williamr@4
   299
     * Disables pictograph drawing in the label text.
williamr@4
   300
     * Only effective in Japanese variant.
williamr@4
   301
     * By default, it is disabled.
williamr@4
   302
     *
williamr@4
   303
     * @since S60 2.6
williamr@4
   304
     */
williamr@4
   305
    IMPORT_C void DisablePictographs();
williamr@4
   306
public: // From CCoeControl
williamr@4
   307
williamr@4
   308
    /**
williamr@4
   309
     * From @c CCoeControl.
williamr@4
   310
     *
williamr@4
   311
     * Handles pointer events. This function gets called whenever a pointer 
williamr@4
   312
     * event occurs in the control, i.e. when the pointer is within the 
williamr@4
   313
     * control's extent, or when the control has grabbed the pointer. 
williamr@4
   314
     * The control should implement this function to handle pointer events.
williamr@4
   315
     * 
williamr@4
   316
     * Note: events of type @c EButton1Down are processed before 
williamr@4
   317
     * @c HandlePointerEventL() is called, in order to transfer keyboard focus 
williamr@4
   318
     * to the control in which the @c EButton1Down event occurred.
williamr@4
   319
     *
williamr@4
   320
     * If overriding @c HandlePointerEventL(), the implementation must include 
williamr@4
   321
     * a base call to @c CCoeControl's @c HandlePointerEventL().
williamr@4
   322
     *
williamr@4
   323
     * @param aPointerEvent The pointer event.
williamr@4
   324
     */
williamr@4
   325
    IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
williamr@4
   326
protected: // from CCoeControl
williamr@4
   327
williamr@4
   328
    /**
williamr@4
   329
     * From @c CCoeControl.
williamr@4
   330
     *
williamr@4
   331
     * Writes the internal state of the control and its components to a stream.
williamr@4
   332
     * Does nothing in release mode.
williamr@4
   333
     * Designed to be overidden and base called by subclasses.
williamr@4
   334
     *
williamr@4
   335
     * @param aWriteStream The write stream.
williamr@4
   336
     */
williamr@4
   337
    IMPORT_C void WriteInternalStateL(RWriteStream& aWriteStream) const;
williamr@4
   338
private:
williamr@4
   339
    IMPORT_C void Reserved_2();
williamr@4
   340
private:
williamr@4
   341
    /**
williamr@4
   342
     * From @c CAknControl.
williamr@4
   343
     */
williamr@4
   344
    IMPORT_C void* ExtensionInterface( TUid aInterface );
williamr@4
   345
private: // new functions
williamr@4
   346
    TInt HeightInPixels() const;
williamr@4
   347
    TInt WidthInPixels(TPtrC& aText) const;
williamr@4
   348
    TInt HeightInPixels(const TDesC& aText) const;
williamr@4
   349
    void SetupGcForEmphasis(CGraphicsContext& aGc) const;
williamr@4
   350
    TBool CheckAndCreateExtension();
williamr@4
   351
    void ConvertColorsForOutlineEffect(TRgb& aFillColor, TRgb& aOutlineColor) const;
williamr@4
   352
williamr@4
   353
public:
williamr@4
   354
    /**
williamr@4
   355
     * @internal
williamr@4
   356
     */
williamr@4
   357
    void DrawToContext( CBitmapContext& aContext, 
williamr@4
   358
        const TRgb* aOverrideColor ) const;
williamr@4
   359
williamr@4
   360
protected:
williamr@4
   361
    
williamr@4
   362
    /**
williamr@4
   363
     * Determines whether text is drawn with underlining or strike-through.
williamr@4
   364
     */
williamr@4
   365
    enum TLabelFlags
williamr@4
   366
        {
williamr@4
   367
        /** Text is drawn with underlining. */
williamr@4
   368
        EUnderlining                  = 0x02,
williamr@4
   369
        
williamr@4
   370
        /** Text is drawn with strike-through. */
williamr@4
   371
        EStrikethrough                = 0x04,
williamr@4
   372
williamr@4
   373
        /** 
williamr@4
   374
         * Determines that bi-directional algorithm still needs to be run
williamr@4
   375
         * against the set text string. This flag allows app to do
williamr@4
   376
         * logical-to-visual conversion in the application side -- since the
williamr@4
   377
         * bi-directional algorithm can only be run once for every text string,
williamr@4
   378
         * we need flagging like this to control whether the algorithm is run
williamr@4
   379
         * inside label or whether the application has already run it and we
williamr@4
   380
         * should not return the algorithm.
williamr@4
   381
         */
williamr@4
   382
        EUseLogicalToVisualConversion = 0x08
williamr@4
   383
        // flags 0x10, 0x20, 0x40 are already used for text emphasis!
williamr@4
   384
        };
williamr@4
   385
    
williamr@4
   386
    /** The label’s text. */
williamr@4
   387
    HBufC* iText;
williamr@4
   388
    
williamr@4
   389
    /** The label’s font. */
williamr@4
   390
    const CFont* iFont;
williamr@4
   391
    
williamr@4
   392
    /** The label’s number of lines of text. */
williamr@4
   393
    TUint8 iNumberOfLines;
williamr@4
   394
    
williamr@4
   395
    /**
williamr@4
   396
     * The label’s flags. These are used to set text emphasis and 
williamr@4
   397
     * characteristics, such as underlining, and strikethrough.
williamr@4
   398
     */
williamr@4
   399
    TUint8 iLabFlags;
williamr@4
   400
williamr@4
   401
    /** The number of pixels between lines of text. */
williamr@4
   402
    TInt iGapBetweenLines;
williamr@4
   403
williamr@4
   404
private:
williamr@4
   405
    TInt iReserveLength;
williamr@4
   406
    CEikLabelExtension* iExtension;
williamr@4
   407
    TInt iSpare[2];
williamr@4
   408
    };
williamr@4
   409
williamr@4
   410
williamr@4
   411
inline const TDesC* CEikLabel::Text() const
williamr@4
   412
	{ return(iText); }
williamr@4
   413
inline const CFont* CEikLabel::Font() const
williamr@4
   414
	{ return(iFont); }
williamr@4
   415
inline TBool CEikLabel::IsUnderlined() const
williamr@4
   416
    {return iLabFlags&EUnderlining;}
williamr@4
   417
inline TBool CEikLabel::IsStrikethrough() const
williamr@4
   418
    {return iLabFlags&EStrikethrough;}
williamr@4
   419
inline TUint8 CEikLabel::NumberOfLines()
williamr@4
   420
	{return iNumberOfLines;}	
williamr@4
   421
williamr@4
   422
#endif // __EIKLABEL_H__