emailuis/uicomponents/src/fsalfwatermark.cpp
changeset 0 8466d47a6819
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     1 /*
       
     2 * Copyright (c) 2008 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:  Alf Watermark object
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 //<cmail> SF
       
    20 #include "emailtrace.h"
       
    21 #include <alf/alfimage.h>
       
    22 #include <alf/alfimagebrush.h>
       
    23 #include <alf/alfbrusharray.h>
       
    24 //</cmail>
       
    25 #include "fsalfwatermark.h"
       
    26 
       
    27 // ---------------------------------------------------------------------------
       
    28 // Factory method.
       
    29 // ---------------------------------------------------------------------------
       
    30 //
       
    31 CFsAlfWatermark* CFsAlfWatermark::NewL( CAlfControl& aParentControl, 
       
    32             CAlfLayout& aParentLayout )
       
    33     {
       
    34     FUNC_LOG;
       
    35     CFsAlfWatermark* self = new (ELeave) CFsAlfWatermark();
       
    36     CleanupStack::PushL(self);
       
    37     self->ConstructL(aParentControl, aParentLayout);
       
    38     CleanupStack::Pop(self);
       
    39     return self;
       
    40     }
       
    41 
       
    42 
       
    43 // ---------------------------------------------------------------------------
       
    44 // C++ destructor.
       
    45 // ---------------------------------------------------------------------------
       
    46 //
       
    47 CFsAlfWatermark::~CFsAlfWatermark()
       
    48     {
       
    49     FUNC_LOG;
       
    50     if ( iWatermarkLayout )
       
    51     	{
       
    52 	    iWatermarkLayout->RemoveAndDestroyAllD();
       
    53     	}
       
    54     }
       
    55 
       
    56 
       
    57 // ---------------------------------------------------------------------------
       
    58 // Gets reference to the position of watermark.
       
    59 // ---------------------------------------------------------------------------
       
    60 //
       
    61 TAlfTimedPoint CFsAlfWatermark::Pos()
       
    62     {
       
    63     FUNC_LOG;
       
    64     return iWatermarkLayout->Pos();
       
    65     }
       
    66     
       
    67 
       
    68 // ---------------------------------------------------------------------------
       
    69 // Gets reference to the size of watermark.
       
    70 // ---------------------------------------------------------------------------
       
    71 //
       
    72 TAlfTimedPoint CFsAlfWatermark::Size()
       
    73     {
       
    74     FUNC_LOG;
       
    75     return iWatermarkLayout->Size();
       
    76     }
       
    77     
       
    78 
       
    79 // ---------------------------------------------------------------------------
       
    80 // Gets reference to the opacity of watermark.
       
    81 // ---------------------------------------------------------------------------
       
    82 //
       
    83 TAlfTimedValue& CFsAlfWatermark::Opacity()
       
    84     {
       
    85     FUNC_LOG;
       
    86     return const_cast<TAlfTimedValue&>(iWatermarkLayout->Opacity());
       
    87     }
       
    88     
       
    89 
       
    90 // ---------------------------------------------------------------------------
       
    91 // Sets the texture for watermark.
       
    92 // ---------------------------------------------------------------------------
       
    93 //
       
    94 // <cmail>
       
    95 void CFsAlfWatermark::SetWatermarkTextureL( CAlfTexture& aTexture )
       
    96 // </cmail>
       
    97     {
       
    98     FUNC_LOG;
       
    99 
       
   100     if ( iWatermarkLayout->Brushes()->Count() == 0 )
       
   101         {
       
   102     	CAlfImageBrush* brush = CAlfImageBrush::NewL(iWatermarkLayout->Env(),TAlfImage(aTexture));
       
   103     	iWatermarkLayout->Brushes()->AppendL(brush,EAlfHasOwnership);
       
   104         }
       
   105     else
       
   106         {
       
   107         CAlfImageBrush& brush = 
       
   108         static_cast<CAlfImageBrush&>(iWatermarkLayout->Brushes()->At(0));
       
   109     	brush.SetImage(TAlfImage(aTexture));
       
   110         }
       
   111     	
       
   112     }
       
   113     
       
   114 
       
   115 // ---------------------------------------------------------------------------
       
   116 // 2nd phase constructor.
       
   117 // ---------------------------------------------------------------------------
       
   118 //
       
   119 void CFsAlfWatermark::ConstructL( CAlfControl& aParentControl, 
       
   120         CAlfLayout& aParentLayout )
       
   121     {
       
   122     FUNC_LOG;
       
   123     iWatermarkLayout = CAlfDeckLayout::AddNewL(aParentControl,&aParentLayout);
       
   124     aParentLayout.MoveVisualToBack( *iWatermarkLayout );
       
   125     iWatermarkLayout->SetFlag(EAlfVisualFlagManualLayout);
       
   126     iWatermarkLayout->EnableBrushesL();
       
   127     }
       
   128 
       
   129 
       
   130 // ---------------------------------------------------------------------------
       
   131 // C++ constructor.
       
   132 // ---------------------------------------------------------------------------
       
   133 //
       
   134 CFsAlfWatermark::CFsAlfWatermark()
       
   135     :iWatermarkLayout(NULL),
       
   136     iWatermarkTexture(NULL)
       
   137     {
       
   138     FUNC_LOG;
       
   139     
       
   140     }
       
   141