epoc32/include/mw/aknmessagequerycontrol.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
parent 1 666f914201fb
child 4 837f303aceeb
permissions -rw-r--r--
Final list of Symbian^2 public API header files
williamr@2
     1
/*
williamr@2
     2
* Copyright (c) 2002-2007 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@2
     5
* under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
williamr@2
     6
* which accompanies this distribution, and is available
williamr@2
     7
* at the URL "http://www.symbianfoundation.org/legal/licencesv10.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:  Implementation of the interface to control message queries,
williamr@2
    15
*                to be contained within CAknMessageQueryDialog
williamr@2
    16
*
williamr@2
    17
*/
williamr@2
    18
williamr@2
    19
williamr@2
    20
#ifndef AKNMESSAGEQUERYCONTROL_H
williamr@2
    21
#define AKNMESSAGEQUERYCONTROL_H
williamr@2
    22
williamr@2
    23
// INCLUDES
williamr@2
    24
williamr@2
    25
#include <akncontrol.h>
williamr@2
    26
#include <aknutils.h>
williamr@2
    27
williamr@2
    28
// FORWARD DECLARATIONS
williamr@2
    29
williamr@2
    30
class CEikEdwin;
williamr@2
    31
class CEikScrollBarFrame;
williamr@2
    32
class CEikRichTextEditor;
williamr@2
    33
class CRichText;
williamr@2
    34
class CAknMessageQueryControlExtension;
williamr@2
    35
williamr@2
    36
enum TMsgQueryTag
williamr@2
    37
    {
williamr@2
    38
    EMsgQueryLink = 0,
williamr@2
    39
    EMsgQueryBold
williamr@2
    40
    };
williamr@2
    41
williamr@2
    42
williamr@2
    43
// CLASS DECLARATION
williamr@2
    44
williamr@2
    45
/**
williamr@2
    46
*  Interface to control to implement message queries,
williamr@2
    47
*  to be contained within @c CAknMessageQueryDialog.
williamr@2
    48
*
williamr@2
    49
*  @since 0.9
williamr@2
    50
*/
williamr@2
    51
NONSHARABLE_CLASS(CAknMessageQueryControl) : public CAknControl
williamr@2
    52
    {
williamr@2
    53
public:
williamr@2
    54
williamr@2
    55
    /**
williamr@2
    56
    * C++ default constructor.
williamr@2
    57
    */
williamr@2
    58
    CAknMessageQueryControl();
williamr@2
    59
williamr@2
    60
    /**
williamr@2
    61
    * Destructor.
williamr@2
    62
    */
williamr@2
    63
    ~CAknMessageQueryControl();
williamr@2
    64
williamr@2
    65
    /**
williamr@2
    66
    * Constructs controls from a resource file.
williamr@2
    67
    * @param aReader The resource reader with which to access
williamr@2
    68
    * @c AVKON_MESSAGE_QUERY resource.
williamr@2
    69
    */
williamr@2
    70
    IMPORT_C void ConstructFromResourceL( TResourceReader& aReader );
williamr@2
    71
williamr@2
    72
    /**
williamr@2
    73
    * Sets the message text.
williamr@2
    74
    * @param aMessage Message text.
williamr@2
    75
    */
williamr@2
    76
    IMPORT_C void SetMessageTextL( TDesC* aMessage );
williamr@2
    77
williamr@2
    78
    /**
williamr@2
    79
    * Gets the number of lines.
williamr@2
    80
    * @return Number of lines.
williamr@2
    81
    */
williamr@2
    82
    inline TInt Lines() const;
williamr@2
    83
williamr@2
    84
    /**
williamr@2
    85
    * Handles key events.
williamr@2
    86
    * @param aKeyEvent The key event.
williamr@2
    87
    * @return Indicates whether or not the key event was used by this control.
williamr@2
    88
    */
williamr@2
    89
    TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode );
williamr@2
    90
williamr@2
    91
    /**
williamr@2
    92
    * Formats message text with links and bold text.
williamr@2
    93
    * To be called from @c CAknMessageQueryDialog.
williamr@2
    94
    *
williamr@2
    95
    * @param  aFormatTextArray          Pointer to text to be formatted
williamr@2
    96
    * @param  aFormatTextLocationArray  Start index of the text
williamr@2
    97
    * @param  aFormatTypeArray          Format type
williamr@2
    98
    *
williamr@2
    99
    * @since 3.2
williamr@2
   100
    */
williamr@2
   101
    void SetMessageTextWithFormattingL(
williamr@2
   102
        TDesC* aMessage,
williamr@2
   103
        RArray<TDesC*>* aFormatTextArray,
williamr@2
   104
        RArray<TInt>* aFormatTextLocationArray,
williamr@2
   105
        RArray<TMsgQueryTag>* aFormatTypeArray );
williamr@2
   106
williamr@2
   107
    /**
williamr@2
   108
    * Fetches the current link chosen by the UI.
williamr@2
   109
    * @since 3.0
williamr@2
   110
    * @return The index of the link or -1 if no link is chosen.
williamr@2
   111
    */
