×

Discussion Board

Results 1 to 6 of 6

Thread: ListBox issue

  1. #1
    Regular Contributor
    Join Date
    May 2007
    Posts
    156

    ListBox issue

    Hello everyone

    In my application I have view which contains CAknDoubleStyleListBox. I'm working in Carbide and I use its UI Designer to create views.

    I can easily manage item on the list, for instance adding, aediting, deleting. What I would like to do know I want to make text colour different for each item. I read a little bit in internet and I found out that to do so I need something called ItemDrawer. So I created class:
    #include <eiklbi.h>
    class CMyItemDrawer : public CListItemDrawer
    {
    public:
    CMyItemDrawer(CAknDoubleStyleListBox* aListBox);

    virtual ~CFlexItemDrawer();

    private: // CListItemDrawer
    virtual void DrawActualItem(TInt aItemIndex, const TRect& aActualItemRect,TBool aItemIsCurrent, TBool aViewIsEmphasized, TBool aViewIsDimmed,TBool aItemIsSelected) const;

    private:
    CAknDoubleStyleListBox* iListBox;
    };

    This is how I overwrite DrawActualItem method:

    CMyItemDrawer::CMyItemDrawer(CAknDoubleStyleListBox* aListBox):
    CListItemDrawer(), iListBox(aListBox)
    {
    // Store a GC for later use
    iGc = &CCoeEnv::Static()->SystemGc();
    SetGc(iGc);
    }

    void CMyItemDrawer:rawActualItem(TInt aItemIndex, const TRect& aActualItemRect,TBool aItemIsCurrent, TBool aViewIsEmphasized, TBool aViewIsDimmed,TBool aItemIsSelected) const
    {
    // Sets all the attributes, like font, text color and background //color.
    const CFont* font = CEikonEnv::Static()->NormalFont();
    iGc->UseFont(font);
    iGc->SetPenColor(/*iTextColor*/KRgbWhite);
    iGc->SetPenStyle(CGraphicsContext::ESolidPen);
    iGc->SetBrushColor(/*iBackColor*/KRgbYellow);
    iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);

    // Draws the item text.
    TPtrC itemText = iListBox->Model()->ItemText(aItemIndex);
    TInt baseline = (aActualItemRect.Height() - font->HeightInPixels()) / 2 + font->AscentInPixels();
    iGc->DrawText(itemText, aActualItemRect, baseline);
    }


    After this I added CreatItemDrawerL method in my list's container:

    void CMainScreen::CreateItemDrawerL()
    {
    iItemDrawer = new (ELeave) MyItemDrawer::CMytemDrawer(iListBox);
    }

    But after that I don't know what to do further. And I am sure there is something more, cause I haven't seen colour change on my list box.

    Please help me out here.
    Best Regards
    songoku

  2. #2
    Regular Contributor
    Join Date
    May 2007
    Posts
    156

    Re: ListBox issue

    Hello

    Could someone help me out here?? If any additional information is needed please let me know.

    BR
    songoku

  3. #3
    Regular Contributor
    Join Date
    May 2007
    Posts
    156

    Re: ListBox issue

    Has really no one ever done that??

    Please, any clue is welcome

    BR
    Adam

  4. #4
    Regular Contributor
    Join Date
    Apr 2007
    Location
    Germany, Stuttgart
    Posts
    241

    Re: ListBox issue

    I think it is nessesary to implement your own custom Listbox, extending CAknDoubleStyleListBox to do change itemdrawer of the listbox.

    Regards
    Andi

  5. #5
    Regular Contributor
    Join Date
    May 2007
    Posts
    156

    Re: ListBox issue

    Thank You for the reply

    I also believe that this is a way to achieve this goal. But the question is how to do that.
    The way I presented above is not complete, do You know what's missing there.

    BR
    songoku

  6. #6
    Regular Contributor
    Join Date
    Apr 2007
    Location
    Germany, Stuttgart
    Posts
    241

    Re: ListBox issue

    In the way I mentioned ahead, just write a own custom Listbox:

    CMyListBox::CMyListBox()
    :CAknDoubleStyleListBox()
    {
    }

    void CMyListBox::ConstructL(const CCoeControl* aParent, TInt aFlags)
    {
    CAknDoubleStyleListBox::ConstructL(aParent, aFlags);
    }


    overwriting the CreateItemDrawerL Method in this way:


    void CMyListBox::CreateItemDrawerL()
    {
    iItemDrawer = new (ELeave) CMyItemDrawer(*this);

    }


    this should work so far.

    Regards,
    Andi

Similar Threads

  1. Full screen listbox skin not rendered correctly
    By template60 in forum Symbian
    Replies: 2
    Last Post: 2007-09-11, 04:34
  2. Query ~ Listbox | functional but no text
    By series60nubee in forum Symbian
    Replies: 5
    Last Post: 2006-03-24, 06:09
  3. Yet another listbox issue
    By larsoveclaesson in forum Symbian User Interface
    Replies: 1
    Last Post: 2005-07-28, 08:40
  4. Using a "custom" listbox in mobile s60
    By ctpthanh in forum Symbian User Interface
    Replies: 4
    Last Post: 2005-04-17, 14:46
  5. Hide Listbox not working with MakeVisible(EFalse)
    By Salvesh in forum Symbian User Interface
    Replies: 3
    Last Post: 2005-02-04, 05:04

Posting Permissions

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