epoc32/include/app/crichbio.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
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@2
     1
/*
williamr@2
     2
* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     3
* All rights reserved.
williamr@2
     4
* This component and the accompanying materials are made available
williamr@4
     5
* under the terms of "Eclipse Public License v1.0"
williamr@2
     6
* which accompanies this distribution, and is available
williamr@4
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
williamr@2
     8
*
williamr@2
     9
* Initial Contributors:
williamr@2
    10
* Nokia Corporation - initial contribution.
williamr@2
    11
*
williamr@2
    12
* Contributors:
williamr@2
    13
*
williamr@2
    14
* Description:  
williamr@2
    15
*     A UI control used by Smart Messaging Viewers.
williamr@2
    16
*
williamr@2
    17
*/
williamr@2
    18
williamr@2
    19
williamr@2
    20
williamr@2
    21
#ifndef _CRICHBIO_H_
williamr@2
    22
#define _CRICHBIO_H_
williamr@2
    23
williamr@2
    24
// INCLUDES
williamr@2
    25
williamr@2
    26
#include <coecntrl.h>           // CCoeControl
williamr@2
    27
#include <badesca.h>            // CDesC16ArrayFlat
williamr@2
    28
#include <txtfrmat.h>           // TCharFormat
williamr@2
    29
#include <MsgEditor.hrh>        // TMsgCursorLocation
williamr@2
    30
williamr@2
    31
// DATA TYPES
williamr@2
    32
williamr@2
    33
/**
williamr@2
    34
 * This enumeration defines the types of CRichBio
williamr@2
    35
 * No longer used meaningfully but defined for BC
williamr@2
    36
 *
williamr@2
    37
 */
williamr@2
    38
enum TRichBioMode
williamr@2
    39
    {
williamr@2
    40
    ERichBioModeEditorBase,
williamr@2
    41
    ERichBioModeStandard
williamr@2
    42
    };
williamr@2
    43
williamr@2
    44
// FORWARD DECLARATIONS
williamr@2
    45
williamr@2
    46
class CEikRichTextEditor;
williamr@2
    47
class CMsgExpandableControlEditor;
williamr@2
    48
williamr@2
    49
/**
williamr@2
    50
 * A UI control used by Smart Messaging Viewers.
williamr@2
    51
 * This control owns an editor, which is capable of viewing rich text content.
williamr@2
    52
 * NOTE! This is only intended for use with the Smart Message Viewers.
williamr@2
    53
 */
williamr@2
    54
