epoc32/include/mw/aknnotecontrol.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 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: 
    15 * 
    16 *
    17 */
    18 
    19 
    20 
    21 #ifndef AKNNOTECONTROL_H
    22 #define AKNNOTECONTROL_H
    23 
    24 // INCLUDES
    25 #include <AknControl.h>
    26 #include <AknUtils.h>
    27 
    28 #include <aknprogresstimer.h>
    29 #include <AknBitmapAnimation.h>
    30 
    31 // FORWARD DECLARATIONS
    32 class CEikImage;
    33 class CEikLabel;
    34 class CEikProgressInfo;
    35 class CAknNoteAttributes;
    36 class CAknTextControl;
    37 class TAknWindowLineLayout;
    38 
    39 // CLASS DECLARATION
    40 
    41 /**
    42 * The control for a note dialog.
    43 *
    44 * Manage layout of elements in a note dialog:- the text, the image and
    45 * animation, the progress bar.
    46 *
    47 * @since Series 60 0.9
    48 * @see CAknNoteDialog, CAknNoteAttributes, CAknText
    49 */
    50 class CAknNoteControl : public CAknControl 
    51 {
    52 friend class CAknNoteAttributes;
    53 
    54 public:	
    55 	
    56 	/**
    57     * C++ default constructor.
    58     */
    59 	IMPORT_C CAknNoteControl();
    60 	
    61 	/**
    62     * Destructor.
    63     */
    64 	IMPORT_C virtual ~CAknNoteControl();
    65 	
    66 	/**
    67 	* Constructs controls from a resource file.
    68 	* @param aRes The resource reader with which to access @c AVKON_NOTE
    69 	* resource.
    70 	*/
    71 	void ConstructFromResourceL(TResourceReader& aRes);
    72 
    73 public:
    74 
    75     /**
    76     * Set the note image. 
    77     *
    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. 
    82     * 
    83     * @param aImage Pointer to image to set.
    84     */
    85     IMPORT_C void SetImageL(CEikImage* aImage);
    86 
    87     /**
    88     * Set the note animation. 
    89     *
    90     * Set the animation in the note attributes.
    91     * Perform layout only for the control. 
    92     * The dialog will not be resized. 
    93     * 
    94     * @param aResource ID of @c BMPANIM_DATA resource.
    95     */
    96 	IMPORT_C void SetAnimationL(TInt aResource);
    97 
    98 	/**
    99     * Set the note icon. 
   100     *
   101     * Set the icon in the note attributes.
   102     * Perform layout only for the control. 
   103     * The dialog will not be resized. 
   104     * 
   105     * @param aIcon Pointer to icon to set.
   106     */
   107     IMPORT_C void SetIconL(CEikImage* aIcon);
   108 
   109     /**
   110     * Set the progress bar final value in the note attributes. 
   111     *  
   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
   115     */	
   116 	IMPORT_C void SetFinalProgressValue(TInt aValue);
   117 
   118 	/**
   119     * Increment the progress bar and draw.
   120     *
   121     * @param  aIncrement The increment to add to the current progress value.
   122     * @return 1 if operation hasn't been completed else 0.
   123     * 
   124     * @see CEikProgressInfo
   125     */
   126 	IMPORT_C TInt IncrementBarsAndDraw(TInt aIncrement);
   127 
   128 	/**
   129     * Create the progress bar.
   130     *
   131     * @see CEikProgressInfo
   132     */
   133 	IMPORT_C void CreateProgressBarL();
   134 
   135 	/**
   136     * Return the progress bar.
   137     *
   138     * @return Pointer to the progress bar.
   139     *
   140     * @see CEikProgressInfo
   141     */
   142 	IMPORT_C CEikProgressInfo* GetProgressInfo();
   143 	
   144 	/**
   145     * Start the note animation.
   146     *
   147     * @see CAknBitmapAnimation
   148     */
   149 	IMPORT_C void StartAnimationL();
   150 
   151 	/**
   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. 
   157     *
   158     * @see CAknBitmapAnimation
   159     */
   160 	IMPORT_C TInt CancelAnimation();
   161 
   162     /**
   163     * Reset the note text.
   164     *
   165     * Perform layout only for the control. 
   166     * The dialog will not be resized. 
   167     *
   168     * @see CAknTextControl
   169     */
   170 	IMPORT_C void ResetText();
   171 
   172     /**
   173     * Set whole text for the note control.
   174     *
   175     * Perform layout only for the control. 
   176     * The dialog will not be resized. 
   177     * @param aText String to set.
   178     */	
   179 	IMPORT_C void SetTextL(const TDesC& aText);
   180 
   181 	/**
   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.
   184     *
   185     * This method prevents @c ParseTextL from having any effect, hence text
   186     * control needs to know font and line width to allocate space.
   187     * 
   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.
   192     *
   193     * Perform layout only for the control. 
   194     * The dialog will not be resized. 
   195     *
   196     * @param aText String to set.
   197     * @param aLineNum Specifies the line of the text to be set.
   198     */
   199 	IMPORT_C void SetTextL(const TDesC& aText,TInt aLineNum);
   200 	
   201     /**
   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
   204     * \%d or \%N in it.
   205     *
   206     * Note:- This method could be replaced by a @c SetTextL method with 
   207     * a variable number of arguments.
   208     *
   209     * Perform layout only for the control. 
   210     * The dialog will not be resized. 
   211     *
   212     * @param aNumber Integer to be set inside the text.
   213     */	
   214 	IMPORT_C void SetTextNumberL(const TInt aNumber);
   215 
   216     /**
   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.
   221     *
   222     * Note:- This method could be replaced by a @c SetTextL method with 
   223     * a variable number of arguments.
   224     *
   225     * Perform layout only for the control. 
   226     * The dialog will not be resized. 
   227     *
   228     * @param aIsPlural @c ETrue if plural form of the text is needed,
   229     * otherwise @c EFalse.
   230     */	
   231 	IMPORT_C void SetTextPluralityL(const TBool aIsPlural);
   232 	
   233 	/**
   234     * Return the number of lines.
   235     *
   236     * @return The number of lines. 
   237     */
   238 	IMPORT_C TInt NumberOfLines() const;
   239 
   240 public:
   241 
   242     /**
   243     * Do layout.
   244     *
   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).
   248     *
   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.
   252     *
   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.
   256     */
   257 	IMPORT_C void Layout();
   258 
   259 	/**
   260     *
   261     * This is used by a dialog to layout the control correctly.
   262     * @return type of layout to be used.
   263     *
   264     */
   265 	void WindowLayout( TAknWindowLineLayout& aLayout ) const;
   266 
   267     /**
   268     * Return the note height. 
   269     *
   270     * The note height is taken from the layout compiler and
   271     * depends on number of lines and the note layout type. 
   272     * 
   273     * @return The note height in pixels.
   274     */
   275 	IMPORT_C TInt NoteHeight() const;
   276 
   277 	/**
   278     * Return the note width. 
   279     *
   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. 
   283     * 
   284     * @return The note width in pixels.
   285     */
   286 	IMPORT_C TInt NoteWidth() const;
   287 
   288 public:	//Interface to CAknNoteDialog 
   289 
   290     /**
   291     * Gets the minimun size requided by the control.
   292     * @return The minimum size required by the control.
   293     */
   294 	TSize MinimumSize();
   295 
   296 	/**
   297     * Accessor to note attributes stored in @c CAknNoteAttributes.
   298     * @return Pointer to @c CAknNoteAttributes.
   299 	*/
   300 	CAknNoteAttributes* Attributes() const;
   301 
   302 	/**
   303     * Used by sleeping notes when going to background,
   304     * in order to stop and delete animations.        
   305     * Calls @c CancelAnimation(). 
   306     */
   307 	void Reset();
   308 	
   309 	/**
   310     * Updates the image according to the current skin.
   311     */
   312 	void CreateDefaultImageL();
   313 
   314 public:
   315 	IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
   316 
   317 public:
   318 		/**
   319 		* Manage indexes into LAF tables
   320 		*
   321         * NP   stands for "Note Popup"
   322         *
   323         * WNP  stands for "Waiting/progress Note Popup"
   324         *
   325         * NWIP stands for "Note With Image Popup"
   326 		*/
   327 		class TIndex 
   328 		{	
   329 		public:
   330 
   331 			/**
   332             * C++ default constructor.
   333             * @param aNumberOfLines Number of lines.
   334             * @param aHasNti Determines whether or not there is a number type
   335             * indication (NTI).
   336             * @param aImageSize Image size.
   337             */		
   338 			TIndex(TInt aNumberOfLines, 
   339 			       TBool aHasNti = EFalse, 
   340 			       TSize aImageSize = TSize(0,0));	
   341 		
   342 		public:	
   343 
   344            /**
   345             * Returns number of lines.
   346             * @return Number of lines.
   347             */			
   348             TInt Lines() const;	
   349 			
   350 		public:	
   351 
   352     	    /**
   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
   359             * Texts Line 1".
   360             */		
   361 			TInt WNPWindowTextsLine1(TInt aLineNum) const;
   362 
   363 			/**
   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
   370             * Texts Line 1".
   371             */
   372 			TInt NWIPWindowTextsLine1L(TInt aLineNum) const;
   373 
   374         	/**
   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.
   378             *
   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 
   383             * 
   384             * @param aLineNum Line number.
   385             * @return Right index into table "Note With Image Popup Window
   386             * Texts Line 1".
   387             */
   388 			TInt NWIPWindowTextsLine1R(TInt aLineNum) const;
   389 
   390 			/**
   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
   394             * indexes.
   395             * @param aLineNum Line number.
   396             * @return Bottom index into table "Note With Image Popup Window
   397             * Texts Line 1".
   398             */
   399 			TInt NWIPWindowTextsLine1B(TInt aLineNum) const;
   400 
   401 			/**
   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.
   406             *
   407             * Table has 4 dimensions:-
   408             * - Dimension 1 indicates the presence of an NTI(index 0 = NO NTI,
   409             * index 1 = NTI)
   410             * - Dimension 2 is the line number
   411             * - Dimension 3 is the image width
   412             * - Dimension 4 is the image height
   413             *
   414             * @param aLineNum Line number.
   415             * @return Width index into table "Note With Image Popup Window
   416             * Texts Line 1".
   417             */
   418 			TInt NWIPWindowTextsLine1W(TInt aLineNum) const;
   419 			
   420             /**
   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.
   425             */
   426 			TInt PopupNoteWindow() const;
   427 	
   428 	        /**
   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.
   435             */
   436 			TInt PopupNoteWaitWindow() const;
   437 
   438 		private:	
   439 			void SelfTest() const;	
   440 			TInt ImageWidthIndex() const;
   441 			TInt ImageHeightIndex() const;
   442 			TInt HasNtiIndex() const;
   443 
   444 		private:	
   445 			TInt  iNumberOfLines;
   446 			TBool iHasNti;
   447 			TSize iImageSize;
   448 		};	
   449 
   450 private:
   451 	//COECONTROL METHODS
   452 	void Draw(const TRect& aRect) const;
   453 	void SizeChanged();
   454 	void DoLayout();
   455 	TInt CountComponentControls() const;
   456 	CCoeControl* ComponentControl(TInt anIndex) const;
   457 private:
   458     /**
   459     * From CAknControl
   460     */
   461     IMPORT_C void* ExtensionInterface( TUid aInterface );
   462 private:	
   463 	//LAYOUT METHODS
   464 	TInt NumberTypeIndicationIndex() const;
   465 	TInt ImageWidthIndex() const;
   466 
   467 	TInt AnimationIndex();
   468 	void AnimationNoteLayout();
   469 
   470 	//Layout for general notes
   471 	void GeneralNoteLayout();
   472 	void GeneralNoteLabelLayout();
   473 	void GeneralNoteIconLayout();
   474 
   475 	//Layout for progress and wait notes
   476 	void ProgressNoteLayout();
   477 	void ProgressNoteLabelLayout();
   478 	void ProgressNoteProgressBarLayout();
   479 	void ProgressNoteIconLayout();
   480 	void ProgressNoteNumberTypeIndicationLayout();
   481 
   482 	//Layout for image notes
   483 	void ImageNoteLayout();
   484 	void ImageNoteLabelLayout();
   485 	void ImageNoteImageLayout();
   486 	void ImageNoteShadowLayout();
   487 	void ImageNoteNumberTypeIndicationLayout();
   488 
   489 	TAknWindowLineLayout GetImageLayout(const TSize& aSize); 
   490 	TAknWindowLineLayout GetImageShadowLayout(const TSize& aSize); 
   491 
   492 	TRect LayoutRect() const;
   493 	void SetLineWidthsL();
   494 
   495 	
   496 	void ReduceImageIfNeeded();
   497 
   498 	void ParseTextL();
   499 
   500 private:
   501 	CAknTextControl*    TextControl() const; 
   502 
   503 	CEikImage* Image() const; 
   504 	CEikImage* Icon() const; 
   505 	
   506 	CEikProgressInfo* ProgressBar() const; 
   507 	
   508 	CAknProgressTimer* Timer() const; 
   509 	CAknBitmapAnimation* Animation() const; 
   510 	
   511 	TBitFlags&  Flags() const; 
   512 
   513 private:
   514 	TInt                iNoteLayout;
   515 	TAknLayoutRect      iShadowRect;
   516 	TBool               iImageHasShadow;
   517 	
   518 	CAknNoteAttributes*  iAttributes;
   519 	CArrayFixFlat<TInt>* iLineWidths;
   520 
   521 public:
   522 	/**
   523 	 * @deprecated - use SetTextL() method. 
   524 	 * @param aText aText string to set.
   525 	 */
   526 	 
   527 	IMPORT_C void SetDynamicTextL(const TDesC& aText);
   528 	
   529 	/**
   530 	 * @deprecated - use @c SetTextL().
   531 	 */		
   532 	IMPORT_C void UpdateAndFormatLabelsL(const TDesC& aLabels);
   533 	
   534 	/**
   535 	 * @deprecated - use @c SetTextL().
   536 	 */		
   537 	IMPORT_C void UpdateLabelsL(const TDesC& aLabel1, 
   538 	                            const TDesC& aLabel2=KNullDesC, 
   539 	                            const TDesC& aLabel3=KNullDesC);
   540 	/**
   541 	 * @deprecated - use @c SetTextL().
   542 	 */	 	
   543 	IMPORT_C void UpdateLabels(const TDesC& aLabel1, 
   544 	                           const TDesC& aLabel2=KNullDesC, 
   545 	                           const TDesC& aLabel3=KNullDesC);
   546 
   547 	/**
   548      * @deprecated - label length is taken care of already.
   549      *
   550      * Don't use this method anymore. Empty implementation.
   551      */
   552 	IMPORT_C void SetLabelReserveLengthL(TInt aLength1=0, 
   553 	                                     TInt aLength2=0, 
   554 	                                     TInt aLength3=0);
   555 	
   556 protected: // from MObjectProvider
   557 
   558     /**
   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
   565     * required.
   566     * @return Pointer to the @c MAknsControlContext object provided. Note that
   567     * the pointer may be @c NULL.
   568     */
   569 	IMPORT_C TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
   570 
   571 public: // new methods
   572 
   573     /**
   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.
   580     */
   581 	IMPORT_C void SetBgRect(const TRect& aRect, 
   582 	                        const TPoint& aPos, 
   583 	                        TBool aOwnerNotDialog = EFalse);
   584 	                        
   585 	/**
   586     * @return note layout type 
   587     * see @c Avkon.hrh for Note dialog constants
   588     */
   589 	TInt NoteLayout() const;
   590 	};
   591 
   592 #endif // AKNNOTECONTROL_H