sl@0
|
1 |
// Copyright (c) 2008-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 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include "drawresource.h"
|
sl@0
|
17 |
#include "wstop.h"
|
sl@0
|
18 |
#include <graphics/sgimage.h>
|
sl@0
|
19 |
|
sl@0
|
20 |
|
sl@0
|
21 |
CWsDrawableSource::CWsDrawableSource(CWsClient *aOwner)
|
sl@0
|
22 |
: CWsObject(aOwner, WS_HANDLE_DRAWABLE_SOURCE)
|
sl@0
|
23 |
{
|
sl@0
|
24 |
}
|
sl@0
|
25 |
|
sl@0
|
26 |
CWsDrawableSource::~CWsDrawableSource()
|
sl@0
|
27 |
{
|
sl@0
|
28 |
if (iDrawableSource && iDrawResource)
|
sl@0
|
29 |
{
|
sl@0
|
30 |
iDrawResource->CloseDrawableSource(iDrawableSource);
|
sl@0
|
31 |
}
|
sl@0
|
32 |
}
|
sl@0
|
33 |
|
sl@0
|
34 |
void CWsDrawableSource::ConstructL(const TWsClCmdCreateDrawableSource &aParams)
|
sl@0
|
35 |
{
|
sl@0
|
36 |
NewObjL();
|
sl@0
|
37 |
|
sl@0
|
38 |
CScreen* screen = NULL;
|
sl@0
|
39 |
if (Rng(0, aParams.iScreenNumber, CWsTop::NumberOfScreens() - 1))
|
sl@0
|
40 |
{
|
sl@0
|
41 |
screen = CWsTop::Screen(aParams.iScreenNumber);
|
sl@0
|
42 |
}
|
sl@0
|
43 |
else
|
sl@0
|
44 |
{
|
sl@0
|
45 |
User::Leave(KErrArgument);
|
sl@0
|
46 |
}
|
sl@0
|
47 |
MWsScreen* pOI=screen;
|
sl@0
|
48 |
CWsDrawableSource::iDrawResource = pOI->ObjectInterface<MWsDrawableSourceProvider>();
|
sl@0
|
49 |
if (!iDrawResource)
|
sl@0
|
50 |
{
|
sl@0
|
51 |
User::Leave(KErrNotSupported);
|
sl@0
|
52 |
}
|
sl@0
|
53 |
User::LeaveIfError(iDrawResource->CreateDrawableSource(aParams.iDrawableId, iDrawableSource));
|
sl@0
|
54 |
IncRefCount();
|
sl@0
|
55 |
}
|
sl@0
|
56 |
|
sl@0
|
57 |
void CWsDrawableSource::CommandL(TInt aOpcode, const TAny *)
|
sl@0
|
58 |
{
|
sl@0
|
59 |
switch(aOpcode)
|
sl@0
|
60 |
{
|
sl@0
|
61 |
case EWsDrawableSourceOpFree:
|
sl@0
|
62 |
iFlags |= EWsClientHandleClosed;
|
sl@0
|
63 |
DecRefCount();
|
sl@0
|
64 |
break;
|
sl@0
|
65 |
default:
|
sl@0
|
66 |
OwnerPanic(EWservPanicOpcode);
|
sl@0
|
67 |
break;
|
sl@0
|
68 |
}
|
sl@0
|
69 |
}
|
sl@0
|
70 |
|
sl@0
|
71 |
/*
|
sl@0
|
72 |
CWsDrawableSource is a reference counted object so we cannot simply close the object as somebody else may have a reference to it
|
sl@0
|
73 |
*/
|
sl@0
|
74 |
void CWsDrawableSource::CloseObject()
|
sl@0
|
75 |
{
|
sl@0
|
76 |
RemoveFromIndex();
|
sl@0
|
77 |
if (!(iFlags & EWsClientHandleClosed))
|
sl@0
|
78 |
{
|
sl@0
|
79 |
DecRefCount();
|
sl@0
|
80 |
}
|
sl@0
|
81 |
}
|
sl@0
|
82 |
|
sl@0
|
83 |
void CWsDrawableSource::IncRefCount()
|
sl@0
|
84 |
{
|
sl@0
|
85 |
iRefCount++;
|
sl@0
|
86 |
}
|
sl@0
|
87 |
|
sl@0
|
88 |
void CWsDrawableSource::DecRefCount()
|
sl@0
|
89 |
{
|
sl@0
|
90 |
if (--iRefCount <= 0)
|
sl@0
|
91 |
{
|
sl@0
|
92 |
delete this;
|
sl@0
|
93 |
}
|
sl@0
|
94 |
}
|
sl@0
|
95 |
|
sl@0
|
96 |
void CWsDrawableSource::DrawResource(MWsGraphicsContext *aGc, const TPoint& aPos, CWindowGc::TGraphicsRotation aRotation) const
|
sl@0
|
97 |
{
|
sl@0
|
98 |
ASSERT(iDrawResource);
|
sl@0
|
99 |
MWsDrawableSourceProvider* drawResource = aGc->ObjectInterface<MWsDrawableSourceProvider>();
|
sl@0
|
100 |
if (drawResource == iDrawResource)
|
sl@0
|
101 |
{
|
sl@0
|
102 |
drawResource->DrawResource(iDrawableSource, aPos, aRotation);
|
sl@0
|
103 |
}
|
sl@0
|
104 |
}
|
sl@0
|
105 |
|
sl@0
|
106 |
void CWsDrawableSource::DrawResource(MWsGraphicsContext *aGc, const TRect& aRect, CWindowGc::TGraphicsRotation aRotation) const
|
sl@0
|
107 |
{
|
sl@0
|
108 |
ASSERT(iDrawResource);
|
sl@0
|
109 |
MWsDrawableSourceProvider* drawResource = aGc->ObjectInterface<MWsDrawableSourceProvider>();
|
sl@0
|
110 |
if (drawResource == iDrawResource)
|
sl@0
|
111 |
{
|
sl@0
|
112 |
drawResource->DrawResource(iDrawableSource, aRect, aRotation);
|
sl@0
|
113 |
}
|
sl@0
|
114 |
}
|
sl@0
|
115 |
|
sl@0
|
116 |
void CWsDrawableSource::DrawResource(MWsGraphicsContext *aGc, const TRect& aRectDest, const TRect& aRectSrc, CWindowGc::TGraphicsRotation aRotation) const
|
sl@0
|
117 |
{
|
sl@0
|
118 |
ASSERT(iDrawResource);
|
sl@0
|
119 |
MWsDrawableSourceProvider* drawResource = aGc->ObjectInterface<MWsDrawableSourceProvider>();
|
sl@0
|
120 |
if (drawResource == iDrawResource)
|
sl@0
|
121 |
{
|
sl@0
|
122 |
drawResource->DrawResource(iDrawableSource, aRectDest, aRectSrc, aRotation);
|
sl@0
|
123 |
}
|
sl@0
|
124 |
}
|
sl@0
|
125 |
|
sl@0
|
126 |
void CWsDrawableSource::DrawResource(MWsGraphicsContext *aGc, const TRect& aRect, const TDesC8& aDes) const
|
sl@0
|
127 |
{
|
sl@0
|
128 |
ASSERT(iDrawResource);
|
sl@0
|
129 |
MWsDrawableSourceProvider* drawResource = aGc->ObjectInterface<MWsDrawableSourceProvider>();
|
sl@0
|
130 |
if (drawResource == iDrawResource)
|
sl@0
|
131 |
{
|
sl@0
|
132 |
drawResource->DrawResource(iDrawableSource, aRect, aDes);
|
sl@0
|
133 |
}
|
sl@0
|
134 |
}
|