2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
21 #ifndef AKNNOTECONTROL_H
22 #define AKNNOTECONTROL_H
25 #include <AknControl.h>
28 #include <aknprogresstimer.h>
29 #include <AknBitmapAnimation.h>
31 // FORWARD DECLARATIONS
34 class CEikProgressInfo;
35 class CAknNoteAttributes;
36 class CAknTextControl;
37 class TAknWindowLineLayout;
42 * The control for a note dialog.
44 * Manage layout of elements in a note dialog:- the text, the image and
45 * animation, the progress bar.
47 * @since Series 60 0.9
48 * @see CAknNoteDialog, CAknNoteAttributes, CAknText
50 class CAknNoteControl : public CAknControl
52 friend class CAknNoteAttributes;
57 * C++ default constructor.
59 IMPORT_C CAknNoteControl();
64 IMPORT_C virtual ~CAknNoteControl();
67 * Constructs controls from a resource file.
68 * @param aRes The resource reader with which to access @c AVKON_NOTE
71 void ConstructFromResourceL(TResourceReader& aRes);
78 * Set the image in the note attributes. This reduces the
79 * size of the image if necessary (only fixed set of
80 * image sizes if supported). Perform layout only for
81 * the control. The dialog will not be resized.
83 * @param aImage Pointer to image to set.
85 IMPORT_C void SetImageL(CEikImage* aImage);
88 * Set the note animation.
90 * Set the animation in the note attributes.
91 * Perform layout only for the control.
92 * The dialog will not be resized.
94 * @param aResource ID of @c BMPANIM_DATA resource.
96 IMPORT_C void SetAnimationL(TInt aResource);
101 * Set the icon in the note attributes.
102 * Perform layout only for the control.
103 * The dialog will not be resized.
105 * @param aIcon Pointer to icon to set.
107 IMPORT_C void SetIconL(CEikImage* aIcon);
110 * Set the progress bar final value in the note attributes.
112 * @param aValue The final value for the progress information control.
113 * If it is zero, the value is set to one.
114 * @see CEikProgressInfo
116 IMPORT_C void SetFinalProgressValue(TInt aValue);
119 * Increment the progress bar and draw.
121 * @param aIncrement The increment to add to the current progress value.
122 * @return 1 if operation hasn't been completed else 0.
124 * @see CEikProgressInfo
126 IMPORT_C TInt IncrementBarsAndDraw(TInt aIncrement);
129 * Create the progress bar.
131 * @see CEikProgressInfo
133 IMPORT_C void CreateProgressBarL();
136 * Return the progress bar.
138 * @return Pointer to the progress bar.
140 * @see CEikProgressInfo
142 IMPORT_C CEikProgressInfo* GetProgressInfo();
145 * Start the note animation.
147 * @see CAknBitmapAnimation
149 IMPORT_C void StartAnimationL();
152 * Stop the note animation.
153 * Calls @c CAknBitmapAnimation::CancelAnimation() for animation object.
154 * @return @c KErrNone if cancellation successful,
155 * @c KErrGenreral if there was no animation object, otherwise another of the
156 * system-wide error codes.
158 * @see CAknBitmapAnimation
160 IMPORT_C TInt CancelAnimation();
163 * Reset the note text.
165 * Perform layout only for the control.
166 * The dialog will not be resized.
168 * @see CAknTextControl
170 IMPORT_C void ResetText();
173 * Set whole text for the note control.
175 * Perform layout only for the control.
176 * The dialog will not be resized.
177 * @param aText String to set.
179 IMPORT_C void SetTextL(const TDesC& aText);
182 * Set text for a specific line. Any previous text will be overwritten,
183 * except for the text that was set for other lines via this method.
185 * This method prevents @c ParseTextL from having any effect, hence text
186 * control needs to know font and line width to allocate space.
188 * This method is kept for backwards compatibility as the same
189 * results could be achieved by the other @c SetTextL with no wrapping
190 * enabled (flag in note attributes) and newline characters in the text to
191 * indicate a new line.
193 * Perform layout only for the control.
194 * The dialog will not be resized.
196 * @param aText String to set.
197 * @param aLineNum Specifies the line of the text to be set.
199 IMPORT_C void SetTextL(const TDesC& aText,TInt aLineNum);
202 * Set the number inside the note text. The text must have been
203 * previously set via resource or via @c SetTextL and must have a
206 * Note:- This method could be replaced by a @c SetTextL method with
207 * a variable number of arguments.
209 * Perform layout only for the control.
210 * The dialog will not be resized.
212 * @param aNumber Integer to be set inside the text.
214 IMPORT_C void SetTextNumberL(const TInt aNumber);
217 * Determine which text is to be used, either the text for
218 * singular notes, e.g. "You have 1 new message" or the text
219 * for plural notes, e.g. "You have %N new messages". These
220 * texts must have been set via resource.
222 * Note:- This method could be replaced by a @c SetTextL method with
223 * a variable number of arguments.
225 * Perform layout only for the control.
226 * The dialog will not be resized.
228 * @param aIsPlural @c ETrue if plural form of the text is needed,
229 * otherwise @c EFalse.
231 IMPORT_C void SetTextPluralityL(const TBool aIsPlural);
234 * Return the number of lines.
236 * @return The number of lines.
238 IMPORT_C TInt NumberOfLines() const;
245 * Before doing layout parse the text (This might be redundant except
246 * when the control attributs are trasfered but is left here to avoid
247 * breaking the functionality of this exported method).
249 * Layout is done only if it is needed, i.e. if the attributes indicates
250 * that something has changed in such a way that layout needs to be
251 * performed again, e.g. a line of text has been added.
253 * This method assumes that the rect of the control has not been changed.
254 * On the contrary, SizeChanged does not assume that the rect is the same
255 * and hence always performs layout.
257 IMPORT_C void Layout();
261 * This is used by a dialog to layout the control correctly.
262 * @return type of layout to be used.
265 void WindowLayout( TAknWindowLineLayout& aLayout ) const;
268 * Return the note height.
270 * The note height is taken from the layout compiler and
271 * depends on number of lines and the note layout type.
273 * @return The note height in pixels.
275 IMPORT_C TInt NoteHeight() const;
278 * Return the note width.
280 * The note width is taken from the layout compiler.
281 * Contrary to the note height, the note width does not depend on
282 * the note layout type or on number of lines.
284 * @return The note width in pixels.
286 IMPORT_C TInt NoteWidth() const;
288 public: //Interface to CAknNoteDialog
291 * Gets the minimun size requided by the control.
292 * @return The minimum size required by the control.
297 * Accessor to note attributes stored in @c CAknNoteAttributes.
298 * @return Pointer to @c CAknNoteAttributes.
300 CAknNoteAttributes* Attributes() const;
303 * Used by sleeping notes when going to background,
304 * in order to stop and delete animations.
305 * Calls @c CancelAnimation().
310 * Updates the image according to the current skin.
312 void CreateDefaultImageL();
315 IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
319 * Manage indexes into LAF tables
321 * NP stands for "Note Popup"
323 * WNP stands for "Waiting/progress Note Popup"
325 * NWIP stands for "Note With Image Popup"
332 * C++ default constructor.
333 * @param aNumberOfLines Number of lines.
334 * @param aHasNti Determines whether or not there is a number type
336 * @param aImageSize Image size.
338 TIndex(TInt aNumberOfLines,
339 TBool aHasNti = EFalse,
340 TSize aImageSize = TSize(0,0));
345 * Returns number of lines.
346 * @return Number of lines.
353 * Return index into table "Waiting/progress Note Popup Window
354 * Texts Line 1". Index depends on the number of text lines and
355 * whether or not there is a number type indication (NTI). See
356 * table in *.lay and LAF specs for working out indexes.
357 * @param aLineNum Line number.
358 * @return Index into table "Waiting/progress Note Popup Window
361 TInt WNPWindowTextsLine1(TInt aLineNum) const;
364 * Return Left index into table "Note With Image Popup Window
365 * Texts Line 1". Index depends on number of text lines, whether or
366 * not there is a number type indication (NTI). See table in *.lay
367 * and LAF specs for working out indexes.
368 * @param aLineNum Line number.
369 * @return Left index into table "Note With Image Popup Window
372 TInt NWIPWindowTextsLine1L(TInt aLineNum) const;
375 * Return Right index into table "Note With Image Popup Window
376 * Texts Line 1". Index depends on number of text lines and image
377 * size. See table in *.lay and LAF specs for working out indexes.
379 * Table has 3 dimensions:-
380 * - Dimension 1 is the line number
381 * - Dimension 2 is the image width
382 * - Dimension 3 is the image height
384 * @param aLineNum Line number.
385 * @return Right index into table "Note With Image Popup Window
388 TInt NWIPWindowTextsLine1R(TInt aLineNum) const;
391 * Return Bottom index into table "Note With Image Popup Window
392 * Texts Line 1". Index is the same as the number of text lines
393 * minus one. See table in *.lay and LAF specs for working out
395 * @param aLineNum Line number.
396 * @return Bottom index into table "Note With Image Popup Window
399 TInt NWIPWindowTextsLine1B(TInt aLineNum) const;
402 * Return Width index into table "Note With Image Popup Window
403 * Texts Line 1". Index depends on number of text lines, whether or
404 * not there is a number type indication (NTI) and image size. See
405 * table in *.lay and LAF specs for working out indexes.
407 * Table has 4 dimensions:-
408 * - Dimension 1 indicates the presence of an NTI(index 0 = NO NTI,
410 * - Dimension 2 is the line number
411 * - Dimension 3 is the image width
412 * - Dimension 4 is the image height
414 * @param aLineNum Line number.
415 * @return Width index into table "Note With Image Popup Window
418 TInt NWIPWindowTextsLine1W(TInt aLineNum) const;
421 * Return indexes for table @c AKN_LAYOUT_WINDOW_popup_note_window.
422 * If there are 0-2 lines the index is 0. If there are 3 lines the
423 * index is 1, if there are 4 or more lines the index is 2.
424 * @return Indexes for table @c AKN_LAYOUT_WINDOW_popup_note_window.
426 TInt PopupNoteWindow() const;
429 * Return indexes for table
430 * @c AKN_LAYOUT_WINDOW_popup_note_wait_window.
431 * If there are 0-2 lines the index is 0. If there are 3 lines the
432 * index is 1, if there are 4 lines the index is 2.
433 * @return Indexes for table
434 * @c AKN_LAYOUT_WINDOW_popup_note_wait_window.
436 TInt PopupNoteWaitWindow() const;
439 void SelfTest() const;
440 TInt ImageWidthIndex() const;
441 TInt ImageHeightIndex() const;
442 TInt HasNtiIndex() const;
452 void Draw(const TRect& aRect) const;
455 TInt CountComponentControls() const;
456 CCoeControl* ComponentControl(TInt anIndex) const;
461 IMPORT_C void* ExtensionInterface( TUid aInterface );
464 TInt NumberTypeIndicationIndex() const;
465 TInt ImageWidthIndex() const;
467 TInt AnimationIndex();
468 void AnimationNoteLayout();
470 //Layout for general notes
471 void GeneralNoteLayout();
472 void GeneralNoteLabelLayout();
473 void GeneralNoteIconLayout();
475 //Layout for progress and wait notes
476 void ProgressNoteLayout();
477 void ProgressNoteLabelLayout();
478 void ProgressNoteProgressBarLayout();
479 void ProgressNoteIconLayout();
480 void ProgressNoteNumberTypeIndicationLayout();
482 //Layout for image notes
483 void ImageNoteLayout();
484 void ImageNoteLabelLayout();
485 void ImageNoteImageLayout();
486 void ImageNoteShadowLayout();
487 void ImageNoteNumberTypeIndicationLayout();
489 TAknWindowLineLayout GetImageLayout(const TSize& aSize);
490 TAknWindowLineLayout GetImageShadowLayout(const TSize& aSize);
492 TRect LayoutRect() const;
493 void SetLineWidthsL();
496 void ReduceImageIfNeeded();
501 CAknTextControl* TextControl() const;
503 CEikImage* Image() const;
504 CEikImage* Icon() const;
506 CEikProgressInfo* ProgressBar() const;
508 CAknProgressTimer* Timer() const;
509 CAknBitmapAnimation* Animation() const;
511 TBitFlags& Flags() const;
515 TAknLayoutRect iShadowRect;
516 TBool iImageHasShadow;
518 CAknNoteAttributes* iAttributes;
519 CArrayFixFlat<TInt>* iLineWidths;
523 * @deprecated - use SetTextL() method.
524 * @param aText aText string to set.
527 IMPORT_C void SetDynamicTextL(const TDesC& aText);
530 * @deprecated - use @c SetTextL().
532 IMPORT_C void UpdateAndFormatLabelsL(const TDesC& aLabels);
535 * @deprecated - use @c SetTextL().
537 IMPORT_C void UpdateLabelsL(const TDesC& aLabel1,
538 const TDesC& aLabel2=KNullDesC,
539 const TDesC& aLabel3=KNullDesC);
541 * @deprecated - use @c SetTextL().
543 IMPORT_C void UpdateLabels(const TDesC& aLabel1,
544 const TDesC& aLabel2=KNullDesC,
545 const TDesC& aLabel3=KNullDesC);
548 * @deprecated - label length is taken care of already.
550 * Don't use this method anymore. Empty implementation.
552 IMPORT_C void SetLabelReserveLengthL(TInt aLength1=0,
556 protected: // from MObjectProvider
559 * From @c MObjectProvider. Gets an (@c MAknsControlContext) object whose
560 * type is encapsulated by the specified @c TTypeUid object. Calls
561 * @c SupplyMopObject(TTypeUid aId, CEikButtonGroupContainer* iCba,
562 * CEikMenuBar* iMenu).
563 * @since Series 60 2.0
564 * @param aId Encapsulates the UID that identifies the type of object
566 * @return Pointer to the @c MAknsControlContext object provided. Note that
567 * the pointer may be @c NULL.
569 IMPORT_C TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
571 public: // new methods
574 * Sets up background rectangle context.
575 * @since Series 60 2.1
576 * @param aRect Rectangle position to layout the outer and the inner
577 * rectangles of the frame.
578 * @param aPos Relative coordinates of parent position in screen.
579 * @param aOwnerNotDialog @c ETrue if the owner is non-dialog control.
581 IMPORT_C void SetBgRect(const TRect& aRect,
583 TBool aOwnerNotDialog = EFalse);
586 * @return note layout type
587 * see @c Avkon.hrh for Note dialog constants
589 TInt NoteLayout() const;
592 #endif // AKNNOTECONTROL_H