2 * Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
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
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Implementation of the interface to control message queries,
15 * to be contained within CAknMessageQueryDialog
20 #ifndef AKNMESSAGEQUERYCONTROL_H
21 #define AKNMESSAGEQUERYCONTROL_H
25 #include <akncontrol.h>
28 // FORWARD DECLARATIONS
31 class CEikScrollBarFrame;
32 class CEikRichTextEditor;
34 class CAknMessageQueryControlExtension;
46 * Interface to control to implement message queries,
47 * to be contained within @c CAknMessageQueryDialog.
51 NONSHARABLE_CLASS(CAknMessageQueryControl) : public CAknControl
56 * C++ default constructor.
58 CAknMessageQueryControl();
63 ~CAknMessageQueryControl();
66 * Constructs controls from a resource file.
67 * @param aReader The resource reader with which to access
68 * @c AVKON_MESSAGE_QUERY resource.
70 IMPORT_C void ConstructFromResourceL( TResourceReader& aReader );
73 * Sets the message text.
74 * @param aMessage Message text.
76 IMPORT_C void SetMessageTextL( TDesC* aMessage );
79 * Gets the number of lines.
80 * @return Number of lines.
82 inline TInt Lines() const;
86 * @param aKeyEvent The key event.
87 * @return Indicates whether or not the key event was used by this control.
89 TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode );
92 * Formats message text with links and bold text.
93 * To be called from @c CAknMessageQueryDialog.
95 * @param aFormatTextArray Pointer to text to be formatted
96 * @param aFormatTextLocationArray Start index of the text
97 * @param aFormatTypeArray Format type
101 void SetMessageTextWithFormattingL(
103 RArray<TDesC*>* aFormatTextArray,
104 RArray<TInt>* aFormatTextLocationArray,
105 RArray<TMsgQueryTag>* aFormatTypeArray );
108 * Fetches the current link chosen by the UI.
110 * @return The index of the link or -1 if no link is chosen.
112 TInt CurrentLink() const;
115 * Determines whether the link is highlighted.
117 * @return @c ETrue if the link is highlighted.
119 IMPORT_C TBool LinkHighLighted() const;
122 * When set, controls knows that it is in listquery dialog where
123 * max. lines is 3 and background is not drawn
125 void SetListQLayout( TBool aListQLayout );
128 * Determines if a link is tapped.
129 * @param aPos Position of the character tapped.
130 * @return @c ETrue if a link is tapped.
133 TBool LinkTappedL( TInt aPos );
136 * Dehighlights the current link (if any is selected) by setting the
137 * current position to 0.
139 void DehighlightLink();
142 * Check if scroll bar has received a pointer down event
143 * @return ETrue if scroll bar has received a pointer down event
145 TBool ScrollBarGrabbing();
147 public: // from CCoeControl
150 * From @c CCoeControl. Sets the control's minimum required size.
151 * @return The minimum size required by the control.
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.
160 TInt CountComponentControls() const;
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.
168 CCoeControl* ComponentControl( TInt anIndex ) const;
171 * From @c CCoeControl. Responds to size changes to sets the size and
172 * position of the contents of this control.
177 * From @c CCoeControl. Sets control as ready to be drawn.
178 * This function calls @c CCoeControl::ActivateL().
180 virtual void ActivateL();
183 * From @c CCoeControl. Handles pointer events
186 void HandlePointerEventL( const TPointerEvent& aPointerEvent );
189 void UpdateScrollIndicatorL();
192 * Highlights or dehighlights the current link with proper font decoration.
194 void SetHighlightOnL( TBool aOn );
197 * Returns if it is possible to scroll one page in the specified direction.
198 * @arg aMoveDown The scroll direction is down, if ETrue.
200 TBool CanScrollPage( TBool aMoveDown );
202 TBool IsLinkVisible( TInt aIndex ) const;
205 * Updates information about the current page:
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
212 void UpdatePageInfo();
215 * Initialisation functions
217 void CreateEditorL();
218 void LayoutEditorL();
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.
227 TBool SetCurPos( TInt aCurPos );
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.
233 * If the message query doesn't use the list query layout (iListQLayout == EFalse),
234 * this function returns immediately.
236 void TruncateTextForListQLayout( TDes& aMessage );
240 * changed editor from CEikEdwin to CEikRichTextEditor
243 CEikRichTextEditor* iEdwin;
244 TInt iNumberOfLines; // Number of lines in the document
245 TInt iTopLine; // Index of the top visible line on the current page, zero-based
246 TInt iLinesPerPage; // Number of lines in one page
248 CEikScrollBarFrame* iSBFrame;
249 TBool iListQLayout; // If ETrue, used by listqueryDialog
252 // with link extension introduced
253 TBool iHighlightOn; // The current position is a link
254 TCharFormatMask iCharFormatMask;
255 TCharFormat iCharFormat;
258 // with multiple link support
259 RArray<TInt> iLinkTextLocationArray; // Link positions; sorted
260 RArray<TDesC*> iLinkTextArray; // Link texts; in sync with iLinkTextLocationArray w.r.t. item order
261 TInt iLinksCount; // Number of all links in the document
262 TInt iVisibleLinksCount; // Number of visibile links on the current page. Updated in UpdatePageInfo().
263 TInt iFirstVisibleLink; // Index of the first visible link, zero-based. Updated in UpdatePageInfo().
265 /** Cursor positions are places on the current page, where a virtual
267 * The positions are considered visible links plus top and bottom of the page.
268 * Position indexes are zero-based. If there are no visible links,
269 * there is only one cursor position with index 0.
271 TInt iPositionsCount; // Number of cursor positions on the current page. Updated in UpdatePageInfo().
272 TInt iCurPos; // Current cursor position on the current page, zero-based
273 TDesC* iFullMessage; // A copy of the full message used in the list query layout for truncation
274 CAknMessageQueryControlExtension* iExtension;
278 * From @c CCoeControl. Draw a control.
280 * @param aRect The region of the control to be redrawn. Not used.
282 IMPORT_C void Draw( const TRect& aRect ) const;
287 * Get a layout rectangle (shift up and left by margins).
289 * @return The layout rectangle.
291 TRect LayoutRect() const;
294 inline TInt CAknMessageQueryControl::Lines() const
296 return iNumberOfLines;
299 #endif // AKNMESSAGEQUERYCONTROL_H