williamr@2: /* williamr@2: * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). williamr@2: * All rights reserved. williamr@2: * This component and the accompanying materials are made available williamr@4: * under the terms of "Eclipse Public License v1.0" williamr@2: * which accompanies this distribution, and is available williamr@4: * at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: * williamr@2: * Initial Contributors: williamr@2: * Nokia Corporation - initial contribution. williamr@2: * williamr@2: * Contributors: williamr@2: * williamr@2: * Description: williamr@2: * williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: williamr@2: #ifndef AKNNOTECONTROL_H williamr@2: #define AKNNOTECONTROL_H williamr@2: williamr@2: // INCLUDES williamr@2: #include williamr@4: #include williamr@2: williamr@2: #include williamr@4: #include williamr@2: williamr@2: // FORWARD DECLARATIONS williamr@2: class CEikImage; williamr@2: class CEikLabel; williamr@2: class CEikProgressInfo; williamr@2: class CAknNoteAttributes; williamr@2: class CAknTextControl; williamr@2: class TAknWindowLineLayout; williamr@2: williamr@2: // CLASS DECLARATION williamr@2: williamr@2: /** williamr@2: * The control for a note dialog. williamr@2: * williamr@2: * Manage layout of elements in a note dialog:- the text, the image and williamr@2: * animation, the progress bar. williamr@2: * williamr@2: * @since Series 60 0.9 williamr@2: * @see CAknNoteDialog, CAknNoteAttributes, CAknText williamr@2: */ williamr@2: class CAknNoteControl : public CAknControl williamr@2: { williamr@2: friend class CAknNoteAttributes; williamr@2: williamr@2: public: williamr@2: williamr@2: /** williamr@2: * C++ default constructor. williamr@2: */ williamr@2: IMPORT_C CAknNoteControl(); williamr@2: williamr@2: /** williamr@2: * Destructor. williamr@2: */ williamr@2: IMPORT_C virtual ~CAknNoteControl(); williamr@2: williamr@2: /** williamr@2: * Constructs controls from a resource file. williamr@2: * @param aRes The resource reader with which to access @c AVKON_NOTE williamr@2: * resource. williamr@2: */ williamr@2: void ConstructFromResourceL(TResourceReader& aRes); williamr@2: williamr@2: public: williamr@2: williamr@2: /** williamr@2: * Set the note image. williamr@2: * williamr@2: * Set the image in the note attributes. This reduces the williamr@2: * size of the image if necessary (only fixed set of williamr@2: * image sizes if supported). Perform layout only for williamr@2: * the control. The dialog will not be resized. williamr@2: * williamr@2: * @param aImage Pointer to image to set. williamr@2: */ williamr@2: IMPORT_C void SetImageL(CEikImage* aImage); williamr@2: williamr@2: /** williamr@2: * Set the note animation. williamr@2: * williamr@2: * Set the animation in the note attributes. williamr@2: * Perform layout only for the control. williamr@2: * The dialog will not be resized. williamr@2: * williamr@2: * @param aResource ID of @c BMPANIM_DATA resource. williamr@2: */ williamr@2: IMPORT_C void SetAnimationL(TInt aResource); williamr@2: williamr@2: /** williamr@2: * Set the note icon. williamr@2: * williamr@2: * Set the icon in the note attributes. williamr@2: * Perform layout only for the control. williamr@2: * The dialog will not be resized. williamr@2: * williamr@2: * @param aIcon Pointer to icon to set. williamr@2: */ williamr@2: IMPORT_C void SetIconL(CEikImage* aIcon); williamr@2: williamr@2: /** williamr@2: * Set the progress bar final value in the note attributes. williamr@2: * williamr@2: * @param aValue The final value for the progress information control. williamr@2: * If it is zero, the value is set to one. williamr@2: * @see CEikProgressInfo williamr@2: */ williamr@2: IMPORT_C void SetFinalProgressValue(TInt aValue); williamr@2: williamr@2: /** williamr@2: * Increment the progress bar and draw. williamr@2: * williamr@2: * @param aIncrement The increment to add to the current progress value. williamr@2: * @return 1 if operation hasn't been completed else 0. williamr@2: * williamr@2: * @see CEikProgressInfo williamr@2: */ williamr@2: IMPORT_C TInt IncrementBarsAndDraw(TInt aIncrement); williamr@2: williamr@2: /** williamr@2: * Create the progress bar. williamr@2: * williamr@2: * @see CEikProgressInfo williamr@2: */ williamr@2: IMPORT_C void CreateProgressBarL(); williamr@2: williamr@2: /** williamr@2: * Return the progress bar. williamr@2: * williamr@2: * @return Pointer to the progress bar. williamr@2: * williamr@2: * @see CEikProgressInfo williamr@2: */ williamr@2: IMPORT_C CEikProgressInfo* GetProgressInfo(); williamr@2: williamr@2: /** williamr@2: * Start the note animation. williamr@2: * williamr@2: * @see CAknBitmapAnimation williamr@2: */ williamr@2: IMPORT_C void StartAnimationL(); williamr@2: williamr@2: /** williamr@2: * Stop the note animation. williamr@2: * Calls @c CAknBitmapAnimation::CancelAnimation() for animation object. williamr@2: * @return @c KErrNone if cancellation successful, williamr@2: * @c KErrGenreral if there was no animation object, otherwise another of the williamr@2: * system-wide error codes. williamr@2: * williamr@2: * @see CAknBitmapAnimation williamr@2: */ williamr@2: IMPORT_C TInt CancelAnimation(); williamr@2: williamr@2: /** williamr@2: * Reset the note text. williamr@2: * williamr@2: * Perform layout only for the control. williamr@2: * The dialog will not be resized. williamr@2: * williamr@2: * @see CAknTextControl williamr@2: */ williamr@2: IMPORT_C void ResetText(); williamr@2: williamr@2: /** williamr@2: * Set whole text for the note control. williamr@2: * williamr@2: * Perform layout only for the control. williamr@2: * The dialog will not be resized. williamr@2: * @param aText String to set. williamr@2: */ williamr@2: IMPORT_C void SetTextL(const TDesC& aText); williamr@2: williamr@2: /** williamr@2: * Set text for a specific line. Any previous text will be overwritten, williamr@2: * except for the text that was set for other lines via this method. williamr@2: * williamr@2: * This method prevents @c ParseTextL from having any effect, hence text williamr@2: * control needs to know font and line width to allocate space. williamr@2: * williamr@2: * This method is kept for backwards compatibility as the same williamr@2: * results could be achieved by the other @c SetTextL with no wrapping williamr@2: * enabled (flag in note attributes) and newline characters in the text to williamr@2: * indicate a new line. williamr@2: * williamr@2: * Perform layout only for the control. williamr@2: * The dialog will not be resized. williamr@2: * williamr@2: * @param aText String to set. williamr@2: * @param aLineNum Specifies the line of the text to be set. williamr@2: */ williamr@2: IMPORT_C void SetTextL(const TDesC& aText,TInt aLineNum); williamr@2: williamr@2: /** williamr@2: * Set the number inside the note text. The text must have been williamr@2: * previously set via resource or via @c SetTextL and must have a williamr@2: * \%d or \%N in it. williamr@2: * williamr@2: * Note:- This method could be replaced by a @c SetTextL method with williamr@2: * a variable number of arguments. williamr@2: * williamr@2: * Perform layout only for the control. williamr@2: * The dialog will not be resized. williamr@2: * williamr@2: * @param aNumber Integer to be set inside the text. williamr@2: */ williamr@2: IMPORT_C void SetTextNumberL(const TInt aNumber); williamr@2: williamr@2: /** williamr@2: * Determine which text is to be used, either the text for williamr@2: * singular notes, e.g. "You have 1 new message" or the text williamr@2: * for plural notes, e.g. "You have %N new messages". These williamr@2: * texts must have been set via resource. williamr@2: * williamr@2: * Note:- This method could be replaced by a @c SetTextL method with williamr@2: * a variable number of arguments. williamr@2: * williamr@2: * Perform layout only for the control. williamr@2: * The dialog will not be resized. williamr@2: * williamr@2: * @param aIsPlural @c ETrue if plural form of the text is needed, williamr@2: * otherwise @c EFalse. williamr@2: */ williamr@2: IMPORT_C void SetTextPluralityL(const TBool aIsPlural); williamr@2: williamr@2: /** williamr@2: * Return the number of lines. williamr@2: * williamr@2: * @return The number of lines. williamr@2: */ williamr@2: IMPORT_C TInt NumberOfLines() const; williamr@2: williamr@2: public: williamr@2: williamr@2: /** williamr@2: * Do layout. williamr@2: * williamr@2: * Before doing layout parse the text (This might be redundant except williamr@2: * when the control attributs are trasfered but is left here to avoid williamr@2: * breaking the functionality of this exported method). williamr@2: * williamr@2: * Layout is done only if it is needed, i.e. if the attributes indicates williamr@2: * that something has changed in such a way that layout needs to be williamr@2: * performed again, e.g. a line of text has been added. williamr@2: * williamr@2: * This method assumes that the rect of the control has not been changed. williamr@2: * On the contrary, SizeChanged does not assume that the rect is the same williamr@2: * and hence always performs layout. williamr@2: */ williamr@2: IMPORT_C void Layout(); williamr@2: williamr@2: /** williamr@2: * williamr@2: * This is used by a dialog to layout the control correctly. williamr@2: * @return type of layout to be used. williamr@2: * williamr@2: */ williamr@2: void WindowLayout( TAknWindowLineLayout& aLayout ) const; williamr@2: williamr@2: /** williamr@2: * Return the note height. williamr@2: * williamr@2: * The note height is taken from the layout compiler and williamr@2: * depends on number of lines and the note layout type. williamr@2: * williamr@2: * @return The note height in pixels. williamr@2: */ williamr@2: IMPORT_C TInt NoteHeight() const; williamr@2: williamr@2: /** williamr@2: * Return the note width. williamr@2: * williamr@2: * The note width is taken from the layout compiler. williamr@2: * Contrary to the note height, the note width does not depend on williamr@2: * the note layout type or on number of lines. williamr@2: * williamr@2: * @return The note width in pixels. williamr@2: */ williamr@2: IMPORT_C TInt NoteWidth() const; williamr@2: williamr@2: public: //Interface to CAknNoteDialog williamr@2: williamr@2: /** williamr@2: * Gets the minimun size requided by the control. williamr@2: * @return The minimum size required by the control. williamr@2: */ williamr@2: TSize MinimumSize(); williamr@2: williamr@2: /** williamr@2: * Accessor to note attributes stored in @c CAknNoteAttributes. williamr@2: * @return Pointer to @c CAknNoteAttributes. williamr@2: */ williamr@2: CAknNoteAttributes* Attributes() const; williamr@2: williamr@2: /** williamr@2: * Used by sleeping notes when going to background, williamr@2: * in order to stop and delete animations. williamr@2: * Calls @c CancelAnimation(). williamr@2: */ williamr@2: void Reset(); williamr@2: williamr@2: /** williamr@2: * Updates the image according to the current skin. williamr@2: */ williamr@2: void CreateDefaultImageL(); williamr@2: williamr@2: public: williamr@2: IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent); williamr@2: williamr@2: public: williamr@2: /** williamr@2: * Manage indexes into LAF tables williamr@2: * williamr@2: * NP stands for "Note Popup" williamr@2: * williamr@2: * WNP stands for "Waiting/progress Note Popup" williamr@2: * williamr@2: * NWIP stands for "Note With Image Popup" williamr@2: */ williamr@2: class TIndex williamr@2: { williamr@2: public: williamr@2: williamr@2: /** williamr@2: * C++ default constructor. williamr@2: * @param aNumberOfLines Number of lines. williamr@2: * @param aHasNti Determines whether or not there is a number type williamr@2: * indication (NTI). williamr@2: * @param aImageSize Image size. williamr@2: */ williamr@2: TIndex(TInt aNumberOfLines, williamr@2: TBool aHasNti = EFalse, williamr@2: TSize aImageSize = TSize(0,0)); williamr@2: williamr@2: public: williamr@2: williamr@2: /** williamr@2: * Returns number of lines. williamr@2: * @return Number of lines. williamr@2: */ williamr@2: TInt Lines() const; williamr@2: williamr@2: public: williamr@2: williamr@2: /** williamr@2: * Return index into table "Waiting/progress Note Popup Window williamr@2: * Texts Line 1". Index depends on the number of text lines and williamr@2: * whether or not there is a number type indication (NTI). See williamr@2: * table in *.lay and LAF specs for working out indexes. williamr@2: * @param aLineNum Line number. williamr@2: * @return Index into table "Waiting/progress Note Popup Window williamr@2: * Texts Line 1". williamr@2: */ williamr@2: TInt WNPWindowTextsLine1(TInt aLineNum) const; williamr@2: williamr@2: /** williamr@2: * Return Left index into table "Note With Image Popup Window williamr@2: * Texts Line 1". Index depends on number of text lines, whether or williamr@2: * not there is a number type indication (NTI). See table in *.lay williamr@2: * and LAF specs for working out indexes. williamr@2: * @param aLineNum Line number. williamr@2: * @return Left index into table "Note With Image Popup Window williamr@2: * Texts Line 1". williamr@2: */ williamr@2: TInt NWIPWindowTextsLine1L(TInt aLineNum) const; williamr@2: williamr@2: /** williamr@2: * Return Right index into table "Note With Image Popup Window williamr@2: * Texts Line 1". Index depends on number of text lines and image williamr@2: * size. See table in *.lay and LAF specs for working out indexes. williamr@2: * williamr@2: * Table has 3 dimensions:- williamr@2: * - Dimension 1 is the line number williamr@2: * - Dimension 2 is the image width williamr@2: * - Dimension 3 is the image height williamr@2: * williamr@2: * @param aLineNum Line number. williamr@2: * @return Right index into table "Note With Image Popup Window williamr@2: * Texts Line 1". williamr@2: */ williamr@2: TInt NWIPWindowTextsLine1R(TInt aLineNum) const; williamr@2: williamr@2: /** williamr@2: * Return Bottom index into table "Note With Image Popup Window williamr@2: * Texts Line 1". Index is the same as the number of text lines williamr@2: * minus one. See table in *.lay and LAF specs for working out williamr@2: * indexes. williamr@2: * @param aLineNum Line number. williamr@2: * @return Bottom index into table "Note With Image Popup Window williamr@2: * Texts Line 1". williamr@2: */ williamr@2: TInt NWIPWindowTextsLine1B(TInt aLineNum) const; williamr@2: williamr@2: /** williamr@2: * Return Width index into table "Note With Image Popup Window williamr@2: * Texts Line 1". Index depends on number of text lines, whether or williamr@2: * not there is a number type indication (NTI) and image size. See williamr@2: * table in *.lay and LAF specs for working out indexes. williamr@2: * williamr@2: * Table has 4 dimensions:- williamr@2: * - Dimension 1 indicates the presence of an NTI(index 0 = NO NTI, williamr@2: * index 1 = NTI) williamr@2: * - Dimension 2 is the line number williamr@2: * - Dimension 3 is the image width williamr@2: * - Dimension 4 is the image height williamr@2: * williamr@2: * @param aLineNum Line number. williamr@2: * @return Width index into table "Note With Image Popup Window williamr@2: * Texts Line 1". williamr@2: */ williamr@2: TInt NWIPWindowTextsLine1W(TInt aLineNum) const; williamr@2: williamr@2: /** williamr@2: * Return indexes for table @c AKN_LAYOUT_WINDOW_popup_note_window. williamr@2: * If there are 0-2 lines the index is 0. If there are 3 lines the williamr@2: * index is 1, if there are 4 or more lines the index is 2. williamr@2: * @return Indexes for table @c AKN_LAYOUT_WINDOW_popup_note_window. williamr@2: */ williamr@2: TInt PopupNoteWindow() const; williamr@2: williamr@2: /** williamr@2: * Return indexes for table williamr@2: * @c AKN_LAYOUT_WINDOW_popup_note_wait_window. williamr@2: * If there are 0-2 lines the index is 0. If there are 3 lines the williamr@2: * index is 1, if there are 4 lines the index is 2. williamr@2: * @return Indexes for table williamr@2: * @c AKN_LAYOUT_WINDOW_popup_note_wait_window. williamr@2: */ williamr@2: TInt PopupNoteWaitWindow() const; williamr@2: williamr@2: private: williamr@2: void SelfTest() const; williamr@2: TInt ImageWidthIndex() const; williamr@2: TInt ImageHeightIndex() const; williamr@2: TInt HasNtiIndex() const; williamr@2: williamr@2: private: williamr@2: TInt iNumberOfLines; williamr@2: TBool iHasNti; williamr@2: TSize iImageSize; williamr@2: }; williamr@2: williamr@2: private: williamr@2: //COECONTROL METHODS williamr@2: void Draw(const TRect& aRect) const; williamr@2: void SizeChanged(); williamr@2: void DoLayout(); williamr@2: TInt CountComponentControls() const; williamr@2: CCoeControl* ComponentControl(TInt anIndex) const; williamr@2: private: williamr@2: /** williamr@2: * From CAknControl williamr@2: */ williamr@2: IMPORT_C void* ExtensionInterface( TUid aInterface ); williamr@2: private: williamr@2: //LAYOUT METHODS williamr@2: TInt NumberTypeIndicationIndex() const; williamr@2: TInt ImageWidthIndex() const; williamr@2: williamr@2: TInt AnimationIndex(); williamr@2: void AnimationNoteLayout(); williamr@2: williamr@2: //Layout for general notes williamr@2: void GeneralNoteLayout(); williamr@2: void GeneralNoteLabelLayout(); williamr@2: void GeneralNoteIconLayout(); williamr@2: williamr@2: //Layout for progress and wait notes williamr@2: void ProgressNoteLayout(); williamr@2: void ProgressNoteLabelLayout(); williamr@2: void ProgressNoteProgressBarLayout(); williamr@2: void ProgressNoteIconLayout(); williamr@2: void ProgressNoteNumberTypeIndicationLayout(); williamr@2: williamr@2: //Layout for image notes williamr@2: void ImageNoteLayout(); williamr@2: void ImageNoteLabelLayout(); williamr@2: void ImageNoteImageLayout(); williamr@2: void ImageNoteShadowLayout(); williamr@2: void ImageNoteNumberTypeIndicationLayout(); williamr@2: williamr@2: TAknWindowLineLayout GetImageLayout(const TSize& aSize); williamr@2: TAknWindowLineLayout GetImageShadowLayout(const TSize& aSize); williamr@2: williamr@2: TRect LayoutRect() const; williamr@2: void SetLineWidthsL(); williamr@2: williamr@2: williamr@2: void ReduceImageIfNeeded(); williamr@2: williamr@2: void ParseTextL(); williamr@2: williamr@2: private: williamr@2: CAknTextControl* TextControl() const; williamr@2: williamr@2: CEikImage* Image() const; williamr@2: CEikImage* Icon() const; williamr@2: williamr@2: CEikProgressInfo* ProgressBar() const; williamr@2: williamr@2: CAknProgressTimer* Timer() const; williamr@2: CAknBitmapAnimation* Animation() const; williamr@2: williamr@2: TBitFlags& Flags() const; williamr@2: williamr@2: private: williamr@2: TInt iNoteLayout; williamr@2: TAknLayoutRect iShadowRect; williamr@2: TBool iImageHasShadow; williamr@2: williamr@2: CAknNoteAttributes* iAttributes; williamr@2: CArrayFixFlat* iLineWidths; williamr@2: williamr@2: public: williamr@2: /** williamr@2: * @deprecated - use SetTextL() method. williamr@2: * @param aText aText string to set. williamr@2: */ williamr@2: williamr@2: IMPORT_C void SetDynamicTextL(const TDesC& aText); williamr@2: williamr@2: /** williamr@2: * @deprecated - use @c SetTextL(). williamr@2: */ williamr@2: IMPORT_C void UpdateAndFormatLabelsL(const TDesC& aLabels); williamr@2: williamr@2: /** williamr@2: * @deprecated - use @c SetTextL(). williamr@2: */ williamr@2: IMPORT_C void UpdateLabelsL(const TDesC& aLabel1, williamr@2: const TDesC& aLabel2=KNullDesC, williamr@2: const TDesC& aLabel3=KNullDesC); williamr@2: /** williamr@2: * @deprecated - use @c SetTextL(). williamr@2: */ williamr@2: IMPORT_C void UpdateLabels(const TDesC& aLabel1, williamr@2: const TDesC& aLabel2=KNullDesC, williamr@2: const TDesC& aLabel3=KNullDesC); williamr@2: williamr@2: /** williamr@2: * @deprecated - label length is taken care of already. williamr@2: * williamr@2: * Don't use this method anymore. Empty implementation. williamr@2: */ williamr@2: IMPORT_C void SetLabelReserveLengthL(TInt aLength1=0, williamr@2: TInt aLength2=0, williamr@2: TInt aLength3=0); williamr@2: williamr@2: protected: // from MObjectProvider williamr@2: williamr@2: /** williamr@2: * From @c MObjectProvider. Gets an (@c MAknsControlContext) object whose williamr@2: * type is encapsulated by the specified @c TTypeUid object. Calls williamr@2: * @c SupplyMopObject(TTypeUid aId, CEikButtonGroupContainer* iCba, williamr@2: * CEikMenuBar* iMenu). williamr@2: * @since Series 60 2.0 williamr@2: * @param aId Encapsulates the UID that identifies the type of object williamr@2: * required. williamr@2: * @return Pointer to the @c MAknsControlContext object provided. Note that williamr@2: * the pointer may be @c NULL. williamr@2: */ williamr@2: IMPORT_C TTypeUid::Ptr MopSupplyObject(TTypeUid aId); williamr@2: williamr@2: public: // new methods williamr@2: williamr@2: /** williamr@2: * Sets up background rectangle context. williamr@2: * @since Series 60 2.1 williamr@2: * @param aRect Rectangle position to layout the outer and the inner williamr@2: * rectangles of the frame. williamr@2: * @param aPos Relative coordinates of parent position in screen. williamr@2: * @param aOwnerNotDialog @c ETrue if the owner is non-dialog control. williamr@2: */ williamr@2: IMPORT_C void SetBgRect(const TRect& aRect, williamr@2: const TPoint& aPos, williamr@2: TBool aOwnerNotDialog = EFalse); williamr@2: williamr@2: /** williamr@2: * @return note layout type williamr@2: * see @c Avkon.hrh for Note dialog constants williamr@2: */ williamr@2: TInt NoteLayout() const; williamr@2: }; williamr@2: williamr@2: #endif // AKNNOTECONTROL_H