williamr@2: /* williamr@2: * Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies). williamr@2: * All rights reserved. williamr@2: * This component and the accompanying materials are made available williamr@2: * 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: * which accompanies this distribution, and is available williamr@2: * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". williamr@2: * williamr@2: * Initial Contributors: williamr@2: * Nokia Corporation - initial contribution. williamr@2: * williamr@2: * Contributors: williamr@2: * williamr@2: * Description: Implementation of the interface to control message queries, williamr@2: * to be contained within CAknMessageQueryDialog williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: #ifndef AKNMESSAGEQUERYCONTROL_H williamr@2: #define AKNMESSAGEQUERYCONTROL_H williamr@2: williamr@2: // INCLUDES williamr@2: williamr@2: #include williamr@2: #include williamr@2: williamr@2: // FORWARD DECLARATIONS williamr@2: williamr@2: class CEikEdwin; williamr@2: class CEikScrollBarFrame; williamr@2: class CEikRichTextEditor; williamr@2: class CRichText; williamr@2: class CAknMessageQueryControlExtension; williamr@2: williamr@2: enum TMsgQueryTag williamr@2: { williamr@2: EMsgQueryLink = 0, williamr@2: EMsgQueryBold williamr@2: }; williamr@2: williamr@2: williamr@2: // CLASS DECLARATION williamr@2: williamr@2: /** williamr@2: * Interface to control to implement message queries, williamr@2: * to be contained within @c CAknMessageQueryDialog. williamr@2: * williamr@2: * @since 0.9 williamr@2: */ williamr@2: NONSHARABLE_CLASS(CAknMessageQueryControl) : public CAknControl williamr@2: { williamr@2: public: williamr@2: williamr@2: /** williamr@2: * C++ default constructor. williamr@2: */ williamr@2: CAknMessageQueryControl(); williamr@2: williamr@2: /** williamr@2: * Destructor. williamr@2: */ williamr@2: ~CAknMessageQueryControl(); williamr@2: williamr@2: /** williamr@2: * Constructs controls from a resource file. williamr@2: * @param aReader The resource reader with which to access williamr@2: * @c AVKON_MESSAGE_QUERY resource. williamr@2: */ williamr@2: IMPORT_C void ConstructFromResourceL( TResourceReader& aReader ); williamr@2: williamr@2: /** williamr@2: * Sets the message text. williamr@2: * @param aMessage Message text. williamr@2: */ williamr@2: IMPORT_C void SetMessageTextL( TDesC* aMessage ); williamr@2: williamr@2: /** williamr@2: * Gets the number of lines. williamr@2: * @return Number of lines. williamr@2: */ williamr@2: inline TInt Lines() const; williamr@2: williamr@2: /** williamr@2: * Handles key events. williamr@2: * @param aKeyEvent The key event. williamr@2: * @return Indicates whether or not the key event was used by this control. williamr@2: */ williamr@2: TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode ); williamr@2: williamr@2: /** williamr@2: * Formats message text with links and bold text. williamr@2: * To be called from @c CAknMessageQueryDialog. williamr@2: * williamr@2: * @param aFormatTextArray Pointer to text to be formatted williamr@2: * @param aFormatTextLocationArray Start index of the text williamr@2: * @param aFormatTypeArray Format type williamr@2: * williamr@2: * @since 3.2 williamr@2: */ williamr@2: void SetMessageTextWithFormattingL( williamr@2: TDesC* aMessage, williamr@2: RArray* aFormatTextArray, williamr@2: RArray* aFormatTextLocationArray, williamr@2: RArray* aFormatTypeArray ); williamr@2: williamr@2: /** williamr@2: * Fetches the current link chosen by the UI. williamr@2: * @since 3.0 williamr@2: * @return The index of the link or -1 if no link is chosen. williamr@2: */ williamr@2: TInt CurrentLink() const; williamr@2: williamr@2: /** williamr@2: * Determines whether the link is highlighted. williamr@2: * @since 2.8 williamr@2: * @return @c ETrue if the link is highlighted. williamr@2: */ williamr@2: IMPORT_C TBool LinkHighLighted() const; williamr@2: williamr@2: /** williamr@2: * When set, controls knows that it is in listquery dialog where williamr@2: * max. lines is 3 and background is not drawn williamr@2: */ williamr@2: void SetListQLayout( TBool aListQLayout ); williamr@2: williamr@2: /** williamr@2: * Determines if a link is tapped. williamr@2: * @param aPos Position of the character tapped. williamr@2: * @return @c ETrue if a link is tapped. williamr@2: * @since 3.2 williamr@2: */ williamr@2: TBool LinkTappedL( TInt aPos ); williamr@2: williamr@2: /** williamr@2: * Dehighlights the current link (if any is selected) by setting the williamr@2: * current position to 0. williamr@2: */ williamr@2: void DehighlightLink(); williamr@2: williamr@2: /** williamr@2: * Check if scroll bar has received a pointer down event williamr@2: * @return ETrue if scroll bar has received a pointer down event williamr@2: */ williamr@2: TBool ScrollBarGrabbing(); williamr@2: williamr@2: public: // from CCoeControl williamr@2: williamr@2: /** williamr@2: * From @c CCoeControl. Sets the control's minimum required size. williamr@2: * @return The minimum size required by the control. williamr@2: */ williamr@2: TSize MinimumSize(); williamr@2: williamr@2: /** williamr@2: * From @c CCoeControl. Gets the number of controls contained in williamr@2: * a compound control. williamr@2: * @return The number of component controls contained by this control. williamr@2: */ williamr@2: TInt CountComponentControls() const; williamr@2: williamr@2: /** williamr@2: * From @c CCoeControl. Gets the specified component of a compound control. williamr@2: * It returns one of the control's component controls, identified by anIndex. williamr@2: * @param anIndex The index of the control to get. williamr@2: * @return The component control with an index of anIndex. williamr@2: */ williamr@2: CCoeControl* ComponentControl( TInt anIndex ) const; williamr@2: williamr@2: /** williamr@2: * From @c CCoeControl. Responds to size changes to sets the size and williamr@2: * position of the contents of this control. williamr@2: */ williamr@2: void SizeChanged(); williamr@2: williamr@2: /** williamr@2: * From @c CCoeControl. Sets control as ready to be drawn. williamr@2: * This function calls @c CCoeControl::ActivateL(). williamr@2: */ williamr@2: virtual void ActivateL(); williamr@2: williamr@2: /** williamr@2: * From @c CCoeControl. Handles pointer events williamr@2: * @since 3.0 williamr@2: */ williamr@2: void HandlePointerEventL( const TPointerEvent& aPointerEvent ); williamr@2: williamr@2: private: williamr@2: void UpdateScrollIndicatorL(); williamr@2: williamr@2: /** williamr@2: * Highlights or dehighlights the current link with proper font decoration. williamr@2: */ williamr@2: void SetHighlightOnL( TBool aOn ); williamr@2: williamr@2: /** williamr@2: * Returns if it is possible to scroll one page in the specified direction. williamr@2: * @arg aMoveDown The scroll direction is down, if ETrue. williamr@2: */ williamr@2: TBool CanScrollPage( TBool aMoveDown ); williamr@2: williamr@2: TBool IsLinkVisible( TInt aIndex ) const; williamr@2: williamr@2: /** williamr@2: * Updates information about the current page: williamr@2: * - visible links williamr@2: * - cursor positions. williamr@2: * The visible links are fetched from the links array. williamr@2: * Number of cursor positions is calculated on the basis of visible links. williamr@2: * Sets variables: iVisibleLinksCount, iFirstVisibleLink, iPositionsCount williamr@2: */ williamr@2: void UpdatePageInfo(); williamr@2: williamr@2: /* williamr@2: * Initialisation functions williamr@2: */ williamr@2: void CreateEditorL(); williamr@2: void LayoutEditorL(); williamr@2: williamr@2: /** williamr@2: * Changes the current position of the virtual cursor. williamr@2: * Dehighlights the old link and highlights the new one, if any is selected. williamr@2: * Checks for the valid range. williamr@2: * @return EFalse if out of range, the position was not changed. ETrue williamr@2: * if the position was changed successfully. williamr@2: */ williamr@2: TBool SetCurPos( TInt aCurPos ); williamr@2: williamr@2: /** williamr@2: * Truncates the text that doesn't fit to the maximum lines number allowed for the williamr@2: * list query layout (=3). The truncated text is expanded with the ellipsis character. williamr@2: * williamr@2: * If the message query doesn't use the list query layout (iListQLayout == EFalse), williamr@2: * this function returns immediately. williamr@2: */ williamr@2: void TruncateTextForListQLayout( TDes& aMessage ); williamr@2: williamr@2: private: williamr@2: /* williamr@2: * changed editor from CEikEdwin to CEikRichTextEditor williamr@2: * @since 2.8 williamr@2: */ williamr@2: CEikRichTextEditor* iEdwin; williamr@2: TInt iNumberOfLines; // Number of lines in the document williamr@2: TInt iTopLine; // Index of the top visible line on the current page, zero-based williamr@2: TInt iLinesPerPage; // Number of lines in one page williamr@2: williamr@2: CEikScrollBarFrame* iSBFrame; williamr@2: TBool iListQLayout; // If ETrue, used by listqueryDialog williamr@2: williamr@2: //@since 2.8 williamr@2: // with link extension introduced williamr@2: TBool iHighlightOn; // The current position is a link williamr@2: TCharFormatMask iCharFormatMask; williamr@2: TCharFormat iCharFormat; williamr@2: williamr@2: //@since 3.0 williamr@2: // with multiple link support williamr@2: RArray iLinkTextLocationArray; // Link positions; sorted williamr@2: RArray iLinkTextArray; // Link texts; in sync with iLinkTextLocationArray w.r.t. item order williamr@2: TInt iLinksCount; // Number of all links in the document williamr@2: TInt iVisibleLinksCount; // Number of visibile links on the current page. Updated in UpdatePageInfo(). williamr@2: TInt iFirstVisibleLink; // Index of the first visible link, zero-based. Updated in UpdatePageInfo(). williamr@2: williamr@2: /** Cursor positions are places on the current page, where a virtual williamr@2: * cursor can stop. williamr@2: * The positions are considered visible links plus top and bottom of the page. williamr@2: * Position indexes are zero-based. If there are no visible links, williamr@2: * there is only one cursor position with index 0. williamr@2: */ williamr@2: TInt iPositionsCount; // Number of cursor positions on the current page. Updated in UpdatePageInfo(). williamr@2: TInt iCurPos; // Current cursor position on the current page, zero-based williamr@2: TDesC* iFullMessage; // A copy of the full message used in the list query layout for truncation williamr@2: CAknMessageQueryControlExtension* iExtension; williamr@2: williamr@2: protected: williamr@2: /** williamr@2: * From @c CCoeControl. Draw a control. williamr@2: * @since 2.0 williamr@2: * @param aRect The region of the control to be redrawn. Not used. williamr@2: */ williamr@2: IMPORT_C void Draw( const TRect& aRect ) const; williamr@2: williamr@2: williamr@2: protected: williamr@2: /** williamr@2: * Get a layout rectangle (shift up and left by margins). williamr@2: * @since 2.6 williamr@2: * @return The layout rectangle. williamr@2: */ williamr@2: TRect LayoutRect() const; williamr@2: }; williamr@2: williamr@2: inline TInt CAknMessageQueryControl::Lines() const williamr@2: { williamr@2: return iNumberOfLines; williamr@2: } williamr@2: williamr@2: #endif // AKNMESSAGEQUERYCONTROL_H williamr@2: williamr@2: // End of file