javauis/lcdui_akn/lcdgr/src/LcdGraphics.cpp
changeset 21 2a9601315dfc
child 23 98ccebc37403
equal deleted inserted replaced
18:e8e63152f320 21:2a9601315dfc
       
     1 /*
       
     2 * Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 #include <fbs.h>
       
    19 #include <biditext.h>
       
    20 #include <bitdev.h>
       
    21 #include <gdi.h>
       
    22 #include <e32math.h>
       
    23 
       
    24 #include "LcdGraphics.h"
       
    25 #include "LcdImage.h"
       
    26 #include <lcdgdrv.h>
       
    27 #include "LcdBitmapSurface.h"
       
    28 
       
    29 #include "DebugArg.h"
       
    30 
       
    31 #include "LcdWindowSurface.h"
       
    32 
       
    33 TPoint AnchorPoint(const TPoint& aPoint, TInt aAnchor, const TSize& aSize);
       
    34 void   ArcVectors(TPoint& aStart, TPoint& aEnd, const TRect& aRect, TInt aStartAngle, TInt aArcAngle);
       
    35 TPoint Vector(const TReal& aAngle, const TSize& aSize);
       
    36 
       
    37 #ifdef _DEBUG
       
    38 class MyBitmapLockCountHack
       
    39 {
       
    40 public:
       
    41     TInt iCount;
       
    42 };
       
    43 #define CHECK_BITMAP_LOCK() ASSERT( ((MyBitmapLockCountHack*)(&iCount))->iCount == 0 )
       
    44 #else
       
    45 #define CHECK_BITMAP_LOCK()
       
    46 #endif
       
    47 
       
    48 const TUint32 KARGBBlack = 0xff000000;
       
    49 
       
    50 /**
       
    51  * Map lcdui stroke style to GDI pen style.
       
    52  */
       
    53 inline CGraphicsContext::TPenStyle PenStyle(TStrokeStyle aStrokeStyle)
       
    54 {
       
    55     return (aStrokeStyle == EStrokeDotted ? CGraphicsContext::EDottedPen : CGraphicsContext::ESolidPen);
       
    56 }
       
    57 
       
    58 //
       
    59 // CLcdGraphics inline methods
       
    60 //
       
    61 inline void CLcdGraphics::SetPenOn()
       
    62 {
       
    63     if (0 == (iState & EPenOn))
       
    64     {
       
    65         iContext->SetPenStyle(PenStyle(iStrokeStyle));
       
    66         iState |= EPenOn;
       
    67     }
       
    68     if (0 == (iState & EPenColor))
       
    69     {
       
    70         iContext->SetPenColor(TRgb::Color16MA(iColor));
       
    71         iState |= EPenColor;
       
    72     }
       
    73 }
       
    74 
       
    75 inline void CLcdGraphics::SetPenOff()
       
    76 {
       
    77     if (iState & EPenOn)
       
    78     {
       
    79         iContext->SetPenStyle(CGraphicsContext::ENullPen);
       
    80         iState ^= EPenOn;
       
    81     }
       
    82 }
       
    83 
       
    84 inline void CLcdGraphics::SetBrushOn()
       
    85 {
       
    86     if (0 == (iState & EBrushOn))
       
    87     {
       
    88         iContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
    89         iState |= EBrushOn;
       
    90     }
       
    91     if (0 == (iState & EBrushColor))
       
    92     {
       
    93         iContext->SetBrushColor(TRgb::Color16MA(iColor));
       
    94         iState |= EBrushColor;
       
    95     }
       
    96 }
       
    97 
       
    98 inline void CLcdGraphics::SetBrushOff()
       
    99 {
       
   100     if (iState & EBrushOn)
       
   101     {
       
   102         iContext->SetBrushStyle(CGraphicsContext::ENullBrush);
       
   103         iState ^= EBrushOn;
       
   104     }
       
   105 }
       
   106 
       
   107 inline void CLcdGraphics::LineMode()
       
   108 {
       
   109     SetPenOn();
       
   110 }
       
   111 
       
   112 inline void CLcdGraphics::FillMode()
       
   113 {
       
   114     SetPenOff();
       
   115     SetBrushOn();
       
   116 }
       
   117 
       
   118 inline void CLcdGraphics::OutlineMode()
       
   119 {
       
   120     SetPenOn();
       
   121     SetBrushOff();
       
   122 }
       
   123 
       
   124 CLcdGraphics* CLcdGraphics::NewL(CLcdGraphicsDriver& aDriver, CCoeControl& aWindow, MDirectContainer& aContainer, TBool aUpdate)
       
   125 {
       
   126     return CLcdGraphics::NewL(aDriver, CLcdWindowSurface::NewL(aWindow, aContainer, aUpdate));
       
   127 }
       
   128 
       
   129 CLcdGraphics* CLcdGraphics::NewL(CLcdGraphicsDriver& aDriver, const CFbsBitmap* aBitmap)
       
   130 {
       
   131     return CLcdGraphics::NewL(aDriver, CLcdBitmapSurface::NewL(aBitmap));
       
   132 }
       
   133 
       
   134 //
       
   135 // aSurface is NOT on cleanup stack.
       
   136 //
       
   137 CLcdGraphics* CLcdGraphics::NewL(CLcdGraphicsDriver& aDriver, CLcdSurface* aSurface)
       
   138 {
       
   139     CleanupStack::PushL(aSurface);
       
   140     CLcdGraphics* graphics = new(ELeave) CLcdGraphics(aDriver, aSurface);
       
   141     CleanupStack::Pop(aSurface);
       
   142     CleanupStack::PushL(graphics);
       
   143     graphics->ConstructL();
       
   144     CleanupStack::Pop(graphics);
       
   145     return graphics;
       
   146 }
       
   147 
       
   148 //
       
   149 //
       
   150 //
       
   151 CLcdGraphics::CLcdGraphics(CLcdGraphicsDriver& aDriver, CLcdSurface* aSurface)
       
   152         : iLcdDriver(aDriver)
       
   153         , iSurface(aSurface)
       
   154         , iIsCanvasGraphicsItemTarget(EFalse)
       
   155 {
       
   156     iStrokeStyle = EStrokeSolid;
       
   157     iColor    = KARGBBlack;
       
   158     iFont     = NULL;
       
   159     iState    = EPenOn|EPenColor;   // Initial state of context
       
   160 }
       
   161 
       
   162 void CLcdGraphics::ConstructL()
       
   163 {
       
   164     //
       
   165     // We require a CLcdGraphicsDevice for transforming bitblts which are
       
   166     // not supported by BITGDI. If the driver cannot create a device for
       
   167     // this surface type we will fail here. A line buffer could be used to
       
   168     // implement a slow version of the transforming blitters to avoid this
       
   169     // failure mode.
       
   170     //
       
   171     iLcdDevice = iLcdDriver.CreateDeviceL(iSurface->ImageType());
       
   172     iLcdDrawCaps = iLcdDevice->DrawingCaps();
       
   173 
       
   174     iDeviceBounds = iSurface->Bounds();
       
   175     iDeviceOrigin = iDeviceBounds.iTl;
       
   176     iDeviceClipRect = iDeviceBounds;
       
   177 
       
   178     iOrigin   = TPoint();
       
   179     iClipRect = TRect(iDeviceBounds.Size());
       
   180 
       
   181 #ifdef __SERIES60_
       
   182     iMIDPictograph  = CMIDPictograph::NewL();
       
   183 #endif
       
   184 }
       
   185 
       
   186 CLcdGraphics::~CLcdGraphics()
       
   187 {
       
   188     delete iLcdDevice;
       
   189     delete iSurface;
       
   190 #ifdef __SERIES60_
       
   191     delete iMIDPictograph;
       
   192 #endif
       
   193 }
       
   194 
       
   195 void CLcdGraphics::Begin()
       
   196 {
       
   197     CHECK_BITMAP_LOCK();
       
   198 
       
   199     TRect bounds = iSurface->Bounds();
       
   200     if (bounds != iDeviceBounds)
       
   201     {
       
   202         iDeviceBounds = bounds;
       
   203         iDeviceOrigin = iDeviceBounds.iTl + iOrigin;
       
   204         iDeviceClipRect = iClipRect;
       
   205         iDeviceClipRect.Move(iDeviceOrigin);
       
   206         iDeviceClipRect.Intersection(bounds);
       
   207     }
       
   208 
       
   209     CBitmapContext* context = iSurface->Context();
       
   210     if (context != iContext)
       
   211     {
       
   212         iContext = context;
       
   213         ASSERT(iContext);
       
   214         iState = 0;
       
   215         iContext->SetPenStyle(CGraphicsContext::ENullPen);
       
   216         iContext->SetBrushStyle(CGraphicsContext::ENullBrush);
       
   217         iContext->SetOrigin(iOrigin);
       
   218         iContext->SetClippingRect(iClipRect);
       
   219         if (iFont)
       
   220         {
       
   221             iContext->UseFont(iFont);
       
   222             iContext->SetUnderlineStyle(iUnderline);
       
   223         }
       
   224     }
       
   225 }
       
   226 
       
   227 void CLcdGraphics::End()
       
   228 {
       
   229     //
       
   230     // This may not be required if we have CLcdGraphics::Flush(rect)
       
   231     //
       
   232     //iSurface->Update();
       
   233 
       
   234     CHECK_BITMAP_LOCK();
       
   235 }
       
   236 
       
   237 /**
       
   238 Maps a color provided as 32bit rgb triple to the closest color representable
       
   239 in the target devices display mode. returns the result as a 32bit rgb triple.
       
   240 */
       
   241 TUint32 CLcdGraphics::QuantizeColor(TUint32 aRGB32)
       
   242 {
       
   243     if (iLcdDevice)
       
   244     {
       
   245         return iLcdDevice->Quantize(aRGB32);
       
   246     }
       
   247     return aRGB32; // iLcdDriver.Quantize( iFbsBitmap->DisplayMode(), aRGB32 );
       
   248 }
       
   249 
       
   250 CLcdSurface* CLcdGraphics::Surface()
       
   251 {
       
   252     return iSurface;
       
   253 }
       
   254 
       
   255 void CLcdGraphics::SetColor(TUint32 aColor)
       
   256 {
       
   257     if (iColor != aColor)
       
   258     {
       
   259         iColor = aColor;
       
   260         iState &= ~(EPenColor|EBrushColor);
       
   261     }
       
   262 }
       
   263 
       
   264 TUint32 CLcdGraphics::Color() const
       
   265 {
       
   266     return iColor;
       
   267 }
       
   268 
       
   269 void CLcdGraphics::SetClipRect(const TPoint& aPosition, const TSize& aSize)
       
   270 {
       
   271     //
       
   272     // We keep a copy of the clipping rectangle for the
       
   273     // blitters. Clip rect is supplied in translated
       
   274     // coordinates, we map to device coords.
       
   275     //
       
   276     iClipRect = TRect(aPosition, aSize);
       
   277     iContext->SetClippingRect(iClipRect);
       
   278     iDeviceClipRect = iClipRect;
       
   279     iDeviceClipRect.Move(iDeviceOrigin);
       
   280     iDeviceClipRect.Intersection(iDeviceBounds);
       
   281 }
       
   282 
       
   283 const TRect& CLcdGraphics::ClipRect() const
       
   284 {
       
   285     return iClipRect;
       
   286 }
       
   287 
       
   288 void CLcdGraphics::Translate(const TPoint& aPoint)
       
   289 {
       
   290     //
       
   291     // Context stores clip rect in translated coords so there
       
   292     // is no need to update the clipping rect.
       
   293     //
       
   294     iContext->SetOrigin(aPoint);
       
   295     iClipRect.Move(iOrigin - aPoint);
       
   296     iOrigin = aPoint;
       
   297     iDeviceOrigin = aPoint + iDeviceBounds.iTl;
       
   298 }
       
   299 
       
   300 const TPoint& CLcdGraphics::Origin() const
       
   301 {
       
   302     return iOrigin;
       
   303 }
       
   304 
       
   305 void CLcdGraphics::SetStrokeStyle(TStrokeStyle aStyle)
       
   306 {
       
   307     if (iStrokeStyle != aStyle)
       
   308     {
       
   309         iStrokeStyle = aStyle;
       
   310         if (iState & EPenOn)
       
   311         {
       
   312             iContext->SetPenStyle(PenStyle(iStrokeStyle));
       
   313         }
       
   314     }
       
   315 }
       
   316 
       
   317 TStrokeStyle CLcdGraphics::StrokeStyle() const
       
   318 {
       
   319     return iStrokeStyle;
       
   320 }
       
   321 
       
   322 void CLcdGraphics::SetFont(TUint32 aFontID)
       
   323 {
       
   324     MMIDFont* font = reinterpret_cast<MMIDFont*>(aFontID << 2);
       
   325     iFont = font->Font();
       
   326     iUnderline = font->IsUnderlined()  ? EUnderlineOn : EUnderlineOff;
       
   327     iHeight = font->Height();
       
   328     iContext->UseFont(iFont);
       
   329     iContext->SetUnderlineStyle(iUnderline);
       
   330 }
       
   331 
       
   332 void CLcdGraphics::Reset(const TSize& aSize)
       
   333 {
       
   334     TRect deviceBounds(iDeviceBounds.iTl, aSize);
       
   335     iDeviceBounds = deviceBounds;
       
   336     iState = 0;
       
   337     iColor = KARGBBlack;
       
   338     iStrokeStyle = EStrokeSolid;
       
   339     iOrigin = TPoint(0,0);
       
   340     iClipRect = TRect(iDeviceBounds.Size());
       
   341     iDeviceClipRect = iDeviceBounds;
       
   342     iDeviceOrigin = iDeviceBounds.iTl;
       
   343     iContext->SetPenStyle(CGraphicsContext::ENullPen);
       
   344     iContext->SetBrushStyle(CGraphicsContext::ENullBrush);
       
   345     iContext->SetOrigin(iOrigin);
       
   346     iContext->SetClippingRect(iClipRect);
       
   347 }
       
   348 
       
   349 void CLcdGraphics::DrawLine(const TPoint& aPoint1, const TPoint& aPoint2)
       
   350 {
       
   351     TInt caps = CLcdGraphicsDevice::ECapDrawLine;
       
   352     if (iStrokeStyle == EStrokeDotted)
       
   353     {
       
   354         caps |= CLcdGraphicsDevice::ECapStrokeDotted;
       
   355     }
       
   356     if ((iLcdDrawCaps & caps) == caps)
       
   357     {
       
   358         ASSERT(iLcdDevice);
       
   359 
       
   360         TPoint p1(aPoint1);
       
   361         TPoint p2(aPoint2);
       
   362 
       
   363         p1 += iDeviceOrigin;
       
   364         p2 += iDeviceOrigin;
       
   365 
       
   366         CHECK_BITMAP_LOCK();
       
   367 
       
   368         iSurface->Begin(iBitmap, iCount);
       
   369 
       
   370         RRegion* visibleRegion = iSurface->VisibleRegion();
       
   371         if (iBitmap.iAddress && visibleRegion)
       
   372         {
       
   373             const TRect* rects = visibleRegion->RectangleList();
       
   374             const TInt   count = visibleRegion->Count();
       
   375             for (TInt i=0; i<count; i++)
       
   376             {
       
   377                 TRect clip(iDeviceClipRect);
       
   378                 clip.Intersection(rects[i]);
       
   379                 iLcdDevice->DrawLine(&iBitmap, p1, p2, iColor, (TStrokeStyle)iStrokeStyle, clip);
       
   380             }
       
   381         }
       
   382 
       
   383         iSurface->End(iCount);
       
   384 
       
   385         CHECK_BITMAP_LOCK();
       
   386     }
       
   387     else
       
   388     {
       
   389         LineMode();
       
   390         const TPoint& p1 = aPoint1;
       
   391         TPoint p2 = aPoint2;
       
   392         if (p1.iY == p2.iY)
       
   393         {
       
   394             /**
       
   395             Horizontal special case - adjust coords to include endpoint
       
   396             */
       
   397             if (p2.iX > p1.iX)
       
   398             {
       
   399                 ++ p2.iX;
       
   400             }
       
   401             else
       
   402             {
       
   403                 -- p2.iX;
       
   404             }
       
   405             iContext->DrawLine(p1,p2);
       
   406         }
       
   407         else if (p1.iX == p2.iX)
       
   408         {
       
   409             /**
       
   410             Vertical special case - adjust coords to include endpoint
       
   411             */
       
   412             if (p2.iY > p1.iY)
       
   413             {
       
   414                 ++ p2.iY;
       
   415             }
       
   416             else
       
   417             {
       
   418                 -- p2.iY;
       
   419             }
       
   420             iContext->DrawLine(p1, p2);
       
   421         }
       
   422         else
       
   423         {
       
   424             /**
       
   425             General slope - have to plot last point since SymbianOS GDI does
       
   426             not draw the last point on a line.
       
   427             */
       
   428             iContext->DrawLine(p1, p2);
       
   429             iContext->Plot(p2);
       
   430         }
       
   431     }
       
   432 }
       
   433 
       
   434 void CLcdGraphics::DrawRect(const TPoint& aPosition, const TSize& aSize)
       
   435 {
       
   436     //
       
   437     // adjust coords for stroked primitives
       
   438     //
       
   439     TRect rect(aPosition, aSize);
       
   440     rect.iBr.iX++;
       
   441     rect.iBr.iY++;
       
   442 
       
   443     TInt caps = CLcdGraphicsDevice::ECapDrawRect;
       
   444     if (iStrokeStyle == EStrokeDotted)
       
   445     {
       
   446         caps |= CLcdGraphicsDevice::ECapStrokeDotted;
       
   447     }
       
   448     if ((iLcdDrawCaps & caps) == caps)
       
   449     {
       
   450         ASSERT(iLcdDevice);
       
   451 
       
   452         rect.Move(iDeviceOrigin);
       
   453 
       
   454         CHECK_BITMAP_LOCK();
       
   455 
       
   456         iSurface->Begin(iBitmap, iCount);
       
   457 
       
   458         RRegion* visibleRegion = iSurface->VisibleRegion();
       
   459         if (iBitmap.iAddress && visibleRegion)
       
   460         {
       
   461             const TRect* rects = visibleRegion->RectangleList();
       
   462             const TInt   count = visibleRegion->Count();
       
   463             for (TInt i=0; i<count; i++)
       
   464             {
       
   465                 TRect clip(iDeviceClipRect);
       
   466                 clip.Intersection(rects[i]);
       
   467                 iLcdDevice->DrawRect(&iBitmap, rect, iColor, (TStrokeStyle)iStrokeStyle, clip);
       
   468             }
       
   469         }
       
   470 
       
   471         iSurface->End(iCount);
       
   472 
       
   473         CHECK_BITMAP_LOCK();
       
   474     }
       
   475     else
       
   476     {
       
   477         OutlineMode();
       
   478         iContext->DrawRect(rect);
       
   479     }
       
   480 }
       
   481 
       
   482 void CLcdGraphics::FillRect(const TPoint& aPosition, const TSize& aSize)
       
   483 {
       
   484     TRect rect(aPosition, aSize);
       
   485     if (iLcdDrawCaps & CLcdGraphicsDevice::ECapFillRect)
       
   486     {
       
   487         ASSERT(iLcdDevice);
       
   488         rect.Move(iDeviceOrigin);
       
   489 
       
   490         CHECK_BITMAP_LOCK();
       
   491 
       
   492         iSurface->Begin(iBitmap, iCount);
       
   493 
       
   494         RRegion* visibleRegion = iSurface->VisibleRegion();
       
   495         if (iBitmap.iAddress && visibleRegion)
       
   496         {
       
   497             const TRect* rects = visibleRegion->RectangleList();
       
   498             const TInt   count = visibleRegion->Count();
       
   499             for (TInt i=0; i<count; i++)
       
   500             {
       
   501                 TRect clip(iDeviceClipRect);
       
   502                 clip.Intersection(rects[i]);
       
   503                 iLcdDevice->FillRect(&iBitmap, rect, iColor, clip);
       
   504             }
       
   505         }
       
   506 
       
   507         iSurface->End(iCount);
       
   508 
       
   509         CHECK_BITMAP_LOCK();
       
   510     }
       
   511     else
       
   512     {
       
   513         FillMode();
       
   514         iContext->DrawRect(rect);
       
   515     }
       
   516 }
       
   517 
       
   518 void CLcdGraphics::DrawArc(const TPoint& aPosition, const TSize& aSize, TInt aStartAngle, TInt aArcAngle)
       
   519 {
       
   520     if (!aArcAngle)
       
   521     {
       
   522         return;
       
   523     }
       
   524 
       
   525     TRect rect(aPosition, aSize);
       
   526     rect.iBr.iX++;
       
   527     rect.iBr.iY++;
       
   528 
       
   529     TInt caps = CLcdGraphicsDevice::ECapDrawArc;
       
   530     if (iStrokeStyle == EStrokeDotted)
       
   531     {
       
   532         caps |= CLcdGraphicsDevice::ECapStrokeDotted;
       
   533     }
       
   534     if ((iLcdDrawCaps & caps) == caps)
       
   535     {
       
   536         ASSERT(iLcdDevice);
       
   537 
       
   538         rect.Move(iDeviceOrigin);
       
   539 
       
   540         CHECK_BITMAP_LOCK();
       
   541 
       
   542         iSurface->Begin(iBitmap, iCount);
       
   543 
       
   544         RRegion* visibleRegion = iSurface->VisibleRegion();
       
   545         if (iBitmap.iAddress && visibleRegion)
       
   546         {
       
   547             const TRect* rects = visibleRegion->RectangleList();
       
   548             const TInt   count = visibleRegion->Count();
       
   549             for (TInt i=0; i<count; i++)
       
   550             {
       
   551                 TRect clip(iDeviceClipRect);
       
   552                 clip.Intersection(rects[i]);
       
   553                 iLcdDevice->DrawArc(&iBitmap, rect, aStartAngle, aArcAngle, iColor, iStrokeStyle, clip);
       
   554             }
       
   555         }
       
   556 
       
   557         iSurface->End(iCount);
       
   558 
       
   559         CHECK_BITMAP_LOCK();
       
   560     }
       
   561     else
       
   562     {
       
   563         OutlineMode();
       
   564         TPoint start;
       
   565         TPoint end;
       
   566         ArcVectors(start, end, rect, aStartAngle, aArcAngle);
       
   567         iContext->DrawArc(rect,start,end);
       
   568     }
       
   569 }
       
   570 
       
   571 void CLcdGraphics::FillArc(const TPoint& aPosition, const TSize& aSize, TInt aStartAngle, TInt aArcAngle)
       
   572 {
       
   573     if (!aArcAngle)
       
   574     {
       
   575         return;
       
   576     }
       
   577     TRect rect(aPosition, aSize);
       
   578     if (iLcdDrawCaps & CLcdGraphicsDevice::ECapFillArc)
       
   579     {
       
   580         ASSERT(iLcdDevice);
       
   581         rect.Move(iDeviceOrigin);
       
   582 
       
   583         CHECK_BITMAP_LOCK();
       
   584 
       
   585         iSurface->Begin(iBitmap, iCount);
       
   586 
       
   587         RRegion* visibleRegion = iSurface->VisibleRegion();
       
   588         if (iBitmap.iAddress && visibleRegion)
       
   589         {
       
   590             const TRect* rects = visibleRegion->RectangleList();
       
   591             const TInt   count = visibleRegion->Count();
       
   592             for (TInt i=0; i<count; i++)
       
   593             {
       
   594                 TRect clip(iDeviceClipRect);
       
   595                 clip.Intersection(rects[i]);
       
   596                 iLcdDevice->FillArc(&iBitmap, rect, aStartAngle, aArcAngle, iColor, clip);
       
   597             }
       
   598         }
       
   599 
       
   600         iSurface->End(iCount);
       
   601 
       
   602         CHECK_BITMAP_LOCK();
       
   603     }
       
   604     else
       
   605     {
       
   606         // Temporarily turn on the pen and set the pen color.
       
   607         SetPenOff();
       
   608         SetBrushOn();
       
   609 
       
   610         // Grow the bounding rect by a 1 pixel border.
       
   611         rect.Grow(1,1);
       
   612 
       
   613         TPoint start;
       
   614         TPoint end;
       
   615         ArcVectors(start, end, rect, aStartAngle, aArcAngle);
       
   616         iContext->DrawPie(rect,start,end);
       
   617     }
       
   618 }
       
   619 
       
   620 void CLcdGraphics::CopyArea(const TPoint& aAreaPosition, const TSize& aAreaSize, const TPoint& aPoint, TInt aAnchor)
       
   621 {
       
   622     TRect  rect(aAreaPosition, aAreaSize);
       
   623     TPoint vector = AnchorPoint(aPoint, aAnchor, aAreaSize) - aAreaPosition;
       
   624     iContext->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
       
   625     iContext->CopyRect(vector, rect);
       
   626     iContext->SetDrawMode(CGraphicsContext::EDrawModePEN);
       
   627 }
       
   628 
       
   629 void CLcdGraphics::DrawRoundRect(const TPoint& aPosition, const TSize& aSize, const TSize& aCornerDiameter)
       
   630 {
       
   631     TRect rect(aPosition, aSize);
       
   632     rect.iBr.iX++;
       
   633     rect.iBr.iY++;
       
   634     TSize cornerRadii;
       
   635     cornerRadii.iWidth  = aCornerDiameter.iWidth/2;
       
   636     cornerRadii.iHeight = aCornerDiameter.iHeight/2;
       
   637     OutlineMode();
       
   638     iContext->DrawRoundRect(rect, cornerRadii);
       
   639 }
       
   640 
       
   641 void CLcdGraphics::FillRoundRect(const TPoint& aPosition, const TSize& aSize, const TSize& aCornerDiameter)
       
   642 {
       
   643     TRect rect(aPosition, aSize);
       
   644     TSize cornerRadii;
       
   645     cornerRadii.iWidth  = aCornerDiameter.iWidth/2;
       
   646     cornerRadii.iHeight = aCornerDiameter.iHeight/2;
       
   647 
       
   648     // Temporarily turn on the pen and set the pen color.
       
   649     SetBrushOn();
       
   650     iContext->SetPenColor(TRgb::Color16MA(iColor));
       
   651     iContext->SetPenStyle(CGraphicsContext::ESolidPen);
       
   652     iContext->DrawRoundRect(rect, cornerRadii);
       
   653     iState |= EPenOn;
       
   654     SetPenOff();    // keep in sync with stroke style
       
   655 }
       
   656 
       
   657 void CLcdGraphics::FillTriangle(const TPoint aPoints[3])
       
   658 {
       
   659 #ifdef RD_JAVA_NGA_ENABLED
       
   660     // Lcdgd implementation for fillTriangle does not support alpha blending,
       
   661     // use CFbsBitGc in case of non-opaque color.
       
   662     if ((iLcdDrawCaps & CLcdGraphicsDevice::ECapFillTriangle) &&
       
   663             ((iColor & 0xFF000000) == 0xFF000000))
       
   664 #else
       
   665     if (iLcdDrawCaps & CLcdGraphicsDevice::ECapFillTriangle)
       
   666 #endif
       
   667     {
       
   668         ASSERT(iLcdDevice);
       
   669         TPoint points[3];
       
   670         points[0] = aPoints[0]+iDeviceOrigin;
       
   671         points[1] = aPoints[1]+iDeviceOrigin;
       
   672         points[2] = aPoints[2]+iDeviceOrigin;
       
   673 
       
   674         CHECK_BITMAP_LOCK();
       
   675 
       
   676         iSurface->Begin(iBitmap, iCount);
       
   677         RRegion* visibleRegion = iSurface->VisibleRegion();
       
   678         if (iBitmap.iAddress && visibleRegion)
       
   679         {
       
   680             const TRect* rects = visibleRegion->RectangleList();
       
   681             const TInt   count = visibleRegion->Count();
       
   682             for (TInt i=0; i<count; i++)
       
   683             {
       
   684                 TRect clip(iDeviceClipRect);
       
   685                 clip.Intersection(rects[i]);
       
   686                 iLcdDevice->FillTriangle(&iBitmap, points, iColor, clip);
       
   687             }
       
   688         }
       
   689 
       
   690         iSurface->End(iCount);
       
   691 
       
   692         CHECK_BITMAP_LOCK();
       
   693     }
       
   694     else
       
   695     {
       
   696         // Temporarily set solid pen style and the pen color.
       
   697         SetBrushOn();
       
   698         iContext->SetPenColor(TRgb::Color16MA(iColor));
       
   699         iContext->SetPenStyle(CGraphicsContext::ESolidPen);
       
   700         iContext->DrawPolygon(aPoints, 3, CGraphicsContext::EAlternate);
       
   701         SetPenOff();    // keep in sync with stroke style
       
   702     }
       
   703 }
       
   704 
       
   705 // ---------------------------------------------------------------------------
       
   706 // CMIDGraphics::DrawImage()
       
   707 // ---------------------------------------------------------------------------
       
   708 //
       
   709 void CLcdGraphics::DrawImage(
       
   710     const CLcdImage& aImage, const TPoint& aPoint, TInt aAnchor, TBool aPremultiplied)
       
   711 {
       
   712     TPoint regionPos;
       
   713     TSize  regionSize(aImage.Size());
       
   714     (void) DrawRegion(
       
   715         aImage, regionPos, regionSize, ETransNone, aPoint, aAnchor, aPremultiplied);
       
   716 }
       
   717 
       
   718 // ---------------------------------------------------------------------------
       
   719 // CMIDGraphics::DrawRegion()
       
   720 // Returns error if no blitter found.
       
   721 // ---------------------------------------------------------------------------
       
   722 //
       
   723 TInt CLcdGraphics::DrawRegion
       
   724 (
       
   725     const CLcdImage& aImage,
       
   726     const TPoint&    aRegionPos,
       
   727     const TSize&     aRegionSize,
       
   728     TInt             aTransform,
       
   729     const TPoint&    aPoint,
       
   730     TInt             aAnchor,
       
   731     TBool            aPremultiplied
       
   732 )
       
   733 {
       
   734     ASSERT(iLcdDrawCaps & CLcdGraphicsDevice::ECapDrawRegion);
       
   735     ASSERT(iLcdDevice);
       
   736 
       
   737     TTransformType transform = (TTransformType)aTransform;
       
   738     TAnchor anchor = (TAnchor)aAnchor;
       
   739 
       
   740     TRect srcRect(aRegionPos, aRegionSize);
       
   741     TPoint dstPoint(iDeviceOrigin + aPoint);
       
   742 
       
   743     TAcceleratedBitmapInfo srcColor;
       
   744     TAcceleratedBitmapInfo srcAlpha;
       
   745 
       
   746     CHECK_BITMAP_LOCK();
       
   747 
       
   748     iSurface->Begin(iBitmap, iCount);
       
   749     aImage.Lock(iCount, srcColor, srcAlpha);
       
   750 
       
   751     //
       
   752     // Compute destination rectangle with anchor point at aRegion.iDstPoint.
       
   753     //
       
   754     TRect dstRect = CalcDstRect(dstPoint, srcRect.Size(), transform, anchor);
       
   755     TInt error = KErrNone;
       
   756 
       
   757     TTransparency transparency = aImage.Transparency();
       
   758 
       
   759 #ifdef RD_JAVA_NGA_ENABLED
       
   760     // In S60 9.2 and onward the target canvas offscreen is not necessarily
       
   761     // fully opaque when the M3G API is using hardware accelerated OpenGL ES API.
       
   762     // Note that in this case target pixels are in premultiplied form.
       
   763     if (aPremultiplied)
       
   764     {
       
   765         if (transparency == ETransparencyMaskChannel)
       
   766         {
       
   767             // Target contains premultiplied pixel components and
       
   768             // and source contains transparent pixels
       
   769             transparency = ETransparencyMaskChannelPre;
       
   770         }
       
   771         if (transparency == ETransparencyAlphaChannel)
       
   772         {
       
   773             // Target contains premultiplied pixel components and
       
   774             // and source contains transparent pixels
       
   775             transparency = ETransparencyAlphaChannelPre;
       
   776         }
       
   777     }
       
   778 #else // !RD_JAVA_NGA_ENABLED
       
   779     (void)aPremultiplied;  // Just to remove a compiler warning
       
   780 #endif // RD_JAVA_NGA_ENABLED
       
   781 
       
   782     RRegion* visibleRegion = iSurface->VisibleRegion();
       
   783     if (iBitmap.iAddress && visibleRegion)
       
   784     {
       
   785         const TRect* rects = visibleRegion->RectangleList();
       
   786         const TInt   count = visibleRegion->Count();
       
   787         for (TInt i=0; i<count; i++)
       
   788         {
       
   789             TRect clip(iDeviceClipRect);
       
   790             clip.Intersection(rects[i]);
       
   791 
       
   792             if (iIsCanvasGraphicsItemTarget)
       
   793             {
       
   794                 // Because rendering function, which is used for drawing image,
       
   795                 // doesn't allow to render on transparent target
       
   796                 // (@see BlitLineColor16MAMaskToColor16MAOpaque), we have to
       
   797                 // do it by ourselves.
       
   798                 error = iLcdDevice->DrawRegionForCanvasGraphicsItem
       
   799                         (
       
   800                             &iBitmap,
       
   801                             dstRect,
       
   802                             &srcColor,
       
   803                             srcAlpha.iAddress ? &srcAlpha : NULL,
       
   804                             aImage.Transparency(),
       
   805                             srcRect,
       
   806                             transform,
       
   807                             clip,
       
   808                             ECanvasGraphicsItemImageRendering
       
   809                         );
       
   810             }
       
   811             else
       
   812             {
       
   813                 error = iLcdDevice->DrawRegion
       
   814                         (
       
   815                             &iBitmap,
       
   816                             dstRect,
       
   817                             &srcColor,
       
   818                             srcAlpha.iAddress ? &srcAlpha : NULL,
       
   819                             transparency,
       
   820                             srcRect,
       
   821                             transform,
       
   822                             clip
       
   823                         );
       
   824             }
       
   825         }
       
   826     }
       
   827 
       
   828     aImage.Unlock(iCount);
       
   829     iSurface->End(iCount);
       
   830 
       
   831     CHECK_BITMAP_LOCK();
       
   832 
       
   833     ASSERT(error == KErrNone);
       
   834 
       
   835     return error;
       
   836 }
       
   837 
       
   838 void CLcdGraphics::DrawBackground(MMIDCanvas* aCanvas, const TPoint& aPosition, const TSize& aSize)
       
   839 {
       
   840 
       
   841     CHECK_BITMAP_LOCK();
       
   842 
       
   843     iSurface->Begin(iBitmap, iCount);
       
   844     aCanvas->DrawBackground(*iContext, aPosition, aSize);
       
   845     iSurface->End(iCount);
       
   846 
       
   847     CHECK_BITMAP_LOCK();
       
   848 
       
   849 }
       
   850 
       
   851 TInt CLcdGraphics::DrawPixels
       
   852 (
       
   853     TInt aType,
       
   854     const TUint8* aAddress,
       
   855     TInt DEBUG_ARG(aLength),
       
   856     TInt aScanLength,
       
   857     TBool aAlpha,
       
   858     const TPoint& aPosition,
       
   859     const TSize& aSize,
       
   860     TInt aTransform,
       
   861     TBool aPremultiplied
       
   862 )
       
   863 {
       
   864     ASSERT(iLcdDevice);
       
   865     TInt err = KErrNotSupported;
       
   866     if (aType == 0)     // we could support others now.
       
   867     {
       
   868         ASSERT(iLcdDrawCaps & CLcdGraphicsDevice::ECapDrawRegion);
       
   869         ASSERT((((TUint32)aAddress) & 0x3) == 0);       // must be word aligned
       
   870         ASSERT(aLength >= ((aSize.iHeight-1)*aScanLength + aSize.iWidth*sizeof(TUint32)));
       
   871         ASSERT(aScanLength >= 0);
       
   872 
       
   873         TTransformType transform  = (TTransformType)aTransform;
       
   874         TTransparency transparency = (aAlpha ? ETransparencyAlphaChannel : ETransparencyIgnoreChannel);
       
   875 
       
   876         TAcceleratedBitmapInfo srcBitmap;
       
   877 
       
   878         CLcdGraphicsDriver::TDriverInfo info;
       
   879         iLcdDriver.GetDriverInfo(info);
       
   880 
       
   881         srcBitmap.iPhysicalAddress = NULL;
       
   882         srcBitmap.iAddress     = const_cast<TUint8*>(aAddress);
       
   883         srcBitmap.iDisplayMode = info.iARGB8888Mode;
       
   884         srcBitmap.iSize        = aSize;
       
   885         srcBitmap.iLinePitch   = aScanLength;
       
   886         srcBitmap.iPixelShift  = 5;     // 32bpp
       
   887 
       
   888 
       
   889         TRect srcRect(aSize);
       
   890         TRect dstRect(aPosition, aSize);
       
   891         dstRect.Move(iDeviceOrigin);
       
   892 
       
   893         CHECK_BITMAP_LOCK();
       
   894 
       
   895         iSurface->Begin(iBitmap, iCount);
       
   896 
       
   897 #ifdef RD_JAVA_NGA_ENABLED
       
   898         // In S60 9.2 and onward the target canvas offscreen is not necessarily
       
   899         // fully opaque when the M3G API is using hardware accelerated OpenGL ES API.
       
   900         // Note that in this case target pixels are in premultiplied form.
       
   901         if (aPremultiplied && transparency == ETransparencyAlphaChannel)
       
   902         {
       
   903             // Target contains premultiplied pixel components and
       
   904             // and source contains transparent pixels
       
   905             transparency = ETransparencyAlphaChannelPre;
       
   906         }
       
   907 #else // !RD_JAVA_NGA_ENABLED
       
   908         (void)aPremultiplied;  // Just to remove a compiler warning
       
   909 #endif // RD_JAVA_NGA_ENABLED
       
   910 
       
   911         RRegion* visibleRegion = iSurface->VisibleRegion();
       
   912         if (iBitmap.iAddress && visibleRegion)
       
   913         {
       
   914             const TRect* rects = visibleRegion->RectangleList();
       
   915             const TInt   count = visibleRegion->Count();
       
   916             for (TInt i=0; i<count; i++)
       
   917             {
       
   918                 TRect clip(iDeviceClipRect);
       
   919                 clip.Intersection(rects[i]);
       
   920 
       
   921                 if (iIsCanvasGraphicsItemTarget)
       
   922                 {
       
   923                     // Because rendering function, which is used for drawing
       
   924                     // RGB data, doesn't blend properly to transparent target
       
   925                     // (@see BlitLineColor16MAAlphaToColor16MAOpaque),
       
   926                     // we have to do it by ourselves.
       
   927                     err = iLcdDevice->DrawRegionForCanvasGraphicsItem
       
   928                           (
       
   929                               &iBitmap,
       
   930                               dstRect,
       
   931                               &srcBitmap,
       
   932                               NULL,
       
   933                               transparency,
       
   934                               srcRect,
       
   935                               transform,
       
   936                               clip,
       
   937                               ECanvasGraphicsItemRGBRendering
       
   938                           );
       
   939                 }
       
   940                 else
       
   941                 {
       
   942                     err = iLcdDevice->DrawRegion
       
   943                           (
       
   944                               &iBitmap,
       
   945                               dstRect,
       
   946                               &srcBitmap,
       
   947                               NULL,
       
   948                               transparency,
       
   949                               srcRect,
       
   950                               transform,
       
   951                               clip
       
   952                           );
       
   953                 }
       
   954             }
       
   955         }
       
   956 
       
   957 
       
   958         iSurface->End(iCount);
       
   959 
       
   960         CHECK_BITMAP_LOCK();
       
   961     }
       
   962     return err;
       
   963 }
       
   964 
       
   965 static TBool IsUniformlyLeftToRight(const TDesC& aText)
       
   966 {
       
   967     const TInt length = aText.Length();
       
   968 
       
   969     for (TInt i = 0; i < length; i++)
       
   970     {
       
   971         switch (TChar(aText[i]).GetBdCategory())
       
   972         {
       
   973         case TChar::ERightToLeft:
       
   974         case TChar::ERightToLeftArabic:
       
   975         case TChar::ERightToLeftEmbedding:
       
   976         case TChar::ERightToLeftOverride:
       
   977         case TChar::EArabicNumber:
       
   978 
       
   979             return EFalse;
       
   980 
       
   981         default:
       
   982             ;
       
   983         }
       
   984     }
       
   985     return ETrue;
       
   986 }
       
   987 
       
   988 void CLcdGraphics::DrawText(const TDesC& aText, const TPoint& aPoint, TInt aAnchor)
       
   989 {
       
   990     LineMode();
       
   991 
       
   992     ASSERT(iFont);
       
   993     TPoint pos = aPoint;
       
   994 
       
   995     if (aAnchor & EAnchorTop)
       
   996     {
       
   997         pos.iY += iFont->FontMaxAscent();
       
   998     }
       
   999     else if (aAnchor & EAnchorBottom)
       
  1000     {
       
  1001         pos.iY -= (iHeight - iFont->FontMaxAscent()); // iHeight includes leading
       
  1002     }
       
  1003 
       
  1004     if (aAnchor & EAnchorHCenter)
       
  1005     {
       
  1006         pos.iX -= iFont->TextWidthInPixels(aText)/2;
       
  1007     }
       
  1008     else if (aAnchor & EAnchorRight)
       
  1009     {
       
  1010         pos.iX -= iFont->TextWidthInPixels(aText);
       
  1011     }
       
  1012 
       
  1013     if (IsUniformlyLeftToRight(aText))
       
  1014     {
       
  1015 #ifdef __SERIES60_
       
  1016         CAknPictographInterface* aknPictographInterface = iMIDPictograph->PictographInterface();
       
  1017 
       
  1018         if (aknPictographInterface)
       
  1019         {
       
  1020             MAknPictographDrawer* aknPictographDrawer = aknPictographInterface->Interface();
       
  1021             aknPictographDrawer->DrawText(*iContext, *iFont, aText, pos);
       
  1022         }
       
  1023         else
       
  1024         {
       
  1025             iContext->DrawText(aText, pos);
       
  1026         }
       
  1027 
       
  1028 #else
       
  1029         iContext->DrawText(aText, pos);
       
  1030 #endif
       
  1031     }
       
  1032     else
       
  1033     {
       
  1034         TBidiText* bidiText = NULL;
       
  1035 
       
  1036         TRAPD(status, bidiText = TBidiText::NewL(aText, 1));
       
  1037         if (status != KErrNone)
       
  1038         {
       
  1039             return;
       
  1040         }
       
  1041         bidiText->WrapText(iFont->TextWidthInPixels(aText), *iFont);
       
  1042 #ifdef __SERIES60_
       
  1043         CAknPictographInterface* aknPictographInterface = iMIDPictograph->PictographInterface();
       
  1044 
       
  1045         if (aknPictographInterface)
       
  1046         {
       
  1047             MAknPictographDrawer* aknPictographDrawer = aknPictographInterface->Interface();
       
  1048             aknPictographDrawer->DrawText(*iContext, *iFont, aText, pos);
       
  1049         }
       
  1050         else
       
  1051         {
       
  1052             bidiText->DrawText(*iContext, pos);
       
  1053         }
       
  1054 #else
       
  1055         bidiText->DrawText(*iContext, pos);
       
  1056 #endif
       
  1057         delete bidiText;
       
  1058     }
       
  1059 }
       
  1060 
       
  1061 void CLcdGraphics::Flush(const TPoint& aPosition, const TSize& aSize)
       
  1062 {
       
  1063     TRect deviceRect(aPosition, aSize);
       
  1064     deviceRect.Move(iDeviceBounds.iTl);
       
  1065     iSurface->Update(deviceRect);
       
  1066 }
       
  1067 
       
  1068 #ifdef RD_JAVA_NGA_ENABLED
       
  1069 
       
  1070 // ---------------------------------------------------------------------------
       
  1071 // CLcdGraphics::CopyGraphics()
       
  1072 // Copies source graphics content
       
  1073 // ---------------------------------------------------------------------------
       
  1074 //
       
  1075 TInt CLcdGraphics::CopyGraphics(CLcdGraphics* aSrcGraphics)
       
  1076 {
       
  1077     ASSERT(iLcdDevice);
       
  1078     CLcdSurface* srcSurface = aSrcGraphics->Surface();
       
  1079     TInt error = KErrNone;
       
  1080     CHECK_BITMAP_LOCK();
       
  1081     iSurface->Begin(iBitmap, iCount);
       
  1082     srcSurface->Begin(aSrcGraphics->iBitmap, iCount);
       
  1083 
       
  1084     RRegion* visibleRegion = iSurface->VisibleRegion();
       
  1085     if (iBitmap.iAddress && visibleRegion)
       
  1086     {
       
  1087         const TRect* rects = visibleRegion->RectangleList();
       
  1088         const TInt   count = visibleRegion->Count();
       
  1089         for (TInt i=0; i<count; i++)
       
  1090         {
       
  1091             TRect clip(iDeviceClipRect);
       
  1092             clip.Intersection(rects[i]);
       
  1093 
       
  1094             error = iLcdDevice->DrawRegion(
       
  1095                         &iBitmap,
       
  1096                         iSurface->Bounds(),
       
  1097                         &aSrcGraphics->iBitmap,
       
  1098                         NULL,
       
  1099                         ETransparencyIgnoreChannel,
       
  1100                         iSurface->Bounds(),
       
  1101                         ETransNone,
       
  1102                         clip);
       
  1103         }
       
  1104     }
       
  1105     srcSurface->End(iCount);
       
  1106     iSurface->End(iCount);
       
  1107     CHECK_BITMAP_LOCK();
       
  1108     ASSERT(error == KErrNone);
       
  1109     return error;
       
  1110 }
       
  1111 
       
  1112 #endif // RD_JAVA_NGA_ENABLED
       
  1113 
       
  1114 void ArcVectors(TPoint& aStart, TPoint& aEnd, const TRect& aRect, TInt aStartAngle, TInt aArcAngle)
       
  1115 {
       
  1116     TPoint  point = aRect.iTl;
       
  1117     TSize   size  = aRect.Size();
       
  1118 
       
  1119     //
       
  1120     // Center.
       
  1121     //
       
  1122     point.iX += size.iWidth/2;
       
  1123     point.iY += size.iHeight/2;
       
  1124 
       
  1125     if (aArcAngle>=360 || aArcAngle <=-360)
       
  1126     {
       
  1127         aStart = point;
       
  1128         aStart.iX += size.iWidth/2;
       
  1129         aEnd   = aStart;
       
  1130     }
       
  1131     else
       
  1132     {
       
  1133         TInt begAngle = aStartAngle;
       
  1134         TInt endAngle = aStartAngle+aArcAngle;
       
  1135         if (aArcAngle < 0)
       
  1136         {
       
  1137             begAngle = endAngle;
       
  1138             endAngle = aStartAngle;
       
  1139         }
       
  1140         aEnd   = point + Vector(endAngle, size);
       
  1141         aStart = point + Vector(begAngle, size);
       
  1142     }
       
  1143 }
       
  1144 
       
  1145 TPoint Vector(const TReal& aAngle, const TSize& aSize)
       
  1146 {
       
  1147     TReal  angle(aAngle * KDegToRad);
       
  1148 
       
  1149     TReal  x;
       
  1150     Math::Cos(x, angle);
       
  1151 
       
  1152     TReal  y;
       
  1153     Math::Sin(y, angle);
       
  1154 
       
  1155     x *= aSize.iWidth;
       
  1156     y *= -aSize.iHeight;
       
  1157 
       
  1158     return TPoint((TInt)x, (TInt)y);
       
  1159 }
       
  1160 
       
  1161 TPoint AnchorPoint(const TPoint& aPoint, TInt aAnchor, const TSize& aSize)
       
  1162 {
       
  1163     TPoint point = aPoint;
       
  1164 
       
  1165     if (aAnchor & MMIDGraphics::EAnchorRight)
       
  1166     {
       
  1167         point.iX -= aSize.iWidth;
       
  1168     }
       
  1169     else if (aAnchor & MMIDGraphics::EAnchorHCenter)
       
  1170     {
       
  1171         point.iX -= aSize.iWidth/2;
       
  1172     }
       
  1173 
       
  1174     if (aAnchor & MMIDGraphics::EAnchorVCenter)
       
  1175     {
       
  1176         point.iY -= aSize.iHeight/2;
       
  1177     }
       
  1178     else if (aAnchor & MMIDGraphics::EAnchorBottom)
       
  1179     {
       
  1180         point.iY -= aSize.iHeight;
       
  1181     }
       
  1182 
       
  1183     return point;
       
  1184 }
       
  1185 
       
  1186 void CLcdGraphics::SetCanvasGraphicsItemtarget(TBool aIsCanvasGraphicsItemTarget)
       
  1187 {
       
  1188     iIsCanvasGraphicsItemTarget = aIsCanvasGraphicsItemTarget;
       
  1189 }
       
  1190 
       
  1191 /////////////////////////////////////////////////////////////
       
  1192 // CMIDPictograph is for Pictograpgh in S60
       
  1193 //
       
  1194 ////////////////////////////////////////////////////////////
       
  1195 #ifdef __SERIES60_
       
  1196 
       
  1197 CMIDPictograph* CMIDPictograph::NewL()
       
  1198 {
       
  1199     CMIDPictograph* self = new(ELeave) CMIDPictograph;
       
  1200     CleanupStack::PushL(self);
       
  1201     self->ConstructL();
       
  1202     CleanupStack::Pop(self);
       
  1203 
       
  1204     return self;
       
  1205 }
       
  1206 //
       
  1207 CMIDPictograph::CMIDPictograph() {}
       
  1208 void CMIDPictograph::ConstructL()
       
  1209 {
       
  1210     CCoeControl *dummyControl = NULL;
       
  1211     iPictographInterface = CAknPictographInterface::NewL(*dummyControl, *this);
       
  1212 }
       
  1213 //Not doing any thing, Canvas has to draw the pictograph
       
  1214 //by calling draw again and again.
       
  1215 void CMIDPictograph::DrawPictographArea() {}
       
  1216 CAknPictographInterface* CMIDPictograph::PictographInterface()
       
  1217 {
       
  1218     return iPictographInterface;
       
  1219 }
       
  1220 
       
  1221 CMIDPictograph::~CMIDPictograph()
       
  1222 {
       
  1223     delete iPictographInterface;
       
  1224 }
       
  1225 
       
  1226 #endif