williamr@2
   112
    TInt CurrentLink() const;
williamr@2
   113
williamr@2
   114
    /**
williamr@2
   115
    * Determines whether the link is highlighted.
williamr@2
   116
    * @since 2.8
williamr@2
   117
    * @return @c ETrue if the link is highlighted.
williamr@2
   118
    */
williamr@2
   119
    IMPORT_C TBool LinkHighLighted() const;
williamr@2
   120
williamr@2
   121
    /**
williamr@2
   122
    * When set, controls knows that it is in listquery dialog where
williamr@2
   123
    * max. lines is 3 and background is not drawn
williamr@2
   124
    */
williamr@2
   125
    void SetListQLayout( TBool aListQLayout );
williamr@2
   126
williamr@2
   127
    /**
williamr@2
   128
    * Determines if a link is tapped.
williamr@2
   129
    * @param  aPos  Position of the character tapped.
williamr@2
   130
    * @return @c ETrue if a link is tapped.
williamr@2
   131
    * @since 3.2
williamr@2
   132
    */
williamr@2
   133
    TBool LinkTappedL( TInt aPos );
williamr@2
   134
    
williamr@2
   135
    /**
williamr@2
   136
    * Dehighlights the current link (if any is selected) by setting the 
williamr@2
   137
    * current position to 0.
williamr@2
   138
    */
williamr@2
   139
    void DehighlightLink();
williamr@2
   140
williamr@2
   141
    /**
williamr@2
   142
    * Check if scroll bar has received a pointer down event
williamr@2
   143
    * @return ETrue if scroll bar has received a pointer down event
williamr@2
   144
    */
williamr@2
   145
    TBool ScrollBarGrabbing();
williamr@2
   146
williamr@2
   147
public:  // from CCoeControl
williamr@2
   148
williamr@2
   149
    /**
williamr@2
   150
    * From @c CCoeControl. Sets the control's minimum required size.
williamr@2
   151
    * @return The minimum size required by the control.
williamr@2
   152
    */
williamr@2
   153
    TSize MinimumSize();
williamr@2
   154
williamr@2
   155
    /**
williamr@2
   156
    * From @c CCoeControl. Gets the number of controls contained in
williamr@2
   157
    * a compound control.
williamr@2
   158
    * @return The number of component controls contained by this control.
williamr@2
   159
    */
williamr@2
   160
    TInt CountComponentControls() const;
williamr@2
   161
williamr@2
   162
    /**
williamr@2
   163
    * From @c CCoeControl. Gets the specified component of a compound control.
williamr@2
   164
    * It returns one of the control's component controls, identified by anIndex.
williamr@2
   165
    * @param anIndex The index of the control to get.
williamr@2
   166
    * @return The component control with an index of anIndex.
williamr@2
   167
    */
williamr@2
   168
    CCoeControl* ComponentControl( TInt anIndex ) const;
williamr@2
   169
williamr@2
   170
    /**
williamr@2
   171
    * From @c CCoeControl. Responds to size changes to sets the size and
williamr@2
   172
    * position of the contents of this control.
williamr@2
   173
    */
williamr@2
   174
    void SizeChanged();
williamr@2
   175
williamr@2
   176
    /**
williamr@2
   177
    * From @c CCoeControl. Sets control as ready to be drawn.
williamr@2
   178
    * This function calls @c CCoeControl::ActivateL().
williamr@2
   179
    */
williamr@2
   180
    virtual void ActivateL();
williamr@2
   181
williamr@2
   182
    /**
williamr@2
   183
    * From @c CCoeControl. Handles pointer events
williamr@2
   184
    * @since 3.0
williamr@2
   185
    */
williamr@2
   186
    void HandlePointerEventL( const TPointerEvent& aPointerEvent );
williamr@2
   187
    
williamr@2
   188
private:
williamr@2
   189
    void UpdateScrollIndicatorL();
williamr@2
   190
williamr@2
   191
    /**
williamr@2
   192
    * Highlights or dehighlights the current link with proper font decoration.
williamr@2
   193
    */
williamr@2
   194
    void SetHighlightOnL( TBool aOn );
williamr@2
   195
williamr@2
   196
    /**
williamr@2
   197
    * Returns if it is possible to scroll one page in the specified direction.
williamr@2
   198
    * @arg aMoveDown The scroll direction is down, if ETrue.
williamr@2
   199
    */
williamr@2
   200
    TBool CanScrollPage( TBool aMoveDown );
williamr@2
   201
williamr@2
   202
    TBool IsLinkVisible( TInt aIndex ) const;  
williamr@2
   203
        
williamr@2
   204
    /**
williamr@2
   205
    * Updates information about the current page:
williamr@2
   206
    * - visible links
williamr@2
   207
    * - cursor positions.
williamr@2
   208
    * The visible links are fetched from the links array.
williamr@2
   209
    * Number of cursor positions is calculated on the basis of visible links.
williamr@2
   210
    * Sets variables: iVisibleLinksCount, iFirstVisibleLink, iPositionsCount
williamr@2
   211
    */
williamr@2
   212
    void UpdatePageInfo();
williamr@2
   213
