os/graphics/windowing/windowserver/test/ANIMWIN.CPP
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// Animated Bitmap Window
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include "MBMCMD.H"
sl@0
    19
#include "ANIMWIN.H"
sl@0
    20
sl@0
    21
sl@0
    22
/*TestWindow11*/
sl@0
    23
sl@0
    24
TestWindow11::TestWindow11() : CTWin()
sl@0
    25
	{
sl@0
    26
	}
sl@0
    27
sl@0
    28
TestWindow11::~TestWindow11()
sl@0
    29
	{
sl@0
    30
	delete iAnim;
sl@0
    31
	delete iAnimDll;
sl@0
    32
	}
sl@0
    33
sl@0
    34
void TestWindow11::InitWinL()
sl@0
    35
	{
sl@0
    36
	iAnimDll=new(ELeave) RAnimDll(Client()->iWs);
sl@0
    37
	//__ASSERT_DEBUG(iAnimDll,Panic());
sl@0
    38
	iAnim=new(ELeave) RMbmAnim(*iAnimDll);
sl@0
    39
	//__ASSERT_DEBUG(iAnim,Panic());
sl@0
    40
sl@0
    41
	CWsBitmap *bitmap=new(ELeave) CWsBitmap(Client()->iWs);
sl@0
    42
	//__ASSERT_DEBUG(bitmap,Panic());
sl@0
    43
	iWin.SetRequiredDisplayMode(EColor256);
sl@0
    44
	User::LeaveIfError(bitmap->Load(VIDEO_MBM_NAME,0));
sl@0
    45
	iVideoSize=bitmap->SizeInPixels();
sl@0
    46
	iWin.SetExtent(TPoint(320-(iVideoSize.iWidth>>1),0),iVideoSize);
sl@0
    47
	delete bitmap;
sl@0
    48
	TRAP_IGNORE(LoadDllL());
sl@0
    49
	}
sl@0
    50
sl@0
    51
void TestWindow11::Draw()
sl@0
    52
	{
sl@0
    53
	TSize size=Size();
sl@0
    54
	TRect rect(size);
sl@0
    55
sl@0
    56
	iGc->SetPenStyle(CGraphicsContext::ENullPen);
sl@0
    57
	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
    58
	iGc->SetBrushColor(TRgb::Gray2(1));
sl@0
    59
	iGc->DrawRect(rect);
sl@0
    60
	}
sl@0
    61
sl@0
    62
void TestWindow11::WinKeyL(const TKeyEvent &aKey,const TTime &)
sl@0
    63
	{
sl@0
    64
	if (aKey.iCode=='p' || aKey.iCode=='P')
sl@0
    65
		{
sl@0
    66
		CheckWindowSize();
sl@0
    67
		iAnim->Activate();
sl@0
    68
		}
sl@0
    69
	else if (aKey.iCode=='s' || aKey.iCode=='S')
sl@0
    70
		iAnim->Deactivate();
sl@0
    71
	else if (aKey.iCode==',' || aKey.iCode=='<')
sl@0
    72
		iAnim->SlowDown();
sl@0
    73
	else if (aKey.iCode=='.' || aKey.iCode=='>')
sl@0
    74
		iAnim->SpeedUp();
sl@0
    75
	}
sl@0
    76
sl@0
    77
void TestWindow11::LoadDllL()
sl@0
    78
	{
sl@0
    79
	_LIT(DllName,"MbmAnim.DLL");
sl@0
    80
	iAnimDll->Load(DllName);
sl@0
    81
	iAnim->ConstructL(iWin);
sl@0
    82
	TBuf<32> name(VIDEO_MBM_NAME);
sl@0
    83
	iAnim->SetMbmFile(name);
sl@0
    84
	}
sl@0
    85
sl@0
    86
void TestWindow11::CheckWindowSize()
sl@0
    87
	{
sl@0
    88
	TSize size=iWin.Size();
sl@0
    89
	if (size.iWidth<iVideoSize.iWidth || size.iHeight<iVideoSize.iHeight)
sl@0
    90
		iWin.SetExtent(TPoint(320-(iVideoSize.iWidth>>1),0),iVideoSize);
sl@0
    91
	}
sl@0
    92
sl@0
    93
sl@0
    94
/*RMbmAnim*/
sl@0
    95
sl@0
    96
void RMbmAnim::ConstructL(const RWindowBase &aDevice)
sl@0
    97
	{
sl@0
    98
	TPtrC8 des(NULL,0);
sl@0
    99
	User::LeaveIfError(RAnim::Construct(aDevice,0,des));
sl@0
   100
	}
sl@0
   101
sl@0
   102
void RMbmAnim::SetMbmFile(const TBuf<32>& aFileName)
sl@0
   103
	{
sl@0
   104
	TPckgBuf<TBuf<32> > param;
sl@0
   105
	param()=aFileName;
sl@0
   106
	Command(EMbmOpSetFileName,param);
sl@0
   107
	}
sl@0
   108
sl@0
   109
void RMbmAnim::Activate()
sl@0
   110
	{
sl@0
   111
	Command(EMbmOpActivate);
sl@0
   112
	}
sl@0
   113
sl@0
   114
void RMbmAnim::Deactivate()
sl@0
   115
	{
sl@0
   116
	Command(EMbmOpDeactivate);
sl@0
   117
	}
sl@0
   118
sl@0
   119
void RMbmAnim::SpeedUp()
sl@0
   120
	{
sl@0
   121
	Command(EMbmOpFaster);
sl@0
   122
	}
sl@0
   123
sl@0
   124
void RMbmAnim::SlowDown()
sl@0
   125
	{
sl@0
   126
	Command(EMbmOpSlower);
sl@0
   127
	}