textinput/peninputarc/src/peninputserverapp/penuiwndctrl.cpp
branchRCL_3
changeset 21 ecbabf52600f
parent 20 ebd48d2de13c
child 22 bd83ceabce89
equal deleted inserted replaced
20:ebd48d2de13c 21:ecbabf52600f
    13 *
    13 *
    14 * Description:
    14 * Description:
    15 *
    15 *
    16 */
    16 */
    17 #include <AknSgcc.h>
    17 #include <AknSgcc.h>
       
    18 #include <AknIncallBubbleNotify.h>
    18 #include <avkon.hrh>
    19 #include <avkon.hrh>
    19 #include <eikappui.h>
    20 #include <eikappui.h>
    20 #include <apgwgnam.h>
    21 #include <apgwgnam.h>
    21 
    22 
    22 #include "penuiwndctrl.h"
    23 #include "penuiwndctrl.h"
    26 #include <akntranseffect.h>
    27 #include <akntranseffect.h>
    27 
    28 
    28 #include <e32property.h>
    29 #include <e32property.h>
    29 #include <avkondomainpskeys.h>
    30 #include <avkondomainpskeys.h>
    30 #endif
    31 #endif
    31 
    32 #include "peninputcmd.h"
    32 
    33 
    33 const TInt KAknCapServerUid = 0x10207218;
    34 const TInt KAknCapServerUid = 0x10207218;
    34 const TInt KAknNotifySrvUid = 0x10281EF2;  
    35 const TInt KAknNotifySrvUid = 0x10281EF2;  
    35     
    36 
       
    37 const TInt KAutoRefreshTimer = 10; //ms
       
    38 const TInt KAutoRefreshLongTimer = 1000; //ms
       
    39 
       
    40 TInt AutoRefreshTimerCallback( TAny* aObject )
       
    41     {
       
    42     CPenUiWndCtrl* wnd = static_cast<CPenUiWndCtrl*>( aObject );
       
    43     wnd->RefreshUI();
       
    44 
       
    45     return 0;
       
    46     }
       
    47 
    36 CPenUiWndCtrl::CPenUiWndCtrl(RWindowGroup& aWndGroup,CFbsBitmap * aBitmap)
    48 CPenUiWndCtrl::CPenUiWndCtrl(RWindowGroup& aWndGroup,CFbsBitmap * aBitmap)
    37     :iWndGroup(aWndGroup),
    49     :iWndGroup(aWndGroup),
    38      iBitmap(aBitmap),
    50      iBitmap(aBitmap),
    39      iAknUiSrv(CAknSgcClient::AknSrv())
    51      iAknUiSrv(CAknSgcClient::AknSrv())
    40 {
    52 {
    42 
    54 
    43 CPenUiWndCtrl::~CPenUiWndCtrl()
    55 CPenUiWndCtrl::~CPenUiWndCtrl()
    44 {
    56 {
    45     delete iPopupWnd;
    57     delete iPopupWnd;
    46 
    58 
       
    59 	delete iIncallBubble;  
    47 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS
    60 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS
    48 
    61 
    49     if ( GfxTransEffect::IsRegistered( this ) )
    62     if ( GfxTransEffect::IsRegistered( this ) )
    50         {
    63         {
    51         // abort component effects (possibly appear effect) 
    64         // abort component effects (possibly appear effect) 
    52         // if aknnote gets destroyed without user interaction or timers
    65         // if aknnote gets destroyed without user interaction or timers
    53         GfxTransEffect::NotifyExternalState( ENotifyGlobalAbort );
    66         GfxTransEffect::NotifyExternalState( ENotifyGlobalAbort );
    54         GfxTransEffect::Deregister(this); //Always deregister in destructor.
    67         GfxTransEffect::Deregister(this); //Always deregister in destructor.
    55         }
    68         }    
    56 #endif    	
    69 #endif   
       
    70     if ( iAutoRefreshTimer && iAutoRefreshTimer->IsActive() )
       
    71         {
       
    72         iAutoRefreshTimer->Cancel();
       
    73         }
       
    74     delete iAutoRefreshTimer; 
       
    75     
       
    76 
       
    77 	Clean();
       
    78 
       
    79     
       
    80 	delete iCursorWnd;   
    57 }
    81 }
    58 
    82 
    59 void CPenUiWndCtrl::ConstructL()
    83 void CPenUiWndCtrl::ConstructL()
    60 {
    84 {
    61     CreateWindowL(iWndGroup);
    85     CreateWindowL(iWndGroup);
    62     SetComponentsToInheritVisibility();
    86     SetComponentsToInheritVisibility();
    63 
    87 
    64     Window().SetRequiredDisplayMode( EColor16MA );
    88     Window().SetRequiredDisplayMode( EColor16MA );
    65     MakeVisible( EFalse );
    89     iIncallBubble = CAknIncallBubble::NewL();        
       
    90 
    66 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS    
    91 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS    
    67     // only change registration, if not registered, don't register
    92     // only change registration, if not registered, don't register
    68     if (!GfxTransEffect::IsRegistered( this ) ) 
    93     if (!GfxTransEffect::IsRegistered( this ) ) 
    69         {
    94         {
    70         GfxTransEffect::Register( this, TUid::Uid( 0x2000B477 ));
    95         GfxTransEffect::Register( this, TUid::Uid( 0x2000B477 ));
    71         }
    96         }
    72 #endif    
    97 #endif    
    73   //  ActivateL();
    98   //  ActivateL();
    74     iPopupWnd = CPenUiPopWnd::NewL(iWndGroup,iBitmap,this);
    99     iPopupWnd = CPenUiPopWnd::NewL(iWndGroup,iBitmap,this);
       
   100     
       
   101     iAutoRefreshTimer = CPeriodic::NewL( CActive::EPriorityStandard );
       
   102 
       
   103     iCursorWnd = new (ELeave) CCursorWindow(this);
       
   104     //iCursorWnd->ConstructL(this);
       
   105     iCursorWnd->SetContainerWindowL(*this);
       
   106     
       
   107     // Update the cursor color
       
   108     SetCursorColor();
       
   109     
       
   110     MakeVisible( EFalse );
    75 }
   111 }
    76 
   112 
    77 
   113 
    78 void CPenUiWndCtrl::Draw(const TRect& aRect) const
   114 void CPenUiWndCtrl::Draw(const TRect& aRect) const
    79     {
   115     {
       
   116     if (iNotUpdating)
       
   117         return;
       
   118 
    80     CWindowGc& gc = SystemGc();
   119     CWindowGc& gc = SystemGc();
    81         
   120     if (iShowPopup)
    82     if ( iShowPopup ) 
       
    83         {
   121         {
    84         //layout is extended by popup
   122         //layout is extended by popup
    85         gc.SetClippingRect( iLayoutClipRect );
   123         TRect rect = aRect;
    86         gc.BitBlt( aRect.iTl, iBitmap, aRect );
   124         rect.Intersection(iLayoutClipRect);
    87         // Add to fix NGA refresh problem
   125         TPoint pos = rect.iTl - iLayoutClipRect.iTl;
    88         CCoeEnv::Static()->WsSession().Flush();
   126         gc.BitBlt(pos, iBitmap, rect);
    89         CCoeEnv::Static()->WsSession().Finish(); 
   127 #ifdef FIX_FOR_NGA
       
   128         //draw bubble
       
   129         for ( TInt i = 0; i < iBubblesCtrl.Count(); ++i )
       
   130             {
       
   131             gc.BitBlt(iBubblesPos[i].iTl, iBubblesArea[i]);
       
   132             }
       
   133 #endif   
    90         return;
   134         return;
    91         }
   135         //layout is extended by popup
    92     
   136         //gc.SetClippingRect( iLayoutClipRect );
       
   137         }
       
   138 #ifdef FIX_FOR_NGA
       
   139     gc.BitBlt(TPoint(0, 0), iBitmap, Rect());
       
   140     //draw bubble
       
   141     for ( TInt i = 0; i < iBubblesCtrl.Count(); ++i )
       
   142         {
       
   143         gc.BitBlt(iBubblesPos[i].iTl, iBubblesArea[i]);
       
   144         }
       
   145 #else    
    93     gc.BitBlt(aRect.iTl,iBitmap,aRect);
   146     gc.BitBlt(aRect.iTl,iBitmap,aRect);
    94     // Add to fix NGA refresh problem
   147 #endif     
       
   148 
       
   149     }
       
   150 
       
   151 void CPenUiWndCtrl::RefreshUI()
       
   152     {
       
   153     StopRefreshTimer();
       
   154     
       
   155     if ( iShowPopup )
       
   156         {
       
   157         iPopupWnd->DrawNow();
       
   158         }
       
   159     else
       
   160         {
       
   161         DrawNow();
       
   162         }
    95     CCoeEnv::Static()->WsSession().Flush();
   163     CCoeEnv::Static()->WsSession().Flush();
    96     CCoeEnv::Static()->WsSession().Finish(); 
   164     CCoeEnv::Static()->WsSession().Finish();
       
   165     
       
   166     }
       
   167 
       
   168 void CPenUiWndCtrl::Clean()
       
   169     {
       
   170     iCursorBmp = NULL;
       
   171     iBubblesArea.Close();
       
   172     iBubblesCtrl.Close();
       
   173     iBubblesPos.Close();
       
   174 	iBubblesMaskArea.Close();
       
   175 	iPopRegion.Close();
       
   176     iChangedBmp= NULL;
       
   177     iBackground = EFalse;
       
   178     iNotUpdating = EFalse;
       
   179     }
       
   180 
       
   181 CCursorWindow::CCursorWindow(CPenUiWndCtrl* aParent)
       
   182                             :iParent(aParent) 
       
   183     {
       
   184     }
       
   185 
       
   186 void CCursorWindow::SetCursorVisible(TBool aFlag)
       
   187     {
       
   188     iCursorVisible = aFlag;
       
   189     DrawNow();
       
   190     }
       
   191 void CCursorWindow::Draw(const TRect &aRect ) const
       
   192     {
       
   193     if(!iCursorVisible)
       
   194         return;
       
   195    
       
   196     CWindowGc& gc = SystemGc();
       
   197     iParent->DrawCursor(gc);  
       
   198     }
       
   199 
       
   200 // ---------------------------------------------------------------------------
       
   201 // CPenUiWndCtrl::SetCursorColor
       
   202 // ---------------------------------------------------------------------------
       
   203 //
       
   204 void CPenUiWndCtrl::SetCursorColor()
       
   205 	{
       
   206 	// Set default cursor color to black
       
   207 	TRgb color( KRgbBlack );
       
   208 	// if the skin is enabled
       
   209     if ( AknsUtils::AvkonSkinEnabled())
       
   210         {
       
   211         // Get the text color under current theme
       
   212         AknsUtils::GetCachedColor( AknsUtils::SkinInstance(),
       
   213 	                               color, 
       
   214 	                               KAknsIIDQsnTextColors, 
       
   215 	                               EAknsCIQsnTextColorsCG60 );
       
   216         }
       
   217     
       
   218     // Set the cursor color
       
   219     iCursorColor = color;
       
   220 	}
       
   221 
       
   222 void CPenUiWndCtrl::DrawCursor(CWindowGc& aGc) const
       
   223     {
       
   224     aGc.SetPenColor( iCursorColor );
       
   225     aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   226     aGc.SetBrushColor( iCursorColor );
       
   227     aGc.SetDrawMode(CGraphicsContext::EDrawModeNOTSCREEN);
       
   228     aGc.SetPenStyle(CGraphicsContext::ESolidPen);
       
   229     aGc.SetPenSize( TSize(1,1));
       
   230     
       
   231     TRect drawRect = iCursorRect;
       
   232     if(!iPopRegion.IsEmpty() && iPopRegion.Intersects(iCursorRect))
       
   233         {
       
   234         RRegion r;
       
   235         r.AddRect(iCursorRect);
       
   236         const TRect* rl = iPopRegion.RectangleList();
       
   237         
       
   238         for(TInt i = 0 ; i < iPopRegion.Count(); ++i)
       
   239             {
       
   240             drawRect = iCursorRect;
       
   241             drawRect.Intersection(rl[i]);
       
   242             if(!drawRect.IsEmpty())
       
   243                 r.SubRect(drawRect);
       
   244             }
       
   245         
       
   246         for(TInt ii = 0; ii < r.Count(); ++ii)
       
   247             {
       
   248         aGc.DrawRect(r.RectangleList()[ii]);
       
   249             }
       
   250         r.Close();
       
   251         }
       
   252     else
       
   253         aGc.DrawRect(iCursorRect);
       
   254 
       
   255     // restore normal draw mode
       
   256     aGc.SetDrawMode(CGraphicsContext::EDrawModePEN);
       
   257     aGc.SetBrushStyle(CGraphicsContext::ENullBrush);
       
   258     
       
   259     }
       
   260 void CPenUiWndCtrl::UpdateCursor(TBool aOnFlag,const CFbsBitmap* aCursorBmp,const TRect& aRect)
       
   261     {
       
   262     if(iNotUpdating || !IsReadyToDraw())
       
   263         {
       
   264         //some times when layout is diabled, the cursor is still change its pos, and draw to the last place
       
   265         //when layout enabled. So we set the cursor invisible, and wait for next cursor updating event.
       
   266 		iCursorWnd->SetCursorVisible(EFalse);
       
   267         return;
       
   268         }
       
   269     
       
   270     iCursorPos = aRect.iTl;
       
   271 	
       
   272     if(iCursorRect != aRect)
       
   273         {
       
   274         iCursorRect = aRect;
       
   275         iCursorWnd->SetRect(iCursorRect);
       
   276         }
       
   277     iCursorWnd->SetCursorVisible(aOnFlag);
       
   278     }
       
   279 
       
   280 // ---------------------------------------------------------------------------
       
   281 // CPenUiWndCtrl::UpdateBubble
       
   282 // ---------------------------------------------------------------------------
       
   283 //
       
   284 void CPenUiWndCtrl::UpdateBubble( const TUint32 aCtrl, 
       
   285 		                          const CFbsBitmap* aBmp,
       
   286 		                          const CFbsBitmap* aMask,
       
   287                                   const TRect& aPos,
       
   288                                   TBool aFlag )
       
   289     {
       
   290 
       
   291 	// Check whether the Ctrl address is exist
       
   292 	TInt idx = iBubblesCtrl.Find( aCtrl );
       
   293 
       
   294     
       
   295     if(aFlag)
       
   296         {
       
   297         if(KErrNotFound == idx)
       
   298             {
       
   299 
       
   300             iBubblesCtrl.Append( aCtrl );
       
   301 
       
   302             iBubblesArea.Append(aBmp);
       
   303             iBubblesMaskArea.Append(aMask);
       
   304             iBubblesPos.Append(aPos);
       
   305             }
       
   306         else
       
   307             {
       
   308             iBubblesPos[idx] = aPos;
       
   309             }
       
   310 
       
   311         }
       
   312     else
       
   313         {
       
   314         //remove
       
   315         if(idx != KErrNotFound)
       
   316             {
       
   317 
       
   318             iBubblesCtrl.Remove( idx );
       
   319 
       
   320             iBubblesArea.Remove(idx);
       
   321             iBubblesMaskArea.Remove(idx);
       
   322             iBubblesPos.Remove(idx);            
       
   323             }        
       
   324         }
       
   325     Invalidate(Rect(), ETrue);
       
   326     }
       
   327 void CPenUiWndCtrl::UpdateICFArea(const CFbsBitmap* aBmp,const TPoint& aPos)
       
   328     {
       
   329     iICFBmp = const_cast<CFbsBitmap*>(aBmp);
       
   330     iIcfPos = aPos;
       
   331     Invalidate(Rect(), ETrue);   
       
   332     }
       
   333 
       
   334 
       
   335 // ---------------------------------------------------------------------------
       
   336 // CPenUiWndCtrl::UpdateChangedArea
       
   337 // ---------------------------------------------------------------------------
       
   338 //
       
   339 void CPenUiWndCtrl::UpdateChangedArea( const TUint32 aCtrl, 
       
   340 		const CFbsBitmap* aBmp,const TRect& aPos,TBool aFlag)
       
   341     {
       
   342     UpdateBubble( aCtrl, aBmp, 0, aPos, aFlag );
       
   343     return;    
       
   344     }
       
   345 
       
   346 
       
   347 void CPenUiWndCtrl::SetPopupArea(const TRect& aRect, TBool aFlag)
       
   348     {
       
   349     if(aFlag) //add pop area
       
   350         {
       
   351         iPopRegion.AddRect(aRect);
       
   352         }
       
   353     else
       
   354         {
       
   355         iPopRegion.SubRect(aRect);
       
   356         }
    97     }
   357     }
    98 
   358 
    99 TInt CPenUiWndCtrl::WndPriority()
   359 TInt CPenUiWndCtrl::WndPriority()
   100     {
   360     {
   101     return iPriority;
   361     return iPriority;
   132     return iPreEditorPriority;
   392     return iPreEditorPriority;
   133     }
   393     }
   134     
   394     
   135 void CPenUiWndCtrl::ShowPenUiL(TBool /*aDimmed*/)
   395 void CPenUiWndCtrl::ShowPenUiL(TBool /*aDimmed*/)
   136     {
   396     {
       
   397     iCursorWnd->SetCursorVisible(EFalse);
   137     if (iResourceChange)
   398     if (iResourceChange)
   138         {
   399         {
   139         ActivateL();
   400         ActivateL();
       
   401         iIncallBubble->SetIncallBubbleFlagsL( EAknStatusBubbleInputShow );
   140         MakeVisible( ETrue );
   402         MakeVisible( ETrue );
   141     	ClaimPointerGrab( ETrue );
   403     	ClaimPointerGrab( ETrue );
   142         return;
   404         return;
   143         }
   405         }
   144 
   406 
   148     DrawableWindow()->SetOrdinalPosition( 0, iPriority);
   410     DrawableWindow()->SetOrdinalPosition( 0, iPriority);
   149     //OnActivate();
   411     //OnActivate();
   150     iWndGroup.SetNonFading(ETrue);
   412     iWndGroup.SetNonFading(ETrue);
   151     //ChangeSysteFadeStatus();
   413     //ChangeSysteFadeStatus();
   152     ActivateL();
   414     ActivateL();
       
   415     iIncallBubble->SetIncallBubbleFlagsL( EAknStatusBubbleInputShow );
   153    // MakeVisible( ETrue );
   416    // MakeVisible( ETrue );
   154 	ClaimPointerGrab( ETrue );
   417 	ClaimPointerGrab( ETrue );
   155 	
   418 	
   156 	
   419 	
   157 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS      
   420 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS      
   168         
   431         
   169         TRect demarcation;
   432         TRect demarcation;
   170         CAknTransitionUtils::GetDemarcation(CAknTransitionUtils::EPopup, 
   433         CAknTransitionUtils::GetDemarcation(CAknTransitionUtils::EPopup, 
   171                                             demarcation);
   434                                             demarcation);
   172         GfxTransEffect::SetDemarcation(this, demarcation);
   435         GfxTransEffect::SetDemarcation(this, demarcation);
       
   436 
       
   437         //todo fix NGA effects error
       
   438         CCoeEnv::Static()->WsSession().Finish();
       
   439         User::After( 1 );
   173         
   440         
   174         this->MakeVisible(ETrue);
   441         this->MakeVisible(ETrue);
   175         
   442         
   176         GfxTransEffect::NotifyExternalState(ECaptureComponentsEnd, (const TDesC8*)this);
   443         GfxTransEffect::NotifyExternalState(ECaptureComponentsEnd, (const TDesC8*)this);
   177         GfxTransEffect::End(this);
   444         GfxTransEffect::End(this);
   189 
   456 
   190 void CPenUiWndCtrl::ClosePenUi(TBool aResChanging)
   457 void CPenUiWndCtrl::ClosePenUi(TBool aResChanging)
   191     {
   458     {
   192     if (aResChanging)
   459     if (aResChanging)
   193         {
   460         {
       
   461         TRAP_IGNORE(iIncallBubble->SetIncallBubbleFlagsL( EAknStatusBubbleInputHide ));
   194         MakeVisible( EFalse );
   462         MakeVisible( EFalse );
   195         return;
   463         return;
   196         }
   464         }
   197 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS           
   465 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS           
   198     if ( GfxTransEffect::IsRegistered( this ))
   466     if ( GfxTransEffect::IsRegistered( this ))
   207         
   475         
   208         TRect demarcation;
   476         TRect demarcation;
   209         CAknTransitionUtils::GetDemarcation(CAknTransitionUtils::EPopup, 
   477         CAknTransitionUtils::GetDemarcation(CAknTransitionUtils::EPopup, 
   210                                             demarcation);
   478                                             demarcation);
   211         GfxTransEffect::SetDemarcation(this, demarcation);
   479         GfxTransEffect::SetDemarcation(this, demarcation);
       
   480 
       
   481         //todo fix NGA effects error
       
   482         CCoeEnv::Static()->WsSession().Finish();
       
   483         User::After( 1 );
   212         
   484         
   213         this->MakeVisible(EFalse);
   485         this->MakeVisible(EFalse);
   214         
   486         
   215         GfxTransEffect::NotifyExternalState(ECaptureComponentsEnd, (const TDesC8*)this);
   487         GfxTransEffect::NotifyExternalState(ECaptureComponentsEnd, (const TDesC8*)this);
   216         GfxTransEffect::End(this);
   488         GfxTransEffect::End(this);
   221         MakeVisible( EFalse );
   493         MakeVisible( EFalse );
   222 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS            
   494 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS            
   223         }
   495         }
   224 #endif // RD_UI_TRANSITION_EFFECTS_POPUPS
   496 #endif // RD_UI_TRANSITION_EFFECTS_POPUPS
   225 
   497 
   226     //iResourceChange = EFalse;
       
   227     iShowPopup = EFalse;
   498     iShowPopup = EFalse;
   228     iWndGroup.SetOrdinalPosition( -1, ECoeWinPriorityNormal-1 );
   499     iWndGroup.SetOrdinalPosition( -1, ECoeWinPriorityNormal-1 );
   229     DrawableWindow()->SetOrdinalPosition(-1, ECoeWinPriorityNormal-1 );
   500     DrawableWindow()->SetOrdinalPosition(-1, ECoeWinPriorityNormal-1 );
   230     //MakeVisible( EFalse );
   501     TRAP_IGNORE(iIncallBubble->SetIncallBubbleFlagsL( EAknStatusBubbleInputHide ));
   231       
       
   232 }
   502 }
   233 
   503 
   234 
   504 
   235 void CPenUiWndCtrl::ShowPopup( const TRect& aRectInScreen, const TRect& aRectInLayout, const TRect& aLayoutTrimRect )
   505 void CPenUiWndCtrl::ShowPopup( const TRect& aRectInScreen, const TRect& aRectInLayout, const TRect& aLayoutTrimRect )
   236     {
   506     {
       
   507     TPoint offset = aLayoutTrimRect.iTl;
       
   508     offset += Position();
       
   509     this->SetPosition( offset );
       
   510     this->SetSize( aLayoutTrimRect.Size() );
       
   511     
   237     iPopupWnd->PopUp( aRectInScreen, aRectInLayout );
   512     iPopupWnd->PopUp( aRectInScreen, aRectInLayout );
   238     iLayoutClipRect = aLayoutTrimRect;
   513     iLayoutClipRect = aLayoutTrimRect;
   239     iShowPopup = ETrue;
   514     iShowPopup = ETrue;
   240     }
   515     }
   241 
   516 
   262         {        
   537         {        
   263         iPopupWnd->MakeVisible(EFalse);//This is a temproary fix due to pop up UI not updated.
   538         iPopupWnd->MakeVisible(EFalse);//This is a temproary fix due to pop up UI not updated.
   264         iPopupWnd->Invalidate(aRect);
   539         iPopupWnd->Invalidate(aRect);
   265         iPopupWnd->MakeVisible(ETrue);//This is a temproary fix due to pop up UI not updated.
   540         iPopupWnd->MakeVisible(ETrue);//This is a temproary fix due to pop up UI not updated.
   266         iPopupWnd->Invalidate(aRect);
   541         iPopupWnd->Invalidate(aRect);
   267         iPopupWnd->DrawNow();
       
   268         }
   542         }
   269     else
   543     else
   270         //DrawNow(aRect);
       
   271         {
   544         {
   272         iInvalidateRect = aRect;
   545         iInvalidateRect = aRect;
   273         Window().Invalidate(aRect);
   546         Window().Invalidate(aRect);
   274         }
   547         }
       
   548 #ifdef FIX_FOR_NGA
       
   549     RestartRefreshTimer();
       
   550 #endif
   275     }
   551     }
   276 
   552 
   277 void CPenUiWndCtrl::OnActivate(EditorType aType)
   553 void CPenUiWndCtrl::OnActivate(EditorType aType)
   278     {
   554     {
   279     //TBool dim = IsDimmed();
   555     //TBool dim = IsDimmed();
   280     RestoreSystemFadeStatus();
   556     RestoreSystemFadeStatus();
   281     //have to call this, otherwise pen UI is faded
   557 	
   282     iWndGroup.SetNonFading(ETrue);
   558 	// if we were opened under a global note
       
   559 	// we need to dim pen ui
       
   560 	if(aType != EGlobleNotesWithEditor && aType != EGlobleNotes)
       
   561 	   {
       
   562 	   //have to call this, otherwise pen UI is faded
       
   563        iWndGroup.SetNonFading(ETrue);
       
   564 	   }
   283     
   565     
   284     if (iResourceChange)
   566     if (iResourceChange)
   285         {
   567         {
   286         return;    
   568         return;    
   287         }
   569         }
   408 void CPenUiWndCtrl::SetResourceChange(TBool aResourceChange)
   690 void CPenUiWndCtrl::SetResourceChange(TBool aResourceChange)
   409     {
   691     {
   410     iResourceChange = aResourceChange;
   692     iResourceChange = aResourceChange;
   411     }
   693     }
   412     
   694     
       
   695 void CPenUiWndCtrl::HandleNGASpecificSignal(TInt aEventType, const TDesC& aEventData)
       
   696     {
       
   697     switch(aEventType)
       
   698         {
       
   699         case ESignalPopupWndClosed:
       
   700             {               
       
   701             ClosePopup();
       
   702             }               
       
   703             break;
       
   704         case ESignalUpdateCursor :
       
   705             {
       
   706             struct SData
       
   707                 {
       
   708                 TBool onOff;
       
   709                 CFbsBitmap* bmp;
       
   710                 TRect rect;
       
   711                 } data;
       
   712             
       
   713             data = * (reinterpret_cast<SData*>( const_cast<TUint16*>( aEventData.Ptr() )));
       
   714             UpdateCursor(data.onOff,data.bmp,data.rect);
       
   715               
       
   716             }
       
   717             break;
       
   718         case ESignalPopupArea:
       
   719             {
       
   720             struct SData
       
   721                 {
       
   722                 TRect rr;
       
   723                 TBool flag;
       
   724                 } data;
       
   725             
       
   726             data = * (reinterpret_cast<SData*>( const_cast<TUint16*>( aEventData.Ptr() )));
       
   727             SetPopupArea(data.rr,data.flag);
       
   728             }
       
   729             break;
       
   730         case ESignalUpdateICFArea:            
       
   731             {
       
   732             struct SData
       
   733                 {
       
   734                 CFbsBitmap* bmp;                        
       
   735                 TPoint pos;
       
   736                 } data;
       
   737             
       
   738             data = * (reinterpret_cast<SData*>( const_cast<TUint16*>( aEventData.Ptr() )));
       
   739             UpdateICFArea(data.bmp,data.pos);
       
   740             }
       
   741             break;
       
   742         case ESignalUpdateBubble:
       
   743             {
       
   744             struct SData
       
   745                 {
       
   746             	TUint32 ctrl;
       
   747                 TBool flag;
       
   748                 TRect pos;
       
   749                 CFbsBitmap* bmp;
       
   750                 CFbsBitmap* mask;
       
   751                 } data;
       
   752             data = * (reinterpret_cast<SData*>( const_cast<TUint16*>( aEventData.Ptr() )));
       
   753             UpdateBubble( data.ctrl, data.bmp, data.mask, data.pos, data.flag );
       
   754             }
       
   755             break;
       
   756         case ESignalUpdateChangedArea:
       
   757             {
       
   758             struct SData
       
   759                 {
       
   760             	TUint32 ctrl;
       
   761                 TBool flag;
       
   762                 CFbsBitmap* bmp;
       
   763                 TRect pos;
       
   764                 } data;
       
   765             data = * (reinterpret_cast<SData*>( const_cast<TUint16*>( aEventData.Ptr() )));
       
   766             UpdateChangedArea( data.ctrl, data.bmp, data.pos, data.flag );
       
   767             }
       
   768             break;
       
   769         case ESignalRegisterBkControl:
       
   770             {
       
   771             
       
   772             struct SData
       
   773                 {
       
   774                 //TBool bChangeFrameId;
       
   775         
       
   776                 TAknsItemID frameID;
       
   777                 TAknsItemID centerID;        
       
   778                 RArray<TCommonBgCtrlSubItem> *subItems;
       
   779                 } data;
       
   780             data = * (reinterpret_cast<SData*>( const_cast<TUint16*>( aEventData.Ptr() )));
       
   781             iSubItems = data.subItems;
       
   782             iFrameID = data.frameID;
       
   783             iCenterID = data.centerID;
       
   784             iBackground = ETrue;
       
   785             }
       
   786             break;
       
   787         case ESignalDisableUpdating:
       
   788             {
       
   789             iNotUpdating = * (reinterpret_cast<TBool*>( const_cast<TUint16*>( aEventData.Ptr() )));
       
   790 			if(iNotUpdating)
       
   791 			    {
       
   792 				UpdateCursor(EFalse,NULL,iCursorWnd?iCursorWnd->Rect():TRect(TPoint(0,0),TSize(0,0)));
       
   793 				}
       
   794             }
       
   795 			break;
       
   796         case ESignalDrawBackground:
       
   797             {
       
   798             struct SData
       
   799                 {
       
   800                 CFbsBitGc* gc;
       
   801                 CFbsBitmap* bmp;
       
   802                 TRect rect;
       
   803                 } data;
       
   804             data = * (reinterpret_cast<SData*>( const_cast<TUint16*>( aEventData.Ptr() )));
       
   805             DrawBubbleAsBackground(data.gc,data.bmp,data.rect);
       
   806             }
       
   807             break;
       
   808         default:
       
   809             break;
       
   810         }
       
   811     
       
   812     }
       
   813 
       
   814 void CPenUiWndCtrl::DrawBkground(CWindowGc& aGc,const TRect& aRect)  const
       
   815     {
       
   816     
       
   817     DrawFrame(aGc,aRect, iFrameID, iCenterID);
       
   818     
       
   819     for( TInt i = 0; i < (*iSubItems).Count(); i++ )
       
   820         {
       
   821         if( (*iSubItems)[i].iIsShow )
       
   822             {
       
   823             DrawFrame(aGc, (*iSubItems)[i].iRect, 
       
   824                        (*iSubItems)[i].iFrameID, 
       
   825                        (*iSubItems)[i].iCenterID );                
       
   826             }
       
   827         }       
       
   828     
       
   829     }
       
   830 
       
   831 void CPenUiWndCtrl::DrawBubbleAsBackground(CFbsBitGc* aGc, CFbsBitmap* aBmp, const TRect& aRect)
       
   832     {
       
   833     for(TInt i = 0 ; i < iBubblesArea.Count(); ++i)
       
   834         {
       
   835         if(iBubblesArea[i] != aBmp) //not draw same bitmap
       
   836             {
       
   837             //gc.BitBlt(iBubblesPos[i],iBubblesArea[i]);
       
   838             TRect r = aRect;
       
   839             TRect rect2 = iBubblesPos[i];
       
   840             r.Intersection(rect2);
       
   841             if(!r.IsEmpty())
       
   842                 {
       
   843                 TRect src = r;
       
   844                 r.Move(TPoint(-aRect.iTl.iX,-aRect.iTl.iY));
       
   845                 src.Move(TPoint(-rect2.iTl.iX,-rect2.iTl.iY));
       
   846                 aGc->BitBlt(r.iTl, iBubblesArea[i], src);
       
   847                 }
       
   848             }
       
   849         }
       
   850     
       
   851     }
       
   852 
       
   853 
       
   854 CCoeControl* CPenUiWndCtrl::ComponentControl(TInt) const
       
   855     {
       
   856     return iCursorWnd;
       
   857     }
       
   858 TInt CPenUiWndCtrl::CountComponentControls() const
       
   859     {
       
   860     return 1;
       
   861     }
       
   862 
       
   863 
       
   864 void CPenUiWndCtrl::DrawFrame(CWindowGc& aGc, const TRect& aRect,TAknsItemID aFrameID,
       
   865                                                 TAknsItemID aCenterID )  const
       
   866     {    
       
   867     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   868     TRect innerRect = aRect;
       
   869     innerRect.Shrink( 4, 4 );
       
   870     
       
   871     AknsDrawUtils::DrawFrame(
       
   872                             skin, aGc, 
       
   873                             aRect, innerRect, 
       
   874                             aFrameID, aCenterID);
       
   875     }
       
   876 
       
   877 void CPenUiWndCtrl::RestartRefreshTimer()
       
   878     {
       
   879     StopRefreshTimer();
       
   880 
       
   881     TTimeIntervalMicroSeconds32 t1 = KAutoRefreshTimer * 1000;
       
   882     TTimeIntervalMicroSeconds32 t2 = KAutoRefreshLongTimer * 1000;
       
   883     iAutoRefreshTimer->Start( t1, t2, TCallBack(AutoRefreshTimerCallback, this) );
       
   884     }
       
   885 
       
   886 void CPenUiWndCtrl::StopRefreshTimer()
       
   887     {
       
   888     if ( iAutoRefreshTimer->IsActive() )
       
   889         {
       
   890         iAutoRefreshTimer->Cancel();
       
   891         }
       
   892     }
       
   893 	
       
   894 void CPenUiWndCtrl::LiftUpPriority()
       
   895     {
       
   896 	TInt priority = GetWndPriority();
       
   897     iPriority =  priority;
       
   898     iWndGroup.SetOrdinalPosition( 0, iPriority);
       
   899     DrawableWindow()->SetOrdinalPosition( 0, iPriority);
       
   900 	}
       
   901 	
   413 //End Of File
   902 //End Of File
   414 // class CInternalBkCtrl
   903 // class CInternalBkCtrl
   415 CInternalBkCtrl::CInternalBkCtrl(RWindowGroup& aWndGroup)    
   904 CInternalBkCtrl::CInternalBkCtrl(RWindowGroup& aWndGroup)    
   416             :iWndGroup(aWndGroup)
   905             :iWndGroup(aWndGroup)
   417     {
   906     {
   493     
   982     
   494 void CPenUiPopWnd::Draw(const TRect& /*aRect*/) const
   983 void CPenUiPopWnd::Draw(const TRect& /*aRect*/) const
   495     {
   984     {
   496     CWindowGc& gc = SystemGc();
   985     CWindowGc& gc = SystemGc();
   497     gc.BitBlt( TPoint(0,0), iBitmap, iRectInLayout ); 
   986     gc.BitBlt( TPoint(0,0), iBitmap, iRectInLayout ); 
   498     // Add to fix NGA refresh problem
   987     }
   499     CCoeEnv::Static()->WsSession().Flush();
   988 
   500     CCoeEnv::Static()->WsSession().Finish(); 
       
   501     }
       
   502