Update contrib.
1 // Copyright (c) 2008-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
22 #ifndef _DISPLAYCONFIGURATION__INCLUDED_
23 #define _DISPLAYCONFIGURATION__INCLUDED_
25 #include <babitflags.h>
30 * Base class for display configuration hierarchy. Defines common facilities for
31 * all configurations (size, mask, accessibility).
33 class TDisplayConfigurationBase
37 * Enumeration of all of the display configuration attributes. Used in combination
38 * when calling ClearSettings() and SettingsDefined(). If attributes are added,
39 * corresponding enumeration bits must also be added.
47 EAttributeMax //this should safely work with value 32.
50 * Enumeration of the panics that may be raised when filling the display configuration
51 * These are all contractual input checks and should be avoidable by correctly written callers.
56 EPanicNegResolution=1, //<Input resolution size has negative ordinate
57 EPanicSemiZeroResolution, //<Input resolution size has only 1 zero ordinate
58 EPanicNonOpaqueBackground, //<Input background color is not opaque
59 EPanicIllegalRotation, //<Input rotation value is out of range
60 EPanicNegTwips, //<Input twips size has negative ordinate
61 EPanicSemiZeroTwips, //<Input twips size has only 1 zero ordinate
62 EPanicConfigInvalid //<Input config version is invalid
66 * Reads the version field.
68 * The version is set automatically in the constructor, or by the GetDisplayConfiguration()
69 * method to indicate the sender's supported structure version. The version reported after
70 * GetDisplayConfiguration() will match the version of one of the hierarchy of TDisplayConfiguration
71 * classes documented in the header, and will never exceed the constructed version.
73 * @return The defined version of this display configuration instance, in bytes.
75 inline TInt Version() const;
77 * Marks the given attribute as undefined.
79 * @param aAttribute The attribute to set as undefined.
81 inline void Clear(TAttribute aAttribute);
83 * Marks all attributes as undefined.
85 inline void ClearAll();
87 * Check if a particular member is defined.
89 * @param aAttribute The attribute to check.
90 * @return ETrue if the attribute is defined, EFalse otherwise.
92 inline TBool IsDefined(TAttribute aAttribute) const;
95 * Constructs a TDisplayConfigurationBase, setting the version to aVersion and all
96 * attributes undefined.
98 * Generally used internally in the constructor chain.
100 * @param aVersion The defined size of this object.
102 inline TDisplayConfigurationBase(TInt aVersion);
104 * Internal function for determining whether a given field name is accessible for an
105 * object of the current defined size. This must be used before trying to access any field.
107 * @param aMember The name of the field to check.
108 * @return ETrue if the field is accessible, EFalse if not.
110 template <class TMember> TBool MemberAccessible(const TMember& aMember) const
112 return iVersion>=sizeof(TMember)+TInt(&aMember)-TInt(this);
114 inline void Panic(TInt aPanicNo); //Should be a TPanic
116 * Compares two TDisplayConfigurationBase instances.
118 * Generally used internally in the comparison chain. The two objects are equivalent if
119 * they have the same version and the same set of attributes defined.
121 * @param aRhs The object to compare with this object
122 * @return ETrue if the objects are equivalent, EFalse if not.
124 inline TBool operator == (const TDisplayConfigurationBase& aRhs) const;
126 //Intentionally blocked functionality
127 inline TDisplayConfigurationBase();
128 inline TDisplayConfigurationBase(const TDisplayConfigurationBase& aDisplayConfigurationBase);
129 inline TDisplayConfigurationBase operator=(const TDisplayConfigurationBase& aRhs) const;
133 * Size to treat this object in bytes. Used to provide backward and forward
138 * Indicates which fields in the configuration have defined values. If a field
139 * contains an undefined value, it must be ignored.
140 * See TAttribute for possible bit values.
142 TBitFlags32 iDefined;
146 * First collection of display configuration settings.
149 class TDisplayConfiguration1 : public TDisplayConfigurationBase
152 /** Defines possible rotation values. */
155 /** Normal orientation is supported. */
157 /** A 90 degree rotation is supported. */
159 /** A 180 degree rotation is supported. */
161 /** A 270 degree rotation is supported. */
163 /** Illegal rotation value. */
168 * Construct a TDisplayConfiguration1 version object with all attributes undefined.
170 * This can be used to create a specific version of configuration:
171 * TDisplayConfiguration config(TDisplayConfiguration1.Version());
173 inline TDisplayConfiguration1();
175 * Defines the resolution for the display, in pixels.
177 * This always corresponds to a rotation of ERotationNormal. If a display can be
178 * disabled, (0,0) can be used to do so. A display can be disabled if the
179 * resolution list includes (0,0).
181 * @param aSize The resolution in pixels.
183 inline void SetResolution(const TSize& aSize);
185 * Retrieves the resolution, if defined.
187 * If the resolution is undefined, the parameter is left unchanged. A resolution
188 * of (0,0) means the display is disabled.
191 * @see TAttribute::EResolution
193 * @param aSize Receives the resolution.
195 inline TBool GetResolution(TSize& aSize) const;
197 * Defines the rotation for the display.
199 * The values that can be passed in here correspond directly to UI rotation values that can be
200 * passed in to CWsScreenDevice::SetScreenSizeAndRotation(), CWsScreenDevice::SetCurrentRotations()
201 * and so on, although the type is defined locally to avoid undesirable interdependencies in
202 * the interface. Variables of the two types may be freely cast to the other type.
204 * @see CFbsBitGc::TGraphicsOrientation
205 * @see CWsScreenDevice
207 * @param aRotation The display rotation.
209 inline void SetRotation(TRotation);
211 * Retrieves the rotation, if defined.
213 * If the rotation is undefined, the parameter is left unchanged.
216 * @see TAttribute::ERotation
218 * @param aSize Receives the rotation
219 * @return ETrue if the rotation is defined, EFalse otherwise.
221 inline TBool GetRotation(TRotation&)const;
223 * Defines the physical size of the display resolution area, in twips.
225 * @param aSizeInTwips Provides the size in twips.
227 inline void SetResolutionTwips(const TSize& aSize);
229 * Retrieves the physical size of the display resolution area, in twips, if defined.
231 * For displays that have a fixed size, or can report their size, the physical
232 * dimensions corresponding to the current resolution shall be defined. Where the display's
233 * physical size cannot be determined (such as with composite video output, or a projector)
234 * an arbitrary size shall be defined that reflects the pixel aspect ratio.
236 * If the display is not connected or output is disabled, the physical size shall not
237 * be defined. If the physical size is undefined, the parameter is left unchanged.
240 * @see TAttribute::EResolutionTwips
242 * @param aSizeInTwips Receives size in twips.
243 * @return ETrue if the size is defined, EFalse if not.
245 inline TBool GetResolutionTwips(TSize& aSize) const;
248 * Constructor for passing through a version already supplied.
250 * Generally used internally in the constructor chain.
252 * @param aVersion - Version of the class already calculated and being passed up
253 * through the classes.
255 inline TDisplayConfiguration1(TInt aVersion);
257 * Compares two TDisplayConfiguration1 instances.
259 * Generally used internally in the comparison chain. The two objects are equivalent if they have
260 * the same version, the same set of attributes defined and all the defined attributes are the
261 * same. Undefined attributes are not compared.
263 * @param aRhs The object to compare with this object.
264 * @return ETrue if the objects are equivalent, EFalse if not.
266 inline TBool operator == (const TDisplayConfiguration1& aRhs)const;
268 //Intentionally blocked functionality
269 inline TDisplayConfiguration1(const TDisplayConfiguration1& aDisplayConfiguration1);
270 inline TDisplayConfiguration1 operator=(const TDisplayConfiguration1& aRhs) const;
273 //Streamable data members
275 TInt iRotation; //0,1,2,3
280 * The display configuration class for general use.
282 * May be extended by adding a chain of classes between this and TDisplayConfiguration1.
283 * If so, also update the typedef TDisplayConfigurationTop.
286 class TDisplayConfiguration : public TDisplayConfiguration1
289 typedef TDisplayConfiguration1 TDisplayConfigurationTop;
292 * Construct a configuration of the default version with all attributes undefined.
294 inline TDisplayConfiguration(): TDisplayConfigurationTop()
297 * Copy constructor. This constructor will read the version field of the source and target
298 * objects and only copy the common set of fields. Any remaining fields in the target
299 * object will be set as undefined.
301 * @param aDisplayConfiguration Configuration to be copied.
303 inline TDisplayConfiguration(const TDisplayConfiguration& aDisplayConfiguration);
305 * Constructs a display configuration for a particular version.
307 * This constructor is designed to be used with the value returned by
308 * MDisplayControlBase::PreferredDisplayConfigurationVersion(), and initializes the members
309 * to represent an object compatible with that.
311 * The version used is the earlier of aVersion and the compile time version
312 * of TDisplayConfiguration.
314 * @param aVersion Caller-defined maximum version of configuration.
316 inline TDisplayConfiguration(TInt aVersion);
318 * Compares two TDisplayConfiguration instances.
320 * The two objects are equivalent if they have the same version, the same set of attributes defined
321 * and all the defined attributes are the same. Undefined attributes are not compared.
323 * @param aRhs The object to compare with this object.
324 * @return ETrue if the objects are equivalent, EFalse if not.
326 inline TBool operator == (const TDisplayConfiguration& aRhs)const
328 return TDisplayConfiguration1::operator==(aRhs);
331 //Intentionally blocked functionality
332 inline TDisplayConfiguration operator=(const TDisplayConfiguration& aRhs) const;
335 #include <graphics/displayconfiguration.inl>
336 #endif // _DISPLAYCONFIGURATION__INCLUDED_