×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Regular Contributor
    Join Date
    Jul 2005
    Posts
    55

    Red face Custom list control (as labels)

    Dear all,
    I'm trying to create a custom control (labels works as list)
    This is just an issue to draw items with special colors for each one
    So the control is simply a class CMyList inherits from CCoeControl, MCoeControlObserver and override functions:
    void SizeChanged();
    TInt CountComponentControls() const;
    CCoeControl* ComponentControl(TInt aIndex) const;
    void Draw(const TRect& aRect) const;
    void HandleControlEventL(CCoeControl *aControl, TCoeEvent aEventType);

    Internally, this class holds list of labels

    I'm creating object from this control in my container as follows:
    iListBox = CMyList::NewL(this);
    iListBox->SetContainerWindowL(*this);
    iCtrlArray.Append(iListBox);

    Also I resize the control in my container SizeChange

    However, the draw function of myControl CMyList:raw isn't called
    I tried iListBox->DrawDeffered and set rect, but nothing happened

    Can you tell me please what i'm missing here?
    Eng. Ahmed Abo El Ella
    Software Developer

  2. #2
    Regular Contributor
    Join Date
    Jul 2005
    Posts
    55

    Re: Custom list control (as labels)

    again i want to highlight that i'm not using the standard lists because I need to view the labels in custom way (custom contents as text with custom colors for each label)

    Thanks
    Eng. Ahmed Abo El Ella
    Software Developer

  3. #3
    Super Contributor
    Join Date
    Nov 2004
    Posts
    1,009

    Re: Custom list control (as labels)

    In your container class where you have created an instance of your custom listbox you have to return that in componentControl() and CountComponentControl().

    Call iListBox->DraWNow();// then all the code placed in your listbox draw should get called.
    Regards,
    Shafali

  4. #4
    Regular Contributor
    Join Date
    Jul 2005
    Posts
    55

    Re: Custom list control (as labels)

    Quote Originally Posted by shafalig82 View Post
    In your container class where you have created an instance of your custom listbox you have to return that in componentControl() and CountComponentControl().

    Call iListBox->DraWNow();// then all the code placed in your listbox draw should get called.

    Thanks for your quick reply
    Actually, i'm using RPointerArray<CCoeControl> to keep track of my controls so in componentControl() and CountComponentControl() I return the list box correctly coz it is appended to control array

    However, I called iListBox->DraWNow(); in my Container::ConstructL after ActivatL
    The function Draw of my list box called, but nothing drawn on screen
    The container draw function affects the screen but iListBox:raw doesn't affect the screen

    I think calling DrawNow isn't the solution coz we don't call it if we created label normally on container

    Thanks for your interest
    Eng. Ahmed Abo El Ella
    Software Developer

  5. #5
    Super Contributor
    Join Date
    Nov 2004
    Posts
    1,009

    Re: Custom list control (as labels)

    Were you able to traverse the draw function of your listbox.

    Did you tried your custom listbox on simple container , Is it working perfectly?
    Regards,
    Shafali

  6. #6
    Regular Contributor
    Join Date
    Jul 2005
    Posts
    55

    Re: Custom list control (as labels)

    No this is my first trial to implement it
    This is my custom control in its simple project

    To make it clearer
    My container:raw function
    CWindowGc& gc = SystemGc();

    gc.SetPenStyle( CGraphicsContext::ENullPen );
    gc.SetBrushColor( KRgbRed );
    gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
    gc.DrawRect( aRect );


    My list box Draw function
    CWindowGc& gc = SystemGc();

    gc.SetPenStyle( CGraphicsContext::ENullPen );
    gc.SetBrushColor( KRgbWhite );
    gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
    gc.DrawRect( aRect );

    So the color is only red
    Eng. Ahmed Abo El Ella
    Software Developer

  7. #7
    Super Contributor
    Join Date
    Nov 2004
    Posts
    1,009

    Re: Custom list control (as labels)

    Did you call the ActivateL() in control's constructL() method.
    Regards,
    Shafali

  8. #8
    Regular Contributor
    Join Date
    Jul 2005
    Posts
    55

    Re: Custom list control (as labels)

    void CListBox::ConstructL(CCoeControl* aParentCtrl)
    {
    iParentCtrl = aParentCtrl;

    //Some data initialization

    //Create label
    CEikLabel* label = new (ELeave)CEikLabel;
    label->SetContainerWindowL(*this);

    //add to list of labels
    iLabelsArray.Append(label);

    ActivateL();
    }
    Eng. Ahmed Abo El Ella
    Software Developer

  9. #9
    Super Contributor
    Join Date
    Nov 2004
    Posts
    1,009

    Re: Custom list control (as labels)

    Quote Originally Posted by AbuElElla View Post
    void CListBox::ConstructL(CCoeControl* aParentCtrl)
    {
    iParentCtrl = aParentCtrl;

    //Some data initialization

    //Create label
    CEikLabel* label = new (ELeave)CEikLabel;
    label->SetContainerWindowL(*this);

    //add to list of labels
    iLabelsArray.Append(label);

    ActivateL();
    }


    You are trying to return label control from your listbox control, as i got from your code.

    Can you pleas elaborate what exactly you want to achieve with your listbox control.

    As of know you can test your listbox control by simply commenting your label controls etc from listbox custom control and doesnt return anything from listbox's component control functions.

    You rect will surely get changed into White as was required by you earlier.
    Regards,
    Shafali

  10. #10
    Regular Contributor
    Join Date
    Jul 2005
    Posts
    55

    Thumbs up Re: Custom list control (as labels)

    Thanks for your patient in this issue
    As you said the control will be drawn white correctly

    But what I missed -shamed for that- is to override SizeChanged which should resize the labels controls to display and also resize the class control with the given Rect

    Thanks again
    Eng. Ahmed Abo El Ella
    Software Developer

Similar Threads

  1. Custom audio file selection list
    By sreekanthbellur in forum Symbian
    Replies: 3
    Last Post: 2009-07-09, 16:38
  2. displaying labels with multiple lines and fonts in a List
    By rien in forum Mobile Java General
    Replies: 6
    Last Post: 2007-09-13, 00:47
  3. problem in custom control.....
    By platinnum in forum Symbian
    Replies: 0
    Last Post: 2005-05-06, 07:29
  4. Custom control in Series 60 form
    By jandrhub in forum Symbian User Interface
    Replies: 3
    Last Post: 2004-03-09, 12:12
  5. List Box control on series -60
    By Nokia_Archive in forum Symbian Tools & SDKs
    Replies: 1
    Last Post: 2002-05-30, 21:03

Posting Permissions

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