×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Oct 2006
    Posts
    40

    How can we display a grid after click on a list box

    Hi,
    all..
    As being learner ... I have develop two small project one MyListbox and other is Mygrid and it is working fine . Now I want to join these two .... i.e. When I'll select one list box and press ok it should open the Grid. I have declared List box and grid in .rss file as Resource. And instantiated List box in Mycontainer.cpp and Grid in MyGridappView.cpp. How can I handle the grid object and display on my S60 mobile screen from the Mycontainer.cpp...

    //------------------------>
    RESOURCE LISTBOX r_akn_My_list
    {
    array_id = r_akn_My_list_items;
    flags = EAknListBoxSelectionList;
    }

    RESOURCE ARRAY r_akn_My_list_items
    {
    items =
    {
    LBUF
    {
    txt = str_default_My_entry1; // defined in MylistBox.loc
    },
    LBUF
    {
    txt = str_default_My_entry2;
    },
    LBUF
    {
    txt = str_default_My_entry3;
    }
    };
    }
    //------------------------>




    //----------------->
    RESOURCE GRID r_selection_My_grid
    { array_id = r_selectiongrid_My_items;
    flags = EAknListBoxSelectionGrid;
    style = r_selectiongrid_My_style;
    }
    RESOURCE GRID_STYLE r_selectiongrid_My_style
    { layoutflags = EAknGridHorizontalOrientation | EAknGridLeftToRight | EAknGridTopToBottom;
    primaryscroll = EAknGridFollowsItemsAndLoops;
    secondaryscroll = EAknGridFollowsItemsAndLoops;
    itemsinprimaryorient = 3;
    itemsinsecondaryorient = 2;
    gapwidth = 5;
    gapheight = 5;
    width = 55;
    height = 70;
    }

    RESOURCE ARRAY r_selectiongrid_My_items
    {
    items =
    { LBUF { txt = "0\tItem 0"; },
    LBUF { txt = "1\tItem 1"; },
    LBUF { txt = "2\tItem 2"; },
    LBUF { txt = "3\tItem 3"; },
    LBUF { txt = "0\tItem 4"; } ,
    LBUF { txt = "1\tItem 5"; } //,
    //LBUF { txt = "2\tItem 6"; }
    };
    }


    Now i want to display the grid (r_selectiongrid ) when i select any list box and press ok (CBA) ......
    say...............
    Listbox "str_default_My_entry1" should open grid;
    Thanks & Regards

    Jyotideep Bhuyan

  2. #2
    Super Contributor
    Join Date
    Oct 2005
    Location
    Hyderabad,India
    Posts
    1,156

    Re: How can we display a grid after click on a list box

    Probably you could have the listbox in one view and the grid in another.
    When you click on the listbox item activate the second view where your grid in been build.Compute the text and icon arrays of the grid respectively and show it up.i hope this would work out.

    Priju

  3. #3
    Registered User
    Join Date
    Oct 2006
    Posts
    40

    Re: How can we display a grid after click on a list box

    Thank U ... for your reply ... can U plz explain it more clearly with an example !!!!


    I have used these codes:

    ~~~~~~~~~~~~~~
    In Mycontainer.cpp
    ~~~~~~~~~~~~~~

    void CMycontainer::ConstructL(const TRect& aRect)
    {
    CreateWindowL();

    iListBox = new (ELeave) CAknDoubleNumberStyleListBox;
    iListBox->SetContainerWindowL( *this );

    TResourceReader rr;
    iCoeEnv->CreateResourceReaderLC(rr,R_AKN_MY_LIST);
    iListBox->ConstructFromResourceL(rr);
    CleanupStack::PopAndDestroy();

    iListBox->CreateScrollBarFrameL(ETrue);
    iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto);

    SetRect(aRect);
    ActivateL();
    }


    CMycontainer::~CMycontainer()
    {
    delete iListBox;
    }


    void CMycontainer::UpdateFromModel()
    {
    TInt pos(iListBox->View()->CurrentItemIndex());
    if(pos==0)
    iEikonEnv->InfoMsg( _L("You have pressed Ok button 1") );
    if(pos==1)

    {
    iEikonEnv->InfoMsg( _L("You have pressed Ok button 2") );

    ************************************
    I WANT TO DISPLAY GRID HERE!!!!!!!!!!!!! But how & why???
    *************************************
    }
    if(pos==2)
    {
    iEikonEnv->InfoMsg( _L("You have pressed Ok button 3") );

    CAknForm* form = new(ELeave) CAknForm;

    CleanupStack::PushL(form);
    form->ConstructL();
    CleanupStack::Pop();
    form->ExecuteLD(R_ONE_TEXT_FIELD_DIALOGLOGSUC);
    }



    }



    void CMycontainer::SizeChanged()
    {

    if(iListBox)
    iListBox->SetRect(Rect());
    }


    TInt CMycontainer::CountComponentControls() const
    {
    return 1; // return nbr of controls inside this container
    }


    CCoeControl* CMycontainer::ComponentControl(TInt aIndex) const
    {
    switch ( aIndex )
    {
    case 0:
    return iListBox;

    default:
    return NULL;
    }
    }


    void CMycontainer::Draw(const TRect& aRect) const
    {
    CWindowGc& gc = SystemGc();

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


    void CMycontainer::HandleControlEventL(
    CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
    {
    // TODO: Add your control event handler code here
    }


    TKeyResponse CMycontainer::OfferKeyEventL(
    const TKeyEvent& aKeyEvent,
    TEventCode aType )
    {

    if(iListBox)
    return iListBox->OfferKeyEventL( aKeyEvent, aType );
    else
    return EKeyWasNotConsumed;
    }

    // End of File


    ~~~~~~~~~~~~~~
    In MyGridappView.cpp:
    ~~~~~~~~~~~~~~


    void CMyGridappView::ConstructL()
    {

    CreateWindowL();


    iGrid = new( ELeave ) CAknGrid;
    iGrid->SetContainerWindowL( *this );
    TResourceReader reader;
    CEikonEnv::Static()->CreateResourceReaderLC(reader, R_SELECTION_MY_GRID);
    iGrid->ConstructFromResourceL(reader);
    CleanupStack::PopAndDestroy();

    SetRect(aRect);
    ActivateL();
    }


    CMyGridappView::CMyGridappView()
    {
    // no implementation required
    }

    CMyGridappView::~CMyGridappView()
    {
    delete iGrid;

    }


    void CMyGridappView::SizeChanged()
    {

    if(iGrid)
    iGrid->SetRect(Rect());
    }


    void CMyGridappView::UpdateFromModelGrid()
    {

    TInt pos = iGrid->CurrentDataIndex();
    if(pos==0)
    iEikonEnv->InfoMsg( _L("You have pressed Ok button 1") );
    if(pos==1)
    iEikonEnv->InfoMsg( _L("You have pressed Ok button 2") );
    if(pos==2)
    iEikonEnv->InfoMsg( _L("You have pressed Ok button 3") );
    if(pos==3)
    iEikonEnv->InfoMsg( _L("You have pressed Ok button 4") );
    if(pos==4)
    iEikonEnv->InfoMsg( _L("You have pressed Ok button 5") );
    if(pos==5)
    iEikonEnv->InfoMsg( _L("You have pressed Ok button 6") );

    }


    TInt CMyGridappView::CountComponentControls() const
    {
    return 1; // return nbr of controls inside this container
    }


    CCoeControl* CMyGridappView::ComponentControl(TInt aIndex) const
    {
    switch ( aIndex )
    {
    case 0:
    return iGrid;

    default:
    return NULL;
    }
    }


    void CMyGridappView::HandleControlEventL(
    CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
    {

    }


    TKeyResponse CMyGridappView::OfferKeyEventL(
    const TKeyEvent& aKeyEvent,
    TEventCode aType )
    {

    if(iGrid)
    return iGrid->OfferKeyEventL( aKeyEvent, aType );
    else
    return EKeyWasNotConsumed;
    }


    void CMyGridappView::Draw(const TRect& aRect) const
    {
    CWindowGc& gc = SystemGc();
    gc.SetPenStyle(CGraphicsContext::ENullPen);
    gc.SetBrushColor(KRgbGray);
    gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
    gc.DrawRect(aRect);
    }
    Thanks & Regards

    Jyotideep Bhuyan

  4. #4
    Super Contributor
    Join Date
    Oct 2005
    Location
    Hyderabad,India
    Posts
    1,156

    Re: How can we display a grid after click on a list box

    make use of the multi view architecture.please have a look at the sdk example explaining the same.
    copy the codes of your listbox onto one view and the ones related to ur grid onto another view. and activate the second view when you hit a entry of your list box. You would understand more if you have a look at the multiview architecture.

    here i find the example..

    \7.0s\Series60_v20_CW\Series60Ex\multiviews

    Priju

  5. #5
    Registered User
    Join Date
    Oct 2006
    Posts
    40

    Smile Re: How can we display a grid after click on a list box

    Thank u bro.............
    Thanks & Regards

    Jyotideep Bhuyan

  6. #6
    Registered User
    Join Date
    Oct 2006
    Posts
    40

    Unhappy Re: How can we display a grid after click on a list box

    ya i did according to you its displaying ... i can view the grids as well as Listbox in two different views Thanx buddy..... but scrolling is not working!!!!!!!!! i cann't move on the grids and listboxes ... using the nvgtion key!!!! ... if U want i can send you the code ......... plz help me !!!!!!!
    Thanks & Regards

    Jyotideep Bhuyan

Similar Threads

  1. How to display list box over a bitmap
    By devl8tly in forum Symbian
    Replies: 1
    Last Post: 2009-04-13, 15:43
  2. Replies: 3
    Last Post: 2007-02-19, 11:41
  3. How to display images in the list box
    By JJe in forum Symbian
    Replies: 2
    Last Post: 2005-10-07, 04:54
  4. Display jpeg on grid list gives kern-exec 3?
    By flicker82 in forum Symbian User Interface
    Replies: 1
    Last Post: 2005-01-18, 05:18
  5. How to display two columns in one list box?
    By Orange_LEE in forum Symbian User Interface
    Replies: 3
    Last Post: 2004-03-17, 09:07

Posting Permissions

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