×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Super Contributor
    Join Date
    Mar 2003
    Posts
    2,426

    Error on drawing Listbox

    I create an Instance of CCknVerticalTextAndIconListBox and populate it with text as given in the sample with the SDK.

    I have populated the modeliconarray with null as in the sample to turn the icons off. When I populate just on item it shows correctly. When I populate more than one items I get an error on iIconList->DrawNow().

    Any reason why this error?

    Also in the sample it says to set the column gap use View()->SetColumnGap(2). But the CListBoxView does not have a method SetColumnGap.

    Any suggestions as to what could be wrong?

    The code is as follows -

    void CTestAppAppView::ConstructL(const TRect& aRect)
    {
    CreateWindowL();
    SetRect(aRect);
    ConstructIconListBoxL();
    ActivateL();

    // here I get an error
    iIconList->DrawNow();

    iIconList->PrepareForFocusGainL();
    iIconList->SetFocus(ETrue);
    iIconList->View()->SelectItemL(0);
    }

    void CTestAppAppView::ConstructIconListBoxL()
    {
    iIconList = new(ELeave) CCknVerticalTextAndIconListBox;
    iIconList->ConstructL(this,ELbmOwnsItemArray,NULL,NULL);
    CTextAndIconListBoxModel* model_ptr = (CTextAndIconListBoxModel*) iIconList->Model();
    //Get the text array from the list box model.
    MDesCArray* temptextArray = model_ptr->ItemTextArray();
    //Cast to CDesCArray*.
    CDesCArray* modelTextArray = (CDesCArray*) temptextArray;
    _LIT(pTemp,"abc");
    modelTextArray->AppendL(pTemp);
    _LIT(pTemp2,"xyz");
    modelTextArray->AppendL(pTemp2);

    //Get pointer to the icon array.
    CArrayPtr<CGulIcon>* modelIconArray=model_ptr->IconArray();

    modelIconArray->ResetAndDestroy();
    modelIconArray->AppendL(NULL);

    iIconList->SetExtent(TPoint(20, 30), TSize(400, 80));

    //Create scroll bar frame.
    iIconList->CreateScrollBarFrameL(ETrue);
    //Set the HORIZONTAL scroll bar to be ON, and the VERTICAL one to be off.
    iIconList->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOn, CEikScrollBarFrame::EOff);
    //Set the border type. This defaults to ENone.
    iIconList->SetBorder(TGulBorder::EThickDeepRaisedWithOutline);

    //Set the gap between items to 1.
    iIconList->View()->ItemDrawer()->SetVerticalInterItemGap(10);
    iIconList->SetItemHeightL(50);

    iIconList->ActivateL();
    }

    Brijesh

    Posted by brijesh Gajaria, brijesh@itfinity.com
    on January 04, 2002 at 09:21

  2. #2
    Super Contributor
    Join Date
    Mar 2003
    Posts
    2,426

    RE: Error on drawing Listbox

    Posted by Forum_Nokia Developer_Support, communicator.developer@nokia.com
    on January 04, 2002 at 13:30

    The icon array contains the icon for every item in the list box. If your listbox has 2 items you need to append 2 NULL's:

    //Get pointer to the icon array.
    CArrayPtr<CGulIcon>* modelIconArray=model_ptr->IconArray();

    modelIconArray->ResetAndDestroy();

    modelIconArray->AppendL(NULL);
    modelIconArray->AppendL(NULL);

    To set the column gap you will need to cast the view returned by your listbox to CSnakingListBoxViewWithGapsAndBrush and then call SetColumnGap, see header file CKNLBV.H

    Regards,
    FN Developer Support

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×