windowing/windowserver/nonnga/CLIENT/RSCRDEV.CPP
changeset 0 5d03bc08d59c
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 // Copyright (c) 1995-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".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Shells for window server screen device
       
    15 // 
       
    16 //
       
    17 
       
    18 #include <e32std.h>
       
    19 #include <e32hal.h>
       
    20 #include "../SERVER/w32cmd.h"
       
    21 #include "CLIENT.H"
       
    22 #include "w32comm.h"
       
    23 #include "scrdevextension.h"
       
    24 
       
    25 const TInt KDefaultScreenNumber = 0 ;
       
    26 
       
    27 EXPORT_C CWsScreenDevice::CWsScreenDevice()
       
    28 /** Default constructor. Developers should use the other constructor overload. */
       
    29 	{
       
    30 	}
       
    31 
       
    32 EXPORT_C CWsScreenDevice::CWsScreenDevice(RWsSession &aWs) : MWsClientClass(aWs.iBuffer)
       
    33 /** Constructs a new screen device attached to a particular window server session.
       
    34 
       
    35 @param aWs The window server session this screen should be attached to. */
       
    36 	{
       
    37 	}
       
    38 
       
    39 EXPORT_C TInt CWsScreenDevice::CreateContext(CGraphicsContext *&aGc)
       
    40 /** Creates a graphics context for this device.
       
    41 
       
    42 This function always causes a flush of the window server buffer.
       
    43 
       
    44 @param aGc On successful return, contains a new graphics context referring 
       
    45 to this screen device. 
       
    46 @return KErrNone if successful, otherwise one of the system-wide error codes. 
       
    47 @see CGraphicsDevice::CreateContext() */
       
    48 	{
       
    49 	if ((aGc=new CWindowGc(this))==NULL)
       
    50 		return(KErrNoMemory);
       
    51 	TInt err=((CWindowGc *)aGc)->Construct();
       
    52 	if (err!=KErrNone)
       
    53 		{
       
    54 		delete aGc;
       
    55 		aGc=NULL;
       
    56 		}
       
    57 	return(err);
       
    58 	}
       
    59 
       
    60 EXPORT_C CWsScreenDevice::~CWsScreenDevice()
       
    61 /** Destructor. */
       
    62 	{
       
    63 	if (iBuffer)
       
    64 		{
       
    65 		if (iWsHandle)
       
    66 			Write(EWsSdOpFree);
       
    67 		}
       
    68 	if (iExtension)
       
    69 		{
       
    70 		delete TypeFaceStore();
       
    71 		delete iExtension;
       
    72 		}
       
    73 	}
       
    74 
       
    75 #pragma warning(disable : 4710)
       
    76 /** 
       
    77 Completes construction of the object.
       
    78 
       
    79 This method invokes Construct(TInt aDefaultScreenNumber) with default Screen number.
       
    80 @return KErrNone if successful, otherwise another of the system-wide error codes. 
       
    81 */
       
    82 EXPORT_C TInt CWsScreenDevice::Construct()
       
    83 	{
       
    84 	return Construct( KDefaultScreenNumber ) ;
       
    85 	}
       
    86 
       
    87 
       
    88 EXPORT_C TInt CWsScreenDevice::Construct(TInt aDefaultScreenNumber)
       
    89 /** Completes construction of the object.
       
    90 
       
    91 This function always causes a flush of the window server buffer.
       
    92 @param aDefaultScreenNumber - This is the screen on which an application will start
       
    93 @return KErrNone if successful, otherwise another of the system-wide error 
       
    94 codes. 
       
    95 @panic TW32Panic 17 in debug builds if called on an already constructed object.*/
       
    96 	{
       
    97 	__ASSERT_DEBUG(iWsHandle == KNullHandle, Panic(EW32PanicGraphicDoubleConstruction));
       
    98 	TInt ret;
       
    99 	TWsClCmdCreateScreenDevice createScreenDevice;
       
   100 	createScreenDevice.screenNumber = aDefaultScreenNumber;
       
   101 	createScreenDevice.clientScreenDevicePointer = (TUint)this;
       
   102 	if ( ( ret=iBuffer->WriteReplyWs(&createScreenDevice,sizeof(createScreenDevice),EWsClOpCreateScreenDevice ) ) < 0 )
       
   103 		{
       
   104 		iBuffer=NULL;
       
   105 		}
       
   106 	else
       
   107 		{
       
   108 		iWsHandle=ret;
       
   109 		//If the extension fails to allocate then clients will be refused access to the extension interface.
       
   110 		TRAP(ret,iExtension=new(ELeave) CScrDevExtension(iBuffer,iWsHandle));
       
   111 		if (ret>=KErrNone)
       
   112 			{
       
   113 			TRAP(ret,iExtension->SetTypefaceStore(CFbsTypefaceStore::NewL(this)));
       
   114 			}
       
   115 		iDisplaySizeInPixels=SizeInPixels();
       
   116 		iPhysicalScreenSizeInTwips=SizeInTwips();
       
   117 		if (iDisplaySizeInPixels.iWidth==0)
       
   118 			{
       
   119 			TMachineInfoV1Buf macInfo;
       
   120 			UserHal::MachineInfo(macInfo);
       
   121 			iPhysicalScreenSizeInTwips=macInfo().iPhysicalScreenSize;
       
   122 			iDisplaySizeInPixels=macInfo().iDisplaySizeInPixels;
       
   123 			}
       
   124 		}
       
   125 	return(ret);
       
   126 	}
       
   127 #pragma warning(default : 4710)
       
   128 
       
   129 EXPORT_C TDisplayMode CWsScreenDevice::DisplayMode() const
       
   130 /** Gets the device's display mode.
       
   131 
       
   132 This function always causes a flush of the window server buffer.
       
   133 
       
   134 @return The device's display mode. 
       
   135 @see CGraphicsDevice::DisplayMode() */
       
   136 	{
       
   137 	return((TDisplayMode)WriteReply(EWsSdOpDisplayMode));
       
   138 	}
       
   139 
       
   140 EXPORT_C TRect CWsScreenDevice::PointerRect() const
       
   141 /** Gets the active area for the pointing device. 
       
   142 
       
   143 This is a device-dependent parameter, and will typically depend on the screen 
       
   144 size and other factors.
       
   145 
       
   146 This function always causes a flush of the window server buffer.
       
   147 
       
   148 @return The active area, measured in pixels. */
       
   149 	{
       
   150 	TPckgBuf<TRect> rectPkg;
       
   151   	WriteReplyP(&rectPkg,EWsSdOpPointerRect);
       
   152 	return(rectPkg());
       
   153 	}
       
   154 
       
   155 EXPORT_C TSize CWsScreenDevice::SizeInPixels() const
       
   156 /** Gets the size of the screen device area in pixels.
       
   157 
       
   158 This function always causes a flush of the window server buffer.
       
   159 
       
   160 @return The x and y dimensions of the screen device area, in pixels. 
       
   161 @see CGraphicsDevice::SizeInPixels() */
       
   162 	{
       
   163 	TPckgBuf<TSize> sizePkg;
       
   164   	WriteReplyP(&sizePkg,EWsSdOpPixelSize);
       
   165 	return(sizePkg());
       
   166 	}
       
   167 
       
   168 EXPORT_C TSize CWsScreenDevice::SizeInTwips() const
       
   169 /** Gets the size of the screen device area in twips.
       
   170 
       
   171 This function always causes a flush of the window server buffer.
       
   172 
       
   173 @return The x and y dimensions of the screen device area, in twips. 
       
   174 @see CGraphicsDevice::SizeInTwips() */
       
   175 	{
       
   176 	TPckgBuf<TSize> sizePkg;
       
   177   	WriteReplyP(&sizePkg,EWsSdOpTwipsSize);
       
   178 	return(sizePkg());
       
   179 	}
       
   180 
       
   181 EXPORT_C TInt CWsScreenDevice::HorizontalTwipsToPixels(TInt aTwips) const
       
   182 /** Translates a twips to a pixel value.
       
   183 
       
   184 @param aTwips The value in twips. 
       
   185 @return The equivalent number of pixels. 
       
   186 @see MGraphicsDeviceMap::HorizontalTwipsToPixels() */
       
   187 	{
       
   188 	TInt64 twips=aTwips;
       
   189 	twips=(twips*iDisplaySizeInPixels.iWidth+(iPhysicalScreenSizeInTwips.iWidth/2))/iPhysicalScreenSizeInTwips.iWidth;
       
   190 	return I64INT(twips);
       
   191 	}
       
   192 
       
   193 EXPORT_C TInt CWsScreenDevice::VerticalTwipsToPixels(TInt aTwips) const
       
   194 /** Translates a vertical dimension of a screen device in twips into pixels.
       
   195 
       
   196 @param aTwips A vertical dimension of a device in twips. 
       
   197 @return The vertical dimension in pixels. */
       
   198 	{
       
   199 	TInt64 twips=aTwips;
       
   200 	twips=(twips*iDisplaySizeInPixels.iHeight+(iPhysicalScreenSizeInTwips.iHeight/2))/iPhysicalScreenSizeInTwips.iHeight;
       
   201 	return I64INT(twips);
       
   202 	}
       
   203 
       
   204 EXPORT_C TInt CWsScreenDevice::HorizontalPixelsToTwips(TInt aPixels) const
       
   205 /** Translates a specified pixel value to a twips value. 
       
   206 
       
   207 @param aPixels The value in pixels to be translated. 
       
   208 @return The equivalent number of twips. */
       
   209 	{
       
   210 	TInt64 pixels=aPixels;
       
   211 	pixels=(pixels*iPhysicalScreenSizeInTwips.iWidth+(iDisplaySizeInPixels.iWidth/2))/iDisplaySizeInPixels.iWidth;
       
   212 	return I64INT(pixels);
       
   213 	}
       
   214 
       
   215 EXPORT_C TInt CWsScreenDevice::VerticalPixelsToTwips(TInt aPixels) const
       
   216 /** Translates a vertical dimension of a screen device in pixels into twips.
       
   217 
       
   218 @param aPixels A vertical dimension of a device in pixels. 
       
   219 @return The vertical dimension in twips. 
       
   220 @see MGraphicsDeviceMap::VerticalPixelsToTwips() */
       
   221 	{
       
   222 	TInt64 pixels=aPixels;
       
   223 	pixels=(pixels*iPhysicalScreenSizeInTwips.iHeight+(iDisplaySizeInPixels.iHeight/2))/iDisplaySizeInPixels.iHeight;
       
   224 	return I64INT(pixels);
       
   225 	}
       
   226 
       
   227 EXPORT_C void CWsScreenDevice::GetPixel(TRgb &aColor,const TPoint &aPixel) const
       
   228 /** Gets the RGB colour of an individual pixel on a screen device.
       
   229 
       
   230 This function always causes a flush of the window server buffer.
       
   231 
       
   232 @param aColor On return, contains the RGB colour of the pixel. 
       
   233 @param aPixel The x,y co-ordinates of the pixel. The top left pixel is (0,0).
       
   234 @see CBitmapDevice::GetPixel() */
       
   235 	{
       
   236 	aColor.SetInternal(((TUint32)WriteReply(&aPixel,sizeof(aPixel),EWsSdOpPixel)));
       
   237 	}
       
   238 
       
   239 EXPORT_C void CWsScreenDevice::GetScanLine(TDes8 &aScanLine,const TPoint &aStartPixel,TInt aPixelLength, TDisplayMode aDispMode) const
       
   240 /** Gets a scanline into a buffer. 
       
   241 
       
   242 The pixels are converted from the current screen display mode format 
       
   243 to the format of the specified device display mode.
       
   244 
       
   245 By specifying the start pixel and number of pixels either the whole or a portion 
       
   246 of a row of screen pixels may be copied.
       
   247 
       
   248 This function always causes a flush of the window server buffer.
       
   249 
       
   250 @param aScanLine A buffer into which pixels are copied, it must be sufficiently 
       
   251 large to store all the scanline pixels. 
       
   252 @param aStartPixel The (x,y) co-ordinates of the first pixel of the bitmap scanline 
       
   253 to be put into the buffer. 
       
   254 @param aPixelLength The number of pixels to put into the buffer.
       
   255 @param aDispMode The display mode into which to convert the pixels. 
       
   256 @see CBitmapDevice::GetScanLine() */
       
   257 	{
       
   258 	TWsSdCmdGetScanLine getScanLine(aStartPixel,aPixelLength,aDispMode);
       
   259 	WriteReplyP(&getScanLine,sizeof(getScanLine),&aScanLine,EWsSdOpGetScanLine);
       
   260 	}
       
   261 
       
   262 EXPORT_C TBool CWsScreenDevice::RectCompare(const TRect &aRect1,const TRect &aRect2) const
       
   263 /** Compares two areas of the screen to see if they have the same content. 
       
   264 
       
   265 If there are any sprites on the screen they are not included in the comparison.
       
   266 
       
   267 This function always causes a flush of the window server buffer.
       
   268 
       
   269 @param aRect1 A rectangle. 
       
   270 @param aRect2 Another rectangle. 
       
   271 @return ETrue if the two screen areas are identical. */
       
   272  	{
       
   273 	return RectCompare(aRect1,aRect2,ERemoveSprite);
       
   274 	}
       
   275 
       
   276 EXPORT_C TBool CWsScreenDevice::RectCompare(const TRect &aRect1,const TRect &aRect2,TUint aFlags) const
       
   277 /** Compares two areas of the screen to see if they have the same content.
       
   278  
       
   279 This function always causes a flush of the window server buffer.
       
   280 
       
   281 @param aRect1 A rectangle. 
       
   282 @param aRect2 Another rectangle.
       
   283 @param aFlags EIncludeSprite to include the sprite in the compare or ERemoveSprite to remove the sprite.
       
   284 @return ETrue if the two screen areas are identical. */
       
   285 	{
       
   286 	TWsSdCmdRectCompare rectCompare(aRect1,aRect2,aFlags);
       
   287  	return(WriteReply(&rectCompare,sizeof(rectCompare),EWsSdOpRectCompare));
       
   288  	}
       
   289 
       
   290 EXPORT_C TInt CWsScreenDevice::CopyScreenToBitmap(const CFbsBitmap *aBitmap) const
       
   291 /** Saves the entire screen to a bitmap.
       
   292 
       
   293 This function always causes a flush of the window server buffer.
       
   294 
       
   295 @param aBitmap Bitmap to be filled with the screen image. 
       
   296 @return KErrNone if successful, otherwise one of the system-wide error codes. */
       
   297 	{
       
   298 	AddToBitmapArray(aBitmap->Handle());
       
   299 	TWsSdCmdCopyScreenToBitmap rectCompare(aBitmap->Handle());
       
   300 	return(WriteReply(&rectCompare,sizeof(rectCompare),EWsSdOpCopyScreenToBitmap));
       
   301 	}
       
   302 
       
   303 EXPORT_C TInt CWsScreenDevice::CopyScreenToBitmap(const CFbsBitmap *aBitmap, const TRect &aRect) const
       
   304 /** Saves a region of the screen to a bitmap.
       
   305 
       
   306 This function always causes a flush of the window server buffer.
       
   307 
       
   308 @param aBitmap Bitmap to be filled with the screen region image. 
       
   309 @param aRect Screen region to be saved. 
       
   310 @return KErrNone if successful, otherwise one of the system-wide error codes. */
       
   311 	{
       
   312 	AddToBitmapArray(aBitmap->Handle());
       
   313 	TWsSdCmdCopyScreenToBitmap2 rectCompare(aRect, aBitmap->Handle());
       
   314 	return(WriteReply(&rectCompare,sizeof(rectCompare),EWsSdOpCopyScreenToBitmap2));
       
   315 	}
       
   316 
       
   317 EXPORT_C TInt CWsScreenDevice::GetNearestFontInTwips(CFont*& aFont,const TFontSpec& aFontSpec)
       
   318 /** Gets the nearest font, in twips, to that in the specified font specification. 
       
   319 
       
   320 This function is replaced by GetNearestFontToDesignHeightInTwips()
       
   321 
       
   322 The font and bitmap server returns a pointer to the nearest matching font 
       
   323 from those available, in aFont.
       
   324 
       
   325 @param aFont On return, this is set to point to the device font closest to the font 
       
   326 specification passed in the second argument.
       
   327 @param aFontSpec An absolute font specification. 
       
   328 @return KErrNone if successful, otherwise another of the system-wide error 
       
   329 codes. 
       
   330 @see MGraphicsDeviceMap::GetNearestFontInTwips()
       
   331 @deprecated */
       
   332 	{
       
   333 	return GetNearestFontToDesignHeightInTwips(aFont, aFontSpec);
       
   334 	}
       
   335 CFbsTypefaceStore* CWsScreenDevice::TypeFaceStore()const
       
   336 /** Helper member fn to access the movable typeface store.
       
   337  **/
       
   338 	{
       
   339 	return iExtension->TypefaceStore();
       
   340 	}
       
   341 
       
   342 EXPORT_C TInt CWsScreenDevice::GetNearestFontToDesignHeightInTwips(CFont*& aFont,const TFontSpec& aFontSpec)
       
   343 /** Gets the nearest font in twips to that specified.
       
   344 
       
   345 The font and bitmap server returns a pointer to the nearest matching font 
       
   346 from those available. Matches to design height of font - this gives no
       
   347 guarantees on the actual physical size of the font.
       
   348 
       
   349 This function replaces GetNearestFontInTwips
       
   350 
       
   351 @param aFont On return, the pointer is set to point to the device font which 
       
   352 most closely approximates to the required font specification.
       
   353 @param aFontSpec An absolute font specification. 
       
   354 @return KErrNone, if successful; otherwise, another of the system-wide error 
       
   355 codes.
       
   356 @see MGraphicsDeviceMap::GetNearestFontToDesignHeightInTwips() */
       
   357 	{
       
   358 	return TypeFaceStore()->GetNearestFontToDesignHeightInTwips(aFont, aFontSpec);
       
   359 	}
       
   360 
       
   361 /** Gets the nearest font, in twips, to that specified. 
       
   362 
       
   363 The font and bitmap server returns a pointer to the nearest matching font 
       
   364 from those available. Matches to max height of font - this does its best 
       
   365 to return a font that will fit within the maximum height specified (but 
       
   366 note that variations due to hinting algorithms may rarely result in this 
       
   367 height being exceeded by up to one pixel). Problems can also be 
       
   368 encountered with bitmap fonts where the typeface exists but doesn't have 
       
   369 a font small enough.
       
   370 
       
   371 @param aFont On return, the pointer is set to point to the device font which 
       
   372 most closely approximates to the required font specification.
       
   373 @param aFontSpec An absolute font specification. 
       
   374 @param aMaxHeight The maximum height within which the font must fit - this
       
   375 overrides the height specified in the TFontSpec. 
       
   376 @return KErrNone, if successful; otherwise, another of the system-wide error 
       
   377 codes.
       
   378 @see MGraphicsDeviceMap::GetNearestFontToMaxHeightInTwips() */
       
   379 EXPORT_C TInt CWsScreenDevice::GetNearestFontToMaxHeightInTwips(CFont*& aFont,const TFontSpec& aFontSpec,TInt aMaxHeight)
       
   380 	{
       
   381 	return TypeFaceStore()->GetNearestFontToMaxHeightInTwips(aFont, aFontSpec, aMaxHeight);
       
   382 	}
       
   383 
       
   384 EXPORT_C TInt CWsScreenDevice::GetNearestFontInPixels(CFont*& aFont,const TFontSpec& aFontSpec)
       
   385 /** Gets the nearest font to that specified for use by a bitmapped graphics device. 
       
   386 
       
   387 This function is replaced by GetNearestFontToDesignHeightInPixels()
       
   388 
       
   389 The font and bitmap server returns a pointer to the nearest matching font 
       
   390 from those available, in aFont.
       
   391 
       
   392 @param aFont On return, this is set to point to the device font that is  
       
   393 closest to the font specification passed in the second argument 
       
   394 @param aFontSpec An absolute font specification 
       
   395 @return KErrNone if successful, otherwise another of the system-wide error 
       
   396 codes. 
       
   397 @see CBitmapDevice::GetNearestFontInPixels()
       
   398 @deprecated */
       
   399 	{
       
   400 	return GetNearestFontToDesignHeightInPixels(aFont, aFontSpec);
       
   401 	}
       
   402 
       
   403 EXPORT_C TInt CWsScreenDevice::GetNearestFontToDesignHeightInPixels(CFont*& aFont,const TFontSpec& aFontSpec)
       
   404 /** Gets the nearest font in pixels to that specified. 
       
   405 
       
   406 The font and bitmap server returns a pointer to the nearest matching font 
       
   407 from those available. Matches to design height of font - this gives no
       
   408 guarantees on the actual physical size of the font.
       
   409 
       
   410 This function replaces GetNearestFontInTwips
       
   411 
       
   412 @param aFont On return, the pointer is set to point to the device font which 
       
   413 most closely approximates to the required font specification.
       
   414 @param aFontSpec An absolute font specification. 
       
   415 @return KErrNone, if successful; otherwise, another of the system-wide error 
       
   416 codes.
       
   417 @see CBitmapDevice::GetNearestFontToDesignHeightInPixels() */
       
   418 	{
       
   419 	return TypeFaceStore()->GetNearestFontToDesignHeightInPixels(aFont, aFontSpec);
       
   420 	}
       
   421 
       
   422 /** Gets the nearest font in pixels to that specified. 
       
   423 
       
   424 The font and bitmap server returns a pointer to the nearest matching font 
       
   425 from those available. Matches to max height of font - this does its best 
       
   426 to return a font that will fit within the maximum height specified (but 
       
   427 note that variations due to hinting algorithms may rarely result in this 
       
   428 height being exceeded by up to one pixel). Problems can also be 
       
   429 encountered with bitmap fonts where the typeface exists but doesn't have 
       
   430 a font small enough.
       
   431 
       
   432 @param aFont On return, the pointer is set to point to the device font which 
       
   433 most closely approximates to the required font specification.
       
   434 @param aFontSpec An absolute font specification. 
       
   435 @param aMaxHeight The maximum height within which the font must fit - this
       
   436 overrides the height specified in the TFontSpec. 
       
   437 @return KErrNone, if successful; otherwise, another of the system-wide error 
       
   438 codes.
       
   439 @see CBitmapDevice::GetNearestFontToMaxHeightInPixels() */
       
   440 EXPORT_C TInt CWsScreenDevice::GetNearestFontToMaxHeightInPixels(CFont*& aFont,const TFontSpec& aFontSpec,TInt aMaxHeight)
       
   441 	{
       
   442 	return TypeFaceStore()->GetNearestFontToMaxHeightInPixels(aFont, aFontSpec, aMaxHeight);
       
   443 	}
       
   444 
       
   445 EXPORT_C TInt CWsScreenDevice::NumTypefaces() const
       
   446 /** Gets the number of typefaces supported by the screen device.
       
   447 
       
   448 @return The number of typefaces supported. 
       
   449 @see CGraphicsDevice::NumTypefaces() */
       
   450 	{
       
   451 	return(TypeFaceStore()->NumTypefaces());
       
   452 	}
       
   453 
       
   454 EXPORT_C void CWsScreenDevice::TypefaceSupport(TTypefaceSupport& aTypefaceSupport,TInt aTypefaceIndex) const
       
   455 /** Gets typeface information for a particular typeface index number.
       
   456 
       
   457 This information is returned in aTypefaceSupport, and includes: the typeface 
       
   458 name and typeface attributes (in a TTypeface object), the number of font heights, 
       
   459 the maximum and minimum font heights and whether it is a scalable typeface.
       
   460 
       
   461 @param aTypefaceSupport On return, if the function executed successfully, 
       
   462 this contains the typeface information.
       
   463 @param aTypefaceIndex A typeface index number, in the range zero to (NumTypefaces() 
       
   464 - 1). 
       
   465 @see CGraphicsDevice::TypefaceSupport() */
       
   466 	{
       
   467 	TypeFaceStore()->TypefaceSupport(aTypefaceSupport,aTypefaceIndex);
       
   468 	}
       
   469 
       
   470 EXPORT_C TInt CWsScreenDevice::FontHeightInTwips(TInt aTypefaceIndex,TInt aHeightIndex) const
       
   471 /** Gets the height in twips of the specified font. 
       
   472 
       
   473 The value returned is rounded up or down to the nearest font height in twips.
       
   474 
       
   475 The specified font is the one with height index number aHeightIndex of the 
       
   476 typeface with index number aTypefaceIndex.
       
   477 
       
   478 @param aTypefaceIndex A typeface index number, in the range: 0 to (NumTypefaces() - 1). 
       
   479 @param aHeightIndex A font height index number, in the range: 0 to (iNumHeights - 1). 
       
   480 @return The height of the font in twips. 
       
   481 @see CGraphicsDevice::FontHeightInTwips() */
       
   482 	{
       
   483 	return(TypeFaceStore()->FontHeightInTwips(aTypefaceIndex,aHeightIndex));
       
   484 	}
       
   485 
       
   486 EXPORT_C TInt CWsScreenDevice::FontHeightInPixels(TInt aTypefaceIndex,TInt aHeightIndex) const
       
   487 /** Gets the height of the specified font in pixels.
       
   488 
       
   489 The value returned is rounded up or down to the nearest font height in pixels.
       
   490 
       
   491 The specified font is the one with height index number aHeightIndex of the 
       
   492 typeface with index number aTypefaceIndex.
       
   493 
       
   494 @param aTypefaceIndex A typeface index number, in the range: 0 to (NumTypefaces() - 1). 
       
   495 @param aHeightIndex A font height index number, in the range: 0 to (iNumHeights - 1).
       
   496 @return The height of the font in pixels. 
       
   497 @see CBitmapDevice::FontHeightInPixels() */
       
   498 	{
       
   499 	return(TypeFaceStore()->FontHeightInPixels(aTypefaceIndex,aHeightIndex));
       
   500 	}
       
   501 
       
   502 EXPORT_C TInt CWsScreenDevice::GetFontById(CFont *&aFont,TUid aUid,const TAlgStyle& aAlgStyle)
       
   503 /** Gets a font by its bitmap UID. 
       
   504 
       
   505 Within a font file each font has its own UID. An algorithmic style is not 
       
   506 part of the actual font description, but is applied to it. For example algorithmic 
       
   507 bolding applies an algorithm to increase the apparent weight of each character 
       
   508 in the font. Note that the algorithm is applied blindly, and that a typeface 
       
   509 may already have a style e.g. it may already be bold or italic. Thus a bold 
       
   510 face will appear extra-bold if algorithmic bolding is applied to it. Algorithmic 
       
   511 effects are not necessarily a substitute for typeface design and should be 
       
   512 used with care.
       
   513 
       
   514 @param aFont On a successful return, contains a pointer to the new CFont. 
       
   515 @param aUid UID of the bitmap font. 
       
   516 @param aAlgStyle The algorithmic style to apply. 
       
   517 @return KErrNone if successful, otherwise one of the system-wide error codes. */
       
   518 	{
       
   519 	return(TypeFaceStore()->GetFontById(aFont,aUid,aAlgStyle));
       
   520 	}
       
   521 
       
   522 EXPORT_C TInt CWsScreenDevice::AddFile(const TDesC& aName,TInt& aId)
       
   523 /** Adds a font file to the device's typeface store. The specified font
       
   524 file must be accessible to any process, i.e. not located inside an
       
   525 application's private directory.
       
   526 
       
   527 @param aName Name of the font file. 
       
   528 @param aId ID for the font file. 
       
   529 @return KErrNone if successful, otherwise one of the system-wide error codes. 
       
   530 @see CBitmapDevice::AddFile() */
       
   531 	{
       
   532 	return(TypeFaceStore()->AddFile(aName, aId));
       
   533 	}
       
   534 
       
   535 EXPORT_C void CWsScreenDevice::RemoveFile(TInt aId)
       
   536 /** Removes a font file from the font store.
       
   537 
       
   538 @param aId The ID of the font file to be removed, default 0. 
       
   539 @see CBitmapDevice::RemoveFile() */
       
   540 	{
       
   541 	TypeFaceStore()->RemoveFile(aId);
       
   542 	}
       
   543 
       
   544 EXPORT_C void CWsScreenDevice::ReleaseFont(CFont* aFont)
       
   545 /** Releases a specified font.
       
   546 
       
   547 This function is used to indicate that the specified font is no longer needed 
       
   548 for use by the screen device. As fonts can be shared between applications, 
       
   549 this function does not delete the copy of the font from RAM, unless the font 
       
   550 was only being used by this device.
       
   551 
       
   552 @param aFont A pointer to the font to be released. 
       
   553 @see MGraphicsDeviceMap::ReleaseFont() */
       
   554 	{
       
   555 	TypeFaceStore()->ReleaseFont(aFont);
       
   556 	}
       
   557 
       
   558 EXPORT_C void CWsScreenDevice::PaletteAttributes(TBool& aModifiable,TInt& aNumEntries) const
       
   559 /** Gets the attributes of the device's palette.
       
   560  
       
   561 This function always causes a flush of the window server buffer.
       
   562 
       
   563 @param aModifiable On return, indicates whether or not the device's palette 
       
   564 is modifiable (true) or fixed (false).
       
   565 @param aNumEntries On return, holds the number of entries in the device's 
       
   566 palette. 
       
   567 @see CFbsScreenDevice::PaletteAttributes() */
       
   568 	{
       
   569 	TInt ret=WriteReply(EWsSdOpPaletteAttributes);
       
   570 	aModifiable=ret&EWsSdSetableBitFlag;
       
   571 	aNumEntries=ret&(~EWsSdSetableBitFlag);
       
   572 	}
       
   573 
       
   574 EXPORT_C void CWsScreenDevice::SetPalette(CPalette* aPalette)
       
   575 /** Sets the screen device's palette.
       
   576 
       
   577 This function always causes a flush of the window server buffer.
       
   578 
       
   579 Use of this function is deprecated. SetCustomPalette() should be used instead.
       
   580 
       
   581 @param aPalette The screen device's new palette. */
       
   582 	{
       
   583 #if defined(__WINS__)
       
   584 	__ASSERT_DEBUG(SetCustomPalette(aPalette)==KErrNone,Panic(EW32PanicSilentFail));
       
   585 #endif
       
   586 	SetCustomPalette(aPalette);
       
   587 	}
       
   588 
       
   589 EXPORT_C TInt CWsScreenDevice::SetCustomPalette(const CPalette* aPalette)
       
   590 /** Sets the custom palette.
       
   591  
       
   592 This function always causes a flush of the window server buffer.
       
   593 
       
   594 @param aPalette The custom palette.
       
   595 @return KErrNone if sucessful, or one of the system error codes.
       
   596 @panic W32 6 aPalette is NULL.
       
   597 @capability WriteDeviceData */
       
   598 	{
       
   599 	__ASSERT_ALWAYS(aPalette,Panic(EW32PanicNullPalette));
       
   600 	TPtr8 palette(NULL,0);
       
   601 	CONST_CAST(CPalette*,aPalette)->GetDataPtr(0,aPalette->Entries(),palette);
       
   602 	TPtr8 empty(NULL,0);
       
   603 	return WriteReplyByProvidingRemoteReadAccess(&empty, sizeof(empty), &palette, EWsSdOpSetPalette);
       
   604 	}
       
   605 
       
   606 EXPORT_C TInt CWsScreenDevice::GetPalette(CPalette*& aPalette) const
       
   607 /** Gets the screen device's palette.
       
   608  
       
   609 This function always causes a flush of the window server buffer.
       
   610 
       
   611 @param aPalette On return, contains the screen device's palette. The caller 
       
   612 takes responsibility for discarding the palette.
       
   613 @return KErrNone if successful, otherwise another of the system-wide error 
       
   614 codes. 
       
   615 @see CFbsScreenDevice::GetPalette() */
       
   616 	{
       
   617 	TBool modifiable;		//Dummy parameter
       
   618 	TInt numEntries;
       
   619 	TInt ret;
       
   620 	PaletteAttributes(modifiable,numEntries);
       
   621 	aPalette=NULL;
       
   622 Retry:
       
   623 	TRAP(ret,aPalette=CPalette::NewL(numEntries));
       
   624 	if (ret==KErrNone)
       
   625 		{
       
   626 		TPtr8 palette(NULL,0);
       
   627 		aPalette->GetDataPtr(0,numEntries,palette);
       
   628 		ret=WriteReplyIntP(numEntries,&palette,EWsSdOpGetPalette);
       
   629 		if (ret!=KErrNone)
       
   630 			{
       
   631 			delete aPalette;
       
   632 			aPalette=NULL;
       
   633 			if (ret>0)		//The mode of the screen display changed
       
   634 				{
       
   635 				numEntries=ret;
       
   636 				goto Retry;
       
   637 				}
       
   638 			}
       
   639 		}
       
   640 	return ret;
       
   641 	}
       
   642 
       
   643 EXPORT_C void CWsScreenDevice::SetScreenSizeAndRotation(const TPixelsTwipsAndRotation &aSizeAndRotation)
       
   644 /** Sets the current screen size in twips and pixels, and the rotation for the 
       
   645 screen device.
       
   646 
       
   647 @param aSizeAndRotation The new rotation and the screen size in both pixels 
       
   648 and twips. */
       
   649 	{
       
   650 	// Need to reset the cache if the ratio of twip/pixels changes
       
   651 	// Using multiply as this is much quicker than divide on ARM
       
   652 	// No need to flush cache if this is a width/height swap
       
   653 	if((iPhysicalScreenSizeInTwips.iWidth * aSizeAndRotation.iPixelSize.iWidth != aSizeAndRotation.iTwipsSize.iWidth * iDisplaySizeInPixels.iWidth
       
   654 		|| iPhysicalScreenSizeInTwips.iHeight * aSizeAndRotation.iPixelSize.iHeight != aSizeAndRotation.iTwipsSize.iHeight * iDisplaySizeInPixels.iHeight)
       
   655 		&& !(aSizeAndRotation.iPixelSize.iHeight == iDisplaySizeInPixels.iWidth
       
   656 		&& aSizeAndRotation.iPixelSize.iWidth == iDisplaySizeInPixels.iHeight
       
   657 		&& iPhysicalScreenSizeInTwips.iHeight == aSizeAndRotation.iTwipsSize.iWidth
       
   658 		&& iPhysicalScreenSizeInTwips.iWidth == aSizeAndRotation.iTwipsSize.iHeight))
       
   659 		{
       
   660 		TypeFaceStore()->ReleaseTwipsCache();
       
   661 		}
       
   662 	Write(&aSizeAndRotation,sizeof(aSizeAndRotation),EWsSdOpSetScreenSizeAndRotation);
       
   663 	iDisplaySizeInPixels=aSizeAndRotation.iPixelSize;
       
   664 	iPhysicalScreenSizeInTwips=aSizeAndRotation.iTwipsSize;
       
   665 	}
       
   666 
       
   667 EXPORT_C void CWsScreenDevice::GetDefaultScreenSizeAndRotation(TPixelsTwipsAndRotation &aSizeAndRotation) const
       
   668 /** Gets the current screen size (in both pixels and twips) and rotation.
       
   669 
       
   670 This function always causes a flush of the window server buffer.
       
   671 
       
   672 @param aSizeAndRotation The default screen size and rotation, defining screen 
       
   673 size in both pixels and twips. */
       
   674 	{
       
   675 	TPckgBuf<TPixelsTwipsAndRotation> sarPkg;
       
   676   	WriteReplyP(&sarPkg,EWsSdOpGetDefaultScreenSizeAndRotation);
       
   677 	aSizeAndRotation=sarPkg();
       
   678 	}
       
   679 
       
   680 EXPORT_C void CWsScreenDevice::SetScreenSizeAndRotation(const TPixelsAndRotation &aSizeAndRotation)
       
   681 /** Sets the current screen size in pixels, and the rotation for the screen device.
       
   682 
       
   683 This function always causes a flush of the window server buffer.
       
   684 
       
   685 @param aSizeAndRotation The new rotation and the screen size in pixels. */
       
   686 	{
       
   687 	if(iDisplaySizeInPixels != aSizeAndRotation.iPixelSize
       
   688 		&& !(aSizeAndRotation.iPixelSize.iHeight == iDisplaySizeInPixels.iWidth
       
   689 		&& aSizeAndRotation.iPixelSize.iWidth == iDisplaySizeInPixels.iHeight))
       
   690 		{
       
   691 		// Reset the twips cache.
       
   692 		TypeFaceStore()->ReleaseTwipsCache();
       
   693 		}
       
   694 	Write(&aSizeAndRotation,sizeof(aSizeAndRotation),EWsSdOpSetScreenSizeAndRotation2);
       
   695 	iDisplaySizeInPixels=aSizeAndRotation.iPixelSize;
       
   696 	iPhysicalScreenSizeInTwips=SizeInTwips();
       
   697 	}
       
   698 
       
   699 EXPORT_C void CWsScreenDevice::GetDefaultScreenSizeAndRotation(TPixelsAndRotation &aSizeAndRotation) const
       
   700 /** Gets the current screen size (in pixels) and the rotation.
       
   701 
       
   702 This function always causes a flush of the window server buffer.
       
   703 
       
   704 @param aSizeAndRotation The default screen size in pixels and the rotation. */
       
   705 	{
       
   706 	TPckgBuf<TPixelsAndRotation> sarPkg;
       
   707   	WriteReplyP(&sarPkg,EWsSdOpGetDefaultScreenSizeAndRotation2);
       
   708 	aSizeAndRotation=sarPkg();
       
   709 	}
       
   710 
       
   711 EXPORT_C TDisplayMode CWsScreenDevice::GetScreenModeDisplayMode(const TInt &aMode) const
       
   712 /** Gets the display mode of the screen for the specified screen mode
       
   713 
       
   714 This function always causes a flush of the window server buffer.
       
   715 
       
   716 @param aMode The index of the screen mode for which the display mode is required
       
   717 @return The display mode for the specified screen mode. */
       
   718 	{
       
   719 	return STATIC_CAST(TDisplayMode,WriteReplyInt(aMode,EWsSdOpGetScreenModeDisplayMode));
       
   720 	}
       
   721  
       
   722 EXPORT_C TPoint CWsScreenDevice::GetDefaultScreenModeOrigin() const
       
   723 /** Gets the origin for the current screen mode
       
   724 
       
   725 This function always causes a flush of the window server buffer.
       
   726 
       
   727 @param aOrigin The default offset of the current 
       
   728 screen mode from the physical screen. */
       
   729 	{
       
   730 	TPckgBuf<TPoint> pntPkg;
       
   731   	WriteReplyP(&pntPkg,EWsSdOpGetDefaultScreenModeOrigin);
       
   732 	return pntPkg();
       
   733 	}
       
   734 
       
   735 EXPORT_C TPoint CWsScreenDevice::GetScreenModeOrigin(TInt aMode) const
       
   736 /** Get the origin of the screen for the specified screen mode.
       
   737 
       
   738 This function always causes a flush of the window server buffer.
       
   739 
       
   740 @param aMode The index of the screen mode for which the screen origin is required. 
       
   741 @param aOrigin The origin of the specified screen mode. */
       
   742 	{
       
   743 	TPckgBuf<TPoint> pntPkg;
       
   744 	WriteReplyP(&aMode,sizeof(aMode),&pntPkg,EWsSdOpGetScreenModeOrigin);
       
   745 	return pntPkg();
       
   746 	}
       
   747 
       
   748 EXPORT_C TSize CWsScreenDevice::GetScreenModeScale(TInt aMode) const
       
   749 /** Gets the scale for the specified screen mode.
       
   750 
       
   751 This function always causes a flush of the window server buffer.
       
   752 
       
   753 @param aMode The index of the screen mode for which the screen scale is required. 
       
   754 @return The scale for the specified screen mode. */
       
   755 	{
       
   756 	TPckgBuf<TSize> pntPkg;
       
   757 	WriteReplyP(&aMode,sizeof(aMode),&pntPkg,EWsSdOpGetScreenModeScale);
       
   758 	return pntPkg();
       
   759 	}
       
   760 
       
   761 EXPORT_C TSize CWsScreenDevice::GetCurrentScreenModeScale() const
       
   762 /** Gets the scale for the current screen mode.
       
   763 
       
   764 This function always causes a flush of the window server buffer.
       
   765 
       
   766 @return The scale for the current screen mode. */
       
   767 	{
       
   768 	TPckgBuf<TSize> pntPkg;
       
   769 	WriteReplyP(&pntPkg,EWsSdOpGetCurrentScreenModeScale);
       
   770 	return pntPkg();
       
   771 	}
       
   772 
       
   773 EXPORT_C TPoint CWsScreenDevice::GetCurrentScreenModeScaledOrigin() const
       
   774 /** Gets the current screen mode's scaled origin.
       
   775 
       
   776 The formula used is (A+B-1)/B
       
   777 
       
   778 where:
       
   779 
       
   780 - A is the screen mode origin in physical coordinates,
       
   781 - B is the screen mode scale width.
       
   782 
       
   783 The result obtained is the scaled origin of the present screen mode.
       
   784 
       
   785 @return The scaled origin for the current screen mode. */
       
   786 	{
       
   787 	TPckgBuf<TPoint> pntPkg;
       
   788 	WriteReplyP(&pntPkg,EWsSdOpGetCurrentScreenModeScaledOrigin);
       
   789 	return pntPkg();
       
   790 	}
       
   791 
       
   792 EXPORT_C TPoint CWsScreenDevice::GetScreenModeScaledOrigin(TInt aMode) const
       
   793 /** Gets the specfied screen mode's scaled origin.
       
   794 
       
   795 The functionality is same as CWsScreenDevice::GetCurrentScreenModeScaledOrigin().
       
   796 
       
   797 It always causes a flush of the window server buffer.
       
   798 
       
   799 @param aMode The index of the screen mode for which the scaled origin is required. 
       
   800 @return The scaled origin for the specified screen mode. */
       
   801 	{
       
   802 	TPckgBuf<TPoint> pntPkg;
       
   803 	WriteReplyP(&aMode,sizeof(aMode),&pntPkg,EWsSdOpGetScreenModeScaledOrigin);
       
   804 	return pntPkg();
       
   805 	}
       
   806 
       
   807 /**
       
   808 @internalComponent
       
   809 @released
       
   810 
       
   811 Used for testing purposes only.
       
   812 
       
   813 @return The present screen mode.
       
   814 */
       
   815 EXPORT_C TSizeMode CWsScreenDevice::GetCurrentScreenModeAttributes() const
       
   816 	{
       
   817 	TPckgBuf<TSizeMode> pntPkg;
       
   818 	WriteReplyP(&pntPkg,EWsSdOpGetCurrentScreenModeAttributes);
       
   819 	return pntPkg();
       
   820 	}
       
   821 
       
   822 /**
       
   823 @internalComponent
       
   824 @released
       
   825 
       
   826 Used for testing purposes only.
       
   827 
       
   828 @param aModeAtt Screen size mode to be set.
       
   829 */
       
   830 EXPORT_C void CWsScreenDevice::SetCurrentScreenModeAttributes(const TSizeMode &aModeAtt)
       
   831 	{
       
   832 	Write(&aModeAtt,sizeof(aModeAtt),EWsSdOpSetCurrentScreenModeAttributes);
       
   833 	}
       
   834 
       
   835 EXPORT_C void CWsScreenDevice::SetAppScreenMode(TInt aMode)
       
   836 /** Sets the application's screen mode; this also sets all the attributes
       
   837 of the screen mode.
       
   838 
       
   839 Note: although this API was added in Symbian OS v8.0, the functionality is 
       
   840 only available from Symbian OS v8.1 onwards.
       
   841 
       
   842 @param aMode The index of the application's new screen mode.*/
       
   843 	{
       
   844 	WriteInt(aMode,EWsSdOpSetAppScreenMode);
       
   845 	}
       
   846 
       
   847 EXPORT_C TInt CWsScreenDevice::NumScreenModes() const
       
   848 /** Gets the number of available screen modes. 
       
   849 
       
   850 Each mode has a different size, and one or more possible rotations/orientations.
       
   851 
       
   852 This function always causes a flush of the window server buffer.
       
   853 
       
   854 @return The number of screen modes. */
       
   855 	{
       
   856 	return(WriteReply(EWsSdOpGetNumScreenModes));
       
   857 	}
       
   858 
       
   859 EXPORT_C TInt CWsScreenDevice::CurrentScreenMode() const
       
   860 /** Gets the current screen mode index.
       
   861 
       
   862 This function always causes a flush of the window server buffer.
       
   863 
       
   864 @return The index into the list of available screen modes of the current screen 
       
   865 mode. */
       
   866 	{
       
   867 	return WriteReply(EWsSdOpGetScreenMode);
       
   868 	}
       
   869 
       
   870 EXPORT_C void CWsScreenDevice::SetScreenMode(TInt aMode)
       
   871 /**
       
   872 @publishedPartner
       
   873 @released
       
   874 
       
   875 Sets the current screen mode.
       
   876 
       
   877 Note that this function is only useful for testing. This is because the screen mode 
       
   878 normally reflects the state of real hardware, e.g. whether the cover is open 
       
   879 or closed on a phone that supports screen flipping.
       
   880  
       
   881 This function always causes a flush of the window server buffer.
       
   882 
       
   883 @param aMode The screen mode index, starting from zero.
       
   884 @capability WriteDeviceData */
       
   885 	{
       
   886 	WriteInt(aMode,EWsSdOpSetScreenMode);
       
   887 	iDisplaySizeInPixels=SizeInPixels();
       
   888 	iPhysicalScreenSizeInTwips=SizeInTwips();
       
   889 	}
       
   890 
       
   891 EXPORT_C void CWsScreenDevice::GetScreenModeSizeAndRotation(TInt aMode, TPixelsTwipsAndRotation &aSizeAndRotation) const
       
   892 /** Get the screen rotation and size, in both pixels and twips, for the specified 
       
   893 screen mode.
       
   894  
       
   895 This function always causes a flush of the window server buffer.
       
   896 
       
   897 @param aMode The index of the screen mode for which the screen size and rotation 
       
   898 are required. 
       
   899 @param aSizeAndRotation The orientation of the specified screen mode, and its 
       
   900 size in both pixels and twips. */
       
   901 	{
       
   902 	TPckgBuf<TPixelsTwipsAndRotation> sarPkg;
       
   903   	WriteReplyP(&aMode,sizeof(aMode),&sarPkg,EWsSdOpGetScreenModeSizeAndRotation);
       
   904 	aSizeAndRotation=sarPkg();
       
   905 	}
       
   906 
       
   907 EXPORT_C void CWsScreenDevice::GetScreenModeSizeAndRotation(TInt aMode, TPixelsAndRotation &aSizeAndRotation) const
       
   908 /** Get the screen rotation and size (in pixels) for the specified screen mode.
       
   909  
       
   910 This function always causes a flush of the window server buffer.
       
   911 
       
   912 @param aMode The index of the screen mode for which the screen size and rotation 
       
   913 are required. 
       
   914 @param aSizeAndRotation The orientation of the specified screen mode, and its 
       
   915 size in pixels. */
       
   916 	{
       
   917 	TPckgBuf<TPixelsAndRotation> sarPkg;
       
   918   	WriteReplyP(&aMode,sizeof(aMode),&sarPkg,EWsSdOpGetScreenModeSizeAndRotation2);
       
   919 	aSizeAndRotation=sarPkg();
       
   920 	}
       
   921 
       
   922 EXPORT_C void CWsScreenDevice::SetCurrentRotations(TInt aMode, CFbsBitGc::TGraphicsOrientation aRotation) const
       
   923 /** 
       
   924 @publishedPartner
       
   925 @released
       
   926 
       
   927 Sets the screen rotation that should be used with a particular screen size. 
       
   928 
       
   929 After calling this function, whenever you change into the screen size specified 
       
   930 by aMode you will have the rotation aRotation. The setting remains in force 
       
   931 until it is explicitly changed using this function. 
       
   932 
       
   933 Panics if the specified rotation is not allowed by the given screen mode.
       
   934 
       
   935 @param aMode The index of the screen mode the rotation applies to. 
       
   936 @param aRotation The new screen orientation.
       
   937 @see GetRotationsList()
       
   938 @capability WriteDeviceData */
       
   939 	{
       
   940 	TWsSdCmdSetScreenRotation screenRotation(aMode,aRotation);
       
   941 	Write(&screenRotation,sizeof(screenRotation),EWsSdOpSetModeRotation);
       
   942 	}
       
   943 
       
   944 EXPORT_C TInt CWsScreenDevice::GetRotationsList(TInt aMode, CArrayFixFlat<TInt> *aRotationList) const
       
   945 /** Gets the list of valid rotations for a particular screen size.
       
   946 
       
   947 The list is initialised in wsini.ini.
       
   948  
       
   949 This function always causes a flush of the window server buffer.
       
   950 
       
   951 @param aMode The index of the screen mode for which the rotation list 
       
   952 is required. 
       
   953 @param aRotationList The list of valid screen orientations. 
       
   954 @return KErrNone if successful, otherwise another of the system-wide error 
       
   955 codes. 
       
   956 @see SetCurrentRotations() */
       
   957 	{
       
   958 	TUint modeList=(TUint)WriteReplyInt(aMode,EWsSdOpGetRotationList);
       
   959 	TUint modeBit=1<<CFbsBitGc::EGraphicsOrientationNormal;
       
   960 	TBool rots[4];
       
   961 	TInt rotations=0;
       
   962 	TInt ii;
       
   963 	for (ii=0;ii<4;ii++)
       
   964 		{
       
   965 		rots[ii]=(modeList&modeBit);
       
   966 		if (rots[ii])
       
   967 			++rotations;
       
   968 		modeBit=modeBit<<1;
       
   969 		}
       
   970 	if (!aRotationList)
       
   971 		return rotations;
       
   972 	TRAPD(err,aRotationList->ResizeL(rotations));
       
   973 	if (err!=KErrNone)
       
   974 		return(err);
       
   975 	rotations=0;
       
   976 	for (ii=0;ii<4;ii++)
       
   977 		{
       
   978 		if (rots[ii])
       
   979 			(*aRotationList)[rotations++]=REINTERPRET_CAST(CFbsBitGc::TGraphicsOrientation&,ii);
       
   980 		}
       
   981 	return KErrNone;
       
   982 	}
       
   983 
       
   984 EXPORT_C TScreenModeEnforcement CWsScreenDevice::ScreenModeEnforcement() const
       
   985 /** Gets the current screen mode enforcement settings.
       
   986 
       
   987 The global screen mode enforcement setting defines the requirements that a 
       
   988 group window must meet to be displayed. The requirements may have been set 
       
   989 in wsini.ini, or using SetScreenModeEnforcement(). 
       
   990  
       
   991 This function always causes a flush of the window server buffer.
       
   992 
       
   993 @return The screen mode enforcement requirements. */
       
   994 	{
       
   995 	return((TScreenModeEnforcement)WriteReply(EWsSdOpScreenModeEnforcement));
       
   996 	}
       
   997 
       
   998 EXPORT_C void CWsScreenDevice::SetScreenModeEnforcement(TScreenModeEnforcement aMode) const
       
   999 /** 
       
  1000 @publishedPartner
       
  1001 @released
       
  1002 
       
  1003 Sets the screen mode enforcement requirements.
       
  1004 
       
  1005 This global setting defines the requirements that a group window must meet 
       
  1006 to be displayed. The value may be set using this function, but is more likely 
       
  1007 to be defined in wsini.ini. 
       
  1008 
       
  1009 @param aMode The screen mode enforcement requirements.
       
  1010 @capability WriteDeviceData */
       
  1011 	{
       
  1012 	WriteInt(aMode,EWsSdOpSetScreenModeEnforcement);
       
  1013 	}
       
  1014 
       
  1015 EXPORT_C TInt CWsScreenDevice::GetScreenNumber() const
       
  1016 /** Get device's screen number 
       
  1017 
       
  1018 @return The device's screen number
       
  1019 @see CWsScreenDevice::Construct( TInt aDefaultScreenNumber ) */
       
  1020 	{
       
  1021 	return WriteReply(EWsSdOpGetScreenNumber);
       
  1022 	}
       
  1023 
       
  1024 /** Gets the available screen size modes.
       
  1025 
       
  1026 This function retrieves all available screen size modes which are supported by
       
  1027 the server.
       
  1028 
       
  1029 @param aModeList On return, the list of available screen size modes.
       
  1030 @return The number of supported screen size modes if successful otherwise returns KErrNoMemory if 
       
  1031 there is insufficient memory to create the array. */
       
  1032 EXPORT_C TInt CWsScreenDevice::GetScreenSizeModeList(RArray<TInt>* aModeList) const
       
  1033 	{
       
  1034 	__ASSERT_ALWAYS(aModeList, Panic(EW32PanicNullArray));
       
  1035 	aModeList->Reset();
       
  1036 	TInt count=WriteReply(EWsSdOpGetNumScreenModes);
       
  1037 	TInt totSize=count*sizeof(TInt);
       
  1038 	TInt* allocMem=static_cast<TInt*>(User::Alloc(totSize));
       
  1039 	if(allocMem==NULL)
       
  1040 		{
       
  1041 		return KErrNoMemory;
       
  1042 		}
       
  1043 	TPtr8 listPtr(reinterpret_cast<TUint8*>(allocMem), totSize);
       
  1044 	count=WriteReplyP(&listPtr, EWsSdOpGetScreenSizeModeList);
       
  1045 	new(aModeList) RArray<TInt>(allocMem, count);
       
  1046 	return count;	
       
  1047 	}	
       
  1048 
       
  1049 EXPORT_C TInt CWsScreenDevice::SetBackLight(TBool aBackLight)
       
  1050 /** Set back light. 
       
  1051 @param aBackLight, ETrue Set the backlight on, EFlase set the backlight off.
       
  1052 @capability EikServ SID */
       
  1053 	{
       
  1054 	return(WriteReplyInt(aBackLight,EWsClOpSetBackLight));
       
  1055 	}
       
  1056 
       
  1057 /** Interface Extension capability
       
  1058 	Use of this interface going forward will allow the published client interface to be dynamically extended.
       
  1059 	Note that the pointer returned is only good for the lifetime of the called CBase derived object.
       
  1060 
       
  1061 	@param  aInterfaceId	uniqueid or well known id of interface
       
  1062 	@return	pointer to interface object matching this ID or NULL if no match.
       
  1063 */
       
  1064 EXPORT_C TAny* CWsScreenDevice::GetInterface(TUint aInterfaceId)
       
  1065 	{
       
  1066 	return iExtension->GetInterface(aInterfaceId);
       
  1067 	}
       
  1068 
       
  1069 /** Returns whether the given screen size mode is dynamic or not.
       
  1070 	Dynamic screen size modes may change their size in pixels and/or twips 
       
  1071 	and other attributes at run time, so they must not be cached. Static size 
       
  1072 	mode attributes will not change at run time, but may not make full use of the display.
       
  1073 	Invalid size modes shall return EFalse.
       
  1074 
       
  1075 	@param aSizeMode The screen size mode to check.
       
  1076 	@return ETrue if the given screen size mode is dynamic, EFalse otherwise.
       
  1077 */
       
  1078 EXPORT_C TBool CWsScreenDevice::IsModeDynamic(TInt /*aSizeMode*/) const
       
  1079 	{
       
  1080 	return EFalse;
       
  1081 	}
       
  1082 
       
  1083 /** Returns whether the current screen size mode is dynamic or not.
       
  1084 
       
  1085 	@return ETrue if current screen size mode is dynamic, EFalse otherwise.
       
  1086 	@see IsModeDynamic
       
  1087 */
       
  1088 EXPORT_C TBool CWsScreenDevice::IsCurrentModeDynamic() const
       
  1089 	{
       
  1090 	return EFalse;
       
  1091 	}