author | sl |
Tue, 10 Jun 2014 14:32:02 +0200 | |
changeset 1 | 260cb5ec6c19 |
permissions | -rw-r--r-- |
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 |
/** |
sl@0 | 17 |
@file |
sl@0 | 18 |
@publishedPartner |
sl@0 | 19 |
@prototype |
sl@0 | 20 |
*/ |
sl@0 | 21 |
|
sl@0 | 22 |
#ifndef _DISPLAYCONFIGURATION_INL__INCLUDED_ |
sl@0 | 23 |
#define _DISPLAYCONFIGURATION_INL__INCLUDED_ |
sl@0 | 24 |
|
sl@0 | 25 |
// |
sl@0 | 26 |
// |
sl@0 | 27 |
// Complete implementation of Base class |
sl@0 | 28 |
// |
sl@0 | 29 |
// |
sl@0 | 30 |
inline TInt TDisplayConfigurationBase::Version() const |
sl@0 | 31 |
{ |
sl@0 | 32 |
return iVersion; |
sl@0 | 33 |
} |
sl@0 | 34 |
|
sl@0 | 35 |
inline void TDisplayConfigurationBase::Clear(TAttribute aAttribute) |
sl@0 | 36 |
{ |
sl@0 | 37 |
iDefined.Clear(+aAttribute); |
sl@0 | 38 |
} |
sl@0 | 39 |
|
sl@0 | 40 |
inline void TDisplayConfigurationBase::ClearAll() |
sl@0 | 41 |
{ |
sl@0 | 42 |
iDefined.ClearAll(); |
sl@0 | 43 |
} |
sl@0 | 44 |
|
sl@0 | 45 |
inline void TDisplayConfigurationBase::Panic(TInt aPanicCode) |
sl@0 | 46 |
{ |
sl@0 | 47 |
_LIT(KCategory,"DISPLAYCONFIG"); |
sl@0 | 48 |
User::Panic(KCategory,aPanicCode); |
sl@0 | 49 |
} |
sl@0 | 50 |
|
sl@0 | 51 |
inline TBool TDisplayConfigurationBase::IsDefined(TAttribute aAttribute) const |
sl@0 | 52 |
{ |
sl@0 | 53 |
//If we have more than 32 attributes then this code may need a rewrite. |
sl@0 | 54 |
__ASSERT_COMPILE(EAttributeMax<=32); |
sl@0 | 55 |
return iDefined.IsSet(+aAttribute); |
sl@0 | 56 |
} |
sl@0 | 57 |
|
sl@0 | 58 |
inline TDisplayConfigurationBase::TDisplayConfigurationBase(TInt aVersion) |
sl@0 | 59 |
{ |
sl@0 | 60 |
if (aVersion < sizeof(*this)) |
sl@0 | 61 |
{ |
sl@0 | 62 |
Panic(EPanicConfigInvalid); |
sl@0 | 63 |
} |
sl@0 | 64 |
iVersion=aVersion; |
sl@0 | 65 |
//default constructor for iDefined sets all-zero. |
sl@0 | 66 |
//Members do not need zapping to zero because they are disabled in iDefined |
sl@0 | 67 |
} |
sl@0 | 68 |
|
sl@0 | 69 |
|
sl@0 | 70 |
inline TBool TDisplayConfigurationBase::operator == (const TDisplayConfigurationBase& aRhs) const |
sl@0 | 71 |
{ |
sl@0 | 72 |
return (aRhs.Version()== Version()) && (const_cast<TBitFlags32&>(aRhs.iDefined) == iDefined ); |
sl@0 | 73 |
} |
sl@0 | 74 |
// |
sl@0 | 75 |
// |
sl@0 | 76 |
// Complete implementation of V1 class |
sl@0 | 77 |
// |
sl@0 | 78 |
// |
sl@0 | 79 |
inline TDisplayConfiguration1::TDisplayConfiguration1():TDisplayConfigurationBase(sizeof(*this)) |
sl@0 | 80 |
,iResolution(TSize::EUninitialized) |
sl@0 | 81 |
{} |
sl@0 | 82 |
|
sl@0 | 83 |
inline TDisplayConfiguration1::TDisplayConfiguration1(TInt aVersion):TDisplayConfigurationBase(aVersion) |
sl@0 | 84 |
,iResolution(TSize::EUninitialized) |
sl@0 | 85 |
{ |
sl@0 | 86 |
if (aVersion > sizeof(TDisplayConfigurationBase) && |
sl@0 | 87 |
aVersion < sizeof(*this)) |
sl@0 | 88 |
{ |
sl@0 | 89 |
Panic(EPanicConfigInvalid); |
sl@0 | 90 |
} |
sl@0 | 91 |
} |
sl@0 | 92 |
|
sl@0 | 93 |
inline void TDisplayConfiguration1::SetResolution(const TSize& aSize) |
sl@0 | 94 |
{ |
sl@0 | 95 |
if (MemberAccessible(iResolution)) |
sl@0 | 96 |
{ |
sl@0 | 97 |
if (aSize.iWidth<0 || aSize.iHeight<0) |
sl@0 | 98 |
{ |
sl@0 | 99 |
Panic(EPanicNegResolution); |
sl@0 | 100 |
} |
sl@0 | 101 |
if ((aSize.iWidth>0 && aSize.iHeight==0)|| |
sl@0 | 102 |
(aSize.iWidth==0 && aSize.iHeight>0)) |
sl@0 | 103 |
{ |
sl@0 | 104 |
Panic(EPanicSemiZeroResolution); |
sl@0 | 105 |
} |
sl@0 | 106 |
iDefined.Set(+EResolution); |
sl@0 | 107 |
iResolution=aSize; |
sl@0 | 108 |
} |
sl@0 | 109 |
} |
sl@0 | 110 |
|
sl@0 | 111 |
inline TBool TDisplayConfiguration1::GetResolution(TSize& aSize) const |
sl@0 | 112 |
{ |
sl@0 | 113 |
if (MemberAccessible(iResolution) && IsDefined(EResolution)) |
sl@0 | 114 |
{ |
sl@0 | 115 |
aSize=iResolution; |
sl@0 | 116 |
return ETrue; |
sl@0 | 117 |
} |
sl@0 | 118 |
return EFalse; |
sl@0 | 119 |
} |
sl@0 | 120 |
|
sl@0 | 121 |
//Accessor for rotation member (index) |
sl@0 | 122 |
inline void TDisplayConfiguration1::SetRotation(TRotation aOrientation) |
sl@0 | 123 |
{ |
sl@0 | 124 |
if (MemberAccessible(iRotation)) |
sl@0 | 125 |
{ |
sl@0 | 126 |
if ((TUint)aOrientation>=(TUint)ERotationIllegal) |
sl@0 | 127 |
{ |
sl@0 | 128 |
Panic(EPanicIllegalRotation); |
sl@0 | 129 |
} |
sl@0 | 130 |
iDefined.Set(+ERotation); |
sl@0 | 131 |
iRotation=aOrientation; |
sl@0 | 132 |
} |
sl@0 | 133 |
|
sl@0 | 134 |
} |
sl@0 | 135 |
//Accessor for rotation member (index) |
sl@0 | 136 |
inline TBool TDisplayConfiguration1::GetRotation(TRotation& aOrientation)const |
sl@0 | 137 |
{ |
sl@0 | 138 |
if (MemberAccessible(iRotation) && IsDefined(ERotation)) |
sl@0 | 139 |
{ |
sl@0 | 140 |
aOrientation=static_cast<TRotation>(iRotation); |
sl@0 | 141 |
return ETrue; |
sl@0 | 142 |
} |
sl@0 | 143 |
return EFalse; |
sl@0 | 144 |
} |
sl@0 | 145 |
//Accessor for resolution value |
sl@0 | 146 |
inline void TDisplayConfiguration1::SetResolutionTwips(const TSize& aSize) |
sl@0 | 147 |
{ |
sl@0 | 148 |
if (MemberAccessible(iTwipsSize)) |
sl@0 | 149 |
{ |
sl@0 | 150 |
if (aSize.iWidth<0 || aSize.iHeight<0) |
sl@0 | 151 |
{ |
sl@0 | 152 |
Panic(EPanicNegTwips); |
sl@0 | 153 |
} |
sl@0 | 154 |
if ((aSize.iWidth>0 && aSize.iHeight==0)|| |
sl@0 | 155 |
(aSize.iWidth==0 && aSize.iHeight>0)) |
sl@0 | 156 |
{ |
sl@0 | 157 |
Panic(EPanicSemiZeroTwips); |
sl@0 | 158 |
} |
sl@0 | 159 |
iDefined.Set(+EResolutionTwips); |
sl@0 | 160 |
iTwipsSize=aSize; |
sl@0 | 161 |
} |
sl@0 | 162 |
} |
sl@0 | 163 |
//Accessor for resolution value |
sl@0 | 164 |
inline TBool TDisplayConfiguration1::GetResolutionTwips(TSize& aSize) const |
sl@0 | 165 |
{ |
sl@0 | 166 |
if (MemberAccessible(iTwipsSize) && IsDefined(EResolutionTwips)) |
sl@0 | 167 |
{ |
sl@0 | 168 |
aSize=iTwipsSize; |
sl@0 | 169 |
return ETrue; |
sl@0 | 170 |
} |
sl@0 | 171 |
return EFalse; |
sl@0 | 172 |
} |
sl@0 | 173 |
|
sl@0 | 174 |
inline TBool TDisplayConfiguration1::operator == (const TDisplayConfiguration1& aRhs)const |
sl@0 | 175 |
{ |
sl@0 | 176 |
if (!TDisplayConfigurationBase::operator ==(aRhs)) |
sl@0 | 177 |
return EFalse; //Check for earlier version compatability |
sl@0 | 178 |
if (Version()<sizeof(*this)) |
sl@0 | 179 |
return ETrue; //If the objects are smaller than this then the check is complete |
sl@0 | 180 |
|
sl@0 | 181 |
TBool isAttrEqual = ETrue; |
sl@0 | 182 |
if(IsDefined(EResolution)) |
sl@0 | 183 |
{ |
sl@0 | 184 |
isAttrEqual = isAttrEqual&(aRhs.iResolution == iResolution); |
sl@0 | 185 |
} |
sl@0 | 186 |
if(IsDefined(ERotation)) |
sl@0 | 187 |
{ |
sl@0 | 188 |
isAttrEqual = isAttrEqual&(aRhs.iRotation == iRotation); |
sl@0 | 189 |
} |
sl@0 | 190 |
if(IsDefined(EResolutionTwips)) |
sl@0 | 191 |
{ |
sl@0 | 192 |
isAttrEqual = isAttrEqual&(aRhs.iTwipsSize == iTwipsSize); |
sl@0 | 193 |
} |
sl@0 | 194 |
|
sl@0 | 195 |
return isAttrEqual; |
sl@0 | 196 |
} |
sl@0 | 197 |
|
sl@0 | 198 |
// |
sl@0 | 199 |
// |
sl@0 | 200 |
// Complete implementation of v2 class (goes here) |
sl@0 | 201 |
// |
sl@0 | 202 |
// |
sl@0 | 203 |
|
sl@0 | 204 |
|
sl@0 | 205 |
// |
sl@0 | 206 |
// |
sl@0 | 207 |
// Complete implementation of Wrapper class |
sl@0 | 208 |
// |
sl@0 | 209 |
// |
sl@0 | 210 |
inline TDisplayConfiguration::TDisplayConfiguration(const TDisplayConfiguration& aDisplayConfiguration): |
sl@0 | 211 |
TDisplayConfigurationTop(TDisplayConfiguration().Version()) |
sl@0 | 212 |
{ |
sl@0 | 213 |
TInt tempSize = aDisplayConfiguration.Version(); |
sl@0 | 214 |
if (tempSize > TDisplayConfiguration().Version()) |
sl@0 | 215 |
{ |
sl@0 | 216 |
tempSize = TDisplayConfiguration().Version(); |
sl@0 | 217 |
} |
sl@0 | 218 |
Mem::Copy(this, &aDisplayConfiguration, tempSize); |
sl@0 | 219 |
//This has copied size for higher version features... |
sl@0 | 220 |
iVersion = tempSize; |
sl@0 | 221 |
//This has copied set flags for higher version features... |
sl@0 | 222 |
TInt flags=iDefined.Value(); |
sl@0 | 223 |
//If we have more than 32 attributes then this code will need a rewrite. |
sl@0 | 224 |
__ASSERT_COMPILE(EAttributeMax<=32); |
sl@0 | 225 |
flags&=(1<<EAttributeMax)-1; |
sl@0 | 226 |
iDefined.SetValue(flags); |
sl@0 | 227 |
} |
sl@0 | 228 |
|
sl@0 | 229 |
inline TDisplayConfiguration::TDisplayConfiguration(TInt aVersion): |
sl@0 | 230 |
TDisplayConfigurationTop(aVersion) |
sl@0 | 231 |
{ |
sl@0 | 232 |
if (TDisplayConfiguration().Version() > aVersion) |
sl@0 | 233 |
{ |
sl@0 | 234 |
iVersion = aVersion; |
sl@0 | 235 |
} |
sl@0 | 236 |
} |
sl@0 | 237 |
|
sl@0 | 238 |
#endif // _DISPLAYCONFIGURATION__INCLUDED_ |