uifw/AvKon/src/AknSyncDraw.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2002 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 *
       
    16 */
       
    17 
       
    18 #include "AknSyncDraw.h"
       
    19 
       
    20 
       
    21 class CCoeControlAccess : public CCoeControl
       
    22 	{
       
    23 public:
       
    24 	using CCoeControl::ActivateGc;
       
    25 	using CCoeControl::DeactivateGc;
       
    26 	using CCoeControl::Window;
       
    27 	using CCoeControl::HandleRedrawEvent;
       
    28 	};
       
    29 
       
    30 
       
    31 enum TSyncDrawFlags
       
    32 	{
       
    33 	EInDrawLoop
       
    34 	};
       
    35 
       
    36 
       
    37 const TInt KSyncDrawArrayGranularity = 4;
       
    38 
       
    39 
       
    40 EXPORT_C void MAknSyncDrawer::MAknSyncDrawer_Reserved_1() {}
       
    41 EXPORT_C void MAknSyncDrawer::MAknSyncDrawer_Reserved_2() {}
       
    42 
       
    43 
       
    44 EXPORT_C TAknSyncControlDrawer::TAknSyncControlDrawer()
       
    45 	{
       
    46 	}
       
    47 
       
    48 EXPORT_C void TAknSyncControlDrawer::SetControl(CCoeControl* aControl)
       
    49 	{
       
    50 	iControl = static_cast<CCoeControlAccess*>(aControl);
       
    51 	}
       
    52 
       
    53 EXPORT_C void TAknSyncControlDrawer::MasrPrepareForDraw()
       
    54 	{
       
    55 	iDrawRect = TRect();
       
    56 	RWindow& window = iControl->Window();
       
    57 	RRegion region;
       
    58 	window.GetInvalidRegion(region);
       
    59 	if (!region.CheckError())
       
    60 		{
       
    61 		iDrawRect = region.BoundingRect();
       
    62 		}
       
    63 	region.Close();
       
    64 	}
       
    65 
       
    66 EXPORT_C void TAknSyncControlDrawer::MasrDraw()
       
    67 	{
       
    68 	if (!iDrawRect.IsEmpty())
       
    69 		iControl->HandleRedrawEvent(iDrawRect);
       
    70 	}
       
    71 
       
    72 EXPORT_C void TAknSyncControlDrawer::MasrDeactivateGc() const
       
    73 	{
       
    74 	iControl->DeactivateGc();
       
    75 	}
       
    76 
       
    77 EXPORT_C void TAknSyncControlDrawer::MasrActivateGc() const
       
    78 	{
       
    79 	iControl->ActivateGc();
       
    80 	}
       
    81 
       
    82 
       
    83 EXPORT_C CAknDrawSynchronizer* CAknDrawSynchronizer::NewL()
       
    84 	{
       
    85 	CAknDrawSynchronizer* self = new(ELeave) CAknDrawSynchronizer();
       
    86 	CleanupStack::PushL(self);
       
    87 	self->ConstructL();
       
    88 	CleanupStack::Pop();
       
    89 	return self;
       
    90 	}
       
    91 
       
    92 EXPORT_C CAknDrawSynchronizer::~CAknDrawSynchronizer()
       
    93 	{
       
    94 	delete iSyncDrawers;
       
    95 	}
       
    96 
       
    97 CAknDrawSynchronizer::CAknDrawSynchronizer()
       
    98 	{
       
    99 	}
       
   100 
       
   101 void CAknDrawSynchronizer::ConstructL()
       
   102 	{
       
   103 	iSyncDrawers = new(ELeave) CSyncDrawers(KSyncDrawArrayGranularity);
       
   104 	}
       
   105 
       
   106 EXPORT_C void CAknDrawSynchronizer::AddL(MAknSyncDrawer* aDrawer)
       
   107 	{
       
   108 	Remove(aDrawer);
       
   109 	iSyncDrawers->AppendL(aDrawer);
       
   110 	}
       
   111 
       
   112 EXPORT_C void CAknDrawSynchronizer::Remove(MAknSyncDrawer* aDrawer)
       
   113 	{
       
   114 	TInt count = iSyncDrawers->Count();
       
   115 	for (TInt ii = count-1; ii >= 0; ii--)
       
   116 		{
       
   117 		if (iSyncDrawers->At(ii) == aDrawer)
       
   118 			iSyncDrawers->Delete(ii);
       
   119 		}
       
   120 	}
       
   121 
       
   122 EXPORT_C void CAknDrawSynchronizer::Signal(const MAknSyncDrawer* aDrawer)
       
   123 	{
       
   124 	if (iFlags[EInDrawLoop])
       
   125 		return;
       
   126 	iFlags.Set(EInDrawLoop);
       
   127 
       
   128 	if (aDrawer)
       
   129 		aDrawer->MasrDeactivateGc();
       
   130 
       
   131 	const TInt count = iSyncDrawers->Count();
       
   132 	TInt ii;
       
   133 
       
   134 	// prepare to draw
       
   135 	for (ii = 0; ii<count; ++ii)
       
   136 		{
       
   137 		MAknSyncDrawer* redrawer = iSyncDrawers->At(ii);
       
   138 		if (redrawer != aDrawer)
       
   139 			redrawer->MasrPrepareForDraw();
       
   140 		}
       
   141 
       
   142 	// draw
       
   143 	for (ii = 0; ii<count; ++ii)
       
   144 		{
       
   145 		MAknSyncDrawer* redrawer = iSyncDrawers->At(ii);
       
   146 		if (redrawer != aDrawer)
       
   147 			redrawer->MasrDraw();
       
   148 		}
       
   149 
       
   150 	if (aDrawer)
       
   151 		aDrawer->MasrActivateGc();
       
   152 
       
   153 	iFlags.Clear(EInDrawLoop);
       
   154 	}
       
   155 
       
   156 
       
   157 // End of File