Esempio n. 1
0
void CProfileListDialog::PreLayoutDynInitL() {
    ButtonGroupContainer().SetDefaultCommand(ECmdProfileListConnect);

    iProfileArray = new (ELeave) CDesCArrayFlat(8);

    // Add default as the first profile
    iProfileArray->AppendL(KDefaultProfileName);

    // Find all profile files from the profile directory and add them to the
    // list    
    RFs &fs = CEikonEnv::Static()->FsSession();
    CDir *dir;
    User::LeaveIfError(fs.GetDir(iProfileDirectory, KEntryAttNormal,
                                 ESortByName, dir));
    CleanupStack::PushL(dir);
    for ( TInt i = 0; i < dir->Count(); i++ ) {
        iProfileArray->AppendL((*dir)[i].iName);
    }
    CleanupStack::PopAndDestroy(); //dir

    // Set profiles to the listbox
    CEikTextListBox *lbox = ((CEikTextListBox*)Control(EProfileListDlgProfileList));
    CTextListBoxModel *lbm = lbox->Model();
    lbm->SetItemTextArray(iProfileArray);
    lbm->SetOwnershipType(ELbmDoesNotOwnItemArray);

    // Enable scroll bars
    CEikScrollBarFrame *sbf = lbox->CreateScrollBarFrameL(ETrue);
    sbf->SetScrollBarVisibilityL(CEikScrollBarFrame::EAuto,
                                 CEikScrollBarFrame::EAuto);

    ButtonGroupContainer().SetDefaultCommand(ECmdProfileListConnect);
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//
void CMnrpNaviControl::CreateListBoxL()
    {
    // Create a control to display a list of descriptors
    iListBox = new (ELeave) CAknSingleHeadingStyleListBox();
    iListBox->SetContainerWindowL( *this );
    iListBox->ConstructL(this, CEikListBox::EViewerFlag );

    // Create scrollbars
    CEikScrollBarFrame* scrollBar = iListBox->CreateScrollBarFrameL();
    scrollBar->SetScrollBarVisibilityL(
                CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
    }
Esempio n. 3
0
EXPORT_C void CEikScrollBarFrame::CreateDoubleSpanScrollBarsL(TBool aWindowOwning, TBool aRemote, TBool aVertical, TBool aHorizontal)
    {
    if (!TAknDoubleSpanScrollBarModel::ModelIsSupported())
        {
        return;
        }

    // This method should not delete the old scrollbars before it is sure that new 
    // one has been succesfully created. Create a temp variable here.
    SBarData newVerticalScrollBar;
    newVerticalScrollBar.iBar = NULL;
    newVerticalScrollBar.iExternalScrollBarAttached = EFalse;
    newVerticalScrollBar.iVisibility = iV.iVisibility;

    SBarData newHorizontalScrollBar;
    newHorizontalScrollBar.iBar = NULL;
    newHorizontalScrollBar.iExternalScrollBarAttached = EFalse;
    if (iExtension)
        newHorizontalScrollBar.iVisibility = iExtension->iH.iVisibility;

    if (aRemote && iExtension && iExtension->iParentWindow)
        {
        // try getting scrollbarframe from parent using mop supply mechanism
        CEikScrollBarFrame* sbf = iExtension->iParentWindow->MopGetObject(sbf);
        if (sbf)
            {
            newVerticalScrollBar.iBar = sbf->VerticalScrollBar();
            newVerticalScrollBar.iExternalScrollBarAttached = ETrue;
            
            newHorizontalScrollBar.iBar = sbf->HorizontalScrollBar();
            newHorizontalScrollBar.iExternalScrollBarAttached = ETrue;
            
            TInt err1 = KErrNone;
            TInt err2 = KErrNone;
            if (newVerticalScrollBar.iBar)
                {
                TRAP(err1, newVerticalScrollBar.iBar->AddExternalFrameL(this));
                }

            if (newHorizontalScrollBar.iBar)
                {
                TRAP(err2, newHorizontalScrollBar.iBar->AddExternalFrameL(this));
                }
            
            if (err1 || err2)
	            {
	            newVerticalScrollBar.iExternalScrollBarAttached = EFalse;
	            newVerticalScrollBar.iBar = NULL;
	            newHorizontalScrollBar.iExternalScrollBarAttached = EFalse;
	            newHorizontalScrollBar.iBar = NULL;
	            }

            User::LeaveIfError(err1);
            User::LeaveIfError(err2);

            if (TypeOfVScrollBar() == EDoubleSpan)
                {
                if( AknLayoutUtils::PenEnabled() )
                    {
	    			// Correction. Giving null reference as parameter screws up the model values
                    newVerticalScrollBar.iModel = TAknDoubleSpanScrollBarModel();
                    }
                else
                    {
                    newVerticalScrollBar.iModel = TAknDoubleSpanScrollBarModel(0);
                    }
                }

            if (TypeOfHScrollBar() == EDoubleSpan)
                {
                if( AknLayoutUtils::PenEnabled() )
                    {
                    // Correction. Giving null reference as parameter screws up the model values
                    newHorizontalScrollBar.iModel = TAknDoubleSpanScrollBarModel();
                    }
                else
                    {
                    newHorizontalScrollBar.iModel = TAknDoubleSpanScrollBarModel(0);
                    }
                }

            }
        else
            {
            User::Leave(KErrNotFound);
            }
        }
    else
        {
        // Create new vertical AknDoubleSpanScrollBar
        newVerticalScrollBar.iBar = 0;
        newVerticalScrollBar.iExternalScrollBarAttached=EFalse;
        
        CAknDoubleSpanScrollBar* verticalScrollBar = NULL;

        MEikScrollBarObserver* observer = NULL;

        if(AknLayoutUtils::PenEnabled())
            {
            if(iExtension)
                {
                observer = iExtension->iScrollBarObserver;
                }
            }

        TInt scrollBarFlags = 
            ( ( iScrollBarFrameFlags & EEnableNudgeButtons ) ? 
                CEikScrollBar::EEnableNudgeButtons : 0 ) |
            ( ( iScrollBarFrameFlags & EDisableExpandedTouchArea ) ? 
                CEikScrollBar::EDisableExpandedTouchArea : 0 );
                
        if (aVertical)
            {
            verticalScrollBar = new(ELeave) CAknDoubleSpanScrollBar(ParentWindow());            
            CleanupStack::PushL(verticalScrollBar);
            verticalScrollBar->ConstructL(
                aWindowOwning, observer ,ParentWindow(),
                CAknScrollBar::EVertical,
                KLongEnoughToCauseComponentsToBeCreated,
                scrollBarFlags );
            CleanupStack::Pop(); // verticalScrollBar
            }
        newVerticalScrollBar.iBar = verticalScrollBar;
        if( AknLayoutUtils::PenEnabled() )
            {
            // Correction. Giving null reference as parameter screws up the model values
            newVerticalScrollBar.iModel = TAknDoubleSpanScrollBarModel();
            }
        else
            {
            newVerticalScrollBar.iModel = TAknDoubleSpanScrollBarModel(0);
            }

        // Create new horizontal AknDoubleSpanScrollBar
        newHorizontalScrollBar.iBar = 0;
        newHorizontalScrollBar.iExternalScrollBarAttached=EFalse;
        CAknDoubleSpanScrollBar* horizontalScrollBar = NULL;
       
        if (aHorizontal)
            {
            horizontalScrollBar = new(ELeave) CAknDoubleSpanScrollBar(ParentWindow());
            CleanupStack::PushL(horizontalScrollBar);
            horizontalScrollBar->ConstructL(
                aWindowOwning, observer ,ParentWindow(),
                CAknScrollBar::EHorizontal,
                KLongEnoughToCauseComponentsToBeCreated,
                scrollBarFlags );
            CleanupStack::Pop(); // horizontalScrollBar
            }
        newHorizontalScrollBar.iBar = horizontalScrollBar;        
        if( AknLayoutUtils::PenEnabled() )
            {
            // Correction. Giving null reference as parameter screws up the model values
            newHorizontalScrollBar.iModel = TAknDoubleSpanScrollBarModel();
            }
        else
            {
            newHorizontalScrollBar.iModel = TAknDoubleSpanScrollBarModel(0);
            }
        }

    TBool oldVerticalScrollbarExists = EFalse;
    TBool oldHorizontalScrollbarExists = EFalse;

    if (iV.iBar)
        oldVerticalScrollbarExists = ETrue;

    if (iExtension && iExtension->iH.iBar)
        oldHorizontalScrollbarExists = ETrue;

    
    if (oldVerticalScrollbarExists || oldHorizontalScrollbarExists)
        {
        // Remove old scroll bar
        DeleteScrollBars();
        }
    
    iV = newVerticalScrollBar;
    
    if (iExtension)
        iExtension->iH = newHorizontalScrollBar;

    }
EXPORT_C void AknPopupLayouts::HandleDraw(CEikonEnv* /*aEikEnv*/,
                  CWindowGc &aGc,
                  const TAknPopupWindowLayoutDef &aDef, 
                  CEikListBox* aListBox, 
                  CAknPopupHeadingPane* aHeading)
    {
    TRect windowRect = MenuRect(const_cast<TAknPopupWindowLayoutDef&>(aDef));
    MAknsSkinInstance *skin = AknsUtils::SkinInstance();
    MAknsControlContext *cc = AknsDrawUtils::ControlContext( aListBox );
    TBool windowFrameDrawn = EFalse;
    if (!cc) cc = aListBox->View()->ItemDrawer()->SkinBackgroundControlContext();
    
    TRegionFix<5> dontDrawRegion;
    TRegionFix<22> drawRegion;
    if ( aListBox )
        {
        dontDrawRegion.AddRect( aListBox->Rect() );

        // If there are scroll bars and they draw their own background, take
        // them out of clipping region
        CEikScrollBarFrame* scrollBarFrame = aListBox->ScrollBarFrame();
        if (scrollBarFrame)
            {
            CEikScrollBar* hBar = scrollBarFrame->GetScrollBarHandle(
                CEikScrollBar::EHorizontal);
            CEikScrollBar* vBar = scrollBarFrame->GetScrollBarHandle(
                CEikScrollBar::EVertical);
            TBool drawHorizontal = ETrue;
            TBool drawVertical = ETrue;
            scrollBarFrame->DrawBackgroundState(drawHorizontal, drawVertical);
            drawHorizontal = drawHorizontal && hBar && hBar->IsVisible();
            drawVertical = drawVertical && vBar && vBar->IsVisible();
            if (drawHorizontal)
                {
                TRect scrollBarRect(hBar->Rect());
                if (hBar->OwnsWindow())
                    {
                    TPoint windowPos = aDef.iWindowRect.iTl;
                    TPoint scrollBarPos = hBar->PositionRelativeToScreen();
                    scrollBarRect.Move(scrollBarPos - windowPos);
                    }
                dontDrawRegion.AddRect(scrollBarRect);
                }
            if (drawVertical)
                {
                TRect scrollBarRect(vBar->Rect());
                if (vBar->OwnsWindow())
                    {
                    TPoint windowPos = aDef.iWindowRect.iTl;
                    TPoint scrollBarPos = vBar->PositionRelativeToScreen();
                    scrollBarRect.Move(scrollBarPos - windowPos);
                    }
                dontDrawRegion.AddRect(scrollBarRect);
                }
            }
        }
    if ( aHeading )
        {
        dontDrawRegion.AddRect( aHeading->Rect() );
        }
    drawRegion.AddRect( windowRect );
    drawRegion.SubRegion( dontDrawRegion );
    if (cc)
        {
        const TAknsItemID *popupBgId = &KAknsIIDQsnBgPopupBackground;
        TAknLayoutRect popupBgRect;
        popupBgRect.LayoutRect(windowRect, SkinLayout::Popup_windows_skin_placing__background_slice__Line_1(windowRect));
        AknsDrawUtils::DrawCachedImage(skin, aGc, popupBgRect.Rect(), *popupBgId);

        const TAknsItemID *sliceId = &KAknsIIDQsnBgSlicePopup;
        TAknLayoutRect sliceRect;
        sliceRect.LayoutRect(windowRect, SkinLayout::Popup_windows_skin_placing__background_slice__Line_2());
        AknsDrawUtils::DrawCachedImage(skin, aGc, sliceRect.Rect(), *sliceId);
            
        TAknLayoutRect topLeft;
        topLeft.LayoutRect(windowRect, SkinLayout::Popup_windows_skin_placing__frame_general__Line_2());

        TAknLayoutRect bottomRight;
        bottomRight.LayoutRect(windowRect, SkinLayout::Popup_windows_skin_placing__frame_general__Line_5());

        TRect outerRect = TRect(topLeft.Rect().iTl, bottomRight.Rect().iBr);
        TRect innerRect = TRect(topLeft.Rect().iBr, bottomRight.Rect().iTl);
        aGc.SetPenStyle(CGraphicsContext::ENullPen);
        const TAknsItemID *frameId = &KAknsIIDQsnFrPopup;
        const TAknsItemID *frameCenterId = &KAknsIIDQsnFrPopupCenter;
        aGc.SetClippingRegion( drawRegion );
        windowFrameDrawn = AknsDrawUtils::DrawFrame(skin, aGc, outerRect, innerRect, *frameId, *frameCenterId);
        aGc.CancelClippingRegion();
        }
    if (!windowFrameDrawn)
        {
        AknDraw::DrawWindowShadow(aGc, aDef.iCover, aDef.iSecond, aDef.iFirst, aDef.iOutline, aDef.iInside);
        }
    }