class CRichBio : public CCoeControl
williamr@2
    55
    {
williamr@2
    56
    public: // construction
williamr@2
    57
williamr@2
    58
        /**
williamr@2
    59
         * Two-phased constructor. Constructs the complete object.
williamr@2
    60
         * The parent control has to have a container window at this stage.
williamr@2
    61
         * The type (TRichBioMode) is legacy code and has no effect on the
williamr@2
    62
         * construction or use of the object. Either ERichBioModeEditorBase
williamr@2
    63
         * or ERichBioModeStandard can be used with the same effect
williamr@2
    64
         * @param aParent The parent control.
williamr@2
    65
         * @param aMode Either ERichBioModeEditorBase or ERichBioModeStandard
williamr@2
    66
         * @return a pointer to the created object.
williamr@2
    67
         */
williamr@2
    68
        IMPORT_C static CRichBio* NewL( const CCoeControl* aParent,
williamr@2
    69
            TRichBioMode aMode );
williamr@2
    70
williamr@2
    71
        /**
williamr@2
    72
         * Constructor.
williamr@2
    73
         * ConstructL must be called after the container window is get.
williamr@2
    74
         * The type (TRichBioMode) is legacy code and has no effect on the
williamr@2
    75
         * construction or use of the object. Either ERichBioModeEditorBase
williamr@2
    76
         * or ERichBioModeStandard can be used with the same effect
williamr@2
    77
         * @param aMode Either ERichBioModeEditorBase or ERichBioModeStandard
williamr@2
    78
         */
williamr@2
    79
        IMPORT_C CRichBio( TRichBioMode aMode );
williamr@2
    80
williamr@2
    81
        /**
williamr@2
    82
         * Second phase constructor.
williamr@2
    83
         * The parent control has to have a container window at this stage.
williamr@2
    84
         * @param aParent The parent control, which has container window.
williamr@2
    85
         */
williamr@2
    86
        IMPORT_C void ConstructL( const CCoeControl* aParent );
williamr@2
    87
williamr@2
    88
    public: // destruction
williamr@2
    89
williamr@2
    90
        /**
williamr@2
    91
         * Destructor
williamr@2
    92
         */
williamr@2
    93
        ~CRichBio();
williamr@2
    94
williamr@2
    95
    public: // own methods
williamr@2
    96
williamr@2
    97
        /**
williamr@2
    98
         * Adds a label and value pair.
williamr@2
    99
         * The client does not need to check the length of the strings. This function will
williamr@2
   100
         * wrap strings that are too long.
williamr@2
   101
         * @param aLabel text to displayed in label text format.
williamr@2
   102
         * @param aValue text to displayed in text format.
williamr@2
   103
         */
williamr@2
   104
        IMPORT_C void AddItemL(const TDesC& aLabel, const TDesC& aValue);
williamr@2
   105
williamr@2
   106
        /**
williamr@2
   107
         * This is needed for scrolling with Editor Base.
williamr@2
   108
         * @return TRect Returns the rectangle of the "current" line.
williamr@2
   109
         */
williamr@2
   110
        IMPORT_C TRect CurrentLineRect();
williamr@2
   111
williamr@2
   112
        /**
williamr@2
   113
         * For accessing the richtext editor.
williamr@2
   114
         * Must not be called before ConstructL has been called.
williamr@2
   115
         * @return Reference to the CEikRichTextEditor
williamr@2
   116
         * @exception Panics if the iEditor is NULL.
williamr@2
   117
         */
williamr@2
   118
        IMPORT_C CEikRichTextEditor& Editor();
williamr@2
   119
williamr@2
   120
        /**
williamr@2
   121
         * Is the editor base mode on.
williamr@2
   122
         * @return ETrue if it is in Editor Base mode.
williamr@2
   123
         */
williamr@2
   124
        IMPORT_C TBool IsEditorBaseMode() const;
williamr@2
   125
williamr@2
   126
        /**
williamr@2
   127
         * Empties the data contents.
williamr@2
   128
         */
williamr@2
   129
        IMPORT_C void Reset();
williamr@2
   130
williamr@2
   131
        /**
williamr@2
   132
        * Returns the preferred size of the control.
williamr@2
   133
        * @param aSize Control may set its preferred size
williamr@2
   134
        */
williamr@2
   135
        IMPORT_C void SetAndGetSizeL( TSize& aSize );
williamr@2
   136
williamr@2
   137
        /**
williamr@2
   138
        * Returns the rich text virtual length.
williamr@2
   139
        * @return text length in rich text.
williamr@2
   140
        */
williamr@2
   141
        IMPORT_C TInt VirtualHeight();
williamr@2
   142
williamr@2
   143
        /**
williamr@2
   144
        * Returns the current cursor position.
williamr@2
   145
        * Even in the viewer mode control contains a hidden cursor.
williamr@2
   146
        * This method return its position.
williamr@2
   147
        * @return a position of the hidden cursor relative to the virtual length.
williamr@2
   148
        */
williamr@2
   149
        IMPORT_C TInt VirtualVisibleTop();
williamr@2
   150
williamr@2
   151
        /**
williamr@2
   152
        * Find out if the cursor is at a certain position.
williamr@2
   153
        * @param aLocation indicates either that the cursor is at the topmost
williamr@2
   154
        * position of the control or at the bottom most position.
williamr@2
   155
        * @return ETrue if the cursor is at the specified position, EFalse otherwise.
williamr@2
   156
        */
williamr@2
   157
        IMPORT_C TBool IsCursorLocation(TMsgCursorLocation aLocation) const;
williamr@2
   158
williamr@2
   159
        /**
williamr@2
   160
         * Performs the internal scrolling of control if needed.
williamr@2
   161
         * @since 3.2
williamr@2
   162
         *
williamr@2
   163
         * @param aPixelsToScroll Amount of pixels to scroll.
williamr@2
   164
         * @param aDirection      Scrolling direction.
williamr@2
   165
         * @return Amount of pixels the where scrolled. Zero value means the component cannot
williamr@2
   166
         * be scrolled to that direction anymore
williamr@2
   167
         */
williamr@2
   168
williamr@2
   169
        IMPORT_C TInt ScrollL( TInt aPixelsToScroll, TMsgScrollDirection aDirection );
williamr@2
   170
        
williamr@2
   171
        /**
williamr@2
   172
         * Prepares control for viewing.
williamr@2
   173
         * @since 3.2
williamr@2
   174
         * @param aEvent	The event type
williamr@2
   175
         * @param aParam Event related parameters
williamr@2
   176
         */
williamr@2
   177
        IMPORT_C void NotifyViewEvent( TMsgViewEvent aEvent, TInt aParam );
williamr@2
   178
williamr@2
   179
    public: // from CCoeControl
williamr@2
   180
williamr@2
   181
        TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
williamr@2
   182
williamr@2
   183
    private: // Helper methods.
williamr@2
   184
williamr@2
   185
        /**
williamr@2
   186
        * Applies the format of label text to viewer.
williamr@2
   187
        * @param aFormat Character format to be applied.
williamr@2
   188
        * @param aMask Character format mask
williamr@2
   189
        */
williamr@2
   190
        void ApplyLabelFormat(TCharFormat& aFormat, TCharFormatMask& aMask);
williamr@2
   191
williamr@2
   192
        /**
williamr@2
   193
        * Applies the format of value text to viewer.
williamr@2
   194
        * @param aFormat Character format to be applied.
williamr@2
   195
        * @param aMask Character format mask
williamr@2
   196
        */
williamr@2
   197
        void ApplyValueFormat(TCharFormat& aFormat, TCharFormatMask& aMask);
williamr@2
   198
williamr@2
   199
        /**
williamr@2
   200
        * Applies the format of value and label text to viewer.
williamr@2
   201
        * @param aFormat Character format to be applied.
williamr@2
   202
        * @param aMask Character format mask
williamr@2
   203
        * @aIsLabel Determines is the text label or value.
williamr@2
   204
        */
williamr@2
   205
        void ApplyFormat(TCharFormat& aFormat, TCharFormatMask& aMask, TBool aIsLabel);
williamr@2
   206
williamr@2
   207
        /**
williamr@2
   208
        * Appends text to RichText viewer.
williamr@2
   209
        * @param aLabel Label text
williamr@2
   210
        * @param aValue value text
williamr@2
   211
        */
williamr@2
   212
        void AddItemToRichTextL(const TDesC& aLabel, const TDesC& aValue);
williamr@2
   213
williamr@2
   214
        /**
williamr@2
   215
        * Add text to viewer, checks and removes linefeeds and carriage returns
williamr@2
   216
        * @param aText text to be added
williamr@2
   217
        * @param aFormat Character format
williamr@2
   218
        * @param aMask Character format mask
williamr@2
   219
        */
williamr@2
   220
        void AppendTextL( const TDesC& aText,
williamr@2
   221
            const TCharFormat& aFormat,
williamr@2
   222
            const TCharFormatMask& aMask );
williamr@2
   223
williamr@2
   224
        /**
williamr@2
   225
        * Checks either cache exists or not.
williamr@2
   226
        * @return TBool exists cache or not
williamr@2
   227
        */
williamr@2
   228
        TBool CacheExists();
williamr@2
   229
williamr@2
   230
        /**
williamr@2
   231
        * Adds items to richtext from cache.
williamr@2
   232
        */
williamr@2
   233
        void LoadFromCacheL();
williamr@2
   234
williamr@2
   235
        /**
williamr@2
   236
        * Adds item to cache
williamr@2
   237
        * @param aLabel label text
williamr@2
   238
        * @param aValue value text
williamr@2
   239
        */
williamr@2
   240
        void CacheItemL(const TDesC& aLabel, const TDesC& aValue);
williamr@2
   241
williamr@2
   242
        /**
williamr@2
   243
        * panic wrapper
williamr@2
   244
        * @param aCode panic code.
williamr@2
   245
        */
williamr@2
   246
        static void Panic( TInt aPanic );
williamr@2
   247
williamr@2
   248
williamr@2
   249
williamr@2
   250
    private:
williamr@2
   251
williamr@2
   252
        /**
williamr@2
   253
         * Default constructor prohibited
williamr@2
   254
         */
williamr@2
   255
        CRichBio();
williamr@2
   256
williamr@2
   257
        /**
williamr@2
   258
         * Copy constructor hidden away.
williamr@2
   259
         */
williamr@2
   260
        CRichBio(const CRichBio& aSource);
williamr@2
   261
williamr@2
   262
        /**
williamr@2
   263
         * Assignment operator hidden away.
williamr@2
   264
         */
williamr@2
   265
        const CRichBio& operator=(const CRichBio& aSource);
williamr@2
   266
williamr@2
   267
    private: // from CCoeControl
williamr@2
   268
williamr@2
   269
        void Draw(const TRect& aRect) const;
williamr@2
   270
williamr@2
   271
        TInt CountComponentControls() const;
williamr@2
   272
williamr@2
   273
        CCoeControl* ComponentControl(TInt aIndex) const;
williamr@2
   274
williamr@2
   275
        void SizeChanged();
williamr@2
   276
williamr@2
   277
    private:
williamr@2
   278
williamr@2
   279
        /// Introduce inner class.
williamr@2
   280
        class CEdwinSizeObserver;
williamr@2
   281
williamr@2
   282
        /// Declare inner class friend.
williamr@2
   283
        friend class CEdwinSizeObserver;
williamr@2
   284
williamr@2
   285
        /// Pointer to the editor size observer.
williamr@2
   286
        CEdwinSizeObserver* iEdwinSizeObserver;
williamr@2
   287
williamr@2
   288
        /// Editor control
williamr@2
   289
        CMsgExpandableControlEditor* iEditor;
williamr@2
   290
williamr@2
   291
        /// preserved for binary compatibility
williamr@2
   292
        TInt iVirtualHeight;
williamr@2
   293
williamr@2
   294
        // startup cache for data
williamr@2
   295
        CDesC16ArrayFlat* iLabelCache;
williamr@2
   296
williamr@2
   297
        // startup cache for data
williamr@2
   298
        CDesC16ArrayFlat* iValueCache;
williamr@2
   299
williamr@2
   300
        // Editor Base mode on or off.
williamr@2
   301
        const TRichBioMode iMode;
williamr@2
   302
williamr@2
   303
        /// is first item
williamr@2
   304
        TBool iIsFirstItem;
williamr@2
   305
williamr@2
   306
    private:
williamr@2
   307
        friend class T_RichBioTestSuite;
williamr@2
   308
    };
williamr@2
   309
williamr@2
   310
#endif //_CRICHBIO_H_
williamr@2
   311
williamr@2
   312
// end of file