List Box Flickers badly on populating

Login to reply to this topic.
Fri, 2006-10-20 10:27
Joined: 2006-10-20
Forum posts: 3
Hi All,
         I have been facing a problem of flicker in the listbox wheneve I populate it........Following below are the snippets I used in the Container:

void CMessageTextListBox::ConstructL(CCoeControl* aWindowOwningContainer,TRect aRect)
{

SetContainerWindowL(*aWindowOwningContainer);

// Application title
    iAppTitle = CCknAppTitle::NewL(CCknAppTitle::EWindow);
    iAppTitle->SetContainerWindowL(*this);
   iAppTitle->SetTextL(*iEikonEnv->AllocReadResourceL(R_TAB_INBOX), CCknAppTitle::EMainTitle);
   

    iListbox = new(ELeave)CCustomListBox();

    iListbox->ConstructL(aWindowOwningContainer,
        CEikListBox::ENoExtendedSelection);


    iListbox->CreateScrollBarFrameL(ETrue);

    iListbox->ScrollBarFrame()->SetScrollBarVisibilityL(
        CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);

   SetIconsArray();

   SetData();

}



void CMessageTextListBox::SetData(TInt aIsmark)
{
    CDesCArrayFlat* listItems;

    Put all the items in listitems first and later to listbox
    .............................................................

    .........................................................
    CTextListBoxModel* model = iListbox->Model();
    model->SetItemTextArray(listItems);

    if(iCursorPos >= 0)
       iListbox->SetCurrentItemIndex(iCursorPos);

    iListbox->HandleItemAdditionL();

    model->SetOwnershipType(ELbmOwnsItemArray);

}


void CMessageTextListBox::SetIconsArray()
{
   // Creates a new icon array.   
   CArrayPtr<CGulIcon>* iconArray = new (ELeave) CArrayPtrFlat<CGulIcon>(3);

   CleanupStack::PushL(iconArray);

                 ................................................................
                file to read the mbm

   iconArray->AppendL( CEikonEnv::Static ()->CreateIconL( .................. );



   CleanupStack::Pop(); // iconArray

   // Sets the icon array.
   CCustomListItemDrawer* itemDrawer = static_cast<CCustomListItemDrawer*>
      (iListbox->View()->ItemDrawer());

   itemDrawer->SetIconArray(iconArray); // transfer ownership

   // Sets the height of the list box item
   TSize size = itemDrawer->MaxIconSize();
   iListbox->SetItemHeightL(2 * size.iHeight);
}


void CMessageTextListBox::Draw(const TRect& aRect) const
{
   
    CWindowGc& gc = SystemGc();
    gc.SetClippingRect(aRect);
    ////gc.Clear(iBorder.OuterRect(aRect));
    gc.SetBrushStyle(CGraphicsContext::ESolidBrush);

    if (IsFocused())
    {
        CEikBorderedControl::Draw(iBorder.OuterRect(aRect)); // Shadow border
        gc.SetBrushColor(TRgb(KFocusedBkgColor));
    }
    else
    {
        gc.SetBrushColor(TRgb(KNonFocusedBkgColor));
    }

    // Fill the controls background. The color depends on the focus status. In
    // this example this has no effect, because contained controls are drawn
    // over the same area. Here just for demonstrating design principle.
    gc.DrawRect(Border().InnerRect(Rect()));
   
    iEikonEnv->WsSession().Flush();
}


void CMessageTextListBox::FocusChanged(TDrawNow aDrawNow)
{
    if (IsFocused()) // This control got focus.
        {
        iAppTitle->SetFocus(ETrue, aDrawNow);
        iListbox->SetFocus(ETrue, aDrawNow);
        }
    else // This control lost focus
        {
        iAppTitle->SetFocus(EFalse, aDrawNow);
        iListbox->SetFocus(EFalse, aDrawNow);
        }
    DrawDeferred();
}


void CMessageTextListBox::SizeChanged()
{
    TRect innerRect = Border().InnerRect(Rect());
   innerRect.iBr.iX = innerRect.iTl.iX + innerRect.Width();

    TRect titleRect(innerRect.iTl,
        TSize(innerRect.Width(), iAppTitle->MinimumSize().iHeight));
    iAppTitle->SetRect(titleRect);
   
    iListbox->SetRect(
        TRect(innerRect.iTl + TPoint(0, iAppTitle->Size().iHeight + 1),
            innerRect.iBr));

   iListbox->ActivateL();
         
}


I'm calling SetRect() from the view file............with rect size being a smaller one............the device being  of series 80. Has anyone been in a similiar situation?


Fri, 2006-10-20 12:54
NewLC AdministratorSymbian AccreditedForum Nokia Champion
Joined: 2003-01-14
Forum posts: 1890
Re: List Box Flickers badly on populating
why do you need to call iEikonEnv->WsSession().Flush(); ?

Eric Bustarret
NewLC Founder & CEO / Professional Symbian OS Consultant

Fri, 2006-10-20 13:47
Joined: 2006-10-20
Forum posts: 3
Re: List Box Flickers badly on populating
I used this more out of desperation.........it takes off furhter re-draw events in the buffer to Ws Session........coming to the point............even if I take it off.........the flicker's still there
  • Login to reply to this topic.