uifw/AvKon/src/aknPopup.cpp
branchRCL_3
changeset 18 0aa5fbdfbc30
parent 16 71dd06cfe933
child 55 aecbbf00d063
equal deleted inserted replaced
16:71dd06cfe933 18:0aa5fbdfbc30
    36 #include <gfxtranseffect/gfxtranseffect.h>
    36 #include <gfxtranseffect/gfxtranseffect.h>
    37 #include <akntransitionutils.h>
    37 #include <akntransitionutils.h>
    38 #endif
    38 #endif
    39 
    39 
    40 #include <AknTasHook.h>
    40 #include <AknTasHook.h>
    41 
       
    42 #include "aknPopup.h"
    41 #include "aknPopup.h"
    43 #include "akntrace.h"
    42 #include "akntrace.h"
    44 #include "aknitemactionmenuregister.h"
    43 #include "aknitemactionmenuregister.h"
    45 
    44 
    46 const TInt KSpaceBelowTitle=7;
    45 const TInt KSpaceBelowTitle=7;
   302 
   301 
   303     iBorder.SetType(TGulBorder::ENone);
   302     iBorder.SetType(TGulBorder::ENone);
   304     iListBox->SetBorder(TGulBorder::ENone);
   303     iListBox->SetBorder(TGulBorder::ENone);
   305 
   304 
   306     // Create extension class
   305     // Create extension class
   307     if (!iPopupListExtension)
   306     iPopupListExtension = new (ELeave) CAknPopupListExtension(); 
   308         iPopupListExtension = new (ELeave) CAknPopupListExtension(); 
       
   309 
   307 
   310     CAknAppUi* appUi = static_cast<CAknAppUi*>( iEikonEnv->EikAppUi() );
   308     CAknAppUi* appUi = static_cast<CAknAppUi*>( iEikonEnv->EikAppUi() );
   311     if ( appUi && appUi->IsSingleClickCompatible() )
   309     if ( appUi && appUi->IsSingleClickCompatible() )
   312         {
   310         {
   313         iPopupListExtension->iFlags |= EPopupSingleClickEnabled;
   311         iPopupListExtension->iFlags |= EPopupSingleClickEnabled;
   419     if ( FindBox() && iListBox->Model()->NumberOfItems() == 0 )
   417     if ( FindBox() && iListBox->Model()->NumberOfItems() == 0 )
   420         {
   418         {
   421         STATIC_CAST(CAknFilteredTextListBoxModel*,
   419         STATIC_CAST(CAknFilteredTextListBoxModel*,
   422                     ListBox()->Model())->Filter()->SetSearchField( NULL );
   420                     ListBox()->Model())->Filter()->SetSearchField( NULL );
   423         FindBox()->Editor().SetFocus( EFalse );                    
   421         FindBox()->Editor().SetFocus( EFalse );                    
       
   422         __ASSERT_DEBUG( iPopupListExtension, Panic( EAknPanicNullPointer ) );
   424         delete iPopupListExtension->iSearchControl;
   423         delete iPopupListExtension->iSearchControl;
   425         iPopupListExtension->iSearchControl = NULL;
   424         iPopupListExtension->iSearchControl = NULL;
   426         }
   425         }
   427 
   426 
   428     if (FindBox())
   427     if (FindBox())
   668 */
   667 */
   669 EXPORT_C void CAknPopupList::ProcessCommandL(TInt aCommandId)
   668 EXPORT_C void CAknPopupList::ProcessCommandL(TInt aCommandId)
   670     {
   669     {
   671     _AKNTRACE_FUNC_ENTER;
   670     _AKNTRACE_FUNC_ENTER;
   672     _AKNTRACE("ProcessCommandL: aCommandId=%d", aCommandId);
   671     _AKNTRACE("ProcessCommandL: aCommandId=%d", aCommandId);
       
   672 	__ASSERT_DEBUG( iPopupListExtension, Panic( EAknPanicNullPointer ) );
   673     // Respond to softkey events
   673     // Respond to softkey events
   674     switch (aCommandId)
   674     switch (aCommandId)
   675         {
   675         {
   676         case EAknSoftkeySelect:
   676         case EAknSoftkeySelect:
   677         case EAknSoftkeyYes:
   677         case EAknSoftkeyYes:
   727 * @param        aEventType        Event observed
   727 * @param        aEventType        Event observed
   728 */
   728 */
   729 EXPORT_C void CAknPopupList::HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType)
   729 EXPORT_C void CAknPopupList::HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType)
   730     {
   730     {
   731     _AKNTRACE_FUNC_ENTER;
   731     _AKNTRACE_FUNC_ENTER;
       
   732 	__ASSERT_DEBUG( iPopupListExtension, Panic( EAknPanicNullPointer ) );
   732     // Respond to events from listbox
   733     // Respond to events from listbox
   733     if (aListBox == iListBox)
   734     if (aListBox == iListBox)
   734         {
   735         {
   735         // if left softkey is empty, we do not handle enter key either.
   736         // if left softkey is empty, we do not handle enter key either.
   736         if (iPopoutCba && iPopoutCba->ButtonGroup())
   737         if (iPopoutCba && iPopoutCba->ButtonGroup())
   816 * @param        aAccept        ETrue if the user accepted. EFalse if the user cancelled.
   817 * @param        aAccept        ETrue if the user accepted. EFalse if the user cancelled.
   817 */
   818 */
   818 EXPORT_C void CAknPopupList::AttemptExitL(TBool aAccept)
   819 EXPORT_C void CAknPopupList::AttemptExitL(TBool aAccept)
   819     {
   820     {
   820     _AKNTRACE_FUNC_ENTER;
   821     _AKNTRACE_FUNC_ENTER;
   821     if ( AknLayoutUtils::PenEnabled() )
   822 	__ASSERT_DEBUG( iPopupListExtension, Panic( EAknPanicNullPointer ) );
   822         {
       
   823         MTouchFeedback* feedback = MTouchFeedback::Instance();
       
   824         if ( feedback )
       
   825             {
       
   826             TTouchLogicalFeedback fbLogicalType = ETouchFeedbackPopUp;
       
   827             if ( CAknTransitionUtils::TransitionsEnabled(
       
   828                     AknTransEffect::EComponentTransitionsOff ) )
       
   829                 {
       
   830                 fbLogicalType = ETouchFeedbackDecreasingPopUp;
       
   831                 }
       
   832             feedback->InstantFeedback(
       
   833                                    this,
       
   834                                    fbLogicalType,
       
   835                                    ETouchFeedbackVibra,
       
   836                                    TPointerEvent() );
       
   837             }
       
   838         }
       
   839     //EFTG-7HWDP6.
   823     //EFTG-7HWDP6.
   840     if( FindBox()
   824     if( FindBox()
   841         && !( FindBox()->Editor().AknEdwinFlags() & EAknEditorFlagTouchInputModeOpened )
   825         && !( FindBox()->Editor().AknEdwinFlags() & EAknEditorFlagTouchInputModeOpened )
   842         && ( iPopupListExtension->iFlags & EPopupLayoutSwitchEvent ) )
   826         && ( iPopupListExtension->iFlags & EPopupLayoutSwitchEvent ) )
   843         {
   827         {
   858             iPopupListExtension->iFlags |= EPopupCancelAfterPointerEvent;
   842             iPopupListExtension->iFlags |= EPopupCancelAfterPointerEvent;
   859             }
   843             }
   860         }
   844         }
   861     else if( !(iPopupListExtension->iFlags & EPopupFepStartEvent) )
   845     else if( !(iPopupListExtension->iFlags & EPopupFepStartEvent) )
   862         {  
   846         {  
       
   847         if ( AknLayoutUtils::PenEnabled() )
       
   848             {
       
   849             MTouchFeedback* feedback = MTouchFeedback::Instance();
       
   850             if ( feedback )
       
   851                 {
       
   852                 TTouchLogicalFeedback fbLogicalType = ETouchFeedbackPopUp;
       
   853                 if ( CAknTransitionUtils::TransitionsEnabled(
       
   854                         AknTransEffect::EComponentTransitionsOff ) )
       
   855                     {
       
   856                     fbLogicalType = ETouchFeedbackDecreasingPopUp;
       
   857                     }
       
   858                 feedback->InstantFeedback(
       
   859                                        this,
       
   860                                        fbLogicalType,
       
   861                                        ETouchFeedbackVibra,
       
   862                                        TPointerEvent() );
       
   863                 }
       
   864             }
   863 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS
   865 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS
   864         // no transition if accepted
   866         // no transition if accepted
   865         if( IsVisible() && GfxTransEffect::IsRegistered(this) && !aAccept )
   867         if( IsVisible() && GfxTransEffect::IsRegistered(this) && !aAccept )
   866             {
   868             {
   867             //If still visible, do a transition to invisible state.
   869             //If still visible, do a transition to invisible state.
   947     TRect outerRect(topLeft.Rect().iTl, bottomRight.Rect().iBr);
   949     TRect outerRect(topLeft.Rect().iTl, bottomRight.Rect().iBr);
   948     TRect innerRect(topLeft.Rect().iBr, bottomRight.Rect().iTl);
   950     TRect innerRect(topLeft.Rect().iBr, bottomRight.Rect().iTl);
   949     
   951     
   950     TInt softkeyHeight( KSoftkeyHeightUndefined );
   952     TInt softkeyHeight( KSoftkeyHeightUndefined );
   951 
   953 
       
   954 	__ASSERT_DEBUG( iPopupListExtension, Panic( EAknPanicNullPointer ) ); 
   952     if (!iPopupListExtension->iBgContext)
   955     if (!iPopupListExtension->iBgContext)
   953         {
   956         {
   954         TRAP_IGNORE( iPopupListExtension->iBgContext = CAknsFrameBackgroundControlContext::NewL(
   957         TRAP_IGNORE( iPopupListExtension->iBgContext = CAknsFrameBackgroundControlContext::NewL(
   955             KAknsIIDQsnFrPopup, outerRect, innerRect, ETrue ) );
   958             KAknsIIDQsnFrPopup, outerRect, innerRect, ETrue ) );
   956         iPopupListExtension->iBgContext->SetParentPos( PositionRelativeToScreen() );
   959         iPopupListExtension->iBgContext->SetParentPos( PositionRelativeToScreen() );
  1113         {
  1116         {
  1114         return aId.MakePtr(this);
  1117         return aId.MakePtr(this);
  1115         }
  1118         }
  1116     if (aId.iUid == MAknsControlContext::ETypeId)
  1119     if (aId.iUid == MAknsControlContext::ETypeId)
  1117         {
  1120         {
  1118         if (iPopupListExtension && iPopupListExtension->iBgContext)
  1121     	__ASSERT_DEBUG( iPopupListExtension, Panic( EAknPanicNullPointer ) );
       
  1122         if (iPopupListExtension->iBgContext)
  1119             {
  1123             {
  1120             return MAknsControlContext::SupplyMopObject(aId, iPopupListExtension->iBgContext);
  1124             return MAknsControlContext::SupplyMopObject(aId, iPopupListExtension->iBgContext);
  1121             }
  1125             }
  1122         else if ( iListBox && 
  1126         else if ( iListBox && 
  1123                   iListBox->View() &&
  1127                   iListBox->View() &&
  1167     _AKNTRACE("HandlePointerEventL: aPointerEvent.iPosition=(%d,%d)", 
  1171     _AKNTRACE("HandlePointerEventL: aPointerEvent.iPosition=(%d,%d)", 
  1168             aPointerEvent.iPosition.iX, aPointerEvent.iPosition.iY);
  1172             aPointerEvent.iPosition.iX, aPointerEvent.iPosition.iY);
  1169     
  1173     
  1170     if ( AknLayoutUtils::PenEnabled() )
  1174     if ( AknLayoutUtils::PenEnabled() )
  1171         {
  1175         {
       
  1176     	__ASSERT_DEBUG( iPopupListExtension, Panic( EAknPanicNullPointer ) );
  1172         iPopupListExtension->iFlags |= EPopupHandlingPointerEvent;
  1177         iPopupListExtension->iFlags |= EPopupHandlingPointerEvent;
  1173 
  1178 
  1174         TInt index;
  1179         TInt index;
  1175         TBool pointerOnItem = iListBox->View()->XYPosToItemIndex( aPointerEvent.iPosition, index );
  1180         TBool pointerOnItem = iListBox->View()->XYPosToItemIndex( aPointerEvent.iPosition, index );
  1176         if ( aPointerEvent.iType == TPointerEvent::EButton1Down
  1181         if ( aPointerEvent.iType == TPointerEvent::EButton1Down
  1239     return NULL;
  1244     return NULL;
  1240     }
  1245     }
  1241     
  1246     
  1242 EXPORT_C TBool CAknPopupList::EnableFind(TBool /*aEnable*/)
  1247 EXPORT_C TBool CAknPopupList::EnableFind(TBool /*aEnable*/)
  1243     {
  1248     {
  1244     if (!iPopupListExtension)
  1249 	__ASSERT_DEBUG( iPopupListExtension, Panic( EAknPanicNullPointer ) );    
  1245         return EFalse; // no extension class, failed
       
  1246     if (!iPopupListExtension->iSearchControl)
  1250     if (!iPopupListExtension->iSearchControl)
  1247         {
  1251         {
  1248         CAknSearchField::TSearchFieldStyle flags = CAknSearchField::EPopupWindow;
  1252         CAknSearchField::TSearchFieldStyle flags = CAknSearchField::EPopupWindow;
  1249         TRAPD(err,
  1253         TRAPD(err,
  1250               iPopupListExtension->iSearchControl = CAknSearchField::NewL( *this, flags, 0, 40 );
  1254               iPopupListExtension->iSearchControl = CAknSearchField::NewL( *this, flags, 0, 40 );
  1272     return ETrue;
  1276     return ETrue;
  1273     }
  1277     }
  1274     
  1278     
  1275 EXPORT_C TBool CAknPopupList::EnableAdaptiveFind(TBool /*aEnable*/)
  1279 EXPORT_C TBool CAknPopupList::EnableAdaptiveFind(TBool /*aEnable*/)
  1276     {
  1280     {
  1277     if (!iPopupListExtension)
  1281 	__ASSERT_DEBUG( iPopupListExtension, Panic( EAknPanicNullPointer ) );    
  1278         return EFalse; // no extension class, failed
       
  1279     if (!iPopupListExtension->iSearchControl)
  1282     if (!iPopupListExtension->iSearchControl)
  1280         {
  1283         {
  1281         CAknSearchField::TSearchFieldStyle flags = CAknSearchField::EPopupAdaptiveSearchWindow;
  1284         CAknSearchField::TSearchFieldStyle flags = CAknSearchField::EPopupAdaptiveSearchWindow;
  1282         TRAPD(err,
  1285         TRAPD(err,
  1283               iPopupListExtension->iSearchControl = CAknSearchField::NewL( *this, flags, 0, 40 );
  1286               iPopupListExtension->iSearchControl = CAknSearchField::NewL( *this, flags, 0, 40 );
  1306     }    
  1309     }    
  1307     
  1310     
  1308 
  1311 
  1309 EXPORT_C CAknSearchField* CAknPopupList::FindBox() const
  1312 EXPORT_C CAknSearchField* CAknPopupList::FindBox() const
  1310     {
  1313     {
  1311     if (iPopupListExtension)
  1314 	__ASSERT_DEBUG( iPopupListExtension, Panic( EAknPanicNullPointer ) );    
  1312         return iPopupListExtension->iSearchControl;
  1315     return iPopupListExtension->iSearchControl;
  1313     return NULL;
       
  1314     }
  1316     }
  1315 
  1317 
  1316 void CAknPopupList::RemoveFindFiltering()
  1318 void CAknPopupList::RemoveFindFiltering()
  1317     {
  1319     {
  1318     if (FindBox())
  1320     if (FindBox())
  1329 EXPORT_C void CAknPopupList::HandleResourceChange(TInt aType)
  1331 EXPORT_C void CAknPopupList::HandleResourceChange(TInt aType)
  1330     {
  1332     {
  1331     _AKNTRACE_FUNC_ENTER;
  1333     _AKNTRACE_FUNC_ENTER;
  1332     if( aType == KEikDynamicLayoutVariantSwitch )
  1334     if( aType == KEikDynamicLayoutVariantSwitch )
  1333         {
  1335         {
  1334         
  1336     	__ASSERT_DEBUG( iPopupListExtension, Panic( EAknPanicNullPointer ) );
  1335         //EFTG-7HWDP6. 
  1337         //EFTG-7HWDP6. 
  1336         //Tapping Edit'area can arouse the CAknPopupList::HandleResourceChange()
  1338         //Tapping Edit'area can arouse the CAknPopupList::HandleResourceChange()
  1337         //when portrait is initial model, and 'Full screen QWERTY keyboard' is default input method.
  1339         //when portrait is initial model, and 'Full screen QWERTY keyboard' is default input method.
  1338         //Just then, EPopupLayoutSwitchEvent will be setted once.
  1340         //Just then, EPopupLayoutSwitchEvent will be setted once.
  1339         if( ( iPopupListExtension->iFlags & EPopupFepStartEvent ) && 
  1341         if( ( iPopupListExtension->iFlags & EPopupFepStartEvent ) &&