javauis/lcdui_akn/lcdui/src/CMIDCustomItem.cpp
branchRCL_3
changeset 83 26b2b12093af
parent 77 7cee158cb8cd
equal deleted inserted replaced
77:7cee158cb8cd 83:26b2b12093af
    74     CleanupStack::Pop(item);
    74     CleanupStack::Pop(item);
    75     return item;
    75     return item;
    76 }
    76 }
    77 
    77 
    78 CMIDCustomItem::CMIDCustomItem(MMIDEnv& aEnv, CMIDUIManager* aUIManager)
    78 CMIDCustomItem::CMIDCustomItem(MMIDEnv& aEnv, CMIDUIManager* aUIManager)
    79     : CMIDControlItem(EDefault, aUIManager)
    79         : CMIDControlItem(EDefault, aUIManager)
    80     , iEntered(EFalse)
    80         , iEntered(EFalse)
    81     , iSupportsInternalTraversal(ETrue)
    81         , iSupportsInternalTraversal(ETrue)
    82     , iEnv(aEnv)
    82         , iEnv(aEnv)
    83     , iResetFrameBuffer(ETrue)
    83         , iResetFrameBuffer(ETrue)
    84     , iDirectAreaAddedToDisplayable(EFalse)
    84         , iDirectAreaAddedToDisplayable(EFalse)
    85     , iS60SelectionKeyCompatibility(EFalse)
    85         , iS60SelectionKeyCompatibility(EFalse)
    86 #ifndef RD_JAVA_NGA_ENABLED
    86 #ifndef RD_JAVA_NGA_ENABLED
    87     , iDirectPaused(ETrue)
    87         , iDirectPaused(ETrue)
    88 #endif
    88 #endif
    89     , iRestoreDirectContentWhenUnfaded(EFalse)
    89         , iRestoreDirectContentWhenUnfaded(EFalse)
    90     , iPreviousVisibility(EFalse)
    90         , iPreviousVisibility(EFalse)
    91     , iConsumerWaitingForDSAResourcesCallback(NULL)
    91         , iConsumerWaitingForDSAResourcesCallback(NULL)
    92     , iUiFixed(EFalse)
    92         , iUiFixed(EFalse)
    93     , iUiToBeFixedLater(EFalse)
    93         , iUiToBeFixedLater(EFalse)
    94 {
    94 {
    95     iMMidItem = this;
    95     iMMidItem = this;
    96 
    96 
    97     //Default values for PointerEventSuppressor
    97     //Default values for PointerEventSuppressor
    98     iPESPointerMovementInTwips = CMIDUIManager::EPESPointerMovementInTwips;
    98     iPESPointerMovementInTwips = CMIDUIManager::EPESPointerMovementInTwips;
   257     DEBUG("< CMIDCustomItem::~CMIDCustomItem");
   257     DEBUG("< CMIDCustomItem::~CMIDCustomItem");
   258     if (iDirectContent)
   258     if (iDirectContent)
   259     {
   259     {
   260         iDirectContent->MdcContainerDestroyed();
   260         iDirectContent->MdcContainerDestroyed();
   261     }
   261     }
   262 
   262     
   263     if (iUiFixed && iForm)
   263     if (iUiFixed && iForm)
   264     {
   264     {
   265         iForm->CurrentDisplayable().ReleaseOrientation();
   265         iForm->CurrentDisplayable().ReleaseOrientation();
   266         iUiFixed = EFalse;
   266         iUiFixed = EFalse;
   267     }
   267     }
   465     DEBUG_INT2("+ CMIDCustomItem::SetPreferredSizeL - requested size = ( %d x %d )", aSize.iWidth, aSize.iHeight);
   465     DEBUG_INT2("+ CMIDCustomItem::SetPreferredSizeL - requested size = ( %d x %d )", aSize.iWidth, aSize.iHeight);
   466 
   466 
   467     iRequestedPreferredSize = CheckRequestedSize(aSize);
   467     iRequestedPreferredSize = CheckRequestedSize(aSize);
   468 
   468 
   469     if (iRequestedPreferredSize.iWidth == -1)
   469     if (iRequestedPreferredSize.iWidth == -1)
   470     {
   470     { // Width is not locked
   471         // Width is not locked
       
   472         iPreferredSize.iWidth = Min(FormClientAreaWidth(),
   471         iPreferredSize.iWidth = Min(FormClientAreaWidth(),
   473                                     PreferredContentSize().iWidth + iContentMargins.iLeft + iContentMargins.iRight);
   472                                     PreferredContentSize().iWidth + iContentMargins.iLeft + iContentMargins.iRight);
   474     }
   473     }
   475     else
   474     else
   476     {
   475     {
   483         iLabelControl->SetWidthL(iPreferredSize.iWidth);
   482         iLabelControl->SetWidthL(iPreferredSize.iWidth);
   484     }
   483     }
   485 
   484 
   486 
   485 
   487     if (iRequestedPreferredSize.iHeight == -1)
   486     if (iRequestedPreferredSize.iHeight == -1)
   488     {
   487     { // Height is not locked
   489         // Height is not locked
       
   490         iPreferredSize.iHeight = PreferredContentSize().iHeight + iContentMargins.iTop
   488         iPreferredSize.iHeight = PreferredContentSize().iHeight + iContentMargins.iTop
   491                                  + iContentMargins.iBottom + LabelHeight();
   489                                  + iContentMargins.iBottom + LabelHeight();
   492     }
   490     }
   493     else
   491     else
   494     {
   492     {
   513     DEBUG_INT("+ CMIDCustomItem::AdjustToSizeL - available height = %d", availableHeight);
   511     DEBUG_INT("+ CMIDCustomItem::AdjustToSizeL - available height = %d", availableHeight);
   514     TInt requestedHeight = PreferredContentSize().iHeight + LabelHeight();
   512     TInt requestedHeight = PreferredContentSize().iHeight + LabelHeight();
   515     DEBUG_INT("+ CMIDCustomItem::AdjustToSizeL - requested height = %d", requestedHeight);
   513     DEBUG_INT("+ CMIDCustomItem::AdjustToSizeL - requested height = %d", requestedHeight);
   516 
   514 
   517     if (requestedHeight > availableHeight)
   515     if (requestedHeight > availableHeight)
   518     {
   516     {// label + control do not fit
   519         // label + control do not fit
       
   520         if (iLabelControl && iLabelControl->Text()->Length() > 0)
   517         if (iLabelControl && iLabelControl->Text()->Length() > 0)
   521         {
   518         {
   522             //reserve one line to the control
   519             //reserve one line to the control
   523             TInt heightForLabel =
   520             TInt heightForLabel =
   524                 ((availableHeight - PreferredContentSize().iHeight) > OneLineLabelHeight()) ?
   521                 ((availableHeight - PreferredContentSize().iHeight) > OneLineLabelHeight()) ?
  1348 
  1345 
  1349     if (iPreviousVisibility)
  1346     if (iPreviousVisibility)
  1350     {
  1347     {
  1351         ChangeDirectContainerVisibility(ETrue);
  1348         ChangeDirectContainerVisibility(ETrue);
  1352     }
  1349     }
  1353 
  1350     
  1354     if (iUiToBeFixedLater && iForm)
  1351     if (iUiToBeFixedLater && iForm)
  1355     {
  1352     {
  1356         iForm->CurrentDisplayable().FixOrientation();
  1353         iForm->CurrentDisplayable().FixOrientation();
  1357         iUiFixed = ETrue;
  1354         iUiFixed = ETrue;
  1358         iUiToBeFixedLater = EFalse;
  1355         iUiToBeFixedLater = EFalse;
  1561 
  1558 
  1562 // ---------------------------------------------------------------------------
  1559 // ---------------------------------------------------------------------------
  1563 // From class MDirectContainer.
  1560 // From class MDirectContainer.
  1564 // CMIDCustomItem::MdcFixUIOrientation(TBool aEnableFix)
  1561 // CMIDCustomItem::MdcFixUIOrientation(TBool aEnableFix)
  1565 // ---------------------------------------------------------------------------
  1562 // ---------------------------------------------------------------------------
  1566 //
  1563 // 
  1567 
  1564 
  1568 void CMIDCustomItem::MdcFixUIOrientation(TBool aEnableFix)
  1565 void CMIDCustomItem::MdcFixUIOrientation(TBool aEnableFix)
  1569 {
  1566 {
  1570     if (aEnableFix)
  1567     if (aEnableFix)
  1571     {
  1568     {
  1572         iEnv.ToLcduiObserver().InvokeLcduiEvent(*this, EFixUIOrientation);
  1569         iEnv.ToLcduiObserver().InvokeLcduiEvent(*this, EFixUIOrientation);
  1573     }
  1570     }
  1574     else
  1571     else
  1575     {
  1572     {
  1576         iEnv.ToLcduiObserver().InvokeLcduiEvent(*this, EUnFixUIOrientation);
  1573         iEnv.ToLcduiObserver().InvokeLcduiEvent(*this, EUnFixUIOrientation);
  1577     }
  1574     }     
  1578 }
  1575 }
  1579 
  1576 
  1580 void CMIDCustomItem::HandleLcduiEvent(int aType)
  1577 void CMIDCustomItem::HandleLcduiEvent(int aType)
  1581 {
  1578 {
  1582     switch (aType)
  1579    switch (aType)
  1583     {
  1580    {
  1584     case EFixUIOrientation:
  1581        case EFixUIOrientation:
  1585         if (!iUiFixed)
  1582            if (!iUiFixed)
  1586         {
  1583            {
  1587             if (iForm)
  1584                if (iForm)
  1588             {
  1585                {
  1589                 iForm->CurrentDisplayable().FixOrientation();
  1586                    iForm->CurrentDisplayable().FixOrientation();
  1590                 iUiFixed = ETrue;
  1587                    iUiFixed = ETrue;
  1591                 iUiToBeFixedLater = EFalse;
  1588                    iUiToBeFixedLater = EFalse;
  1592             }
  1589                }
  1593             else
  1590                else
  1594             {
  1591                {
  1595                 iUiToBeFixedLater = ETrue;
  1592                    iUiToBeFixedLater = ETrue;
  1596             }
  1593                }
  1597         }
  1594            }
  1598         break;
  1595            break;
  1599     case EUnFixUIOrientation:
  1596        case EUnFixUIOrientation:
  1600         if (iForm && iUiFixed)
  1597            if (iForm && iUiFixed)
  1601         {
  1598            {
  1602             iForm->CurrentDisplayable().ReleaseOrientation();
  1599                iForm->CurrentDisplayable().ReleaseOrientation();
  1603             iUiFixed = EFalse;
  1600                iUiFixed = EFalse;
  1604             iUiToBeFixedLater = EFalse;
  1601                iUiToBeFixedLater = EFalse;
  1605         }
  1602            }
  1606         break;
  1603            break;    
  1607     }
  1604     }
  1608 }
  1605 }
  1609 //
  1606 //
  1610 // ---------------------------------------------------------------------------
  1607 // ---------------------------------------------------------------------------
  1611 //
  1608 //
  1612 void CMIDCustomItem::MdcAddMMAPIContentBounds(const TRect& /*aRect*/)
  1609 void CMIDCustomItem::MdcAddContentBounds(const TRect& /*aRect*/)
  1613 {
  1610 {
  1614     iDirectAreaAddedToDisplayable = UpdateDirectContentBounds();
  1611     iDirectAreaAddedToDisplayable = UpdateDirectContentBounds();
  1615 }
  1612 }
  1616 
  1613 
  1617 // ---------------------------------------------------------------------------
  1614 // ---------------------------------------------------------------------------
  1618 //
  1615 //
  1619 // ---------------------------------------------------------------------------
  1616 // ---------------------------------------------------------------------------
  1620 //
  1617 //
  1621 void CMIDCustomItem::MdcRemoveMMAPIContentBounds(const TRect& /*aRect*/)
  1618 void CMIDCustomItem::MdcRemoveContentBounds(const TRect& /*aRect*/)
  1622 {
  1619 {
  1623     if (iForm && iDirectAreaAddedToDisplayable)
  1620     if (iForm && iDirectAreaAddedToDisplayable)
  1624     {
  1621     {
  1625         // Remove clipping rect
  1622         // Remove clipping rect
  1626         Form()->CurrentDisplayable().RemoveDirectContentArea(iDirectArea);
  1623         Form()->CurrentDisplayable().RemoveDirectContentArea(iDirectArea);