os/graphics/windowing/windowserver/test/ANIMWIN.CPP
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 1999-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 // Animated Bitmap Window
    15 // 
    16 //
    17 
    18 #include "MBMCMD.H"
    19 #include "ANIMWIN.H"
    20 
    21 
    22 /*TestWindow11*/
    23 
    24 TestWindow11::TestWindow11() : CTWin()
    25 	{
    26 	}
    27 
    28 TestWindow11::~TestWindow11()
    29 	{
    30 	delete iAnim;
    31 	delete iAnimDll;
    32 	}
    33 
    34 void TestWindow11::InitWinL()
    35 	{
    36 	iAnimDll=new(ELeave) RAnimDll(Client()->iWs);
    37 	//__ASSERT_DEBUG(iAnimDll,Panic());
    38 	iAnim=new(ELeave) RMbmAnim(*iAnimDll);
    39 	//__ASSERT_DEBUG(iAnim,Panic());
    40 
    41 	CWsBitmap *bitmap=new(ELeave) CWsBitmap(Client()->iWs);
    42 	//__ASSERT_DEBUG(bitmap,Panic());
    43 	iWin.SetRequiredDisplayMode(EColor256);
    44 	User::LeaveIfError(bitmap->Load(VIDEO_MBM_NAME,0));
    45 	iVideoSize=bitmap->SizeInPixels();
    46 	iWin.SetExtent(TPoint(320-(iVideoSize.iWidth>>1),0),iVideoSize);
    47 	delete bitmap;
    48 	TRAP_IGNORE(LoadDllL());
    49 	}
    50 
    51 void TestWindow11::Draw()
    52 	{
    53 	TSize size=Size();
    54 	TRect rect(size);
    55 
    56 	iGc->SetPenStyle(CGraphicsContext::ENullPen);
    57 	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
    58 	iGc->SetBrushColor(TRgb::Gray2(1));
    59 	iGc->DrawRect(rect);
    60 	}
    61 
    62 void TestWindow11::WinKeyL(const TKeyEvent &aKey,const TTime &)
    63 	{
    64 	if (aKey.iCode=='p' || aKey.iCode=='P')
    65 		{
    66 		CheckWindowSize();
    67 		iAnim->Activate();
    68 		}
    69 	else if (aKey.iCode=='s' || aKey.iCode=='S')
    70 		iAnim->Deactivate();
    71 	else if (aKey.iCode==',' || aKey.iCode=='<')
    72 		iAnim->SlowDown();
    73 	else if (aKey.iCode=='.' || aKey.iCode=='>')
    74 		iAnim->SpeedUp();
    75 	}
    76 
    77 void TestWindow11::LoadDllL()
    78 	{
    79 	_LIT(DllName,"MbmAnim.DLL");
    80 	iAnimDll->Load(DllName);
    81 	iAnim->ConstructL(iWin);
    82 	TBuf<32> name(VIDEO_MBM_NAME);
    83 	iAnim->SetMbmFile(name);
    84 	}
    85 
    86 void TestWindow11::CheckWindowSize()
    87 	{
    88 	TSize size=iWin.Size();
    89 	if (size.iWidth<iVideoSize.iWidth || size.iHeight<iVideoSize.iHeight)
    90 		iWin.SetExtent(TPoint(320-(iVideoSize.iWidth>>1),0),iVideoSize);
    91 	}
    92 
    93 
    94 /*RMbmAnim*/
    95 
    96 void RMbmAnim::ConstructL(const RWindowBase &aDevice)
    97 	{
    98 	TPtrC8 des(NULL,0);
    99 	User::LeaveIfError(RAnim::Construct(aDevice,0,des));
   100 	}
   101 
   102 void RMbmAnim::SetMbmFile(const TBuf<32>& aFileName)
   103 	{
   104 	TPckgBuf<TBuf<32> > param;
   105 	param()=aFileName;
   106 	Command(EMbmOpSetFileName,param);
   107 	}
   108 
   109 void RMbmAnim::Activate()
   110 	{
   111 	Command(EMbmOpActivate);
   112 	}
   113 
   114 void RMbmAnim::Deactivate()
   115 	{
   116 	Command(EMbmOpDeactivate);
   117 	}
   118 
   119 void RMbmAnim::SpeedUp()
   120 	{
   121 	Command(EMbmOpFaster);
   122 	}
   123 
   124 void RMbmAnim::SlowDown()
   125 	{
   126 	Command(EMbmOpSlower);
   127 	}