uiacceltk/hitchcock/Client/src/alfdropshadowbrush.cpp
changeset 0 15bf7259bb7c
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c) 2007 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:   Drop shadow brush
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "alf/alfdropshadowbrush.h"
       
    21 #include "alf/alfconstants.h"
       
    22 #include "alf/alfgencomponent.h"
       
    23 #include "alflogger.h"
       
    24 
       
    25 #include <uiacceltk/HuiUtil.h>
       
    26 
       
    27 struct CAlfDropShadowBrush::TDropShadowPrivateData
       
    28     {
       
    29     TAlfTimedValue iSoftness;
       
    30     TAlfTimedValue iDepth;
       
    31     };
       
    32 
       
    33 // ======== MEMBER FUNCTIONS ========
       
    34 
       
    35 
       
    36 // ---------------------------------------------------------------------------
       
    37 // Constructor
       
    38 // ---------------------------------------------------------------------------
       
    39 //
       
    40 CAlfDropShadowBrush::CAlfDropShadowBrush()
       
    41     {
       
    42     }
       
    43 
       
    44 // ---------------------------------------------------------------------------
       
    45 // 2nd phase constructor (with metric depth)
       
    46 // ---------------------------------------------------------------------------
       
    47 //
       
    48 void CAlfDropShadowBrush::ConstructL( CAlfEnv& aEnv, const TAlfMetric&  aDepth )
       
    49     {
       
    50     TPckgC<TAlfMetric> paramsPckg( aDepth );
       
    51     
       
    52     CAlfBrush::ConstructL(
       
    53         aEnv,
       
    54         EAlfDropShadowBrushCreateMetric,
       
    55         0,
       
    56         paramsPckg
       
    57         );
       
    58         
       
    59     iDropShadowData = new (ELeave) TDropShadowPrivateData;
       
    60     }
       
    61 
       
    62 // ---------------------------------------------------------------------------
       
    63 // 2-phased constructor
       
    64 // ---------------------------------------------------------------------------
       
    65 //    
       
    66 EXPORT_C CAlfDropShadowBrush* CAlfDropShadowBrush::NewL(
       
    67         CAlfEnv& aEnv,
       
    68         const TAlfMetric&  aDepth )
       
    69     {
       
    70     CAlfDropShadowBrush* self = NewLC( aEnv, aDepth );
       
    71     CleanupStack::Pop( self);
       
    72     return self;
       
    73     }
       
    74 
       
    75 // ---------------------------------------------------------------------------
       
    76 // 2-phased constructor with the object left on the cleanup stack
       
    77 // ---------------------------------------------------------------------------
       
    78 //    
       
    79 EXPORT_C CAlfDropShadowBrush* CAlfDropShadowBrush::NewLC(
       
    80         CAlfEnv& aEnv,
       
    81         const TAlfMetric&  aDepth )
       
    82     {
       
    83     CAlfDropShadowBrush* self = new (ELeave) CAlfDropShadowBrush;
       
    84     CleanupStack::PushL( self );
       
    85     self->ConstructL( aEnv, aDepth );
       
    86     return self;
       
    87     }
       
    88 
       
    89 // ---------------------------------------------------------------------------
       
    90 // 2nd phase constructor (with pixel depth)
       
    91 // ---------------------------------------------------------------------------
       
    92 //    
       
    93 void CAlfDropShadowBrush::ConstructL( CAlfEnv& aEnv, TInt aDepth )
       
    94     {
       
    95     TPckgC<TInt> paramsPckg( aDepth );
       
    96     
       
    97     CAlfBrush::ConstructL(
       
    98         aEnv,
       
    99         EAlfDropShadowBrushCreate,
       
   100         0,
       
   101         paramsPckg
       
   102         );
       
   103         
       
   104     iDropShadowData = new (ELeave) TDropShadowPrivateData;
       
   105     }
       
   106 
       
   107 // ---------------------------------------------------------------------------
       
   108 // 2-phased constructor
       
   109 // ---------------------------------------------------------------------------
       
   110 //    
       
   111 EXPORT_C CAlfDropShadowBrush* CAlfDropShadowBrush::NewL(
       
   112         CAlfEnv& aEnv,
       
   113         TInt aDepth )
       
   114     {
       
   115     CAlfDropShadowBrush* self = NewLC( aEnv, aDepth );
       
   116     CleanupStack::Pop( self);
       
   117     return self;
       
   118     }
       
   119 
       
   120 // ---------------------------------------------------------------------------
       
   121 // 2-phased constructor with the object left on the cleanup stack
       
   122 // ---------------------------------------------------------------------------
       
   123 //    
       
   124 EXPORT_C CAlfDropShadowBrush* CAlfDropShadowBrush::NewLC(
       
   125         CAlfEnv& aEnv,
       
   126         TInt aDepth )
       
   127     {
       
   128     CAlfDropShadowBrush* self = new (ELeave) CAlfDropShadowBrush;
       
   129     CleanupStack::PushL( self );
       
   130     self->ConstructL( aEnv, aDepth );
       
   131     return self;
       
   132     }
       
   133 
       
   134 // ---------------------------------------------------------------------------
       
   135 // destructor
       
   136 // ---------------------------------------------------------------------------
       
   137 //    
       
   138 CAlfDropShadowBrush::~CAlfDropShadowBrush()
       
   139     {
       
   140     delete iDropShadowData;
       
   141     }
       
   142 
       
   143 // ---------------------------------------------------------------------------
       
   144 // Softness getter
       
   145 // ---------------------------------------------------------------------------
       
   146 //    
       
   147 EXPORT_C const TAlfTimedValue& CAlfDropShadowBrush::Softness() const
       
   148     {
       
   149     TPckg<TAlfTimedValue> buf(iDropShadowData->iSoftness);
       
   150     TInt err = Comms()->DoSynchronousCmd( EAlfDropShadowBrushGetSoftness, buf, buf);
       
   151 
       
   152     if ( err != KErrNone )
       
   153         {
       
   154         __ALFLOGSTRING1( "CAlfDropShadowBrush::Softness panic error %d", err )
       
   155         USER_INVARIANT();
       
   156         }
       
   157     
       
   158     return iDropShadowData->iSoftness;
       
   159     }
       
   160 
       
   161 // ---------------------------------------------------------------------------
       
   162 // Softness setter
       
   163 // ---------------------------------------------------------------------------
       
   164 //    
       
   165 EXPORT_C void CAlfDropShadowBrush::SetSoftness( const TAlfTimedValue& aSoftness )
       
   166     {
       
   167     TPckgC<TAlfTimedValue> buf(aSoftness);
       
   168 
       
   169     TInt err = Comms()->DoCmdNoReply( EAlfDropShadowBrushSetSoftness, buf );
       
   170 
       
   171     if ( err == KErrNone )
       
   172         {
       
   173         iDropShadowData->iSoftness = aSoftness;
       
   174         }
       
   175     else
       
   176         {
       
   177         __ALFLOGSTRING1( "CAlfDropShadowBrush::SetSoftness panic error %d", err )
       
   178         USER_INVARIANT();
       
   179         }
       
   180     }
       
   181 
       
   182 // ---------------------------------------------------------------------------
       
   183 // Depth getter
       
   184 // ---------------------------------------------------------------------------
       
   185 //    
       
   186 EXPORT_C const TAlfTimedValue& CAlfDropShadowBrush::Depth() const
       
   187     {
       
   188     TPckg<TAlfTimedValue> buf(iDropShadowData->iDepth);
       
   189     TInt err = Comms()->DoSynchronousCmd( EAlfDropShadowBrushGetDepth, buf, buf);
       
   190 
       
   191     if ( err != KErrNone )
       
   192         {
       
   193         __ALFLOGSTRING1( "CAlfDropShadowBrush::Depth panic error %d", err )
       
   194         USER_INVARIANT();
       
   195         }
       
   196     
       
   197     return iDropShadowData->iDepth;
       
   198     }
       
   199 
       
   200 // ---------------------------------------------------------------------------
       
   201 // Depth setter
       
   202 // ---------------------------------------------------------------------------
       
   203 //    
       
   204 EXPORT_C void CAlfDropShadowBrush::SetDepth( const TAlfTimedValue& aDepth )
       
   205     {
       
   206     TPckgC<TAlfTimedValue> buf(aDepth);
       
   207 
       
   208     TInt err = Comms()->DoCmdNoReply( EAlfDropShadowBrushSetDepth, buf );
       
   209 
       
   210     if ( err == KErrNone )
       
   211         {
       
   212         iDropShadowData->iDepth = aDepth;
       
   213         }
       
   214     else
       
   215         {
       
   216         __ALFLOGSTRING1( "CAlfDropShadowBrush::SetDepth panic error %d", err )
       
   217         USER_INVARIANT();
       
   218         }
       
   219     }
       
   220     
       
   221 // ---------------------------------------------------------------------------
       
   222 // Softness setter
       
   223 // ---------------------------------------------------------------------------
       
   224 //
       
   225 EXPORT_C void CAlfDropShadowBrush::SetSoftness(const TAlfMetric& aSoftness)
       
   226     {
       
   227     TPckgC<TAlfMetric> buf(aSoftness);
       
   228 
       
   229     TInt err = Comms()->DoCmdNoReply( EAlfDropShadowBrushSetSoftnessMetric, buf );
       
   230 
       
   231     if ( err != KErrNone )
       
   232         {
       
   233         __ALFLOGSTRING1( "CAlfDropShadowBrush::SetSoftness panic error %d", err )
       
   234         USER_INVARIANT();
       
   235         }        
       
   236     }
       
   237 
       
   238 // ---------------------------------------------------------------------------
       
   239 // Depth setter
       
   240 // ---------------------------------------------------------------------------
       
   241 //
       
   242 EXPORT_C void CAlfDropShadowBrush::SetDepth(const TAlfMetric& aDepth)
       
   243     {
       
   244     TPckgC<TAlfMetric> buf(aDepth);
       
   245 
       
   246     TInt err = Comms()->DoCmdNoReply( EAlfDropShadowBrushSetDepthMetric, buf );
       
   247 
       
   248     if ( err != KErrNone )
       
   249         {
       
   250         __ALFLOGSTRING1( "CAlfDropShadowBrush::SetDepth panic error %d", err )
       
   251         USER_INVARIANT();
       
   252         }        
       
   253     }
       
   254 
       
   255 // ---------------------------------------------------------------------------
       
   256 // Color setter
       
   257 // ---------------------------------------------------------------------------
       
   258 //
       
   259 EXPORT_C void CAlfDropShadowBrush::SetColor(const TRgb& aColor)
       
   260     {
       
   261     TPckgC<TRgb> buf(aColor);
       
   262 
       
   263     TInt err = Comms()->DoCmdNoReply( EAlfDropShadowBrushSetColor, buf );
       
   264 
       
   265     if ( err != KErrNone )
       
   266         {
       
   267         __ALFLOGSTRING1( "CAlfDropShadowBrush::SetColor panic error %d", err )
       
   268         USER_INVARIANT();
       
   269         }        
       
   270         
       
   271     }