messagingappbase/msgeditor/mediacontrolinc/MsgMediaControl.h
changeset 79 2981cb3aa489
parent 0 72b543305e3a
equal deleted inserted replaced
25:84d9eb65b26f 79:2981cb3aa489
       
     1 /*
       
     2 * Copyright (c) 2005-2006 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 *       Message Editor Base Media control.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #ifndef MSGMEDIACONTROL_H
       
    22 #define MSGMEDIACONTROL_H
       
    23 
       
    24 // INCLUDES
       
    25 #include <AknsItemID.h>
       
    26 
       
    27 #include <MsgBaseControl.h>         // for CMsgBaseControl
       
    28 #include <MsgBaseControlObserver.h>
       
    29 #include <msgasynccontrolobserver.h>
       
    30 #include <msgasynccontrol.h>
       
    31 #include <MsgEditor.hrh>            // NotifyViewEvent
       
    32 #include <caf/caftypes.h>               // KMaxCafUniqueId
       
    33 
       
    34 // CONSTANTS
       
    35 
       
    36 // MACROS
       
    37 
       
    38 // DATA TYPES
       
    39 
       
    40 // FUNCTION PROTOTYPES
       
    41 
       
    42 // FORWARD DECLARATIONS
       
    43 
       
    44 class CMsgFrameControl;
       
    45 class CMsgIconControl;
       
    46 class TMMSource;
       
    47 class TMMFileHandleSource;
       
    48 class TAknsItemID;
       
    49 class CMsgMediaControl;
       
    50 class CAknBitmapAnimation;
       
    51 
       
    52 // DATA TYPES
       
    53 
       
    54 // CLASS DECLARATION
       
    55 
       
    56 // ==========================================================
       
    57 
       
    58 /**
       
    59 * Message Editor Base control handling images in MMS
       
    60 */
       
    61 class CMsgMediaControl : public CMsgBaseControl,
       
    62                          public MCoeControlHitTest,
       
    63                          public MMsgAsyncControl
       
    64     {
       
    65     public:
       
    66     
       
    67         /**
       
    68         * Destructor.
       
    69         */
       
    70         virtual ~CMsgMediaControl();
       
    71 
       
    72         /**
       
    73         * Start playing media. Method does not start animation. 
       
    74         */         
       
    75         virtual void PlayL() = 0;
       
    76 
       
    77         /**
       
    78         * Stops playing media. 
       
    79         */         
       
    80         virtual void Stop() = 0;
       
    81         
       
    82         /**
       
    83         * Pauses playing media. 
       
    84         */         
       
    85         virtual void PauseL() = 0;
       
    86              
       
    87         /**
       
    88         * Return state
       
    89         */
       
    90         TMsgAsyncControlState State() const;
       
    91 
       
    92         /**
       
    93         * Return error code.
       
    94         */
       
    95         TInt Error() const;
       
    96         
       
    97         /**
       
    98         * Sets unique content ID used when loading/reloading media.
       
    99         * Default unique ID is used if not set.
       
   100         */
       
   101         inline void SetUniqueContentIdL( const TDesC& aUniqueId );
       
   102         
       
   103         /**
       
   104         * Returns current unique content ID.
       
   105         */
       
   106         inline const TDesC& UniqueContentId() const;
       
   107         
       
   108         /**
       
   109         *
       
   110         */
       
   111         void AddObserverL( MMsgAsyncControlObserver& aObserver );
       
   112         
       
   113         /**
       
   114         *
       
   115         */
       
   116         void RemoveObserver( MMsgAsyncControlObserver& aObserver );
       
   117         
       
   118         /**
       
   119         * Prepares control for viewing.
       
   120         * From CMsgBaseControl
       
   121         */
       
   122         void NotifyViewEvent( TMsgViewEvent aEvent, TInt aParam );
       
   123         
       
   124         /**
       
   125         * Loads icon from specified file using given bitmap id and mask id. 
       
   126         *
       
   127         * @param aFileName      File to load icons from
       
   128         * @param aId            Item Id.
       
   129         * @param aFileBitmapId  ID of the icon bitmap. KErrNotFound accepted, in which
       
   130         *                       case nothing is loaded
       
   131         * @param aFileMaskId    ID of the icon mask. -1 (default) if no mask needed.
       
   132         *
       
   133         * @return ETrue:  icon has changed.
       
   134         *         EFalse: icon has not changed.
       
   135         */
       
   136         IMPORT_C TBool LoadIconL( const TDesC& aFileName,                                   
       
   137                                   const TAknsItemID& aId,
       
   138                                   const TInt aFileBitmapId,
       
   139                                   const TInt aFileMaskId = -1 );
       
   140         
       
   141         /**
       
   142         * Sets icon to specified size.
       
   143         *
       
   144         * @param aNewSize  New size.
       
   145         */
       
   146         IMPORT_C void SetIconSizeL( const TSize& aNewSize );
       
   147         
       
   148         /**
       
   149         * Sets icon visible/invisible.
       
   150         *
       
   151         * @param aVisibility ETrue sets icon visible
       
   152                              EFalse sets icon invisible
       
   153         */
       
   154         IMPORT_C void SetIconVisible( TBool aVisibility );
       
   155         
       
   156         /**
       
   157         * Sets animation control. Ownership transferred.
       
   158         *
       
   159         * @param aAnimationControl New animation control. Setting animation control
       
   160         *                          to NULL will remove animation.
       
   161         */
       
   162         IMPORT_C void SetAnimationL( CAknBitmapAnimation* aAnimationControl );
       
   163         
       
   164         /**
       
   165         * Sets animation to specified size.
       
   166         *
       
   167         * @param aNewSize  New size.
       
   168         */
       
   169         IMPORT_C void SetAnimationSizeL( const TSize& aNewSize );
       
   170         
       
   171         /**
       
   172         * Sets animation visible/invisible.
       
   173         *
       
   174         * @param aVisibility ETrue sets animation visible
       
   175                              EFalse sets animation invisible
       
   176         */
       
   177         IMPORT_C void SetAnimationVisibleL( TBool aVisibility );
       
   178         
       
   179         /**
       
   180         * Returns the current loaded icon's bitmap id.
       
   181         *
       
   182         * @return Current loaded icon's bitmap id. 
       
   183         *         If icon has not beed loaded returns KErrNotFound.
       
   184         */
       
   185         IMPORT_C TInt IconBitmapId() const;
       
   186         
       
   187         /**
       
   188         * Releases current animation
       
   189         */
       
   190         IMPORT_C void ReleaseAnimation();
       
   191         
       
   192     public: // from CMsgBaseControl
       
   193         
       
   194         /**
       
   195         * Returns the current control rect.
       
   196         * From CMsgBaseControl
       
   197         */
       
   198         TRect CurrentLineRect();
       
   199         
       
   200         /**
       
   201         * Handles clipboard operation.
       
   202         * From CMsgBaseControl
       
   203         */
       
   204         void ClipboardL( TMsgClipboardFunc aFunc );
       
   205         
       
   206         /**
       
   207         * Handles editing operation.
       
   208         * From CMsgBaseControl
       
   209         */
       
   210         void EditL( TMsgEditFunc aFunc );
       
   211         
       
   212         /**
       
   213         * Checks if the focus change up or down is possible and
       
   214         * returns ETrue if it is.
       
   215         * From CMsgBaseControl
       
   216         */
       
   217         TBool IsFocusChangePossible( TMsgFocusDirection aDirection ) const;
       
   218         
       
   219         /**
       
   220         * Checks if the cursor location is on the topmost or downmost position
       
   221         * and returns ETrue if it is.
       
   222         * From CMsgBaseControl
       
   223         */
       
   224         TBool IsCursorLocation( TMsgCursorLocation aLocation ) const;
       
   225         
       
   226         /**
       
   227         * Returns edit permission flags.
       
   228         * From CMsgBaseControl
       
   229         */
       
   230         TUint32 EditPermission() const;
       
   231     
       
   232     public: // From CCoeControl
       
   233 
       
   234         /**
       
   235         * Called when size is changed.
       
   236         * From CMsgBaseControl
       
   237         */
       
   238         void SizeChanged();
       
   239         
       
   240         /**
       
   241         * From CCoeControl,Draw.
       
   242         * @param aRect draw rect
       
   243         */
       
   244         void Draw( const TRect& aRect ) const;
       
   245         
       
   246         /**
       
   247         * Handles resource change events.
       
   248         * From CCoeControl
       
   249         */
       
   250         void HandleResourceChange( TInt aType );
       
   251         
       
   252          /**
       
   253         * From CCoeControl. See coecntrl.h
       
   254         */
       
   255         void HandlePointerEventL( const TPointerEvent& aPointerEvent );
       
   256         
       
   257     public: // from MCoeControlHitTest
       
   258     
       
   259         /**
       
   260         * Evaluates whether control is "hit" by touch event.
       
   261         */
       
   262         TBool HitRegionContains( const TPoint& aPoint, const CCoeControl& aControl ) const;
       
   263             
       
   264     protected: 
       
   265 
       
   266         /**
       
   267         * C++ constructor.
       
   268         */
       
   269         CMsgMediaControl( MMsgBaseControlObserver& aBaseControlObserver,
       
   270                           TMsgControlId aMediaControlId,
       
   271                           TMsgControlType aMediaControlType );
       
   272             
       
   273         /**
       
   274         * Symbian constructor.
       
   275         */
       
   276         void BaseConstructL( const CCoeControl& aParent, MMsgAsyncControlObserver* aObserver );
       
   277         
       
   278         /**
       
   279         * Sets state and calls observer  
       
   280         */
       
   281         inline void SetState( TMsgAsyncControlState aState, 
       
   282                               TBool aDoNotCallObserver = EFalse );
       
   283         
       
   284         /**
       
   285         *
       
   286         */
       
   287         void ResetIconId();
       
   288         
       
   289         /**
       
   290         *
       
   291         */
       
   292         void DoUpdateFocus( TDrawNow aDrawNow );
       
   293         
       
   294         /**
       
   295         * Calculates correct extent for component controls.
       
   296         */
       
   297         void SetComponentControlExtents();
       
   298         
       
   299         /**
       
   300         * Set background frame for animation.
       
   301         */
       
   302         void SetAnimationBackGroundFrameL();
       
   303         
       
   304         /**
       
   305         * Tests whether animation is currently visible.
       
   306         *
       
   307         * @return ETrue     if animation is visible
       
   308         *         EFalse    otherwise.
       
   309         */
       
   310         TBool AnimationVisible() const;
       
   311         
       
   312         /**
       
   313         * Returns visible placeholder (i.e. icon or animation) control.
       
   314         *
       
   315         * @return NULL          if no placeholder is visible
       
   316         *         CCoeControl*  otherwise currently visible placeholder.
       
   317         */
       
   318         CCoeControl* VisiblePlaceholder() const;
       
   319                 
       
   320     protected: // from CMsgBaseControl
       
   321 
       
   322         /**
       
   323         * Prepares for read only or non read only state.
       
   324         * @param aReadOnly
       
   325         */
       
   326         void PrepareForReadOnly( TBool aReadOnly );
       
   327     
       
   328     protected: // from CCoeControl
       
   329         
       
   330         /**
       
   331         * This is called when the focus of the control is changed.
       
   332         * @param aDrawNow
       
   333         */
       
   334         void FocusChanged( TDrawNow aDrawNow );
       
   335         
       
   336         /**
       
   337         * From CCoeControl Return count of controls be included in this component
       
   338         */
       
   339         TInt CountComponentControls() const;
       
   340 
       
   341         /**
       
   342         * From CCoeControl Return pointer to component in question.
       
   343         */
       
   344         CCoeControl* ComponentControl( TInt aIndex ) const;
       
   345         
       
   346     protected: //Data
       
   347 
       
   348         CArrayPtrFlat<MMsgAsyncControlObserver>* iObservers;
       
   349         
       
   350         TMsgAsyncControlState iState;
       
   351         
       
   352         TInt iError;
       
   353         TInt iBaseLine;
       
   354         
       
   355         CMsgIconControl* iIconControl;
       
   356         CMsgFrameControl* iFrame;
       
   357     
       
   358         TBuf<ContentAccess::KMaxCafUniqueId> iUniqueContentId;
       
   359         
       
   360         CAknBitmapAnimation* iAnimation;
       
   361     };
       
   362 
       
   363 
       
   364 #include <msgmediacontrol.inl>
       
   365 
       
   366 #endif // MSGMEDIACONTROL_H