epoc32/include/mw/aknmessagequerycontrol.h
branchSymbian2
changeset 2 2fe1408b6811
parent 1 666f914201fb
child 4 837f303aceeb
     1.1 --- a/epoc32/include/mw/aknmessagequerycontrol.h	Tue Nov 24 13:55:44 2009 +0000
     1.2 +++ b/epoc32/include/mw/aknmessagequerycontrol.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -1,1 +1,301 @@
     1.4 -aknmessagequerycontrol.h
     1.5 +/*
     1.6 +* Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies).
     1.7 +* All rights reserved.
     1.8 +* This component and the accompanying materials are made available
     1.9 +* 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
    1.10 +* which accompanies this distribution, and is available
    1.11 +* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
    1.12 +*
    1.13 +* Initial Contributors:
    1.14 +* Nokia Corporation - initial contribution.
    1.15 +*
    1.16 +* Contributors:
    1.17 +*
    1.18 +* Description:  Implementation of the interface to control message queries,
    1.19 +*                to be contained within CAknMessageQueryDialog
    1.20 +*
    1.21 +*/
    1.22 +
    1.23 +
    1.24 +#ifndef AKNMESSAGEQUERYCONTROL_H
    1.25 +#define AKNMESSAGEQUERYCONTROL_H
    1.26 +
    1.27 +// INCLUDES
    1.28 +
    1.29 +#include <akncontrol.h>
    1.30 +#include <aknutils.h>
    1.31 +
    1.32 +// FORWARD DECLARATIONS
    1.33 +
    1.34 +class CEikEdwin;
    1.35 +class CEikScrollBarFrame;
    1.36 +class CEikRichTextEditor;
    1.37 +class CRichText;
    1.38 +class CAknMessageQueryControlExtension;
    1.39 +
    1.40 +enum TMsgQueryTag
    1.41 +    {
    1.42 +    EMsgQueryLink = 0,
    1.43 +    EMsgQueryBold
    1.44 +    };
    1.45 +
    1.46 +
    1.47 +// CLASS DECLARATION
    1.48 +
    1.49 +/**
    1.50 +*  Interface to control to implement message queries,
    1.51 +*  to be contained within @c CAknMessageQueryDialog.
    1.52 +*
    1.53 +*  @since 0.9
    1.54 +*/
    1.55 +NONSHARABLE_CLASS(CAknMessageQueryControl) : public CAknControl
    1.56 +    {
    1.57 +public:
    1.58 +
    1.59 +    /**
    1.60 +    * C++ default constructor.
    1.61 +    */
    1.62 +    CAknMessageQueryControl();
    1.63 +
    1.64 +    /**
    1.65 +    * Destructor.
    1.66 +    */
    1.67 +    ~CAknMessageQueryControl();
    1.68 +
    1.69 +    /**
    1.70 +    * Constructs controls from a resource file.
    1.71 +    * @param aReader The resource reader with which to access
    1.72 +    * @c AVKON_MESSAGE_QUERY resource.
    1.73 +    */
    1.74 +    IMPORT_C void ConstructFromResourceL( TResourceReader& aReader );
    1.75 +
    1.76 +    /**
    1.77 +    * Sets the message text.
    1.78 +    * @param aMessage Message text.
    1.79 +    */
    1.80 +    IMPORT_C void SetMessageTextL( TDesC* aMessage );
    1.81 +
    1.82 +    /**
    1.83 +    * Gets the number of lines.
    1.84 +    * @return Number of lines.
    1.85 +    */
    1.86 +    inline TInt Lines() const;
    1.87 +
    1.88 +    /**
    1.89 +    * Handles key events.
    1.90 +    * @param aKeyEvent The key event.
    1.91 +    * @return Indicates whether or not the key event was used by this control.
    1.92 +    */
    1.93 +    TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode );
    1.94 +
    1.95 +    /**
    1.96 +    * Formats message text with links and bold text.
    1.97 +    * To be called from @c CAknMessageQueryDialog.
    1.98 +    *
    1.99 +    * @param  aFormatTextArray          Pointer to text to be formatted
   1.100 +    * @param  aFormatTextLocationArray  Start index of the text
   1.101 +    * @param  aFormatTypeArray          Format type
   1.102 +    *
   1.103 +    * @since 3.2
   1.104 +    */
   1.105 +    void SetMessageTextWithFormattingL(
   1.106 +        TDesC* aMessage,
   1.107 +        RArray<TDesC*>* aFormatTextArray,
   1.108 +        RArray<TInt>* aFormatTextLocationArray,
   1.109 +        RArray<TMsgQueryTag>* aFormatTypeArray );
   1.110 +
   1.111 +    /**
   1.112 +    * Fetches the current link chosen by the UI.
   1.113 +    * @since 3.0
   1.114 +    * @return The index of the link or -1 if no link is chosen.
   1.115 +    */
   1.116 +    TInt CurrentLink() const;
   1.117 +
   1.118 +    /**
   1.119 +    * Determines whether the link is highlighted.
   1.120 +    * @since 2.8
   1.121 +    * @return @c ETrue if the link is highlighted.
   1.122 +    */
   1.123 +    IMPORT_C TBool LinkHighLighted() const;
   1.124 +
   1.125 +    /**
   1.126 +    * When set, controls knows that it is in listquery dialog where
   1.127 +    * max. lines is 3 and background is not drawn
   1.128 +    */
   1.129 +    void SetListQLayout( TBool aListQLayout );
   1.130 +
   1.131 +    /**
   1.132 +    * Determines if a link is tapped.
   1.133 +    * @param  aPos  Position of the character tapped.
   1.134 +    * @return @c ETrue if a link is tapped.
   1.135 +    * @since 3.2
   1.136 +    */
   1.137 +    TBool LinkTappedL( TInt aPos );
   1.138 +    
   1.139 +    /**
   1.140 +    * Dehighlights the current link (if any is selected) by setting the 
   1.141 +    * current position to 0.
   1.142 +    */
   1.143 +    void DehighlightLink();
   1.144 +
   1.145 +    /**
   1.146 +    * Check if scroll bar has received a pointer down event
   1.147 +    * @return ETrue if scroll bar has received a pointer down event
   1.148 +    */
   1.149 +    TBool ScrollBarGrabbing();
   1.150 +
   1.151 +public:  // from CCoeControl
   1.152 +
   1.153 +    /**
   1.154 +    * From @c CCoeControl. Sets the control's minimum required size.
   1.155 +    * @return The minimum size required by the control.
   1.156 +    */
   1.157 +    TSize MinimumSize();
   1.158 +
   1.159 +    /**
   1.160 +    * From @c CCoeControl. Gets the number of controls contained in
   1.161 +    * a compound control.
   1.162 +    * @return The number of component controls contained by this control.
   1.163 +    */
   1.164 +    TInt CountComponentControls() const;
   1.165 +
   1.166 +    /**
   1.167 +    * From @c CCoeControl. Gets the specified component of a compound control.
   1.168 +    * It returns one of the control's component controls, identified by anIndex.
   1.169 +    * @param anIndex The index of the control to get.
   1.170 +    * @return The component control with an index of anIndex.
   1.171 +    */
   1.172 +    CCoeControl* ComponentControl( TInt anIndex ) const;
   1.173 +
   1.174 +    /**
   1.175 +    * From @c CCoeControl. Responds to size changes to sets the size and
   1.176 +    * position of the contents of this control.
   1.177 +    */
   1.178 +    void SizeChanged();
   1.179 +
   1.180 +    /**
   1.181 +    * From @c CCoeControl. Sets control as ready to be drawn.
   1.182 +    * This function calls @c CCoeControl::ActivateL().
   1.183 +    */
   1.184 +    virtual void ActivateL();
   1.185 +
   1.186 +    /**
   1.187 +    * From @c CCoeControl. Handles pointer events
   1.188 +    * @since 3.0
   1.189 +    */
   1.190 +    void HandlePointerEventL( const TPointerEvent& aPointerEvent );
   1.191 +    
   1.192 +private:
   1.193 +    void UpdateScrollIndicatorL();
   1.194 +
   1.195 +    /**
   1.196 +    * Highlights or dehighlights the current link with proper font decoration.
   1.197 +    */
   1.198 +    void SetHighlightOnL( TBool aOn );
   1.199 +
   1.200 +    /**
   1.201 +    * Returns if it is possible to scroll one page in the specified direction.
   1.202 +    * @arg aMoveDown The scroll direction is down, if ETrue.
   1.203 +    */
   1.204 +    TBool CanScrollPage( TBool aMoveDown );
   1.205 +
   1.206 +    TBool IsLinkVisible( TInt aIndex ) const;  
   1.207 +        
   1.208 +    /**
   1.209 +    * Updates information about the current page:
   1.210 +    * - visible links
   1.211 +    * - cursor positions.
   1.212 +    * The visible links are fetched from the links array.
   1.213 +    * Number of cursor positions is calculated on the basis of visible links.
   1.214 +    * Sets variables: iVisibleLinksCount, iFirstVisibleLink, iPositionsCount
   1.215 +    */
   1.216 +    void UpdatePageInfo();
   1.217 +
   1.218 +    /*
   1.219 +    *  Initialisation functions
   1.220 +    */
   1.221 +    void CreateEditorL();
   1.222 +    void LayoutEditorL();
   1.223 +    
   1.224 +    /**
   1.225 +    * Changes the current position of the virtual cursor.
   1.226 +    * Dehighlights the old link and highlights the new one, if any is selected.
   1.227 +    * Checks for the valid range.
   1.228 +    * @return EFalse if out of range, the position was not changed. ETrue
   1.229 +    * if the position was changed successfully.
   1.230 +    */
   1.231 +    TBool SetCurPos( TInt aCurPos );
   1.232 +    
   1.233 +    /**
   1.234 +    * Truncates the text that doesn't fit to the maximum lines number allowed for the
   1.235 +    * list query layout (=3). The truncated text is expanded with the ellipsis character.
   1.236 +    *
   1.237 +    * If the message query doesn't use the list query layout (iListQLayout == EFalse),
   1.238 +    * this function returns immediately.
   1.239 +    */
   1.240 +    void TruncateTextForListQLayout( TDes& aMessage );
   1.241 +
   1.242 +private:
   1.243 +    /*
   1.244 +    * changed editor from CEikEdwin to CEikRichTextEditor
   1.245 +    * @since 2.8
   1.246 +    */
   1.247 +    CEikRichTextEditor* iEdwin;
   1.248 +    TInt iNumberOfLines;    // Number of lines in the document
   1.249 +    TInt iTopLine;    // Index of the top visible line on the current page, zero-based
   1.250 +    TInt iLinesPerPage; // Number of lines in one page
   1.251 +
   1.252 +    CEikScrollBarFrame* iSBFrame;
   1.253 +    TBool iListQLayout; // If ETrue, used by listqueryDialog
   1.254 +
   1.255 +    //@since 2.8
   1.256 +    // with link extension introduced
   1.257 +    TBool iHighlightOn; // The current position is a link
   1.258 +    TCharFormatMask iCharFormatMask;
   1.259 +    TCharFormat iCharFormat;
   1.260 +
   1.261 +    //@since 3.0
   1.262 +    // with multiple link support
   1.263 +    RArray<TInt> iLinkTextLocationArray;    // Link positions; sorted
   1.264 +    RArray<TDesC*> iLinkTextArray;  // Link texts; in sync with iLinkTextLocationArray w.r.t. item order
   1.265 +    TInt iLinksCount;   // Number of all links in the document
   1.266 +    TInt iVisibleLinksCount;    // Number of visibile links on the current page. Updated in UpdatePageInfo().
   1.267 +    TInt iFirstVisibleLink; // Index of the first visible link, zero-based. Updated in UpdatePageInfo().
   1.268 +    
   1.269 +    /** Cursor positions are places on the current page, where a virtual
   1.270 +    * cursor can stop.
   1.271 +    * The positions are considered visible links plus top and bottom of the page.
   1.272 +    * Position indexes are zero-based. If there are no visible links,
   1.273 +    * there is only one cursor position with index 0.
   1.274 +    */
   1.275 +    TInt iPositionsCount;   // Number of cursor positions on the current page. Updated in UpdatePageInfo().
   1.276 +    TInt iCurPos;   // Current cursor position on the current page, zero-based
   1.277 +    TDesC* iFullMessage;    // A copy of the full message used in the list query layout for truncation
   1.278 +    CAknMessageQueryControlExtension* iExtension;
   1.279 +
   1.280 +protected:
   1.281 +    /**
   1.282 +    * From @c CCoeControl. Draw a control.
   1.283 +    * @since 2.0
   1.284 +    * @param aRect The region of the control to be redrawn. Not used.
   1.285 +    */
   1.286 +    IMPORT_C void Draw( const TRect& aRect ) const;
   1.287 +
   1.288 +
   1.289 +protected:
   1.290 +    /**
   1.291 +    * Get a layout rectangle (shift up and left by margins).
   1.292 +    * @since 2.6
   1.293 +    * @return The layout rectangle.
   1.294 +    */
   1.295 +    TRect LayoutRect() const;
   1.296 +    };
   1.297 +
   1.298 +inline TInt CAknMessageQueryControl::Lines() const
   1.299 +    {
   1.300 +    return iNumberOfLines;
   1.301 +    }
   1.302 +
   1.303 +#endif // AKNMESSAGEQUERYCONTROL_H
   1.304 +
   1.305 +// End of file