textinput/peninputarc/src/peninputlayoutcontrol/peninputlayouthwrwindow.cpp
changeset 0 eb1f2e154e89
child 7 6defe5d1bd39
equal deleted inserted replaced
-1:000000000000 0:eb1f2e154e89
       
     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:  Implementation for hwr window base and transparent window
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include <coemain.h>
       
    21 #include "peninputlayouthwrwnd.h"
       
    22 #include "peninputlayoutrootctrl.h"
       
    23 #include "peninputlayouttimer.h"
       
    24 #include "peninputlayout.h"
       
    25 
       
    26 #include <settingsinternalcrkeys.h>
       
    27 
       
    28 #include "peninputpentracedecorator.h"
       
    29 
       
    30 const TUint8 KDefaultTransparency = 128;
       
    31 const TInt KDefaultPenSize = 3;
       
    32 const TInt KFadeAreaCount = 30;
       
    33 
       
    34 /******************** start of CHwrWndBase **********************************/
       
    35 // Implementation of Class CHwrWndBase
       
    36 //
       
    37 
       
    38 // ---------------------------------------------------------------------------
       
    39 // CHwrWndBase::CHwrWndBase
       
    40 // C++ default constructor
       
    41 // (other items were commented in a header).
       
    42 // ---------------------------------------------------------------------------
       
    43 //
       
    44 EXPORT_C CHwrWndBase::CHwrWndBase(const TRect& aRect,CFepUiLayout* aUiLayout,TInt aControlId):
       
    45                     CFepUiBaseCtrl(aRect,aUiLayout,aControlId), 
       
    46                     iHasNewTrace(EFalse),
       
    47                     iSubmitted(ETrue)
       
    48     {
       
    49     const TTimeIntervalMicroSeconds32 KDefaultCharDelay = 1000*500; //1/2 seconds    
       
    50     const TTimeIntervalMicroSeconds32 KDefaultStrokeDelay = 1000*300; //1/10 seconds
       
    51     
       
    52     
       
    53     SetControlType(ECtrlHwrWnd);
       
    54     SetPenColor(KRgbBlack);
       
    55     SetPenSize(TSize(KDefaultPenSize,KDefaultPenSize));
       
    56     iStrokeEndMark=TPoint(0xffff,0);
       
    57     iStrokeDelay = KDefaultStrokeDelay;    
       
    58     iCharDelay = KDefaultCharDelay;    
       
    59     iDirtyRect.SetRect(0,0,0,0);
       
    60     }
       
    61 
       
    62 // ---------------------------------------------------------------------------
       
    63 // CHwrWndBase::~CHwrWndBase
       
    64 // Destructor
       
    65 // (other items were commented in a header).
       
    66 // ---------------------------------------------------------------------------
       
    67 //
       
    68 EXPORT_C CHwrWndBase::~CHwrWndBase()
       
    69     {
       
    70 
       
    71     iListOfPoints.Close();
       
    72     delete iCharacterTimer;
       
    73     iCharacterTimer = NULL;
       
    74     delete iStrokeTimer;
       
    75     iStrokeTimer = NULL;     
       
    76     }
       
    77 
       
    78 // ---------------------------------------------------------------------------
       
    79 // CHwrWndBase::ClearStroke
       
    80 // Clear the stroke
       
    81 // (other items were commented in a header).
       
    82 // ---------------------------------------------------------------------------
       
    83 //   
       
    84 EXPORT_C void CHwrWndBase::ClearStroke()
       
    85     {
       
    86     iDirtyRect.Intersection(iRect);
       
    87     
       
    88     ClearRect( iRect );       
       
    89 
       
    90     iListOfPoints.Reset();            
       
    91     
       
    92     iHasNewTrace=EFalse;
       
    93     iSubmitted = ETrue;
       
    94     
       
    95     if(AbleToDraw())
       
    96         {
       
    97         RootControl()->DrawRect(iRect);
       
    98         UpdateArea(iRect, EFalse);
       
    99         }
       
   100 
       
   101     iDirtyRect.SetRect(0,0,0,0);        
       
   102     }
       
   103 
       
   104 // ---------------------------------------------------------------------------
       
   105 // CHwrWndBase::AddGuidingLine
       
   106 // Add a guilding line.
       
   107 // (other items were commented in a header).
       
   108 // ---------------------------------------------------------------------------
       
   109 // 
       
   110 EXPORT_C void CHwrWndBase::AddGuidingLine(const TPoint& /*aStart*/, const TPoint& /*aEnd*/)
       
   111     {
       
   112     //not implemented
       
   113     }
       
   114 
       
   115 // ---------------------------------------------------------------------------
       
   116 // CHwrWndBase::EndStrokeL
       
   117 // Do recognition after a stroke is ended.
       
   118 // (other items were commented in a header).
       
   119 // ---------------------------------------------------------------------------
       
   120 //   
       
   121 void CHwrWndBase::EndStrokeL(TBool aCharacterTimerFlag)
       
   122     {
       
   123     if(iHasNewTrace)    //only do this when we have new trace
       
   124         {               
       
   125         if(aCharacterTimerFlag)
       
   126             {
       
   127             iCharacterTimer->SetTimer(iCharDelay);  //set character timer            
       
   128             //only send finish event when character timer starter, 
       
   129             //otherwise, send charater timer out event.
       
   130             ReportEvent(EEventHwrStrokeFinished); 
       
   131             iSubmitted = EFalse;
       
   132             }            
       
   133         else
       
   134             {
       
   135             ReportEvent(EEventHwrCharacterTimerOut);
       
   136             iSubmitted = ETrue;
       
   137             }
       
   138         
       
   139         iHasNewTrace=EFalse; //Current stroke is ended,reset the flag.
       
   140         
       
   141         }
       
   142     else
       
   143         {
       
   144         //no new trace, no need to update the candidate content, just show it.
       
   145         if(!aCharacterTimerFlag)
       
   146             {
       
   147             ReportEvent(EEventHwrCharacterTimerOut);
       
   148             iSubmitted = ETrue;
       
   149             }
       
   150         }
       
   151     }
       
   152 
       
   153 // ---------------------------------------------------------------------------
       
   154 // CHwrWndBase::CancelCharWriting
       
   155 // Cancel current drawing. Clears the stroke and stops the timer
       
   156 // (other items were commented in a header).
       
   157 // ---------------------------------------------------------------------------
       
   158 //
       
   159 EXPORT_C void CHwrWndBase::CancelCharWriting()
       
   160     {
       
   161     SetPointerDown(EFalse);
       
   162     
       
   163     //cancel timer
       
   164     iCharacterTimer->Cancel();
       
   165     iStrokeTimer->Cancel();            
       
   166     
       
   167     //reset the stroke
       
   168     ClearStroke();
       
   169     ReportEvent(EEventHwrStrokeCanceled);
       
   170     }
       
   171 // ---------------------------------------------------------------------------
       
   172 // CHwrWndBase::Draw
       
   173 // Draw the window and stroke
       
   174 // (other items were commented in a header).
       
   175 // ---------------------------------------------------------------------------
       
   176 //
       
   177 EXPORT_C void CHwrWndBase::Draw()
       
   178     {
       
   179 	if(!AbleToDraw())
       
   180         return;
       
   181     
       
   182     //draw back ground
       
   183     DrawBackground();
       
   184     DrawStroke(ETrue);
       
   185     }
       
   186 
       
   187 // ---------------------------------------------------------------------------
       
   188 // CHwrWndBase::DrawLine
       
   189 // Draw a line
       
   190 // (other items were commented in a header).
       
   191 // ---------------------------------------------------------------------------
       
   192 //   
       
   193 TRect CHwrWndBase::DrawLine(const TPoint& aPt1,const TPoint& aPt2,TBool /*aDrawFlag*/)
       
   194     {
       
   195     //do nothing
       
   196     return TRect(aPt1,aPt2);
       
   197     }
       
   198     
       
   199 // ---------------------------------------------------------------------------
       
   200 // CHwrWndBase::HandlePointerDownEventL
       
   201 // handle pointer down event
       
   202 // (other items were commented in a header).
       
   203 // ---------------------------------------------------------------------------
       
   204 //    
       
   205 EXPORT_C CFepUiBaseCtrl* CHwrWndBase::HandlePointerDownEventL( const TPoint& aPt)
       
   206     {
       
   207     CFepUiBaseCtrl::HandlePointerDownEventL(aPt);
       
   208         
       
   209     iPtPrev = aPt;
       
   210 
       
   211     iListOfPoints.AppendL(aPt- Rect().iTl);
       
   212     iStrokeTimer->Cancel();
       
   213     iCharacterTimer->Cancel();
       
   214 
       
   215     iHasNewTrace=ETrue;
       
   216     iSubmitted = EFalse;
       
   217     
       
   218     TRect rect;    
       
   219     rect = DrawPoint(aPt,ETrue);
       
   220     if(iDirtyRect.IsEmpty())
       
   221         iDirtyRect = rect;
       
   222     else
       
   223         {
       
   224         iDirtyRect.BoundingRect(rect);
       
   225         }
       
   226 
       
   227     UpdateArea(rect,EFalse);         
       
   228    
       
   229     ReportEvent(EEventHwrStrokeStarted);
       
   230     return this; 
       
   231     }
       
   232 
       
   233 // ---------------------------------------------------------------------------
       
   234 // CHwrWndBase::HanldePointerUpEventL
       
   235 // handle pointer up event
       
   236 // (other items were commented in a header).
       
   237 // ---------------------------------------------------------------------------
       
   238 //    
       
   239 EXPORT_C CFepUiBaseCtrl* CHwrWndBase::HandlePointerUpEventL( const TPoint& aPoint)
       
   240     {
       
   241     iListOfPoints.AppendL(iStrokeEndMark);
       
   242     iStrokeTimer->SetTimer(iStrokeDelay);  
       
   243     CFepUiBaseCtrl::HandlePointerUpEventL(aPoint); 
       
   244     // For EKZG-7JCBGW
       
   245     // iCtrlWithPointerDown of its CControlGroup must be set to NULL
       
   246     // when its up event occurs.
       
   247     CFepUiBaseCtrl* parent = ParentCtrl();
       
   248     while ( parent )
       
   249         {
       
   250         parent->CancelPointerDownL();
       
   251         parent = parent->ParentCtrl();
       
   252         }    
       
   253     return this;  
       
   254     }
       
   255 
       
   256 // ---------------------------------------------------------------------------
       
   257 // CHwrWndBase::HandleButtonMoveEventL
       
   258 // Handle button move event
       
   259 // (other items were commented in a header).
       
   260 // ---------------------------------------------------------------------------
       
   261 //
       
   262 EXPORT_C CFepUiBaseCtrl* CHwrWndBase::HandlePointerMoveEventL(const TPoint& aPoint)
       
   263     {
       
   264     if(!PointerDown())
       
   265        return this;   
       
   266     
       
   267     iListOfPoints.AppendL(aPoint - Rect().iTl);     
       
   268     
       
   269     TRect rect=DrawLine(iPtPrev,aPoint,ETrue);
       
   270     
       
   271     /*if(!rect.IsEmpty())
       
   272         {
       
   273         TRect& drawrect = DirtyRect();
       
   274         drawrect.BoundingRect(rect); //find the bounding rect and set the rect
       
   275         }    */
       
   276     UpdateArea(rect,EFalse);         
       
   277     iPtPrev=aPoint;    
       
   278     return this;
       
   279     }
       
   280 
       
   281 
       
   282 // ---------------------------------------------------------------------------
       
   283 // CHwrWndBase::CancelPointerDownL
       
   284 // Cancel the pointer down event in HWR window
       
   285 // (other items were commented in a header).
       
   286 // ---------------------------------------------------------------------------
       
   287 //
       
   288 void CHwrWndBase::CancelPointerDownL()
       
   289     {
       
   290     if( !PointerDown() )
       
   291         {
       
   292         return;
       
   293         }
       
   294 	//allow pen up in other control. Do us normal pen up
       
   295 	if( iListOfPoints.Count() > 0 )
       
   296         {
       
   297         iListOfPoints.AppendL(iStrokeEndMark);
       
   298         iStrokeTimer->SetTimer(iStrokeDelay);   
       
   299         }
       
   300 
       
   301 	SetPointerDown(EFalse);
       
   302     CFepUiBaseCtrl::CancelPointerDownL();
       
   303     }
       
   304 
       
   305 // ---------------------------------------------------------------------------
       
   306 // CHwrWndBase::UpdateRegion
       
   307 // Updates the area where other control made dirty
       
   308 // (other items were commented in a header).
       
   309 // ---------------------------------------------------------------------------
       
   310 //     
       
   311 void CHwrWndBase::UpdateRegion(CFepUiBaseCtrl* aCtrl)
       
   312     {
       
   313     if(aCtrl)
       
   314         {
       
   315         TRect rect;
       
   316         if(iDirtyRect.Intersects(aCtrl->Rect()))
       
   317             {
       
   318             DrawStroke(ETrue);
       
   319             rect.Intersection(iDirtyRect);
       
   320             UpdateArea(rect,EFalse);
       
   321             } 
       
   322         }    
       
   323     }
       
   324 
       
   325 // ---------------------------------------------------------------------------
       
   326 // CHwrWndBase::HandleTimerOut
       
   327 // Handle timer out event.
       
   328 // (other items were commented in a header).
       
   329 // ---------------------------------------------------------------------------
       
   330 //
       
   331 EXPORT_C void CHwrWndBase::HandleTimerOut(TInt aTimeType)
       
   332     {
       
   333     switch(aTimeType)
       
   334         {
       
   335         case CLayoutTimer::ECharacterTimer:
       
   336             {
       
   337             TRAP_IGNORE(EndStrokeAndClearL());
       
   338             }
       
   339             break;
       
   340         case CLayoutTimer::EStrokeTimer:
       
   341             {
       
   342             TRAP_IGNORE(EndStrokeL(ETrue));
       
   343             }
       
   344             break;
       
   345         default:
       
   346             //Do nothing
       
   347             break;
       
   348         }
       
   349     }
       
   350 
       
   351 // ---------------------------------------------------------------------------
       
   352 // CHwrWndBase::ConstructL
       
   353 // Symbian second phrase constructor
       
   354 // (other items were commented in a header).
       
   355 // ---------------------------------------------------------------------------
       
   356 //
       
   357 EXPORT_C void CHwrWndBase::ConstructL()
       
   358     {    
       
   359     BaseConstructL();
       
   360     iCharacterTimer = CLayoutTimer::NewL(this,CLayoutTimer::ECharacterTimer);
       
   361     iStrokeTimer = CLayoutTimer::NewL(this);    
       
   362     }
       
   363 
       
   364 
       
   365 // ---------------------------------------------------------------------------
       
   366 // CHwrWndBase::DrawStroke
       
   367 // Draw stroke
       
   368 // (other items were commented in a header).
       
   369 // ---------------------------------------------------------------------------
       
   370 //
       
   371 EXPORT_C TRect CHwrWndBase::DrawStroke(TBool /*aDrawFlag*/)
       
   372     {
       
   373     //not implemented
       
   374     return TRect();
       
   375     }
       
   376 
       
   377 
       
   378 // ---------------------------------------------------------------------------
       
   379 // CHwrWndBase::EndStrokeAndClearL
       
   380 // Called when character timer out. Not implemented, it's for derivated class.
       
   381 // (other items were commented in a header).
       
   382 // ---------------------------------------------------------------------------
       
   383 //       
       
   384 void CHwrWndBase::EndStrokeAndClearL()
       
   385     {
       
   386     EndStrokeL(EFalse);
       
   387     ClearStroke();
       
   388     } 
       
   389 
       
   390 // ---------------------------------------------------------------------------
       
   391 // CHwrWndBase::OnDeActivate
       
   392 // Response to layout de activation event
       
   393 // (other items were commented in a header).
       
   394 // ---------------------------------------------------------------------------
       
   395 //     
       
   396 EXPORT_C void CHwrWndBase::OnDeActivate()
       
   397     {
       
   398     CFepUiBaseCtrl::OnDeActivate();
       
   399     iStrokeTimer->Cancel();
       
   400     iCharacterTimer->Cancel();
       
   401     }
       
   402    
       
   403 // ---------------------------------------------------------------------------
       
   404 // CHwrWndBase::OnLayoutDraggingStart
       
   405 // Response to layout dragging start event
       
   406 // (other items were commented in a header).
       
   407 // ---------------------------------------------------------------------------
       
   408 //     
       
   409 EXPORT_C void CHwrWndBase::OnLayoutDraggingStart()
       
   410     {
       
   411     if ( iHasNewTrace )
       
   412         {
       
   413         ReportEvent(EEventHwrStrokeFinished);
       
   414         iHasNewTrace=EFalse;
       
   415         }
       
   416     iStrokeTimer->Cancel();
       
   417     
       
   418     if ( !iSubmitted )
       
   419         {
       
   420         ReportEvent(EEventHwrCharacterTimerOut);
       
   421         iSubmitted = ETrue;
       
   422         }
       
   423     iCharacterTimer->Cancel();
       
   424     iListOfPoints.Reset();                
       
   425     }
       
   426     
       
   427 // ---------------------------------------------------------------------------
       
   428 // CHwrWndBase::OnLayoutDraggingEnd
       
   429 // Response to layout dragging end event
       
   430 // (other items were commented in a header).
       
   431 // ---------------------------------------------------------------------------
       
   432 //     
       
   433 EXPORT_C void CHwrWndBase::OnLayoutDraggingEnd()
       
   434     {
       
   435     }    
       
   436    
       
   437 /******************** end of CHwrWndBase **********************************/
       
   438 
       
   439 
       
   440 
       
   441 
       
   442 //class CTransparentHwrWnd
       
   443 // ---------------------------------------------------------------------------
       
   444 // CTransparentHwrWnd::CTransparentHwrWnd
       
   445 // C++ default constructor
       
   446 // (other items were commented in a header).
       
   447 // ---------------------------------------------------------------------------
       
   448 //
       
   449 EXPORT_C CTransparentHwrWnd::CTransparentHwrWnd(const TRect& aRect,
       
   450                              CFepUiLayout* aUiLayout,TInt aCtrlId,
       
   451                              TBool aFullScreenFlag)
       
   452                             :CHwrWndBase(aRect,aUiLayout,aCtrlId),
       
   453                              iIsFullScreen(aFullScreenFlag),
       
   454                              iTraceOutsideWindowFlag(EFalse),
       
   455                              iTransparencyFactor(KDefaultTransparency)
       
   456     {
       
   457     SetControlType(ECtrlTransparentHwrWnd);
       
   458 
       
   459     const TRgb KDefaultMaskCol(200,200,200);
       
   460 
       
   461     if(iIsFullScreen)
       
   462         {
       
   463         SetMaskBkCol( TRgb(KTransparentColor)); //full transparent
       
   464         }
       
   465     else
       
   466         SetMaskBkCol(KDefaultMaskCol);
       
   467     
       
   468     SetBorderColor(TRgb(KOpaqueColor));
       
   469     //transparent window allow dragging on top of it
       
   470     SetAllowOverlap(ETrue);
       
   471     }
       
   472 
       
   473 // ---------------------------------------------------------------------------
       
   474 // CTransparentHwrWnd::~CTransparentHwrWnd
       
   475 // Destructor
       
   476 // (other items were commented in a header).
       
   477 // ---------------------------------------------------------------------------
       
   478 //
       
   479 EXPORT_C CTransparentHwrWnd::~CTransparentHwrWnd()
       
   480     {
       
   481     if(iTraceOutsideWindowFlag)
       
   482         {
       
   483         TRAP_IGNORE(RequireRegionUpdateL(EFalse));
       
   484         }
       
   485 
       
   486     if ( iPenTraceDecorator )
       
   487         {
       
   488         delete iPenTraceDecorator;
       
   489         iPenTraceDecorator = NULL;
       
   490         }
       
   491     }
       
   492 
       
   493 // ---------------------------------------------------------------------------
       
   494 // CTransparentHwrWnd::NewL
       
   495 // Factory function
       
   496 // (other items were commented in a header).
       
   497 // ---------------------------------------------------------------------------
       
   498 //
       
   499 EXPORT_C CTransparentHwrWnd* CTransparentHwrWnd::NewL(const TRect& aRect,
       
   500                                     CFepUiLayout* aUiLayout,TInt aCtrlId,
       
   501                                     TBool aFullScreenFlag)
       
   502     {
       
   503     CTransparentHwrWnd* wnd=new(ELeave) CTransparentHwrWnd(aRect,aUiLayout,
       
   504                                                         aCtrlId,aFullScreenFlag);
       
   505     CleanupStack::PushL(wnd);
       
   506     wnd->ConstructL ();
       
   507     CleanupStack::Pop(wnd);
       
   508     return wnd;
       
   509     }
       
   510 
       
   511 // ---------------------------------------------------------------------------
       
   512 // CTransparentHwrWnd::SetWndTransparencyFactor
       
   513 // Set the transparency factor
       
   514 // (other items were commented in a header).
       
   515 // ---------------------------------------------------------------------------
       
   516 //
       
   517 void EXPORT_C CTransparentHwrWnd::SetWndTransparencyFactor(TUint8 aFactor)
       
   518     {
       
   519     if(iTransparencyFactor != aFactor)
       
   520         {
       
   521         //change mask col        
       
   522         TUint8 col = aFactor;
       
   523         
       
   524         SetMaskBkCol(TRgb( 255- col, 255 - col, 255 - col));     
       
   525         
       
   526         iTransparencyFactor = aFactor;
       
   527         Draw();
       
   528         UpdateArea(Rect(),ETrue);
       
   529         UiLayout()->LayoutOwner()->FlushUi();
       
   530         }
       
   531     }
       
   532 
       
   533 
       
   534 // -----------------------------------------------------------------------------
       
   535 // CTransparentHwrWnd::EnableTraceOutsideWindow
       
   536 // Enable/disable trace outside of hwr window.
       
   537 // (other items were commented in a header).
       
   538 // -----------------------------------------------------------------------------
       
   539 //     
       
   540 EXPORT_C void CTransparentHwrWnd::EnableTraceOutsideWindow(TBool aFlag)
       
   541     {
       
   542     iTraceOutsideWindowFlag = aFlag;
       
   543     TRAP_IGNORE(RequireRegionUpdateL(aFlag));
       
   544     }
       
   545 
       
   546 
       
   547 // ---------------------------------------------------------------------------
       
   548 // CTransparentHwrWnd::Draw
       
   549 // Draw hwr window
       
   550 // (other items were commented in a header).
       
   551 // ---------------------------------------------------------------------------
       
   552 //
       
   553 EXPORT_C void CTransparentHwrWnd::Draw()
       
   554     {
       
   555 	if(!AbleToDraw())
       
   556         return;
       
   557     
       
   558     if(iIsFullScreen)
       
   559         {
       
   560         DrawStroke(ETrue);
       
   561         return;
       
   562         }       
       
   563 
       
   564     CFbsBitGc* gc= static_cast<CFbsBitGc*> (BitGc());
       
   565     
       
   566     DrawMaskBackground();
       
   567     // ----- draw bitmaps -----
       
   568     DrawBackground();
       
   569     DrawFrame( Rect() );
       
   570     //draw stroke
       
   571     gc->SetPenSize( PenSize() ); 
       
   572     gc->SetPenColor( PenColor() );
       
   573     
       
   574     if ( PenTraceDecorationActivated() )
       
   575         {
       
   576         //clear decoration buffer
       
   577         if ( StrokeList().Count() > 0 )
       
   578             {
       
   579             iPenTraceDecorator->Clear();
       
   580             }
       
   581         }
       
   582 
       
   583     DrawStroke(ETrue);
       
   584     }
       
   585 
       
   586 // ---------------------------------------------------------------------------
       
   587 // CTransparentHwrWnd::DrawStroke
       
   588 // Draw stroke
       
   589 // (other items were commented in a header).
       
   590 // ---------------------------------------------------------------------------
       
   591 //
       
   592 EXPORT_C TRect CTransparentHwrWnd::DrawStroke(TBool aDrawFlag)
       
   593     {
       
   594     TRect DirtyRect;
       
   595     TRect rect;
       
   596     TPoint pt;
       
   597     TPoint prevPt;
       
   598     
       
   599     //rect = DrawPoint(pt,aDrawFlag);
       
   600     //DirtyRect = rect; 
       
   601     TBool bBeginStroke = ETrue;
       
   602     for(TInt i = 0; i < StrokeList().Count(); ++i)
       
   603         {
       
   604         pt = StrokeList()[i] ;
       
   605         //skip the stroke end mark, plot the start point for the stroke
       
   606         if(pt == StrokeEndMark())
       
   607             {
       
   608             bBeginStroke = ETrue;
       
   609             continue;            
       
   610             }
       
   611 
       
   612         pt += Rect().iTl;        
       
   613         if(bBeginStroke)    
       
   614             {
       
   615             //plot the start point for the new line
       
   616             rect = DrawPoint(pt,aDrawFlag);
       
   617             bBeginStroke = EFalse;            
       
   618             }
       
   619         else
       
   620             {
       
   621             rect = DrawLine(prevPt,pt,aDrawFlag);
       
   622             }
       
   623         DirtyRect.BoundingRect(rect); //find the bounding rect
       
   624         prevPt = pt;
       
   625         }
       
   626     
       
   627     return DirtyRect;
       
   628     }
       
   629 
       
   630 // ---------------------------------------------------------------------------
       
   631 // CTransparentHwrWnd::DrawPoint
       
   632 // Draw a point
       
   633 // (other items were commented in a header).
       
   634 // ---------------------------------------------------------------------------
       
   635 //   
       
   636 TRect CTransparentHwrWnd::DrawPoint(const TPoint& aPoint,TBool aDrawFlag)
       
   637     {
       
   638     TRect affectedRect(0,0,0,0);
       
   639 
       
   640     if ( PenTraceDecorationActivated( ) )
       
   641         {
       
   642         TRect wndRect = Rect();
       
   643         
       
   644         TPoint pt1 = aPoint - wndRect.iTl; //decorator's coordinate system
       
   645         TRect changedRect = iPenTraceDecorator->DrawPoint( pt1 ); //decorator's coordinate system
       
   646         TPoint drawpos = changedRect.iTl + wndRect.iTl;
       
   647 
       
   648         CFbsBitGc* gc = static_cast<CFbsBitGc*>( BitGc() );
       
   649 
       
   650         gc->Activate( BitmapDevice() );
       
   651         gc->SetBrushColor( BkColor() );
       
   652         gc->SetBrushStyle( CGraphicsContext::ESolidBrush );
       
   653         
       
   654         gc->BitBltMasked( drawpos, iPenTraceDecorator->BitsBitmap(), 
       
   655                 changedRect, iPenTraceDecorator->MaskBitmap(), EFalse );
       
   656         
       
   657         gc->RectDrawnTo( affectedRect ); //get the affected rect since last draw
       
   658 
       
   659         //gc->Activate( MaskBitmapDevice() );
       
   660         //gc->BitBlt( drawpos, iPenTraceDecorator->MaskBitmap(), changedRect );
       
   661         }
       
   662     else
       
   663         {
       
   664         CFbsBitGc* gc= static_cast<CFbsBitGc*> (BitGc());
       
   665     
       
   666         gc->Activate( BitmapDevice() );
       
   667         gc->SetPenSize( PenSize());
       
   668         if(aDrawFlag)
       
   669             gc->SetPenColor( PenColor() );
       
   670         else    //erase the point            
       
   671             gc->SetPenColor( BkColor());
       
   672         gc->Plot( aPoint );
       
   673         gc->RectDrawnTo(affectedRect); //get the affected rect since last draw
       
   674 
       
   675         TRect maskRect;
       
   676 
       
   677         gc->Activate( MaskBitmapDevice());
       
   678         gc->SetPenColor( KOpaqueColor );
       
   679         //use same color to get opague point
       
   680         gc->Plot( aPoint );
       
   681         gc->RectDrawnTo(maskRect);
       
   682 
       
   683         affectedRect.BoundingRect(maskRect); //find the bounding rect
       
   684         if(!iTraceOutsideWindowFlag)
       
   685             affectedRect.Intersection(iRect); //drawing not allowed outside of 
       
   686         
       
   687         }
       
   688     return affectedRect;
       
   689     }
       
   690 
       
   691 // ---------------------------------------------------------------------------
       
   692 // CTransparentHwrWnd::DrawLine
       
   693 // Draw a line
       
   694 // (other items were commented in a header).
       
   695 // ---------------------------------------------------------------------------
       
   696 //   
       
   697 TRect CTransparentHwrWnd::DrawLine(const TPoint& aPt1,const TPoint& aPt2,TBool aDrawFlag)
       
   698     {
       
   699     TRect affectedRect(0,0,0,0);
       
   700 
       
   701     if ( PenTraceDecorationActivated() )
       
   702         {
       
   703         TRect wndRect = Rect();
       
   704         
       
   705         TPoint pt1 = aPt1 - wndRect.iTl; //decorator's coordinate system
       
   706         TPoint pt2 = aPt2 - wndRect.iTl; //decorator's coordinate system
       
   707         
       
   708         TRect changedRect = iPenTraceDecorator->DrawNextLine( pt1, pt2 ); //decorator's coordinate system
       
   709         
       
   710         TPoint drawpos = changedRect.iTl + wndRect.iTl;
       
   711 
       
   712         CFbsBitGc* gc= static_cast<CFbsBitGc*>( BitGc() );
       
   713 
       
   714         gc->Activate( BitmapDevice() );
       
   715         gc->SetBrushColor( BkColor() );
       
   716         gc->SetBrushStyle( CGraphicsContext::ESolidBrush );
       
   717         
       
   718         gc->BitBltMasked( drawpos, iPenTraceDecorator->BitsBitmap(), 
       
   719                 changedRect, iPenTraceDecorator->MaskBitmap(), EFalse );
       
   720         
       
   721         gc->RectDrawnTo( affectedRect ); //get the affected rect since last draw
       
   722 
       
   723         //gc->Activate( MaskBitmapDevice() );
       
   724         //gc->BitBlt( drawpos, iPenTraceDecorator->MaskBitmap(), changedRect );        
       
   725         }
       
   726     
       
   727     else
       
   728         {
       
   729         CFbsBitGc* gc= static_cast<CFbsBitGc*> (BitGc());
       
   730     
       
   731         gc->Activate( BitmapDevice() );
       
   732         SetClipRegion(); 
       
   733         gc->SetPenSize( PenSize());
       
   734         if(aDrawFlag)
       
   735             gc->SetPenColor( PenColor() );
       
   736         else            
       
   737             gc->SetPenColor( BkColor());
       
   738         gc->SetPenStyle(CGraphicsContext::ESolidPen);       
       
   739         gc->DrawLine( aPt1,aPt2 );
       
   740 
       
   741         gc->RectDrawnTo(affectedRect); //get the affected rect since last draw
       
   742         CancelClipRegion();
       
   743          
       
   744         TRect maskRect;
       
   745 
       
   746         gc->Activate( MaskBitmapDevice() );
       
   747         SetClipRegion();        
       
   748         gc->SetPenColor( KOpaqueColor );
       
   749        
       
   750         //use same color as in bitmap to get opague line
       
   751         //gc->SetPenStyle(CGraphicsContext::ESolidPen);        
       
   752         gc->DrawLine( aPt1,aPt2 );
       
   753         gc->RectDrawnTo(maskRect);
       
   754 
       
   755         //affectedRect.BoundingRect(maskRect); //find the bounding rect
       
   756 /*        if(!iTraceOutsideWindowFlag)
       
   757             {
       
   758             TRect r = affectedRect;
       
   759             affectedRect.Intersection(iRect); //drawing not allowed outside of 
       
   760             
       
   761             }*/
       
   762         CancelClipRegion();                
       
   763         }
       
   764     return affectedRect;
       
   765     } 
       
   766 
       
   767 void CTransparentHwrWnd::DrawFrame( const TRect& aFrameRect )
       
   768 	{
       
   769     CFbsBitGc* gc= static_cast<CFbsBitGc*> ( BitGc() );        
       
   770 	
       
   771     gc->Activate( MaskBitmapDevice() );    
       
   772     gc->SetPenColor( KOpaqueColor );
       
   773     gc->SetPenSize( BorderSize() );
       
   774     gc->SetPenStyle( CGraphicsContext::ESolidPen ); 
       
   775     gc->SetBrushStyle( CGraphicsContext::ENullBrush );
       
   776     gc->DrawRect( aFrameRect );
       
   777 	
       
   778     gc->Activate( BitmapDevice() );
       
   779     gc->SetPenColor( BorderColor() );
       
   780     gc->SetPenSize( BorderSize() );
       
   781     gc->SetPenStyle(CGraphicsContext::ESolidPen); 
       
   782     gc->SetBrushStyle( CGraphicsContext::ENullBrush );
       
   783     gc->DrawRect( aFrameRect );	    		
       
   784 	}
       
   785 
       
   786 // ---------------------------------------------------------------------------
       
   787 // CTransparentHwrWnd::HandlePointerDownL
       
   788 // handle pointer down event
       
   789 // (other items were commented in a header).
       
   790 // ---------------------------------------------------------------------------
       
   791 //
       
   792 EXPORT_C CFepUiBaseCtrl* CTransparentHwrWnd::HandlePointerDownEventL(const TPoint& aPoint)
       
   793     {
       
   794     if ( PenTraceDecorationActivated() )
       
   795         {
       
   796         iPenTraceDecorator->SetPenTraceColor( PenColor() );
       
   797         iPenTraceDecorator->SetDisplayModeL( BitmapDevice()->DisplayMode(), EFalse );
       
   798         iPenTraceDecorator->ResizeL( Rect().Size() );
       
   799         }
       
   800     
       
   801     // handle drawing in first box
       
   802 	//capture pointer
       
   803     CHwrWndBase::HandlePointerDownEventL(aPoint);
       
   804     CapturePointer();    
       
   805     return this;
       
   806     }
       
   807 
       
   808 
       
   809 // ---------------------------------------------------------------------------
       
   810 // CTransparentHwrWnd::HandlePointerUpL
       
   811 // Handle point up event
       
   812 // (other items were commented in a header).
       
   813 // ---------------------------------------------------------------------------
       
   814 //
       
   815 EXPORT_C CFepUiBaseCtrl* CTransparentHwrWnd::HandlePointerUpEventL(
       
   816                                                         const TPoint& aPoint)
       
   817     {
       
   818 	//release capture
       
   819     CHwrWndBase::HandlePointerUpEventL(aPoint);
       
   820     CapturePointer(EFalse);    
       
   821     return this;
       
   822     }
       
   823 // ---------------------------------------------------------------------------
       
   824 // CTransparentHwrWnd::HandlePointerMoveEventL
       
   825 // Handle point move event
       
   826 // (other items were commented in a header).
       
   827 // ---------------------------------------------------------------------------
       
   828 //
       
   829 EXPORT_C CFepUiBaseCtrl* CTransparentHwrWnd::HandlePointerMoveEventL(
       
   830                                                          const TPoint& aPoint)
       
   831     {   
       
   832     if(!PointerDown())
       
   833        return this;
       
   834     
       
   835 	//ignore events outside of window if it's TraceOutSideWindow flag is not set
       
   836 	TRect r;
       
   837 	TSize s(PenSize());
       
   838 	TSize s2(3*s.iWidth/2,3*s.iHeight/2);
       
   839 	
       
   840 	r.SetRect(TPoint(aPoint-TSize(s.iWidth/2,s.iHeight/2)),s2);
       
   841 	TRect r1 = r;
       
   842 	r.Intersection(Rect());
       
   843 	TBool inside = (r == r1);
       
   844 
       
   845     //if(iTraceOutsideWindowFlag || inside)//Rect().Contains(aPoint))
       
   846     if(iTraceOutsideWindowFlag || Rect().Contains(aPoint))
       
   847         {
       
   848         return CHwrWndBase::HandlePointerMoveEventL(aPoint);
       
   849         }
       
   850             
       
   851     return this;
       
   852     }
       
   853 
       
   854 // ---------------------------------------------------------------------------
       
   855 // CTransparentHwrWnd::UpdateValidRegion
       
   856 // Update the valid region when one control hiden or shown
       
   857 // ---------------------------------------------------------------------------
       
   858 //
       
   859 EXPORT_C void CTransparentHwrWnd::UpdateValidRegion(CFepUiBaseCtrl* aCtrl,
       
   860                                                     TBool aRemovedFlag)
       
   861     {
       
   862     RRegion region(8);
       
   863     region.Copy(Region());   
       
   864     if(iTraceOutsideWindowFlag) //Ignore if trace can not be outside of hwr window
       
   865         {
       
   866         if(aCtrl)
       
   867             {                        
       
   868             if(aCtrl->Hiden() || aRemovedFlag)
       
   869                 {
       
   870                 region.Union(aCtrl->Region());
       
   871                 }
       
   872             else
       
   873                 region.SubRegion(aCtrl->Region());
       
   874             
       
   875             }
       
   876         else // recalculate the region
       
   877             {
       
   878 
       
   879             region.Clear();
       
   880             region.AddRect(UiLayout()->Rect());
       
   881             CFepUiBaseCtrl* ctrl;
       
   882             for(TInt i = 0; i < RootControl()->ControlList().Count(); i++)
       
   883                 {
       
   884                 ctrl = RootControl()->ControlList()[i];
       
   885                 if(ctrl->Ready() && !ctrl->Hiden() && 
       
   886                             !ctrl->IsKindOfControl(ECtrlTransparentHwrWnd))
       
   887                     {                    
       
   888                     region.SubRect(ctrl->Rect());
       
   889                     }
       
   890                 }
       
   891             }
       
   892         }
       
   893     else
       
   894         {
       
   895         region.Clear();
       
   896         region.AddRect(Rect());    
       
   897         }
       
   898         
       
   899     SetRegion(region);        
       
   900     }   
       
   901 
       
   902 // ---------------------------------------------------------------------------
       
   903 // CTransparentHwrWnd::ClearStroke
       
   904 // Clear all strokes.
       
   905 // ---------------------------------------------------------------------------
       
   906 //
       
   907 EXPORT_C void CTransparentHwrWnd::ClearStroke()
       
   908     {
       
   909     if ( PenTraceDecorationActivated() )
       
   910         {
       
   911         iPenTraceDecorator->Clear();
       
   912         }
       
   913     
       
   914     CHwrWndBase::ClearStroke();
       
   915     }
       
   916 
       
   917 // ---------------------------------------------------------------------------
       
   918 // CTransparentHwrWnd::InstallPenTraceDecoratorL
       
   919 // Install a new pen trace decorator.
       
   920 // ---------------------------------------------------------------------------
       
   921 //
       
   922 EXPORT_C TBool CTransparentHwrWnd::InstallPenTraceDecoratorL(const TDesC& /*aDecoratorName*/, TBool aEnable )
       
   923     {
       
   924     if ( iPenTraceDecorator )
       
   925         {
       
   926         delete iPenTraceDecorator;
       
   927         iPenTraceDecorator = NULL;
       
   928         }
       
   929     
       
   930     iPenTraceDecorator = CPeninputPenTraceDecorator::NewL();
       
   931     if ( aEnable )
       
   932         {
       
   933         iPenTraceDecorator->Enable();
       
   934         }
       
   935     return ETrue;
       
   936     }
       
   937 
       
   938 // ---------------------------------------------------------------------------
       
   939 // CTransparentHwrWnd::SupportPenTraceDecoration
       
   940 // Test whether this window support trace decoration.
       
   941 // ---------------------------------------------------------------------------
       
   942 //
       
   943 EXPORT_C TBool CTransparentHwrWnd::SupportPenTraceDecoration()
       
   944     {
       
   945     return iPenTraceDecorator ? ETrue : EFalse;
       
   946     }
       
   947 
       
   948 // ---------------------------------------------------------------------------
       
   949 // CTransparentHwrWnd::PenTraceDecorationActivated
       
   950 // Test whether pen trace decoration is activated.
       
   951 // ---------------------------------------------------------------------------
       
   952 //
       
   953 EXPORT_C TBool CTransparentHwrWnd::PenTraceDecorationActivated()
       
   954     {
       
   955     if ( iPenTraceDecorator )
       
   956         {
       
   957         return iPenTraceDecorator->Enabled();
       
   958         }
       
   959     return EFalse;
       
   960     }
       
   961 
       
   962 // ---------------------------------------------------------------------------
       
   963 // CTransparentHwrWnd::ActivatePenTraceDecoration
       
   964 // Activate/deactivate pen trace decoration.
       
   965 // ---------------------------------------------------------------------------
       
   966 //
       
   967 EXPORT_C void CTransparentHwrWnd::ActivatePenTraceDecoration(TBool aActive, TBool aReleaseBuffer )
       
   968     {
       
   969     if ( iPenTraceDecorator )
       
   970         {
       
   971         if ( aActive )
       
   972             {
       
   973             iPenTraceDecorator->Enable();
       
   974             }
       
   975         else
       
   976             {
       
   977             iPenTraceDecorator->Disable( aReleaseBuffer );
       
   978             }
       
   979         }
       
   980     }
       
   981 // ---------------------------------------------------------------------------
       
   982 // CTransparentHwrWndExt::CTransparentHwrWndExt
       
   983 // (other items were commented in a header).
       
   984 // ---------------------------------------------------------------------------
       
   985 //
       
   986 EXPORT_C CTransparentHwrWndExt::CTransparentHwrWndExt( const TRect& aRect,
       
   987                                                        CFepUiLayout* aUiLayout,
       
   988                                                        TInt aControlId,
       
   989                                                        TBool aFullScreenFlag, 
       
   990                                                        TBool aShowGuideLine )
       
   991     :CTransparentHwrWnd( aRect, aUiLayout, aControlId, aFullScreenFlag ),
       
   992      iShowGuideLine( aShowGuideLine ), iGuideLineStyle( EGuideLineNone ),
       
   993      iGuideLineColor( TRgb(0) ), iGuideLineWidth( 1 ), iEnableFade( EFalse )
       
   994     {
       
   995         
       
   996     }
       
   997 
       
   998 // ---------------------------------------------------------------------------
       
   999 // CTransparentHwrWndExt::~CTransparentHwrWndExt
       
  1000 // (other items were commented in a header).
       
  1001 // ---------------------------------------------------------------------------
       
  1002 //             
       
  1003 EXPORT_C CTransparentHwrWndExt* CTransparentHwrWndExt::NewL( const TRect& aRect,
       
  1004                                                              CFepUiLayout* aUiLayout,
       
  1005                                                              TInt aControlId,
       
  1006                                                              TBool aFullScreenFlag, 
       
  1007                                                              TBool aShowGuideLine )
       
  1008     {
       
  1009     CTransparentHwrWndExt* wnd=new (ELeave) CTransparentHwrWndExt( aRect,
       
  1010                                                                    aUiLayout,
       
  1011                                                                    aControlId,
       
  1012                                                                    aFullScreenFlag,
       
  1013                                                                    aShowGuideLine );
       
  1014     CleanupStack::PushL(wnd);
       
  1015     wnd->ConstructL ();
       
  1016     CleanupStack::Pop(wnd);
       
  1017     return wnd;
       
  1018     }
       
  1019 
       
  1020 // ---------------------------------------------------------------------------
       
  1021 // CTransparentHwrWndExt::ConstructL
       
  1022 // (other items were commented in a header).
       
  1023 // ---------------------------------------------------------------------------
       
  1024 // 
       
  1025 EXPORT_C void CTransparentHwrWndExt::ConstructL()
       
  1026     {
       
  1027     iStrokeEndMark=TPoint(0xffff,0);
       
  1028     iFadeTimer = CPeriodic::NewL( CActive::EPriorityStandard );
       
  1029     // Construct GS CenRep
       
  1030     if(iGSRepository == NULL)
       
  1031         {
       
  1032         TRAP_IGNORE(iGSRepository
       
  1033                 = CRepository::NewL(KCRUidPersonalizationSettings) );
       
  1034         }
       
  1035     TInt newValue = 3;
       
  1036     if ( iGSRepository )
       
  1037         {
       
  1038         iGSRepository->Get( KSettingsWritingSpeed, newValue );  
       
  1039         }    
       
  1040     SetFadingSpeed(newValue);
       
  1041     iFadeBeginPos = Rect().iTl.iX;
       
  1042     iFadeEndPos = Rect().iTl.iX;
       
  1043     CHwrWndBase::ConstructL();
       
  1044     }
       
  1045 // ---------------------------------------------------------------------------
       
  1046 // CTransparentHwrWndExt::~CTransparentHwrWndExt
       
  1047 // (other items were commented in a header).
       
  1048 // ---------------------------------------------------------------------------
       
  1049 //  
       
  1050 EXPORT_C CTransparentHwrWndExt::~CTransparentHwrWndExt()
       
  1051     {
       
  1052     iListOfShownPoints.Close();
       
  1053     delete iFadeTimer;
       
  1054     delete iGSRepository;
       
  1055     }
       
  1056 
       
  1057 // ---------------------------------------------------------------------------
       
  1058 // CTransparentHwrWndExt::HideGuideLine
       
  1059 // (other items were commented in a header).
       
  1060 // ---------------------------------------------------------------------------
       
  1061 //    
       
  1062 EXPORT_C void CTransparentHwrWndExt::HideGuideLine( TBool aHideFlag )
       
  1063     {
       
  1064     iShowGuideLine = aHideFlag;
       
  1065     }
       
  1066 
       
  1067 // ---------------------------------------------------------------------------
       
  1068 // CTransparentHwrWndExt::SetTopGuideLinePosition
       
  1069 // (other items were commented in a header).
       
  1070 // ---------------------------------------------------------------------------
       
  1071 //    
       
  1072 EXPORT_C void CTransparentHwrWndExt::SetTopGuideLinePosition( const TPoint& aLeftTop, 
       
  1073                                                               const TPoint& aRightBottom )
       
  1074     {
       
  1075     iTlOfTopGuideLine = aLeftTop;
       
  1076     iBrOfTopGuideLine = aRightBottom;        
       
  1077     }
       
  1078 
       
  1079 // ---------------------------------------------------------------------------
       
  1080 // CTransparentHwrWndExt::SetBottomGuideLinePosition
       
  1081 // (other items were commented in a header).
       
  1082 // ---------------------------------------------------------------------------
       
  1083 //    
       
  1084 EXPORT_C void CTransparentHwrWndExt::SetBottomGuideLinePosition( const TPoint& aLeftTop, 
       
  1085                                                                  const TPoint& aRightBottom )
       
  1086     {
       
  1087     iTlOfBottomGuideLine = aLeftTop;
       
  1088     iBrOfBottomGuideLine = aRightBottom;        
       
  1089     }
       
  1090     
       
  1091 // ---------------------------------------------------------------------------
       
  1092 // CTransparentHwrWndExt::SetGuideLineStyle
       
  1093 // (other items were commented in a header).
       
  1094 // ---------------------------------------------------------------------------
       
  1095 //
       
  1096 EXPORT_C void CTransparentHwrWndExt::SetGuideLineStyle( TInt aGuideLineStyle )
       
  1097     {
       
  1098     iGuideLineStyle = aGuideLineStyle;
       
  1099     }    
       
  1100 
       
  1101 // ---------------------------------------------------------------------------
       
  1102 // CTransparentHwrWndExt::RefreshUI
       
  1103 // (other items were commented in a header).
       
  1104 // ---------------------------------------------------------------------------
       
  1105 //    
       
  1106 EXPORT_C void CTransparentHwrWndExt::RefreshUI()
       
  1107     {
       
  1108     if( !Hiden() )
       
  1109         {
       
  1110         Draw();
       
  1111         UpdateArea(Rect(), ETrue);        
       
  1112         }    
       
  1113     }    
       
  1114 
       
  1115 // ---------------------------------------------------------------------------
       
  1116 // CTransparentHwrWndExt::SetGuideLineColor
       
  1117 // (other items were commented in a header).
       
  1118 // ---------------------------------------------------------------------------
       
  1119 //
       
  1120 EXPORT_C void CTransparentHwrWndExt::SetGuideLineColor( const TRgb& aColor )
       
  1121     {
       
  1122     iGuideLineColor = aColor;
       
  1123     }
       
  1124 
       
  1125 // ---------------------------------------------------------------------------
       
  1126 // CTransparentHwrWndExt::SetGuideLineWidth
       
  1127 // (other items were commented in a header).
       
  1128 // ---------------------------------------------------------------------------
       
  1129 //    
       
  1130 EXPORT_C void CTransparentHwrWndExt::SetGuideLineWidth( TInt aWidth )
       
  1131     {
       
  1132     iGuideLineWidth = aWidth;
       
  1133     }		
       
  1134   
       
  1135 // ---------------------------------------------------------------------------
       
  1136 // CTransparentHwrWndExt::Draw
       
  1137 // (other items were commented in a header).
       
  1138 // ---------------------------------------------------------------------------
       
  1139 //            
       
  1140 EXPORT_C void CTransparentHwrWndExt::Draw()
       
  1141     {
       
  1142     //if(Hiden() || !Ready() || !UiLayout()->LayoutReady())
       
  1143       //  return;
       
  1144     if(!AbleToDraw())
       
  1145         return;
       
  1146     CTransparentHwrWnd::Draw();
       
  1147     
       
  1148     if ( iShowGuideLine && iShowGuideLine != EGuideLineNone )
       
  1149         {
       
  1150         DrawGuidingLine();
       
  1151         }
       
  1152     }   
       
  1153 
       
  1154 // ---------------------------------------------------------------------------
       
  1155 // CTransparentHwrWndExt::DrawStroke
       
  1156 // (other items were commented in a header).
       
  1157 // ---------------------------------------------------------------------------
       
  1158 //           
       
  1159 EXPORT_C TRect CTransparentHwrWndExt::DrawStroke(TBool aDrawFlag)
       
  1160     {
       
  1161     TRect DirtyRect;
       
  1162     if(iListOfShownPoints.Count())
       
  1163         {
       
  1164         TRect rect;
       
  1165         TPoint pt;
       
  1166         TPoint prevPt;
       
  1167 
       
  1168         TBool beginStroke = ETrue;
       
  1169         for(TInt i=0;i<iListOfShownPoints.Count();i++)
       
  1170             { 
       
  1171             pt=iListOfShownPoints[i] ;
       
  1172             
       
  1173             if(pt == StrokeEndMark() )
       
  1174                 {
       
  1175                 beginStroke = ETrue;
       
  1176                 continue;
       
  1177                 }
       
  1178             else
       
  1179                 {
       
  1180                 if ( beginStroke )
       
  1181                     {
       
  1182                     rect = DrawPoint(pt,aDrawFlag);
       
  1183                     beginStroke = EFalse;
       
  1184                     }
       
  1185                 else
       
  1186                     {
       
  1187                     rect = DrawLine(prevPt,pt,aDrawFlag);
       
  1188                     }
       
  1189                 
       
  1190                 DirtyRect.BoundingRect(rect);
       
  1191                 prevPt=pt;
       
  1192                 }
       
  1193             }
       
  1194         }
       
  1195     return DirtyRect;
       
  1196     }
       
  1197     
       
  1198 // ---------------------------------------------------------------------------
       
  1199 // CTransparentHwrWndExt::DrawPoint
       
  1200 // (other items were commented in a header).
       
  1201 // ---------------------------------------------------------------------------
       
  1202 //       
       
  1203 TRect CTransparentHwrWndExt::DrawPoint(const TPoint& aPoint,TBool aDrawFlag)
       
  1204     {
       
  1205     TRect affectedRect(0,0,0,0);
       
  1206         {
       
  1207         CFbsBitGc* gc= static_cast<CFbsBitGc*> (BitGc());
       
  1208     
       
  1209         gc->Activate( BitmapDevice() );
       
  1210         gc->SetPenSize( PenSize());
       
  1211         if(aDrawFlag)
       
  1212             gc->SetPenColor( PenColor() );
       
  1213         else    //erase the point            
       
  1214             gc->SetPenColor( BkColor());
       
  1215         gc->Plot( aPoint );
       
  1216         gc->RectDrawnTo(affectedRect); //get the affected rect since last draw
       
  1217 
       
  1218         TRect maskRect;
       
  1219 
       
  1220         gc->Activate( MaskBitmapDevice());
       
  1221         if ( ( aPoint.iX > iFadeBeginPos ) && ( aPoint.iX <= iFadeEndPos ) )
       
  1222             {
       
  1223             
       
  1224             TRgb rgb( 128 - TransparencyFactor()/2,
       
  1225                       128 - TransparencyFactor()/2,
       
  1226                       128 - TransparencyFactor()/2 );
       
  1227             gc->SetPenColor( rgb );
       
  1228             }
       
  1229         else
       
  1230             {
       
  1231             gc->SetPenColor( KOpaqueColor );
       
  1232             }
       
  1233         //use same color to get opague point
       
  1234         gc->Plot( aPoint );
       
  1235         gc->RectDrawnTo(maskRect);
       
  1236 
       
  1237         affectedRect.BoundingRect(maskRect); //find the bounding rect
       
  1238         //if(!TraceOutsideWindowFlag())
       
  1239             affectedRect.Intersection(iRect); //drawing not allowed outside of 
       
  1240         
       
  1241         }
       
  1242     return affectedRect;
       
  1243     }
       
  1244 
       
  1245 // ---------------------------------------------------------------------------
       
  1246 // CTransparentHwrWndExt::DrawLine
       
  1247 // (other items were commented in a header).
       
  1248 // ---------------------------------------------------------------------------
       
  1249 //   
       
  1250 TRect CTransparentHwrWndExt::DrawLine(const TPoint& aPt1,const TPoint& aPt2,TBool aDrawFlag)
       
  1251     {
       
  1252     TRect affectedRect(0,0,0,0);
       
  1253         {
       
  1254         CFbsBitGc* gc= static_cast<CFbsBitGc*> (BitGc());
       
  1255     
       
  1256         gc->Activate( BitmapDevice() );
       
  1257         gc->SetClippingRect(Rect()); 
       
  1258         gc->SetPenSize( PenSize());
       
  1259         if(aDrawFlag)
       
  1260             gc->SetPenColor( PenColor() );
       
  1261         else            
       
  1262             gc->SetPenColor( BkColor());
       
  1263         gc->SetPenStyle(CGraphicsContext::ESolidPen);       
       
  1264         gc->DrawLine( aPt1,aPt2 );
       
  1265 
       
  1266         gc->RectDrawnTo(affectedRect); //get the affected rect since last draw
       
  1267         gc->CancelClippingRect();
       
  1268          
       
  1269         TRect maskRect;
       
  1270 
       
  1271         gc->Activate( MaskBitmapDevice() );
       
  1272         gc->SetClippingRect(Rect());   
       
  1273         if ( ( Min(aPt1.iX, aPt2.iX) > iFadeBeginPos ) && 
       
  1274             ( Max(aPt1.iX, aPt2.iX) <= iFadeEndPos ) )
       
  1275             {
       
  1276             TRgb rgb( 128 - TransparencyFactor()/2,
       
  1277                       128 - TransparencyFactor()/2,
       
  1278                       128 - TransparencyFactor()/2 )       ;
       
  1279             gc->SetPenColor( rgb );
       
  1280 //            gc->SetPenColor( KRgbRed );
       
  1281             }  
       
  1282         else
       
  1283             {
       
  1284             gc->SetPenColor( KOpaqueColor );
       
  1285             } 
       
  1286 
       
  1287         //use same color as in bitmap to get opague line
       
  1288         //gc->SetPenStyle(CGraphicsContext::ESolidPen);        
       
  1289         gc->DrawLine( aPt1,aPt2 );
       
  1290         gc->RectDrawnTo(maskRect);
       
  1291 
       
  1292         //affectedRect.BoundingRect(maskRect); //find the bounding rect
       
  1293 /*        if(!iTraceOutsideWindowFlag)
       
  1294             {
       
  1295             TRect r = affectedRect;
       
  1296             affectedRect.Intersection(iRect); //drawing not allowed outside of 
       
  1297             
       
  1298             }*/
       
  1299         gc->CancelClippingRect();             
       
  1300         }
       
  1301     return affectedRect;
       
  1302     } 
       
  1303 
       
  1304 // ---------------------------------------------------------------------------
       
  1305 // CTransparentHwrWndExt::OnDeActivate
       
  1306 // (other items were commented in a header).
       
  1307 // ---------------------------------------------------------------------------
       
  1308 //   
       
  1309 EXPORT_C void CTransparentHwrWndExt::OnDeActivate()
       
  1310     {
       
  1311     CHwrWndBase::OnDeActivate();
       
  1312     iFadeTimer->Cancel();
       
  1313     iListOfShownPoints.Reset();
       
  1314     }
       
  1315 
       
  1316 // ---------------------------------------------------------------------------
       
  1317 // CTransparentHwrWndExt::OnLayoutDraggingStart
       
  1318 // (other items were commented in a header).
       
  1319 // ---------------------------------------------------------------------------
       
  1320 //   
       
  1321 EXPORT_C void CTransparentHwrWndExt::OnLayoutDraggingStart()
       
  1322     {
       
  1323     iFadeTimer->Cancel();
       
  1324     iListOfShownPoints.Reset();                
       
  1325     CHwrWndBase::OnLayoutDraggingStart();
       
  1326     }
       
  1327 
       
  1328 // ---------------------------------------------------------------------------
       
  1329 // CTransparentHwrWndExt::EndStrokeAndClearL
       
  1330 // (other items were commented in a header).
       
  1331 // ---------------------------------------------------------------------------
       
  1332 //   
       
  1333 void CTransparentHwrWndExt::EndStrokeAndClearL()
       
  1334     {
       
  1335     iFadeTimer->Cancel();
       
  1336     iListOfShownPoints.Reset();
       
  1337     iFadeBeginPos = Rect().iTl.iX;
       
  1338     iFadeEndPos = Rect().iTl.iX;
       
  1339     CHwrWndBase::EndStrokeAndClearL();
       
  1340     } 
       
  1341 
       
  1342 // ---------------------------------------------------------------------------
       
  1343 // CTransparentHwrWndExt::CancelPointerDownL
       
  1344 // (other items were commented in a header).
       
  1345 // ---------------------------------------------------------------------------
       
  1346 //   
       
  1347 void CTransparentHwrWndExt::CancelPointerDownL()
       
  1348     {
       
  1349     if( !PointerDown() )
       
  1350         {
       
  1351         return;
       
  1352         }
       
  1353 	//allow pen up in other control. Do us normal pen up
       
  1354 	if( iListOfShownPoints.Count() > 0 )
       
  1355         {
       
  1356         iListOfShownPoints.AppendL(iStrokeEndMark);
       
  1357         iFadeTimer->Cancel();
       
  1358         }
       
  1359     
       
  1360     CHwrWndBase::CancelPointerDownL();
       
  1361     }
       
  1362 
       
  1363 // ---------------------------------------------------------------------------
       
  1364 // CTransparentHwrWndExt::HandlePointerDownEventL
       
  1365 // (other items were commented in a header).
       
  1366 // ---------------------------------------------------------------------------
       
  1367 //               
       
  1368 EXPORT_C CFepUiBaseCtrl* CTransparentHwrWndExt::HandlePointerDownEventL(const TPoint& aPoint)
       
  1369     {
       
  1370     iListOfShownPoints.AppendL(aPoint);
       
  1371     iFadeMaxPos = aPoint.iX;
       
  1372     
       
  1373     if ( aPoint.iX < iFadeEndPos )
       
  1374         {
       
  1375         iFadeTimer->Cancel();
       
  1376         EndStrokeAndClearL();
       
  1377         }
       
  1378     if( !iFadeTimer->IsActive() && iEnableFade)
       
  1379         {
       
  1380         iFadeTimer->Start( iFadeBeginTime, iFadeIntervalTime, TCallBack( UpdateShownArea, this ) );
       
  1381         }
       
  1382         
       
  1383     return CTransparentHwrWnd::HandlePointerDownEventL(aPoint);
       
  1384     }
       
  1385 
       
  1386 // ---------------------------------------------------------------------------
       
  1387 // CTransparentHwrWndExt::HandlePointerMoveEventL
       
  1388 // (other items were commented in a header).
       
  1389 // ---------------------------------------------------------------------------
       
  1390 //       
       
  1391 EXPORT_C CFepUiBaseCtrl* CTransparentHwrWndExt::HandlePointerMoveEventL(const TPoint& aPoint)
       
  1392     {
       
  1393     if(!PointerDown())
       
  1394        return this;
       
  1395     
       
  1396     iListOfShownPoints.AppendL(aPoint);
       
  1397     
       
  1398     if( aPoint.iX < iFadeMaxPos )
       
  1399         {
       
  1400         iFadeMaxPos = aPoint.iX;
       
  1401         }
       
  1402 
       
  1403     return CTransparentHwrWnd::HandlePointerMoveEventL(aPoint);
       
  1404     }
       
  1405 
       
  1406 // ---------------------------------------------------------------------------
       
  1407 // CTransparentHwrWndExt::HandlePointerUpEventL
       
  1408 // (other items were commented in a header).
       
  1409 // ---------------------------------------------------------------------------
       
  1410 //        
       
  1411 EXPORT_C CFepUiBaseCtrl* CTransparentHwrWndExt::HandlePointerUpEventL(const TPoint& aPoint)
       
  1412     {
       
  1413     iListOfShownPoints.AppendL(iStrokeEndMark);
       
  1414     iFadeMaxPos = Rect().iBr.iX;	
       
  1415     return CTransparentHwrWnd::HandlePointerUpEventL(aPoint);
       
  1416     }
       
  1417     
       
  1418 // ---------------------------------------------------------------------------
       
  1419 // CTransparentHwrWndExt::UpdateShownArea
       
  1420 // (other items were commented in a header).
       
  1421 // ---------------------------------------------------------------------------
       
  1422 // 
       
  1423 TInt CTransparentHwrWndExt::UpdateShownArea( TAny* aAny )
       
  1424     {
       
  1425     CTransparentHwrWndExt* self = static_cast<CTransparentHwrWndExt*>(aAny);
       
  1426     self->DoUpdateShownArea();
       
  1427     
       
  1428     return KErrNone;
       
  1429     }
       
  1430 
       
  1431 // ---------------------------------------------------------------------------
       
  1432 // CTransparentHwrWndExt::DoUpdateShownArea
       
  1433 // (other items were commented in a header).
       
  1434 // ---------------------------------------------------------------------------
       
  1435 //     
       
  1436 void CTransparentHwrWndExt::DoUpdateShownArea()
       
  1437     {
       
  1438     iFadeBeginPos = iFadeEndPos > iFadeMaxPos ? iFadeMaxPos : iFadeEndPos;
       
  1439     iFadeEndPos = iFadeBeginPos + Rect().Width()/KFadeAreaCount;
       
  1440     iFadeEndPos = iFadeEndPos > iFadeMaxPos ? iFadeMaxPos : iFadeEndPos;
       
  1441     
       
  1442     TRect eraseRect(Rect());
       
  1443     eraseRect.iTl.iX = eraseRect.iBr.iX = iFadeBeginPos;
       
  1444     
       
  1445     for( TInt i = iListOfShownPoints.Count()-1; i >= 0; i-- )
       
  1446         {
       
  1447         if ( iListOfShownPoints[i].iX <= iFadeBeginPos )
       
  1448             {
       
  1449             if( iListOfShownPoints[i].iX < eraseRect.iTl.iX )
       
  1450                 {
       
  1451                 eraseRect.iTl.iX = iListOfShownPoints[i].iX;
       
  1452                 }
       
  1453             iListOfShownPoints.Remove(i);
       
  1454             }
       
  1455         }
       
  1456     eraseRect.iTl.iX -= PenSize().iWidth;
       
  1457     eraseRect.iBr.iX += PenSize().iWidth;
       
  1458     Draw();
       
  1459     UpdateArea( eraseRect, EFalse );      
       
  1460     }
       
  1461     
       
  1462 EXPORT_C void CTransparentHwrWndExt::CancelCharWriting()
       
  1463     {
       
  1464     iFadeTimer->Cancel();
       
  1465     iListOfShownPoints.Reset();
       
  1466     iFadeBeginPos = Rect().iTl.iX;
       
  1467     iFadeEndPos = Rect().iTl.iX;
       
  1468     CHwrWndBase::CancelCharWriting();
       
  1469     }
       
  1470     
       
  1471 void CTransparentHwrWndExt::DrawGuidingLine()
       
  1472     {
       
  1473     CFbsBitGc* gc= static_cast<CFbsBitGc*> ( BitGc() );        
       
  1474 
       
  1475     gc->Activate( MaskBitmapDevice() );
       
  1476     gc->SetPenSize( TSize( iGuideLineWidth, iGuideLineWidth ) );
       
  1477     gc->SetPenColor( KOpaqueColor );
       
  1478     gc->SetPenStyle(CGraphicsContext::ESolidPen); 
       
  1479                                       
       
  1480     switch ( iGuideLineStyle )
       
  1481         {
       
  1482         case  EGuideLineTop:
       
  1483             {
       
  1484             gc->DrawLine( iTlOfTopGuideLine, iBrOfTopGuideLine );    
       
  1485             }                    
       
  1486             break;
       
  1487         case  EGuideLineBottom:
       
  1488             {
       
  1489             gc->DrawLine( iTlOfBottomGuideLine, iBrOfBottomGuideLine );                        
       
  1490             }
       
  1491             break;
       
  1492         case  EGuideLineBoth:
       
  1493             {
       
  1494             gc->DrawLine( iTlOfTopGuideLine, iBrOfTopGuideLine );
       
  1495             gc->DrawLine( iTlOfBottomGuideLine, iBrOfBottomGuideLine );
       
  1496             }
       
  1497             break;
       
  1498         default:
       
  1499             // Do nothing
       
  1500             break;
       
  1501         }                
       
  1502 
       
  1503     gc->Activate( BitmapDevice() );
       
  1504     gc->SetPenSize( TSize( iGuideLineWidth, iGuideLineWidth ) );
       
  1505     gc->SetPenColor( iGuideLineColor );
       
  1506     gc->SetPenStyle(CGraphicsContext::ESolidPen); 
       
  1507                                       
       
  1508     switch ( iGuideLineStyle )
       
  1509         {
       
  1510         case  EGuideLineTop:
       
  1511             {
       
  1512             gc->DrawLine( iTlOfTopGuideLine, iBrOfTopGuideLine );    
       
  1513             }                    
       
  1514             break;
       
  1515         case  EGuideLineBottom:
       
  1516             {
       
  1517             gc->DrawLine( iTlOfBottomGuideLine, iBrOfBottomGuideLine );                        
       
  1518             }
       
  1519             break;
       
  1520         case  EGuideLineBoth:
       
  1521             {
       
  1522             gc->DrawLine( iTlOfTopGuideLine, iBrOfTopGuideLine );
       
  1523             gc->DrawLine( iTlOfBottomGuideLine, iBrOfBottomGuideLine );
       
  1524             }
       
  1525             break;
       
  1526         default:
       
  1527             // Do nothing
       
  1528             break;
       
  1529         }                        
       
  1530     }
       
  1531 // end of file
       
  1532