×

Discussion Board

Results 1 to 14 of 14
  1. #1
    Registered User
    Join Date
    Mar 2003
    Location
    Holland
    Posts
    25

    changing font is CEikDirectoryTreeListBox

    Hi,

    in my application I use a CEikDirectoryTreeListBox which very nicely shows directory trees. I want to zoom in and out on such a directory tree but I don't know how to change the font and font heigth used for the item text.
    I use the following method:

    CDirTree::UpdateTreeAfterZoomL(CFont* aFont)
    {
    CListBoxData* data = new(ELeave) CListBoxData;
    CleanupStack::PushL(data);
    data->ConstructL(aFont);
    CleanupStack::Pop(); // data
    iItemDrawer->SetData(data);
    UpdateL();
    }

    CDirTree is a class dervived from CEikDirectoryTreeListBox and iItemDrawer is an object from the CDirectoryTreeListItemDrawer class.
    It is very easy to change the font color to e.g. blue by putting the next statement in the method:

    iItemDrawer->SetTextColor(KRgbBlue);

    It is also very easy to change the item heigth to e.g. 15 pixels by using:

    SetItemHeightL(15);

    But is not easy to change the used font because the CDirectoryTreeListItemDrawer class doesn't have a member SetFont().

    I hoped that by using SetData, which sets the font storage data (a CListBoxData class) for the item drawer and transfers ownership of that data, the problem would be solved. But it isn't

    Who can advise me on this subject?

    Thanks,
    --
    André van Wieringen
    Excelbian
    Software for Wireless

  2. #2
    Registered User
    Join Date
    Mar 2003
    Location
    Holland
    Posts
    25

    changing font in CeikDirectoryTreeListBox

    Hi,

    nobody of the assembled "experts" answered my question. So I had to do it myself :)

    It was more easy than I thought.

    The Class CDirectoryTreeListItemDrawer inherits from CHierarchicalListItemDrawer which has a protected data member iFont and it is this font which decides upon the used font in the listbox item.

    So I created a new

    Class CDirDrawer : public CDirectoryTreeListItemDrawer

    and put the method

    void SetFont(CFont* aFont) in this class.

    The implementation of this method is

    void CDirDrawer::SetFont(CFont* aFont)
    {
    iFont = aFont;
    }

    And by changing the implementation of UpdateTreeAfterZoomL into

    void CDirTree::UpdateTreeAfterZoomL(CFont* aFont)
    {
    iDrawer = (CDirDrawer*) iItemDrawer;
    iDrawer->SetFont(aFont);
    UpdateL();
    }

    I could change the font and now I am able to zoom into and out of the directory listing

    Andre van Wieringen
    Excelbian
    Software for Wireless
    www.excelbian.com

  3. #3
    Regular Contributor
    Join Date
    Apr 2005
    Posts
    73

    "CEikDirectoryTreeListBox" not showing anything

    hi Andre,
    I m also creating "CEikDirectoryTreeListBox" for nokia 9500, it not giving any error also it is not showing anything. Can u pls guide where i m missing something.

    I m also attaching my code with my request.

    Thanks In Advance.

    Incide ConstructL() of my view:

    mylistbox=new(ELeave) CEikDirectoryTreeListBox();
    mylistbox->SetContainerWindowL(*this);
    mylistbox->ConstructL(this,CEikListBox::ENoExtendedSelection,CDirectoryTreeListBoxModel::EShowSystem,0,0);

    //TDriveNumber tdr(EDriveC);
    mylistbox->CreateListL(_L("C:\\"));
    mylistbox->CreateScrollBarFrameL(ETrue);
    mylistbox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto);

    SetRect(aRect);
    ActivateL();
    mylistbox->DrawNow();

  4. #4
    Registered User
    Join Date
    Mar 2003
    Location
    Holland
    Posts
    25
    Hi Amitjoshi,

    do you have something in your view class which resembles the following piece of code?

    CCoeControl* CAppMyView::ComponentControl(int aIndex) const
    {
    switch (aIndex)
    {
    case 0:
    return iMyListBox;
    default:
    return NULL;
    }
    }

    Regards,

    André van Wieringen

  5. #5
    Regular Contributor
    Join Date
    Apr 2005
    Posts
    73
    Hi Andre,
    Thanks but I have already done the "ComponentControl" part in my code it looks like this:

    CCoeControl* Cmyleftview::ComponentControl(TInt aIndex) const
    {
    switch (aIndex)
    {
    case 0:
    return iTitle;
    break;
    case 1:
    return mylistbox;
    break;
    default:
    return NULL;
    }
    }


    I have made two view and also did the command handling for them. But the problem is in creating "CEikDirectoryTreeListBox" on the left view. Infact i hav created it also and the code i hav pasted in previous reply but the it is not showing anything,the left view is looking empty (i.e. the CEikDirectoryTreeListBox is not showing up the directory tree of specified drive(EDriveC).
    There is no sign of "CEikDirectoryTreeListBox" in Left View.

    Pls put some light on it.
    Thanks
    Amit

  6. #6
    Registered User
    Join Date
    Jan 2005
    Posts
    391
    AND CountComponentControls() const ?

    Good Job!

  7. #7
    Regular Contributor
    Join Date
    Apr 2005
    Posts
    73

    CEikDirectoryTreeListBox Not appearing

    Hi,
    I have already done all these things even then the Directory structure is not appearing on the list.


    TInt Cmyleftview::CountComponentControls() const
    {
    return 2;
    }


    CCoeControl* Cmyleftview::ComponentControl(TInt aIndex) const
    {
    switch (aIndex)
    {
    case 0:
    return iTitle;
    break;
    case 1:
    return mylistbox;
    break;
    default:
    return NULL;
    }
    }

    Can u pls give any helping code or example code for this.

    Regards
    Amit

  8. #8
    Registered User
    Join Date
    Jan 2005
    Posts
    391
    please read the sdk example "custumcontrol"

  9. #9
    Registered User
    Join Date
    Mar 2003
    Location
    Holland
    Posts
    25
    Hi Amit,

    don't you need something like

    mylistbox->DtlModel()->ExpandAllItemsL());

    after

    ActivateL();

    in order to really display something?

    André

  10. #10
    Regular Contributor
    Join Date
    Apr 2005
    Posts
    73

    Thanks but still not working

    Hi Andre,
    i have added the line of code but still CEikDirectoryTreeListBox is not appearing. I thing i m missing something so i m mailing my code to you pls hav a look.
    If u hav any code sample related to this pls mail me.

    /************************************************************
    ConstructL()
    {
    mylistbox=new(ELeave) CEikDirectoryTreeListBox();
    mylistbox->SetContainerWindowL(*this);
    mylistbox->ConstructL(this,CEikListBox::ENoExtendedSelection,CDirectoryTreeListBoxModel::EShowSystem,0,0);

    mylistbox->CreateListL(_L("C:\\"));
    mylistbox->CreateScrollBarFrameL(ETrue);
    mylistbox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto);

    SetRect(aRect);
    ActivateL();
    mylistbox->DtlModel()->ExpandAllItemsL();
    mylistbox->DrawNow();


    *****************************
    TInt Cmyleftview::CountComponentControls() const
    {
    return 2;
    }

    ***************************

    CCoeControl* Cmyleftview::ComponentControl(TInt aIndex) const
    {
    switch (aIndex)
    {
    case 0:
    return iTitle;
    break;
    case 1:
    return mylistbox;
    break;
    default:
    return NULL;
    }
    }
    /**********************************************************

    Regards
    Amit

  11. #11
    Regular Contributor
    Join Date
    Apr 2005
    Posts
    73

    small Problem

    hi Andre,
    can u pls send a code piece for "CEikDirectoryListBox", i got stuck in it.

    Thanks & Regards
    Amit

  12. #12
    Registered User
    Join Date
    Mar 2003
    Location
    Holland
    Posts
    25
    Hi Amit,

    below a piece of code which deals with the CEikDirectoryTreeListBox. It's part of a larger whole. So I hope it doesn't make the issue more diffuse instead of more clear.

    void CDirTree::ConstructL(CLocalFM* aControl,CLocalFM::TPanelSettings* aSettings,CFont* aFont,TInt aZoomFactor)
    {
    iParent=aControl;
    iPanelSettings=aSettings;
    //
    TFileName str;
    CEikonEnv::Static()->ReadResource(str,R_LOCALFM_TEXT_PLEASE_WAIT);
    CEikonEnv::Static()->BusyMsgL(str,EHRightVTop,0);
    //
    TInt modelFlags=CDirectoryTreeListBoxModel::EShowSystem | CDirectoryTreeListBoxModel::EShowHidden | CEikListBox::EMultipleSelection;
    CEikDirectoryTreeListBox::ConstructL(aControl,0,modelFlags);
    CreateScrollBarFrameL();
    ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
    UpdateScrollBarsL();
    //
    ActivateL();
    //
    TDriveNumber aDrive=(TDriveNumber)(iPanelSettings->iPath[0]-'A');
    TRAPD(retcode,CreateListL(&aDrive));
    if (retcode != KErrNone)
    User::Leave(retcode);
    TRAP(retcode,DtlModel()->ExpandAllItemsL());
    if (retcode != KErrNone)
    User::Leave(retcode);
    SetCurrentItemPathL(iPanelSettings->iPath);
    UpdateScrollBarsL();
    //
    iParent->iCursorX->ConstructL(&Window(),CPointerCursor::EXCursorFolder);
    iIsDrag=FALSE;
    iWasDrag=FALSE;
    iDragFirstPoint=TPoint(0,0);
    //
    iDrawer = (CDirDrawer*) iItemDrawer;
    iDrawer->SetHighlightedBackColor(KRgbBlack);
    iDrawer->SetHighlightedTextColor(KRgbWhite);

    UpdateTreeAfterZoomL(aFont,aZoomFactor);
    //
    CEikonEnv::Static()->BusyMsgCancel();
    }

    Best regards,

    André van Wieringen

  13. #13
    Regular Contributor
    Join Date
    Apr 2005
    Posts
    73

    Thanks Andre

    Thanks a lot.

    I hav also solved my problm it was a problem of setting rect for view and listbox.
    Great help from u.

    Regards
    Amit

  14. #14
    chishti.hameed
    Guest

    Re: changing font in CeikDirectoryTreeListBox

    Quote Originally Posted by acvwieringen
    Hi,

    nobody of the assembled "experts" answered my question. So I had to do it myself :)

    It was more easy than I thought.

    The Class CDirectoryTreeListItemDrawer inherits from CHierarchicalListItemDrawer which has a protected data member iFont and it is this font which decides upon the used font in the listbox item.

    So I created a new

    Class CDirDrawer : public CDirectoryTreeListItemDrawer

    and put the method

    void SetFont(CFont* aFont) in this class.

    The implementation of this method is

    void CDirDrawer::SetFont(CFont* aFont)
    {
    iFont = aFont;
    }

    And by changing the implementation of UpdateTreeAfterZoomL into

    void CDirTree::UpdateTreeAfterZoomL(CFont* aFont)
    {
    iDrawer = (CDirDrawer*) iItemDrawer;
    iDrawer->SetFont(aFont);
    UpdateL();
    }

    I could change the font and now I am able to zoom into and out of the directory listing

    Andre van Wieringen
    Excelbian
    Software for Wireless
    www.excelbian.com
    How can i use/create Tree control for s60?

    Thanks ahead

Posting Permissions

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