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__INCLUDED_
|
sl@0
|
23 |
#define _DISPLAYCONFIGURATION__INCLUDED_
|
sl@0
|
24 |
|
sl@0
|
25 |
#include <babitflags.h>
|
sl@0
|
26 |
#include <gdi.h>
|
sl@0
|
27 |
|
sl@0
|
28 |
|
sl@0
|
29 |
/**
|
sl@0
|
30 |
* Base class for display configuration hierarchy. Defines common facilities for
|
sl@0
|
31 |
* all configurations (size, mask, accessibility).
|
sl@0
|
32 |
*/
|
sl@0
|
33 |
class TDisplayConfigurationBase
|
sl@0
|
34 |
{
|
sl@0
|
35 |
public:
|
sl@0
|
36 |
/**
|
sl@0
|
37 |
* Enumeration of all of the display configuration attributes. Used in combination
|
sl@0
|
38 |
* when calling ClearSettings() and SettingsDefined(). If attributes are added,
|
sl@0
|
39 |
* corresponding enumeration bits must also be added.
|
sl@0
|
40 |
*/
|
sl@0
|
41 |
enum TAttribute
|
sl@0
|
42 |
{
|
sl@0
|
43 |
EResolution = 0,
|
sl@0
|
44 |
ERotation,
|
sl@0
|
45 |
EResolutionTwips,
|
sl@0
|
46 |
|
sl@0
|
47 |
EAttributeMax //this should safely work with value 32.
|
sl@0
|
48 |
};
|
sl@0
|
49 |
/**
|
sl@0
|
50 |
* Enumeration of the panics that may be raised when filling the display configuration
|
sl@0
|
51 |
* These are all contractual input checks and should be avoidable by correctly written callers.
|
sl@0
|
52 |
*
|
sl@0
|
53 |
**/
|
sl@0
|
54 |
enum TPanics
|
sl@0
|
55 |
{
|
sl@0
|
56 |
EPanicNegResolution=1, //<Input resolution size has negative ordinate
|
sl@0
|
57 |
EPanicSemiZeroResolution, //<Input resolution size has only 1 zero ordinate
|
sl@0
|
58 |
EPanicNonOpaqueBackground, //<Input background color is not opaque
|
sl@0
|
59 |
EPanicIllegalRotation, //<Input rotation value is out of range
|
sl@0
|
60 |
EPanicNegTwips, //<Input twips size has negative ordinate
|
sl@0
|
61 |
EPanicSemiZeroTwips, //<Input twips size has only 1 zero ordinate
|
sl@0
|
62 |
EPanicConfigInvalid //<Input config version is invalid
|
sl@0
|
63 |
};
|
sl@0
|
64 |
public:
|
sl@0
|
65 |
/**
|
sl@0
|
66 |
* Reads the version field.
|
sl@0
|
67 |
*
|
sl@0
|
68 |
* The version is set automatically in the constructor, or by the GetDisplayConfiguration()
|
sl@0
|
69 |
* method to indicate the sender's supported structure version. The version reported after
|
sl@0
|
70 |
* GetDisplayConfiguration() will match the version of one of the hierarchy of TDisplayConfiguration
|
sl@0
|
71 |
* classes documented in the header, and will never exceed the constructed version.
|
sl@0
|
72 |
*
|
sl@0
|
73 |
* @return The defined version of this display configuration instance, in bytes.
|
sl@0
|
74 |
*/
|
sl@0
|
75 |
inline TInt Version() const;
|
sl@0
|
76 |
/**
|
sl@0
|
77 |
* Marks the given attribute as undefined.
|
sl@0
|
78 |
*
|
sl@0
|
79 |
* @param aAttribute The attribute to set as undefined.
|
sl@0
|
80 |
*/
|
sl@0
|
81 |
inline void Clear(TAttribute aAttribute);
|
sl@0
|
82 |
/**
|
sl@0
|
83 |
* Marks all attributes as undefined.
|
sl@0
|
84 |
*/
|
sl@0
|
85 |
inline void ClearAll();
|
sl@0
|
86 |
/**
|
sl@0
|
87 |
* Check if a particular member is defined.
|
sl@0
|
88 |
*
|
sl@0
|
89 |
* @param aAttribute The attribute to check.
|
sl@0
|
90 |
* @return ETrue if the attribute is defined, EFalse otherwise.
|
sl@0
|
91 |
*/
|
sl@0
|
92 |
inline TBool IsDefined(TAttribute aAttribute) const;
|
sl@0
|
93 |
protected:
|
sl@0
|
94 |
/**
|
sl@0
|
95 |
* Constructs a TDisplayConfigurationBase, setting the version to aVersion and all
|
sl@0
|
96 |
* attributes undefined.
|
sl@0
|
97 |
*
|
sl@0
|
98 |
* Generally used internally in the constructor chain.
|
sl@0
|
99 |
*
|
sl@0
|
100 |
* @param aVersion The defined size of this object.
|
sl@0
|
101 |
*/
|
sl@0
|
102 |
inline TDisplayConfigurationBase(TInt aVersion);
|
sl@0
|
103 |
/**
|
sl@0
|
104 |
* Internal function for determining whether a given field name is accessible for an
|
sl@0
|
105 |
* object of the current defined size. This must be used before trying to access any field.
|
sl@0
|
106 |
*
|
sl@0
|
107 |
* @param aMember The name of the field to check.
|
sl@0
|
108 |
* @return ETrue if the field is accessible, EFalse if not.
|
sl@0
|
109 |
*/
|
sl@0
|
110 |
template <class TMember> TBool MemberAccessible(const TMember& aMember) const
|
sl@0
|
111 |
{
|
sl@0
|
112 |
return iVersion>=sizeof(TMember)+TInt(&aMember)-TInt(this);
|
sl@0
|
113 |
}
|
sl@0
|
114 |
inline void Panic(TInt aPanicNo); //Should be a TPanic
|
sl@0
|
115 |
/**
|
sl@0
|
116 |
* Compares two TDisplayConfigurationBase instances.
|
sl@0
|
117 |
*
|
sl@0
|
118 |
* Generally used internally in the comparison chain. The two objects are equivalent if
|
sl@0
|
119 |
* they have the same version and the same set of attributes defined.
|
sl@0
|
120 |
*
|
sl@0
|
121 |
* @param aRhs The object to compare with this object
|
sl@0
|
122 |
* @return ETrue if the objects are equivalent, EFalse if not.
|
sl@0
|
123 |
*/
|
sl@0
|
124 |
inline TBool operator == (const TDisplayConfigurationBase& aRhs) const;
|
sl@0
|
125 |
private:
|
sl@0
|
126 |
//Intentionally blocked functionality
|
sl@0
|
127 |
inline TDisplayConfigurationBase();
|
sl@0
|
128 |
inline TDisplayConfigurationBase(const TDisplayConfigurationBase& aDisplayConfigurationBase);
|
sl@0
|
129 |
inline TDisplayConfigurationBase operator=(const TDisplayConfigurationBase& aRhs) const;
|
sl@0
|
130 |
|
sl@0
|
131 |
protected:
|
sl@0
|
132 |
/**
|
sl@0
|
133 |
* Size to treat this object in bytes. Used to provide backward and forward
|
sl@0
|
134 |
* compatibility.
|
sl@0
|
135 |
*/
|
sl@0
|
136 |
TInt iVersion;
|
sl@0
|
137 |
/**
|
sl@0
|
138 |
* Indicates which fields in the configuration have defined values. If a field
|
sl@0
|
139 |
* contains an undefined value, it must be ignored.
|
sl@0
|
140 |
* See TAttribute for possible bit values.
|
sl@0
|
141 |
*/
|
sl@0
|
142 |
TBitFlags32 iDefined;
|
sl@0
|
143 |
};
|
sl@0
|
144 |
|
sl@0
|
145 |
/**
|
sl@0
|
146 |
* First collection of display configuration settings.
|
sl@0
|
147 |
*
|
sl@0
|
148 |
*/
|
sl@0
|
149 |
class TDisplayConfiguration1 : public TDisplayConfigurationBase
|
sl@0
|
150 |
{
|
sl@0
|
151 |
public:
|
sl@0
|
152 |
/** Defines possible rotation values. */
|
sl@0
|
153 |
enum TRotation
|
sl@0
|
154 |
{
|
sl@0
|
155 |
/** Normal orientation is supported. */
|
sl@0
|
156 |
ERotationNormal,
|
sl@0
|
157 |
/** A 90 degree rotation is supported. */
|
sl@0
|
158 |
ERotation90CW,
|
sl@0
|
159 |
/** A 180 degree rotation is supported. */
|
sl@0
|
160 |
ERotation180,
|
sl@0
|
161 |
/** A 270 degree rotation is supported. */
|
sl@0
|
162 |
ERotation270CW,
|
sl@0
|
163 |
/** Illegal rotation value. */
|
sl@0
|
164 |
ERotationIllegal
|
sl@0
|
165 |
};
|
sl@0
|
166 |
public:
|
sl@0
|
167 |
/**
|
sl@0
|
168 |
* Construct a TDisplayConfiguration1 version object with all attributes undefined.
|
sl@0
|
169 |
*
|
sl@0
|
170 |
* This can be used to create a specific version of configuration:
|
sl@0
|
171 |
* TDisplayConfiguration config(TDisplayConfiguration1.Version());
|
sl@0
|
172 |
*/
|
sl@0
|
173 |
inline TDisplayConfiguration1();
|
sl@0
|
174 |
/**
|
sl@0
|
175 |
* Defines the resolution for the display, in pixels.
|
sl@0
|
176 |
*
|
sl@0
|
177 |
* This always corresponds to a rotation of ERotationNormal. If a display can be
|
sl@0
|
178 |
* disabled, (0,0) can be used to do so. A display can be disabled if the
|
sl@0
|
179 |
* resolution list includes (0,0).
|
sl@0
|
180 |
*
|
sl@0
|
181 |
* @param aSize The resolution in pixels.
|
sl@0
|
182 |
*/
|
sl@0
|
183 |
inline void SetResolution(const TSize& aSize);
|
sl@0
|
184 |
/**
|
sl@0
|
185 |
* Retrieves the resolution, if defined.
|
sl@0
|
186 |
*
|
sl@0
|
187 |
* If the resolution is undefined, the parameter is left unchanged. A resolution
|
sl@0
|
188 |
* of (0,0) means the display is disabled.
|
sl@0
|
189 |
*
|
sl@0
|
190 |
* @see IsDefined
|
sl@0
|
191 |
* @see TAttribute::EResolution
|
sl@0
|
192 |
*
|
sl@0
|
193 |
* @param aSize Receives the resolution.
|
sl@0
|
194 |
*/
|
sl@0
|
195 |
inline TBool GetResolution(TSize& aSize) const;
|
sl@0
|
196 |
/**
|
sl@0
|
197 |
* Defines the rotation for the display.
|
sl@0
|
198 |
*
|
sl@0
|
199 |
* The values that can be passed in here correspond directly to UI rotation values that can be
|
sl@0
|
200 |
* passed in to CWsScreenDevice::SetScreenSizeAndRotation(), CWsScreenDevice::SetCurrentRotations()
|
sl@0
|
201 |
* and so on, although the type is defined locally to avoid undesirable interdependencies in
|
sl@0
|
202 |
* the interface. Variables of the two types may be freely cast to the other type.
|
sl@0
|
203 |
*
|
sl@0
|
204 |
* @see CFbsBitGc::TGraphicsOrientation
|
sl@0
|
205 |
* @see CWsScreenDevice
|
sl@0
|
206 |
*
|
sl@0
|
207 |
* @param aRotation The display rotation.
|
sl@0
|
208 |
*/
|
sl@0
|
209 |
inline void SetRotation(TRotation);
|
sl@0
|
210 |
/**
|
sl@0
|
211 |
* Retrieves the rotation, if defined.
|
sl@0
|
212 |
*
|
sl@0
|
213 |
* If the rotation is undefined, the parameter is left unchanged.
|
sl@0
|
214 |
*
|
sl@0
|
215 |
* @see IsDefined
|
sl@0
|
216 |
* @see TAttribute::ERotation
|
sl@0
|
217 |
*
|
sl@0
|
218 |
* @param aSize Receives the rotation
|
sl@0
|
219 |
* @return ETrue if the rotation is defined, EFalse otherwise.
|
sl@0
|
220 |
*/
|
sl@0
|
221 |
inline TBool GetRotation(TRotation&)const;
|
sl@0
|
222 |
/**
|
sl@0
|
223 |
* Defines the physical size of the display resolution area, in twips.
|
sl@0
|
224 |
*
|
sl@0
|
225 |
* @param aSizeInTwips Provides the size in twips.
|
sl@0
|
226 |
*/
|
sl@0
|
227 |
inline void SetResolutionTwips(const TSize& aSize);
|
sl@0
|
228 |
/**
|
sl@0
|
229 |
* Retrieves the physical size of the display resolution area, in twips, if defined.
|
sl@0
|
230 |
*
|
sl@0
|
231 |
* For displays that have a fixed size, or can report their size, the physical
|
sl@0
|
232 |
* dimensions corresponding to the current resolution shall be defined. Where the display's
|
sl@0
|
233 |
* physical size cannot be determined (such as with composite video output, or a projector)
|
sl@0
|
234 |
* an arbitrary size shall be defined that reflects the pixel aspect ratio.
|
sl@0
|
235 |
*
|
sl@0
|
236 |
* If the display is not connected or output is disabled, the physical size shall not
|
sl@0
|
237 |
* be defined. If the physical size is undefined, the parameter is left unchanged.
|
sl@0
|
238 |
*
|
sl@0
|
239 |
* @see IsDefined
|
sl@0
|
240 |
* @see TAttribute::EResolutionTwips
|
sl@0
|
241 |
*
|
sl@0
|
242 |
* @param aSizeInTwips Receives size in twips.
|
sl@0
|
243 |
* @return ETrue if the size is defined, EFalse if not.
|
sl@0
|
244 |
*/
|
sl@0
|
245 |
inline TBool GetResolutionTwips(TSize& aSize) const;
|
sl@0
|
246 |
protected:
|
sl@0
|
247 |
/**
|
sl@0
|
248 |
* Constructor for passing through a version already supplied.
|
sl@0
|
249 |
*
|
sl@0
|
250 |
* Generally used internally in the constructor chain.
|
sl@0
|
251 |
*
|
sl@0
|
252 |
* @param aVersion - Version of the class already calculated and being passed up
|
sl@0
|
253 |
* through the classes.
|
sl@0
|
254 |
*/
|
sl@0
|
255 |
inline TDisplayConfiguration1(TInt aVersion);
|
sl@0
|
256 |
/**
|
sl@0
|
257 |
* Compares two TDisplayConfiguration1 instances.
|
sl@0
|
258 |
*
|
sl@0
|
259 |
* Generally used internally in the comparison chain. The two objects are equivalent if they have
|
sl@0
|
260 |
* the same version, the same set of attributes defined and all the defined attributes are the
|
sl@0
|
261 |
* same. Undefined attributes are not compared.
|
sl@0
|
262 |
*
|
sl@0
|
263 |
* @param aRhs The object to compare with this object.
|
sl@0
|
264 |
* @return ETrue if the objects are equivalent, EFalse if not.
|
sl@0
|
265 |
*/
|
sl@0
|
266 |
inline TBool operator == (const TDisplayConfiguration1& aRhs)const;
|
sl@0
|
267 |
private:
|
sl@0
|
268 |
//Intentionally blocked functionality
|
sl@0
|
269 |
inline TDisplayConfiguration1(const TDisplayConfiguration1& aDisplayConfiguration1);
|
sl@0
|
270 |
inline TDisplayConfiguration1 operator=(const TDisplayConfiguration1& aRhs) const;
|
sl@0
|
271 |
|
sl@0
|
272 |
private:
|
sl@0
|
273 |
//Streamable data members
|
sl@0
|
274 |
TSize iResolution;
|
sl@0
|
275 |
TInt iRotation; //0,1,2,3
|
sl@0
|
276 |
TSize iTwipsSize;
|
sl@0
|
277 |
};
|
sl@0
|
278 |
|
sl@0
|
279 |
/**
|
sl@0
|
280 |
* The display configuration class for general use.
|
sl@0
|
281 |
*
|
sl@0
|
282 |
* May be extended by adding a chain of classes between this and TDisplayConfiguration1.
|
sl@0
|
283 |
* If so, also update the typedef TDisplayConfigurationTop.
|
sl@0
|
284 |
*
|
sl@0
|
285 |
*/
|
sl@0
|
286 |
class TDisplayConfiguration : public TDisplayConfiguration1
|
sl@0
|
287 |
{
|
sl@0
|
288 |
private:
|
sl@0
|
289 |
typedef TDisplayConfiguration1 TDisplayConfigurationTop;
|
sl@0
|
290 |
public:
|
sl@0
|
291 |
/**
|
sl@0
|
292 |
* Construct a configuration of the default version with all attributes undefined.
|
sl@0
|
293 |
*/
|
sl@0
|
294 |
inline TDisplayConfiguration(): TDisplayConfigurationTop()
|
sl@0
|
295 |
{}
|
sl@0
|
296 |
/**
|
sl@0
|
297 |
* Copy constructor. This constructor will read the version field of the source and target
|
sl@0
|
298 |
* objects and only copy the common set of fields. Any remaining fields in the target
|
sl@0
|
299 |
* object will be set as undefined.
|
sl@0
|
300 |
*
|
sl@0
|
301 |
* @param aDisplayConfiguration Configuration to be copied.
|
sl@0
|
302 |
*/
|
sl@0
|
303 |
inline TDisplayConfiguration(const TDisplayConfiguration& aDisplayConfiguration);
|
sl@0
|
304 |
/**
|
sl@0
|
305 |
* Constructs a display configuration for a particular version.
|
sl@0
|
306 |
*
|
sl@0
|
307 |
* This constructor is designed to be used with the value returned by
|
sl@0
|
308 |
* MDisplayControlBase::PreferredDisplayConfigurationVersion(), and initializes the members
|
sl@0
|
309 |
* to represent an object compatible with that.
|
sl@0
|
310 |
*
|
sl@0
|
311 |
* The version used is the earlier of aVersion and the compile time version
|
sl@0
|
312 |
* of TDisplayConfiguration.
|
sl@0
|
313 |
*
|
sl@0
|
314 |
* @param aVersion Caller-defined maximum version of configuration.
|
sl@0
|
315 |
*/
|
sl@0
|
316 |
inline TDisplayConfiguration(TInt aVersion);
|
sl@0
|
317 |
/**
|
sl@0
|
318 |
* Compares two TDisplayConfiguration instances.
|
sl@0
|
319 |
*
|
sl@0
|
320 |
* The two objects are equivalent if they have the same version, the same set of attributes defined
|
sl@0
|
321 |
* and all the defined attributes are the same. Undefined attributes are not compared.
|
sl@0
|
322 |
*
|
sl@0
|
323 |
* @param aRhs The object to compare with this object.
|
sl@0
|
324 |
* @return ETrue if the objects are equivalent, EFalse if not.
|
sl@0
|
325 |
*/
|
sl@0
|
326 |
inline TBool operator == (const TDisplayConfiguration& aRhs)const
|
sl@0
|
327 |
{
|
sl@0
|
328 |
return TDisplayConfiguration1::operator==(aRhs);
|
sl@0
|
329 |
}
|
sl@0
|
330 |
private:
|
sl@0
|
331 |
//Intentionally blocked functionality
|
sl@0
|
332 |
inline TDisplayConfiguration operator=(const TDisplayConfiguration& aRhs) const;
|
sl@0
|
333 |
};
|
sl@0
|
334 |
|
sl@0
|
335 |
#include <graphics/displayconfiguration.inl>
|
sl@0
|
336 |
#endif // _DISPLAYCONFIGURATION__INCLUDED_
|