textinput/peninputhwrfscn/src/peninputhwrfscnwritingbox.cpp
changeset 0 eb1f2e154e89
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 chinese peninput full screen hwr
       
    15 *
       
    16 */
       
    17 
       
    18 #include "peninputhwrfscnwritingbox.h"
       
    19 #include "peninputhwrfscnlayout.h"
       
    20 #include "peninputhwrfscndatastore.h"
       
    21 #include "peninputhwrfscnevent.h"
       
    22 
       
    23 // ============================ MEMBER FUNCTIONS ===============================
       
    24   
       
    25 // -----------------------------------------------------------------------------
       
    26 // CPeninputHwrfscnWritingBox::NewL()
       
    27 // .
       
    28 // -----------------------------------------------------------------------------
       
    29 //
       
    30 CPeninputHwrfscnWritingBox* CPeninputHwrfscnWritingBox::NewL( 
       
    31     CPeninputHwrfscnLayout* aLayout )
       
    32     {
       
    33     CPeninputHwrfscnWritingBox* self = new( ELeave ) 
       
    34         CPeninputHwrfscnWritingBox( aLayout );
       
    35     CleanupStack::PushL( self );
       
    36     self->ConstructL();
       
    37     CleanupStack::Pop();
       
    38     return self;
       
    39     }
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 // CPeninputHwrfscnWritingBox::~CPeninputHwrfscnWritingBox()
       
    43 // .
       
    44 // -----------------------------------------------------------------------------
       
    45 //
       
    46 CPeninputHwrfscnWritingBox::~CPeninputHwrfscnWritingBox()
       
    47     {
       
    48     iStrokeList.Reset();
       
    49     iStrokeList.Close();
       
    50     }
       
    51 
       
    52 // -----------------------------------------------------------------------------
       
    53 // CPeninputHwrfscnWritingBox::Show()
       
    54 // .
       
    55 // -----------------------------------------------------------------------------
       
    56 //       
       
    57 void CPeninputHwrfscnWritingBox::Show( TBool /*aVisible*/ )
       
    58     {    
       
    59     }
       
    60 
       
    61 // -----------------------------------------------------------------------------
       
    62 // CPeninputHwrfscnWritingBox::Draw()
       
    63 // .
       
    64 // -----------------------------------------------------------------------------
       
    65 // 
       
    66 void CPeninputHwrfscnWritingBox::Draw()
       
    67     {
       
    68     iHwrWnd->Draw();
       
    69     }
       
    70     
       
    71 // -----------------------------------------------------------------------------
       
    72 // CPeninputHwrfscnWritingBox::HandleControlEvent()
       
    73 // .
       
    74 // -----------------------------------------------------------------------------
       
    75 //
       
    76 void CPeninputHwrfscnWritingBox::HandleControlEvent( TInt aEventType, 
       
    77     CFepUiBaseCtrl* /*aCtrl*/, 
       
    78 	const TDesC& /*aEventData*/ )
       
    79     {
       
    80     switch( aEventType )
       
    81         {
       
    82         case EEventHwrCharacterTimerOut:
       
    83             {
       
    84             OnStrokeCharacterTimerOut();
       
    85             iLayout->EnableStrokeFilter( ETrue );
       
    86             }
       
    87             break;
       
    88             
       
    89         case EEventHwrStrokeStarted:
       
    90             {
       
    91             OnStrokeStarted();
       
    92             iLayout->EnableStrokeFilter( EFalse );
       
    93             }
       
    94             break;
       
    95             
       
    96         case EEventHwrStrokeFinished:
       
    97             {
       
    98             OnStrokeFinished();		
       
    99             }
       
   100             break;
       
   101             
       
   102         default: 
       
   103             break;       
       
   104         }
       
   105     }		                        
       
   106 
       
   107 // -----------------------------------------------------------------------------
       
   108 // CPeninputHwrfscnWritingBox::HandleCommand()
       
   109 // .
       
   110 // -----------------------------------------------------------------------------
       
   111 //
       
   112 void CPeninputHwrfscnWritingBox::HandleCommand( TInt /*aCommand*/, 
       
   113     TUint8* /*aData*/ )
       
   114     {
       
   115     
       
   116     }    
       
   117 
       
   118 // -----------------------------------------------------------------------------
       
   119 // CPeninputHwrfscnWritingBox::BeforePropertyChangedL()
       
   120 // .
       
   121 // -----------------------------------------------------------------------------
       
   122 //
       
   123 TBool CPeninputHwrfscnWritingBox::BeforePropertyChangedL(            
       
   124     MPeninputHwrfscnPropertySubscriber::TPeninputHwrfscnProperty /*aProptery*/ )
       
   125     {
       
   126     return EFalse;
       
   127     }
       
   128 
       
   129 // -----------------------------------------------------------------------------
       
   130 // CPeninputHwrfscnWritingBox::PropertyChangedL()
       
   131 // .
       
   132 // -----------------------------------------------------------------------------
       
   133 //    
       
   134 void CPeninputHwrfscnWritingBox::PropertyChangedL( 
       
   135 	    MPeninputHwrfscnPropertySubscriber::TPeninputHwrfscnProperty aProptery )
       
   136     {
       
   137       switch( aProptery )
       
   138         {
       
   139         case EPeninputHwrfscnPropertyWriteSpeed:
       
   140             {
       
   141             TTimeIntervalMicroSeconds32 speed = 
       
   142                 iLayout->DataStore().WritingSpeed();
       
   143             SetWritingSpeed( speed );
       
   144             }
       
   145             break;
       
   146             
       
   147         case EPeninputHwrfscnPropertyPenSize:
       
   148             {
       
   149             TSize penSize = iLayout->DataStore().PenSize();
       
   150             SetPenSize( penSize );
       
   151             }
       
   152             break;
       
   153             
       
   154         case EPeninputHwrfscnPropertyPenColor:
       
   155             {
       
   156             TRgb& color = iLayout->DataStore().PenColor();
       
   157             SetPenColor( color );
       
   158             }
       
   159             break;
       
   160             
       
   161         default:
       
   162             break;
       
   163         }
       
   164     }	    
       
   165 
       
   166 // -----------------------------------------------------------------------------
       
   167 // CPeninputHwrfscnWritingBox::CPeninputHwrfscnWritingBox()
       
   168 // .
       
   169 // -----------------------------------------------------------------------------
       
   170 //	
       
   171 CPeninputHwrfscnWritingBox::CPeninputHwrfscnWritingBox( 
       
   172     CPeninputHwrfscnLayout* aLayout )
       
   173     :CPeninputHwrfscnBasePanel( aLayout )
       
   174     {
       
   175     
       
   176     }
       
   177 
       
   178 // -----------------------------------------------------------------------------
       
   179 // CPeninputHwrfscnWritingBox::ConstructL()
       
   180 // .
       
   181 // -----------------------------------------------------------------------------
       
   182 //
       
   183 void CPeninputHwrfscnWritingBox::ConstructL()
       
   184     {
       
   185     TRect hwrRect( TPoint( 0, 0 ), iLayout->ScreenSize() );
       
   186     
       
   187     //create full screen hwr window
       
   188     iHwrWnd = CTransparentHwrWnd::NewL( hwrRect, iLayout, 
       
   189         ECtrlTransparentHwrWnd, ETrue );
       
   190     AddToRootControlL( iHwrWnd );
       
   191     
       
   192     //add this to datastore subscriber list
       
   193     iLayout->DataStore().AddSubscriber( this );
       
   194     
       
   195     //load the default hwr settings: pen size, speed, color
       
   196     iLayout->DataStore().LoadAndPublishDefaultL();
       
   197     
       
   198     //get stroke end mark
       
   199     TPoint strokeEndMark = iLayout->DataStore().StrokeEndMark();
       
   200 
       
   201     //set it to window
       
   202     iHwrWnd->SetStrokeEndMark( strokeEndMark );
       
   203     iHwrWnd->AddEventObserver( this );
       
   204     iHwrWnd->EnableTraceOutsideWindow( ETrue );
       
   205     
       
   206     Draw();
       
   207     }
       
   208 
       
   209 // -----------------------------------------------------------------------------
       
   210 // CPeninputHwrfscnWritingBox::SizeChanged()
       
   211 // .
       
   212 // -----------------------------------------------------------------------------
       
   213 //    	  
       
   214 void CPeninputHwrfscnWritingBox::SizeChanged()
       
   215     {
       
   216     TRect hwrRect( TPoint( 0, 0 ), iLayout->ScreenSize() );
       
   217     iHwrWnd->SetRect( hwrRect ); 
       
   218     }
       
   219 
       
   220 // -----------------------------------------------------------------------------
       
   221 // CPeninputHwrfscnWritingBox::LafChanged()
       
   222 // .
       
   223 // -----------------------------------------------------------------------------
       
   224 //	    
       
   225 void CPeninputHwrfscnWritingBox::LafChanged()
       
   226     {
       
   227     
       
   228     }
       
   229 
       
   230 // -----------------------------------------------------------------------------
       
   231 // CPeninputHwrfscnWritingBox::OnStrokeCharacterTimerOut()
       
   232 // .
       
   233 // -----------------------------------------------------------------------------
       
   234 //	
       
   235 void CPeninputHwrfscnWritingBox::OnStrokeCharacterTimerOut()
       
   236     {
       
   237     // Get stroke list is called by event handler
       
   238     TPtrC ptr;
       
   239     ptr.Set( reinterpret_cast<TText*>( &iStrokeList ), 
       
   240         sizeof( &iStrokeList ) );
       
   241     ReportEvent( EHwrEventEndWriting, iHwrWnd, ptr );
       
   242     } 
       
   243 
       
   244 // -----------------------------------------------------------------------------
       
   245 // CPeninputHwrfscnWritingBox::OnStrokeStarted()
       
   246 // .
       
   247 // -----------------------------------------------------------------------------
       
   248 //	    
       
   249 void CPeninputHwrfscnWritingBox::OnStrokeStarted()
       
   250     {
       
   251     ReportEvent( EHwrEventBeginWriting, iHwrWnd, KNullDesC );
       
   252     }
       
   253 
       
   254 // -----------------------------------------------------------------------------
       
   255 // CPeninputHwrfscnWritingBox::OnStrokeStarted()
       
   256 // .
       
   257 // -----------------------------------------------------------------------------
       
   258 //	
       
   259 void CPeninputHwrfscnWritingBox::OnStrokeFinished()
       
   260     {
       
   261     // copy data from iHwrWnd's stroke list
       
   262     iStrokeList.Reset();
       
   263     RArray<TPoint> dataList = iHwrWnd->StrokeList();
       
   264     for( TInt i = 0; i < dataList.Count(); i++ )
       
   265         {
       
   266         iStrokeList.Append( dataList[i] );
       
   267         }
       
   268     }
       
   269     
       
   270 // -----------------------------------------------------------------------------
       
   271 // CPeninputHwrfscnWritingBox::CancelCharWriting()
       
   272 // .
       
   273 // -----------------------------------------------------------------------------
       
   274 //	
       
   275 void CPeninputHwrfscnWritingBox::CancelCharWriting()
       
   276     {
       
   277     iLayout->EnableStrokeFilter( ETrue );
       
   278     iHwrWnd->CancelCharWriting();
       
   279     }
       
   280 
       
   281 // -----------------------------------------------------------------------------
       
   282 // CPeninputHwrfscnWritingBox::SetWritingSpeed()
       
   283 // .
       
   284 // -----------------------------------------------------------------------------
       
   285 //    
       
   286 void CPeninputHwrfscnWritingBox::SetWritingSpeed( 
       
   287     const TTimeIntervalMicroSeconds32& aCharDelay )
       
   288     {
       
   289     iHwrWnd->SetCharacterDelay( aCharDelay );
       
   290     }
       
   291 
       
   292 // -----------------------------------------------------------------------------
       
   293 // CPeninputHwrfscnWritingBox::SetBoxPenSize()
       
   294 // .
       
   295 // -----------------------------------------------------------------------------
       
   296 //    
       
   297 void CPeninputHwrfscnWritingBox::SetPenSize( const TSize aSize )
       
   298     {
       
   299     iHwrWnd->SetPenSize( aSize );   
       
   300     }
       
   301 
       
   302 // -----------------------------------------------------------------------------
       
   303 // CPeninputHwrfscnWritingBox::SetBoxPenColor()
       
   304 // .
       
   305 // -----------------------------------------------------------------------------
       
   306 //    
       
   307 void CPeninputHwrfscnWritingBox::SetPenColor( const TRgb aCol )
       
   308     {
       
   309     iHwrWnd->SetPenColor( aCol );
       
   310     }
       
   311 
       
   312 //End of file