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