extras/calcsoft/src/CalcFunc.cpp
branchRCL_3
changeset 21 a7d8840c0b8c
parent 19 99b535de1dda
equal deleted inserted replaced
19:99b535de1dda 21:a7d8840c0b8c
   372         iIsKeyLongPress = ETrue;
   372         iIsKeyLongPress = ETrue;
   373         }
   373         }
   374         
   374         
   375     //Get the selected button
   375     //Get the selected button
   376     CAknButton* button = (CAknButton*)aControl;
   376     CAknButton* button = (CAknButton*)aControl;
   377     
   377 
   378     for ( TInt i = 0; i < KCountOfButtons; ++i )
   378     for ( TInt i = 0; i < KCountOfButtons; ++i )
   379         {
   379         {
   380         if ( button == iButtons[i] )
   380         if ( button == iButtons[i] )
   381             {
   381             {
   382             if(iSelected != i)
   382             if(iSelected != i)
   383             return;
   383             return;
   384             
   384             
   385             //break;
   385             //break;
   386             }
   386             }
   387         }    
   387         }    
       
   388 
       
   389     // Check if the button has been pressed.
       
   390     CAknButtonState* state = button->State(EnNormal);
       
   391     if ( aEventType == EEventStateChanged && state->Flags() == EnNormal )
       
   392         {
       
   393         iInputData = ETrue;
       
   394         }
   388     
   395     
   389     if ( !button->IsDimmed() )
   396     if ( !button->IsDimmed() )
   390         {
   397         {
   391                 //handles all the commands for the buttons
   398                 //handles all the commands for the buttons
   392             if( !AknLayoutUtils::PenEnabled() )
   399             if( !AknLayoutUtils::PenEnabled() )
   411                 }
   418                 }
   412             }
   419             }
   413             }
   420             }
   414             else
   421             else
   415             {
   422             {
   416              if ( iIsKeyLongPress )
   423             // Input data if the button has been pressed or long pressed.
       
   424             if ( iInputData || iIsKeyLongPress )
   417                 {
   425                 {
   418                 iContainer->View()->HandleCommandL(KButtonsIdTblTouch[iSelected]);
   426                 iContainer->View()->HandleCommandL(KButtonsIdTblTouch[iSelected]);
       
   427                 iInputData = EFalse;
   419                 }
   428                 }
   420             }   
   429             }   
   421 
   430 
   422         } 
   431         } 
   423     if( iErrorCode != KErrNone )
   432     if( iErrorCode != KErrNone )
   855         iLastKeyCode = aKeyEvent.iCode;
   864         iLastKeyCode = aKeyEvent.iCode;
   856         
   865         
   857     }
   866     }
   858     else if (aType == EEventKeyDown)
   867     else if (aType == EEventKeyDown)
   859     {
   868     {
   860         iIsOfferKeyEvent = ETrue;        
   869     iIsOfferKeyEvent = ETrue; 
       
   870     // If the enter key has been pressed, set the button and input data.
       
   871     if ( aKeyEvent.iCode == EKeyEnter || aKeyEvent.iScanCode == EStdKeyEnter )
       
   872         {
       
   873         exitCode = EKeyWasConsumed;
       
   874         HandleMiddleSoftKeyOREKeyOKL();
       
   875         iShiftKeyPressed = EPtiCaseLower;
       
   876         return exitCode;
       
   877         }       
   861     }
   878     }
   862     else if (aType == EEventKeyUp)
   879     else if (aType == EEventKeyUp)
   863     {
   880     {
   864         iIsOfferKeyEvent = EFalse;        
   881     iIsOfferKeyEvent = EFalse;
       
   882     // Release the button when enter key released.
       
   883     if ( aKeyEvent.iCode == EKeyEnter || aKeyEvent.iScanCode == EStdKeyEnter )
       
   884         {
       
   885         NotifyReleaseKeyL();
       
   886         }
   865     }
   887     }
   866     
   888     
   867    
   889    
   868     return exitCode;
   890     return exitCode;
   869 }
   891 }
   918             NULL,
   940             NULL,
   919             NULL,
   941             NULL,
   920             NULL,
   942             NULL,
   921             _L(""),
   943             _L(""),
   922             _L(""),
   944             _L(""),
   923             0,
   945             // Report the observer when the button recieve the key down event.
       
   946             KAknButtonReportOnKeyDown, 
   924             0
   947             0
   925             );     
   948             );     
   926             
   949             
   927             }
   950             }
   928         else
   951         else
   933             NULL,
   956             NULL,
   934             iCalcAppEnv->PressedButtonBmp(count),
   957             iCalcAppEnv->PressedButtonBmp(count),
   935             NULL,
   958             NULL,
   936             _L(""),
   959             _L(""),
   937             _L(""),
   960             _L(""),
   938             0,
   961             // Report the observer when the button recieve the key down event.
       
   962             KAknButtonReportOnKeyDown,
   939             0
   963             0
   940             );     
   964             );     
   941             /*if((count == ESqrtButton) && !iIsChangeSignDimmed)
   965             /*if((count == ESqrtButton) && !iIsChangeSignDimmed)
   942             {
   966             {
   943                 iButtons[count]->SetDimmed(ETrue);
   967                 iButtons[count]->SetDimmed(ETrue);
  1161         state->SetFlags(EnNormal);
  1185         state->SetFlags(EnNormal);
  1162          }
  1186          }
  1163 
  1187 
  1164     if( aOldId != aNewId )
  1188     if( aOldId != aNewId )
  1165         {
  1189         {
       
  1190         button->SetFocus( EFalse, EDrawNow );
  1166         button = iButtons[aNewId];        
  1191         button = iButtons[aNewId];        
  1167         }
  1192         }
  1168     }
  1193     }
  1169 
  1194 
  1170 // ---------------------------------------------------------
  1195 // ---------------------------------------------------------
  1195         if( aOldId != aNewId )
  1220         if( aOldId != aNewId )
  1196         {       
  1221         {       
  1197         button->SetFocus( EFalse, EDrawNow );      
  1222         button->SetFocus( EFalse, EDrawNow );      
  1198         button = iButtons[aNewId];        
  1223         button = iButtons[aNewId];        
  1199         button->SetFocus( ETrue, EDrawNow );
  1224         button->SetFocus( ETrue, EDrawNow );
  1200         }
  1225         }  
  1201     }
  1226     }
  1202 // ---------------------------------------------------------
  1227 // ---------------------------------------------------------
  1203 // CCalcFuncmapSubPane::SetLayout
  1228 // CCalcFuncmapSubPane::SetLayout
  1204 // Set functionmap button layout.
  1229 // Set functionmap button layout.
  1205 // (other items were commented in a header).
  1230 // (other items were commented in a header).
  1647         iSelected = buttonValue;
  1672         iSelected = buttonValue;
  1648         if ( iButtons[buttonValue]->Rect().Contains( aPointerEvent.iPosition ) )
  1673         if ( iButtons[buttonValue]->Rect().Contains( aPointerEvent.iPosition ) )
  1649             {
  1674             {
  1650             RedrawHighlight( oldSelect, iSelected );
  1675             RedrawHighlight( oldSelect, iSelected );
  1651             }
  1676             }
  1652         if( aPointerEvent.iType == TPointerEvent::EButton1Down )
  1677         else
  1653             {
  1678             {
  1654             iContainer->View()->HandleCommandL(KButtonsIdTblTouch[iSelected]);
  1679             //when user drag outside of button,the Button Up event is missed always.
  1655             iInputData = ETrue;
  1680             //Because the pointer is out of the button and it can't get the pointer
  1656             }
  1681             //event any more. We simulate the button up event to release the button
       
  1682             //when user drag out of button
       
  1683             if( aPointerEvent.iType == TPointerEvent::EDrag )
       
  1684                 {
       
  1685                 TPointerEvent event = aPointerEvent;
       
  1686                 event.iType = TPointerEvent::EButton1Up;
       
  1687                 iInputData = EFalse;
       
  1688                 if( iErrorCode != KErrNone )
       
  1689                    {
       
  1690                    ErrorMsgL( iErrorCode );
       
  1691                    iErrorCode = KErrNone;
       
  1692                    }
       
  1693                 CCoeControl::HandlePointerEventL( event );
       
  1694                 return;
       
  1695                 }
       
  1696             }
       
  1697 
       
  1698 
  1657         if( aPointerEvent.iType == TPointerEvent::EButton1Up )
  1699         if( aPointerEvent.iType == TPointerEvent::EButton1Up )
  1658             {
  1700             {
  1659             iInputData = EFalse;
  1701             iInputData = EFalse;
  1660             if( iErrorCode != KErrNone )
  1702             if( iErrorCode != KErrNone )
  1661                 {
  1703                 {
  1762 // ---------------------------------------------------------
  1804 // ---------------------------------------------------------
  1763 //
  1805 //
  1764 
  1806 
  1765 void CCalcFuncmapSubPane::HandleMiddleSoftKeyOREKeyOKL()
  1807 void CCalcFuncmapSubPane::HandleMiddleSoftKeyOREKeyOKL()
  1766    {
  1808    {
  1767          //get the selected button id
  1809      //get the selected button id
  1768         CAknButton* button = iButtons[iSelected];
  1810     CAknButton* button = iButtons[iSelected];
  1769         //put the button in the pressed state
  1811     //put the button in the pressed state
  1770         CAknButtonState* state = button->State(EnNormal);
  1812     CAknButtonState* state = button->State(EnNormal);
  1771         //Put the button in pressed state
  1813     //Put the button in pressed state
  1772         
  1814     
  1773         TKeyEvent aKeyEvent;
  1815     TKeyEvent aKeyEvent;
  1774         aKeyEvent.iScanCode = EStdKeyEnter;
  1816     aKeyEvent.iScanCode = EStdKeyEnter;
  1775         TEventCode aType = EEventKeyDown;
  1817     TEventCode aType = EEventKeyDown;
  1776         button->OfferKeyEventL(aKeyEvent,aType);
  1818     button->OfferKeyEventL(aKeyEvent,aType);
  1777         //put to pressed state
  1819 
  1778         state->SetFlags(EnPressed);
  1820     //put to pressed state
  1779         button->DrawNow();
  1821     state->SetFlags(EnPressed);
  1780         
  1822     button->DrawNow();
  1781         if(!iIsOfferKeyEvent)
  1823 
  1782         {
       
  1783             NotifyReleaseKeyL();
       
  1784         }
       
  1785    }
  1824    }
  1786    
  1825    
  1787 // ---------------------------------------------------------
  1826 // ---------------------------------------------------------
  1788 // CCalcFuncmapSubPane::GetChangeSignButtonState
  1827 // CCalcFuncmapSubPane::GetChangeSignButtonState
  1789 // Returns the state of change sign button
  1828 // Returns the state of change sign button