williamr@2
   214
    /*
williamr@2
   215
    *  Initialisation functions
williamr@2
   216
    */
williamr@2
   217
    void CreateEditorL();
williamr@2
   218
    void LayoutEditorL();
williamr@2
   219
    
williamr@2
   220
    /**
williamr@2
   221
    * Changes the current position of the virtual cursor.
williamr@2
   222
    * Dehighlights the old link and highlights the new one, if any is selected.
williamr@2
   223
    * Checks for the valid range.
williamr@2
   224
    * @return EFalse if out of range, the position was not changed. ETrue
williamr@2
   225
    * if the position was changed successfully.
williamr@2
   226
    */
williamr@2
   227
    TBool SetCurPos( TInt aCurPos );
williamr@2
   228
    
williamr@2
   229
    /**
williamr@2
   230
    * Truncates the text that doesn't fit to the maximum lines number allowed for the
williamr@2
   231
    * list query layout (=3). The truncated text is expanded with the ellipsis character.
williamr@2
   232
    *
williamr@2
   233
    * If the message query doesn't use the list query layout (iListQLayout == EFalse),
williamr@2
   234
    * this function returns immediately.
williamr@2
   235
    */
williamr@2
   236
    void TruncateTextForListQLayout( TDes& aMessage );
williamr@2
   237
williamr@2
   238
private:
williamr@2
   239
    /*
williamr@2
   240
    * changed editor from CEikEdwin to CEikRichTextEditor
williamr@2
   241
    * @since 2.8
williamr@2
   242
    */
williamr@2
   243
    CEikRichTextEditor* iEdwin;
williamr@2
   244
    TInt iNumberOfLines;    // Number of lines in the document
williamr@2
   245
    TInt iTopLine;    // Index of the top visible line on the current page, zero-based
williamr@2
   246
    TInt iLinesPerPage; // Number of lines in one page
williamr@2
   247
williamr@2
   248
    CEikScrollBarFrame* iSBFrame;
williamr@2
   249
    TBool iListQLayout; // If ETrue, used by listqueryDialog
williamr@2
   250
williamr@2
   251
    //@since 2.8
williamr@2
   252
    // with link extension introduced
williamr@2
   253
    TBool iHighlightOn; // The current position is a link
williamr@2
   254
    TCharFormatMask iCharFormatMask;
williamr@2
   255
    TCharFormat iCharFormat;
williamr@2
   256
williamr@2
   257
    //@since 3.0
williamr@2
   258
    // with multiple link support
williamr@2
   259
    RArray<TInt> iLinkTextLocationArray;    // Link positions; sorted
williamr@2
   260
    RArray<TDesC*> iLinkTextArray;  // Link texts; in sync with iLinkTextLocationArray w.r.t. item order
williamr@2
   261
    TInt iLinksCount;   // Number of all links in the document
williamr@2
   262
    TInt iVisibleLinksCount;    // Number of visibile links on the current page. Updated in UpdatePageInfo().
williamr@2
   263
    TInt iFirstVisibleLink; // Index of the first visible link, zero-based. Updated in UpdatePageInfo().
williamr@2
   264
    
williamr@2
   265
    /** Cursor positions are places on the current page, where a virtual
williamr@2
   266
    * cursor can stop.
williamr@2
   267
    * The positions are considered visible links plus top and bottom of the page.
williamr@2
   268
    * Position indexes are zero-based. If there are no visible links,
williamr@2
   269
    * there is only one cursor position with index 0.
williamr@2
   270
    */
williamr@2
   271
    TInt iPositionsCount;   // Number of cursor positions on the current page. Updated in UpdatePageInfo().
williamr@2
   272
    TInt iCurPos;   // Current cursor position on the current page, zero-based
williamr@2
   273
    TDesC* iFullMessage;    // A copy of the full message used in the list query layout for truncation
williamr@2
   274
    CAknMessageQueryControlExtension* iExtension;
williamr@2
   275
williamr@2
   276
protected:
williamr@2
   277
    /**
williamr@2
   278
    * From @c CCoeControl. Draw a control.
williamr@2
   279
    * @since 2.0
williamr@2
   280
    * @param aRect The region of the control to be redrawn. Not used.
williamr@2
   281
    */
williamr@2
   282
    IMPORT_C void Draw( const TRect& aRect ) const;
williamr@2
   283
williamr@2
   284
williamr@2
   285
protected:
williamr@2
   286
    /**
williamr@2
   287
    * Get a layout rectangle (shift up and left by margins).
williamr@2
   288
    * @since 2.6
williamr@2
   289
    * @return The layout rectangle.
williamr@2
   290
    */
williamr@2
   291
    TRect LayoutRect() const;
williamr@2
   292
    };
williamr@2
   293
williamr@2
   294
inline TInt CAknMessageQueryControl::Lines() const
williamr@2
   295
    {
williamr@2
   296
    return iNumberOfLines;
williamr@2
   297
    }
williamr@2
   298
williamr@2
   299
#endif // AKNMESSAGEQUERYCONTROL_H
williamr@2
   300
williamr@2
   301
// End of file