lafagnosticuifoundation/cone/src/COECCNTX.CPP
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <coeccntx.h>
       
    17 
       
    18 
       
    19 //
       
    20 // Class MCoeControlContext
       
    21 //
       
    22 EXPORT_C MCoeControlContext::MCoeControlContext()
       
    23 	{
       
    24 	}
       
    25 
       
    26 /** Activates a graphics context for the specified window.
       
    27 
       
    28 This function is called whenever a control is about to be drawn. Its default 
       
    29 implementation activates the graphics context given by aGc for the window 
       
    30 given by aWindow, and calls PrepareContext(). 
       
    31 
       
    32 This function may be overridden by derived classes.
       
    33 
       
    34 @param aGc The graphics context to activate. When called from CCoeControl::ActivateGc(), 
       
    35 this is the system graphics context.
       
    36 @param aWindow The window for which the graphics context is to be activated. */
       
    37 EXPORT_C void MCoeControlContext::ActivateContext(CWindowGc& aGc,RDrawableWindow& aWindow) const
       
    38 	{
       
    39 	aGc.Activate(aWindow);
       
    40 	PrepareContext(aGc);
       
    41 	}
       
    42 
       
    43 /** Resets the control context. 
       
    44 
       
    45 The default implementation first resets the graphics context given by aGc, 
       
    46 and then calls PrepareContext(). The function may be overridden by derived 
       
    47 classes.
       
    48 
       
    49 @param aGc The graphics context to be reset. */
       
    50 EXPORT_C void MCoeControlContext::ResetContext(CWindowGc& aGc) const
       
    51 	{
       
    52 	aGc.Reset();
       
    53 	PrepareContext(aGc);
       
    54 	}
       
    55 
       
    56 /** Initialises graphics context settings.
       
    57 
       
    58 This function should be implemented by derived classes to initialise the graphics 
       
    59 context, given by aGc, with the required settings. The default implementation 
       
    60 is empty.
       
    61 
       
    62 @param aGc The graphics context to be initialised. */
       
    63 EXPORT_C void MCoeControlContext::PrepareContext(CWindowGc& /*aGc*/) const
       
    64 	{
       
    65 	}
       
    66 
       
    67 EXPORT_C void MCoeControlContext::MCoeControlContext_Reserved1()
       
    68 	{
       
    69 	}
       
    70 
       
    71 EXPORT_C void MCoeControlContext::MCoeControlContext_Reserved2()
       
    72 	{
       
    73 	}
       
    74 //
       
    75 // Class CCoeBrushAndPenContext
       
    76 //
       
    77 
       
    78 CCoeBrushAndPenContext::CCoeBrushAndPenContext()
       
    79 	{}
       
    80 
       
    81 /** Allocates and constructs a new brush and pen graphics context object.
       
    82 
       
    83 @return A pointer to the newly created object */
       
    84 EXPORT_C CCoeBrushAndPenContext* CCoeBrushAndPenContext::NewL()
       
    85 	{
       
    86 	CCoeBrushAndPenContext* self=new(ELeave) CCoeBrushAndPenContext;
       
    87 	return self;
       
    88 	} 
       
    89 
       
    90 /** Prepares the graphics context for drawing the control in its normal state. 
       
    91 
       
    92 The function uses the brush and pen properties which have been set, or uses 
       
    93 a black pen and a black solid brush by default. When a bitmap has been set 
       
    94 a patterned style brush is selected 
       
    95 
       
    96 @param aGc The window graphics context. */
       
    97 EXPORT_C void CCoeBrushAndPenContext::PrepareContext(CWindowGc& aGc) const
       
    98 	{
       
    99 	if (iBitmap)
       
   100 		{
       
   101 		aGc.UseBrushPattern(iBitmap);
       
   102 		aGc.SetBrushStyle(CGraphicsContext::EPatternedBrush);
       
   103 		return;
       
   104 		}
       
   105 	aGc.SetBrushStyle(iBrushStyle);
       
   106 	aGc.SetBrushColor(iBrushColor);
       
   107 	aGc.SetPenColor(iPenColor);
       
   108 	}
       
   109 
       
   110 /** Sets the brush style.
       
   111 
       
   112 @param aBrushStyle The brush style to be used for drawing. */
       
   113 EXPORT_C void CCoeBrushAndPenContext::SetBrushStyle(CWindowGc::TBrushStyle aBrushStyle)
       
   114 	{
       
   115 	iBrushStyle=aBrushStyle;
       
   116 	}
       
   117 
       
   118 /** Sets the brush colour.
       
   119 
       
   120 @param aColor The brush colour. */
       
   121 EXPORT_C void CCoeBrushAndPenContext::SetBrushColor(TRgb aColor)
       
   122 	{
       
   123 	iBrushColor=aColor;
       
   124 	}
       
   125 
       
   126 /** Sets the drawing brush pattern bitmap. 
       
   127 
       
   128 When a bitmap has been set, a patterned style brush is selected automatically. 
       
   129 
       
   130 @param aBitmap The pattern bitmap. */
       
   131 EXPORT_C void CCoeBrushAndPenContext::SetBrushBitmap(const CFbsBitmap& aBitmap)
       
   132 	{
       
   133 	iBitmap=&aBitmap;
       
   134 	}
       
   135 
       
   136 /** Sets the pen colour. 
       
   137 
       
   138 @param aColor The pen colour. */
       
   139 EXPORT_C void CCoeBrushAndPenContext::SetPenColor(TRgb aColor)
       
   140 	{
       
   141 	iPenColor=aColor;
       
   142 	}
       
   143 
       
   144 /** Gets the brush style. 
       
   145 
       
   146 @return The current brush style. */
       
   147 EXPORT_C CWindowGc::TBrushStyle CCoeBrushAndPenContext::BrushStyle() const
       
   148 	{
       
   149 	return iBrushStyle;
       
   150 	}
       
   151 
       
   152 /** Gets the brush colour. 
       
   153 
       
   154 @return The current brush colour. */
       
   155 EXPORT_C TRgb CCoeBrushAndPenContext::BrushColor() const
       
   156 	{
       
   157 	return iBrushColor;
       
   158 	}
       
   159 
       
   160 /** Gets a reference to the bitmap used to pattern the drawing brush.
       
   161 
       
   162 @return The pattern bitmap. */
       
   163 EXPORT_C const CFbsBitmap& CCoeBrushAndPenContext::BrushBitmap() const
       
   164 	{
       
   165 	return *iBitmap;
       
   166 	}
       
   167 
       
   168 /** Gets the pen colour. 
       
   169 
       
   170 @return The current pen colour. */
       
   171 EXPORT_C TRgb CCoeBrushAndPenContext::PenColor() const
       
   172 	{
       
   173 	return iPenColor;
       
   174 	}
       
   175 
       
   176 
       
   177 //
       
   178 // Class MCoeControlBrushContext deprecated as of Release 005u
       
   179 //
       
   180 
       
   181 EXPORT_C MCoeControlBrushContext::MCoeControlBrushContext()
       
   182 	{
       
   183 	}
       
   184 
       
   185 /** Sets the brush settings for the specified graphics context. 
       
   186 
       
   187 If iBitmap is set, it sets this as the brush pattern and sets the brush style 
       
   188 to EPatternedBrush. Otherwise, it sets the brush style and brush colour using 
       
   189 the values of iBrushStyle and iBrushColor.
       
   190 
       
   191 @param aGc The graphics context to set. */
       
   192 EXPORT_C void MCoeControlBrushContext::PrepareContext(CWindowGc& aGc) const
       
   193 	{
       
   194 	if (iBitmap)
       
   195 		{
       
   196 		aGc.UseBrushPattern(iBitmap);
       
   197 		aGc.SetBrushStyle(CGraphicsContext::EPatternedBrush);
       
   198 		return;
       
   199 		}
       
   200 	aGc.SetBrushStyle(iBrushStyle);
       
   201 	aGc.SetBrushColor(iBrushColor);
       
   202 	}