sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Sets all members to default values. Initializes the size field to match the object size. sl@0: // sl@0: // sl@0: /** sl@0: @file sl@0: @publishedpartner sl@0: @released sl@0: */ sl@0: sl@0: inline TSurfaceConfiguration::TSurfaceConfiguration() sl@0: {} sl@0: sl@0: /** sl@0: Copy constructor. This constructor will read the size field of the source and target sl@0: objects and only copy the minimum set of fields indicated. Any remaining fields in the target sl@0: object will be set to default values. sl@0: sl@0: @param aSurfaceConfiguration Config to copy sl@0: */ sl@0: inline TSurfaceConfiguration::TSurfaceConfiguration(const TSurfaceConfiguration& aSurfaceConfiguration): sl@0: TSurfaceConfiguration2(0) sl@0: { sl@0: TInt tempSize = aSurfaceConfiguration.Size(); sl@0: if (tempSize > sizeof(*this)) sl@0: { sl@0: tempSize = sizeof(*this); sl@0: } sl@0: Mem::Copy(this, &aSurfaceConfiguration, tempSize); sl@0: iSize = tempSize; sl@0: } sl@0: sl@0: /** sl@0: This constructor will take any value, but it is designed to be used with sl@0: a value returned by RWsSession::PreferredSurfaceConfigurationSize, sl@0: and initializes the members to represent an object compatible with that. sl@0: sl@0: If the aPreferredMaxSize is larger than the actual size of TSurfaceConfiguration, indicating sl@0: that the server supports a newer version of the interface than the caller is aware of, then sl@0: the actual size is used. sl@0: sl@0: If the aPreferredMaxSize is smaller than the actual size of TSurfaceConfiguration, indicating sl@0: that the server supports an earlier version of the interface, then this value is used. It must sl@0: match the Size() member of one of the defined hierarchy of TSurfaceConfiguration classes. sl@0: sl@0: @param aPreferredMaxSize User defined max size sl@0: @see RWsSession::PreferredSurfaceConfigurationSize sl@0: */ sl@0: inline TSurfaceConfiguration::TSurfaceConfiguration(TInt aPreferredMaxSize): sl@0: TSurfaceConfiguration2(sizeof(*this)) sl@0: { sl@0: if (sizeof(*this) > aPreferredMaxSize) sl@0: { sl@0: iSize = aPreferredMaxSize; sl@0: } sl@0: } sl@0: sl@0: /** Default constructor for configuration 1 sl@0: */ sl@0: inline TSurfaceConfiguration1::TSurfaceConfiguration1():TSurfaceConfigurationSize(sizeof(*this)) sl@0: ,iExtent(TRect::EUninitialized), iViewport(TRect::EUninitialized) sl@0: {} sl@0: sl@0: /** sl@0: Constructor for configuration 1 passing through a size already calculated sl@0: sl@0: @param aSize Size of the class already calculated and being passed up through the classes sl@0: */ sl@0: inline TSurfaceConfiguration1::TSurfaceConfiguration1(TInt aSize):TSurfaceConfigurationSize(aSize) sl@0: ,iExtent(TRect::EUninitialized), iViewport(TRect::EUninitialized) sl@0: {} sl@0: sl@0: /** sl@0: The method sets the surface ID to be set as the background surface. sl@0: sl@0: The default initial value held in this class for surface ID is the null surface ID. sl@0: sl@0: Note that SetBackgroundSurface() will not accept a null surface ID, so this parameter must always be set. sl@0: sl@0: @param aSurfaceId Surface ID to set sl@0: @return KErrNone on success or a system-wide error code sl@0: - KErrNotSupported if not supported. sl@0: @post The Surface Id values are updated in the object of this class if supported. The sl@0: SetBackgroundSurface API must be called passing object of this class as parameter to sl@0: get the desired effect. sl@0: */ sl@0: inline TInt TSurfaceConfiguration1::SetSurfaceId (const TSurfaceId& aSurfaceId) sl@0: { sl@0: if (MemberAccessible(iSurfaceId)) sl@0: { sl@0: iSurfaceId = aSurfaceId; sl@0: return KErrNone; sl@0: } sl@0: return KErrNotSupported; sl@0: } sl@0: sl@0: /** sl@0: The method gets the surface ID stored in the object of this class. sl@0: sl@0: @param aSurfaceId User surface id to be set sl@0: @post The aSurface parameter is filled in. sl@0: @post If the instance of TSurfaceConfiguration is too small, the null surface ID will be set. sl@0: */ sl@0: inline void TSurfaceConfiguration1::GetSurfaceId (TSurfaceId& aSurfaceId) const sl@0: { sl@0: if (MemberAccessible(iSurfaceId)) sl@0: { sl@0: aSurfaceId = iSurfaceId; sl@0: } sl@0: else sl@0: { sl@0: aSurfaceId.CreateNullId(); sl@0: } sl@0: } sl@0: sl@0: /** sl@0: The method sets the area of the surface that should be mapped to the specified window area. sl@0: The viewport is in surface coordinates. sl@0: sl@0: In SetBackgroundSurface(), if not set or if the set viewport is empty, the size of the whole surface sl@0: is used as the viewport. If the surface is changed then the viewport will track the size of sl@0: the surface. sl@0: sl@0: Setting any ordinate of the viewport outside the surface size is not required specified behavior for sl@0: this interface. The call will not fail if any ordinates are out of range, and the internal NGA Composition sl@0: handling of this case will produce a representative image. This current behavior is that the NGA Composition sl@0: will clamp any out-of-range ordinate to the size of the surface. sl@0: sl@0: @param aViewport A rectangle of the area, in relative coordinates to the surface sl@0: @return KErrNone on success or a system-wide error code sl@0: - KErrNotSupported if not supported. sl@0: @post The viewport values are updated in the object of this class. This does not imply that the sl@0: viewport is set for the surface. The SetBackgroundSurface API must be called passing an object of sl@0: this class as parameter to get the desired effect. sl@0: */ sl@0: inline TInt TSurfaceConfiguration1::SetViewport (const TRect& aViewport) sl@0: { sl@0: if (MemberAccessible(iViewport)) sl@0: { sl@0: iViewport = aViewport; sl@0: return KErrNone; sl@0: } sl@0: return KErrNotSupported; sl@0: } sl@0: sl@0: /** sl@0: This method gets the viewport stored in the object of this class. The viewport is in surface sl@0: coordinates. sl@0: sl@0: If viewport was not set or an empty viewport was set, the value returned is an empty viewport. This sl@0: is an indication that the viewport used by the server is equal to the size of the surface. The sl@0: actual size of the surface is not returned. sl@0: sl@0: @param aViewport User viewport to be set. sl@0: @post The aViewport rectangle is filled in. sl@0: @post If the instance of TSurfaceConfiguration is too small, the empty viewport rectangle will be returned. sl@0: */ sl@0: inline void TSurfaceConfiguration1::GetViewport (TRect& aViewport) const sl@0: { sl@0: if (MemberAccessible(iViewport)) sl@0: { sl@0: aViewport = iViewport; sl@0: } sl@0: else sl@0: { sl@0: aViewport = TRect(); sl@0: } sl@0: } sl@0: sl@0: /** sl@0: This method sets the relative orientation of viewport to window extent. The default value is sl@0: EGraphicsOrientationNormal. sl@0: sl@0: The rotation effect is applied to the input viewport area, around the centre-point of the viewport. sl@0: sl@0: @param aOrientation User orientation to be set sl@0: @return KErrNone on success or a system-wide error code sl@0: - KErrNotSupported if not supported. sl@0: - KErrArgument if aOrientation is out of range sl@0: @post The orientation is updated in the object of this class. This does not imply that the orientation sl@0: is set for the surface content. The SetBackgroundSurface API must be called passing an object of sl@0: this class as parameter to get the desired effect. sl@0: */ sl@0: inline TInt TSurfaceConfiguration1::SetOrientation (CFbsBitGc::TGraphicsOrientation aOrientation) sl@0: { sl@0: if (MemberAccessible(iOrientation)) sl@0: { sl@0: __ASSERT_COMPILE(CFbsBitGc::EGraphicsOrientationNormal==0 && sl@0: CFbsBitGc::EGraphicsOrientationRotated270 == 3); sl@0: if(aOrientation < CFbsBitGc::EGraphicsOrientationNormal || sl@0: aOrientation > CFbsBitGc::EGraphicsOrientationRotated270) sl@0: { sl@0: return KErrArgument; sl@0: } sl@0: iOrientation = aOrientation; sl@0: return KErrNone; sl@0: } sl@0: return KErrNotSupported; sl@0: } sl@0: sl@0: /** sl@0: The method gets the surface orientation angle stored in the object of this class. It is the sl@0: relative orientation of viewport to window extent. If orientation was not set, the value returned sl@0: will be EGraphicsOrientationNormal. sl@0: sl@0: @return orientation in this object sl@0: @post If the instance of TSurfaceConfiguration is too small, the default EGraphicsOrientationNormal sl@0: setting will be returned. sl@0: */ sl@0: inline CFbsBitGc::TGraphicsOrientation TSurfaceConfiguration1::Orientation() const sl@0: { sl@0: if (MemberAccessible(iOrientation)) sl@0: { sl@0: return iOrientation; sl@0: } sl@0: else sl@0: { sl@0: return CFbsBitGc::EGraphicsOrientationNormal; sl@0: } sl@0: } sl@0: sl@0: /** sl@0: This method sets the area of the window where the surface content is to be placed. The extent is sl@0: in window coordinates. sl@0: sl@0: If not set or if the set extent is empty, the size of the entire window is used as the default extent. sl@0: The default extent changes according to the change in the window size. The empty extent is an indication sl@0: to the server that the extent should fill the entire window without the client tracking the change in sl@0: the window size. sl@0: sl@0: In SetBackgroundSurface() it is legal to set the extent larger than the window, or the window may sl@0: become smaller than the extent. In these cases the output will be transformed on the basis of this sl@0: larger extent, but then clipped to the window outline. sl@0: sl@0: @param aExtent Area on the window where the surface contents specified by viewport sl@0: should be mapped sl@0: @return KErrNone on success or a system-wide error code sl@0: - KErrNotSupported if not supported. sl@0: @post The extent values are updated in the object of this class. This does not imply that the sl@0: extent is set for the surface. The SetBackgroundSurface API must be called passing an object of sl@0: this class as parameter to get the desired effect. sl@0: */ sl@0: inline TInt TSurfaceConfiguration1::SetExtent(const TRect& aExtent) sl@0: { sl@0: if (MemberAccessible(iExtent)) sl@0: { sl@0: iExtent = aExtent; sl@0: return KErrNone; sl@0: } sl@0: return KErrNotSupported; sl@0: } sl@0: sl@0: /** sl@0: The method gets the extent stored in the object of this class. The extent is in window coordinates. sl@0: sl@0: If extent was not set or an empty extent was set, the value returned will be an empty extent. This sl@0: is an indication that the extent used by the server is equal to the size of the window. The actual sl@0: size of the window is not returned. sl@0: sl@0: @param aExtent User extent to be set sl@0: @post The aExtent parameter is filled in sl@0: @post If the instance of TSurfaceConfiguration is too small, the empty extent rectangle will be returned. sl@0: */ sl@0: inline void TSurfaceConfiguration1::GetExtent(TRect& aExtent) const sl@0: { sl@0: if (MemberAccessible(iExtent)) sl@0: { sl@0: aExtent = iExtent; sl@0: } sl@0: else sl@0: { sl@0: aExtent = TRect(); sl@0: } sl@0: } sl@0: sl@0: /** sl@0: This method identifies which attributes are available to use. sl@0: sl@0: Generally, any version of the server will accept any version of TSurfaceConfiguration, ignoring sl@0: newer version attributes it does not recognize and substituting defaults for attributes not present sl@0: in older version. sl@0: sl@0: However, by using this method in conjunction with GetBackgroundSurface() the intelligent client can sl@0: identify which blocks of attributes are actually present and supported after a call to sl@0: GetBackgroundSurface, avoiding preparing complex attributes, or reducing user-interface control sl@0: gadgets. sl@0: sl@0: @return ETrue if all these attributes are available to use; otherwise EFalse sl@0: */ sl@0: inline TBool TSurfaceConfiguration1::SupportsAllMembers() sl@0: { sl@0: if (Size() >= sizeof(*this)) sl@0: { sl@0: return ETrue; sl@0: } sl@0: else sl@0: { sl@0: return EFalse; sl@0: } sl@0: } sl@0: sl@0: /** sl@0: Constructs the TSurfaceConfigurationSize class, enters the size field and blanks everything else sl@0: sl@0: @param aSize The size to set for the configuration sl@0: @return ETrue If all these attributes are available to use; otherwise EFalse sl@0: */ sl@0: inline TSurfaceConfigurationSize::TSurfaceConfigurationSize(TInt aSize) sl@0: { sl@0: Mem::FillZ(this,aSize); sl@0: iSize = aSize; sl@0: } sl@0: sl@0: /** sl@0: Reads the size field. The size is set automatically in the constructor, or by the sl@0: GetBackgroundSurface method to indicate the sender’s supported structure size, and imply a sl@0: compatible version identifier. The size reported after GetBackgroundSurface will match sl@0: the expected size of one of the hierarchy of TSurfaceConfiguration classes documented in the sl@0: header, and will never exceed the constructed size. sl@0: sl@0: @return ETrue if all these attributes are available to use; otherwise EFalse sl@0: */ sl@0: inline TInt TSurfaceConfigurationSize::Size() const sl@0: { sl@0: return iSize; sl@0: } sl@0: sl@0: inline TBool TSurfaceConfigurationSize::operator == (const TSurfaceConfigurationSize& aRhs)const sl@0: { sl@0: return aRhs.Size()==Size(); //If the two objects are not the same version then we can't compare them! sl@0: } sl@0: inline TBool TSurfaceConfiguration1::operator == (const TSurfaceConfiguration1& aRhs)const sl@0: { sl@0: if (!TSurfaceConfigurationSize::operator ==(aRhs)) sl@0: return EFalse; //Check for earlier version compatability sl@0: if (Size()= sizeof(*this)) sl@0: { sl@0: return ETrue; sl@0: } sl@0: else sl@0: { sl@0: return EFalse; sl@0: } sl@0: } sl@0: sl@0: inline TBool TSurfaceConfiguration2::operator == (const TSurfaceConfiguration2& aRhs)const sl@0: { sl@0: if (!TSurfaceConfiguration1::operator ==(aRhs)) sl@0: return EFalse; //Check for earlier version compatability sl@0: if (Size()