uiacceltk/hitchcock/coretoolkit/src/HuiBrush.cpp
changeset 0 15bf7259bb7c
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c) 2006-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:   Implementation of CHuiBrush. Brushes augment visuals with 
       
    15 *                graphical effects.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #include "uiacceltk/HuiBrush.h"
       
    22 #include "uiacceltk/HuiGc.h"
       
    23 #include "uiacceltk/HuiVisual.h"
       
    24 #include "uiacceltk/HuiStatic.h"
       
    25 #include "uiacceltk/HuiProbe.h"
       
    26 #include "uiacceltk/HuiUtil.h"
       
    27 
       
    28 
       
    29 EXPORT_C CHuiBrush::CHuiBrush()
       
    30         : iOpacity(1.0f), iEnabled(ETrue), iChanged(EFalse) 
       
    31     {
       
    32     HUI_PROBE_ASSOCIATE_WITH_CURRENT_SESSION
       
    33     HUI_PROBE_REPORT_CONSTRUCTED
       
    34     }
       
    35 
       
    36 
       
    37 EXPORT_C CHuiBrush::~CHuiBrush()
       
    38     {
       
    39     iGuideVisual = NULL;
       
    40     
       
    41     HUI_PROBE_REPORT_DESTRUCTED
       
    42     }
       
    43     
       
    44     
       
    45 EXPORT_C void CHuiBrush::ExpandVisualRect(TRect& /*aRect*/) const
       
    46     {
       
    47     // The brush does not expand the rectangle by default.
       
    48     }
       
    49     
       
    50     
       
    51 EXPORT_C void CHuiBrush::SetChanged()
       
    52     {
       
    53     iChanged = ETrue;
       
    54     }
       
    55 
       
    56 
       
    57 EXPORT_C TBool CHuiBrush::Changed() const
       
    58     {
       
    59     if ( iChanged )
       
    60         {
       
    61         return ETrue;
       
    62         }
       
    63     
       
    64     return iOpacity.Changed();
       
    65     }
       
    66     
       
    67 EXPORT_C void CHuiBrush::ClearChanged()
       
    68     {
       
    69     iChanged = EFalse;
       
    70     iOpacity.ClearChanged();
       
    71     }
       
    72 
       
    73 
       
    74 EXPORT_C void CHuiBrush::SetClipToVisual(TBool aClipToVisual)
       
    75     {
       
    76     iClipToVisual = aClipToVisual;
       
    77     }
       
    78     
       
    79     
       
    80 EXPORT_C TBool CHuiBrush::ClipToVisual() const
       
    81     {
       
    82     return iClipToVisual;
       
    83     }
       
    84     
       
    85 
       
    86 EXPORT_C void CHuiBrush::SetLayer(THuiBrushLayer aLayer)
       
    87     {
       
    88     iLayer = aLayer;
       
    89     }
       
    90     
       
    91 
       
    92 EXPORT_C THuiBrushLayer CHuiBrush::Layer() const
       
    93     {
       
    94     return iLayer;
       
    95     }
       
    96     
       
    97     
       
    98 EXPORT_C void CHuiBrush::BeginDraw(CHuiGc& aGc, const MHuiBrushGuide& aGuide) const
       
    99     {
       
   100     if(iClipToVisual)
       
   101         {
       
   102         // Visual content clipping is affected by transformation.
       
   103         aGc.PushClip();
       
   104         aGc.Clip(aGuide.BrushRect());
       
   105         }
       
   106     }
       
   107 
       
   108 
       
   109 EXPORT_C void CHuiBrush::Draw(CHuiGc& /*aGc*/, const MHuiBrushGuide& /*aGuide*/) const
       
   110     {
       
   111     }
       
   112 
       
   113 
       
   114 EXPORT_C void CHuiBrush::EndDraw(CHuiGc& aGc, const MHuiBrushGuide& /*aGuide*/) const
       
   115     {
       
   116     if(iClipToVisual)
       
   117         {
       
   118         // Visual content clipping is affected by transformation.
       
   119         aGc.PopClip();
       
   120         }
       
   121 
       
   122     iChanged = EFalse;
       
   123     }
       
   124 
       
   125 
       
   126 HUI_SESSION_OBJECT_IMPL_EXPORT(CHuiBrush, ETypeBrush)
       
   127 
       
   128 EXPORT_C void CHuiBrush::BrushExtension(const TUid& /*aExtensionUid*/, TAny** /*aExtensionParameters*/)
       
   129     {
       
   130     }
       
   131     
       
   132 void CHuiBrush::ActivateBrushGuide(const CHuiVisual* aNewGuide) const
       
   133     {
       
   134     iGuideVisual = const_cast<CHuiVisual*>(aNewGuide);     
       
   135     }
       
   136 
       
   137 CHuiVisual* CHuiBrush::BrushGuide() const
       
   138     {
       
   139     return iGuideVisual;     
       
   140     }
       
   141