Listbox in side listbox ???

Login to reply to this topic.
Mon, 2006-01-09 09:30
Joined: 2005-02-22
Forum posts: 39
Hi ,

I  want a way in Listbox to open a new listbox window
When a  list Item is selected (Say on click )

How can i do that ?

Can i just create a new listbox on the event when a list item is selected .

Does i need to create new window or child window or some thing  like that

Please help ....

Any pointer will be of great help 

Regards
Veeraj Thaploo


Mon, 2006-01-09 11:32
Joined: 2004-10-12
Forum posts: 44
Re: Listbox in side listbox ???
Well, you can create a new view or perhaps re-use the existing list?
Tue, 2006-01-10 06:31
Joined: 2005-02-22
Forum posts: 39
Re: Listbox in side listbox ???
thanks  .. i will try using same listbox
Wed, 2006-01-11 14:44
Joined: 2005-02-22
Forum posts: 39
Re: Listbox in side listbox ???
Hi,

Can u please tell me how can i re-use a list  ??

I tried a way  .. it  works but  I want  some generic way

to call list from inside the list ..

I am posting my code here

I wan some Suggestion on design level ...

Any suggestion will be of great  help
-------------------------------------------------------------------------

// INCLUDE FILES
#include "V_DriveContainer.h"

#include <eiklabel.h>  // for example label control

#include <AknsDrawUtils.h>// skin
#include <AknsBasicBackgroundControlContext.h> //skin
#include <badesca.h>
#include <aknlists.h>
#include <aknnotewrappers.h>


// ================= MEMBER FUNCTIONS =======================

// ---------------------------------------------------------
// CV_DriveContainer::ConstructL(const TRect& aRect)
// EPOC two phased constructor
// ---------------------------------------------------------
//

void CV_DriveContainer::ConstructL(const TRect& aRect)
    {
    CreateWindowL();
   SetRect(aRect);
   //list->SetListBoxObserver( this );
   CreateMyList(aRect);
    ActivateL();

    }

// Destructor
CV_DriveContainer::~CV_DriveContainer()
    {
      if(list)
      {
         delete list;
         list=NULL;
      }
/*   if(listinside)
      {
         delete listinside;
         listinside=NULL;
      }
    */
    }

//--------------------------------------------------------
// Create list view
//-----------------------------------------------------------


void CV_DriveContainer::CreateMyList(const TRect& aRect)
{

   TInt iCount =5;

   _LIT(KListItemFormat,"\t%S\t%S\t" ); //"%d\t%S\t%S\t"

   list = new (ELeave)CAknDoubleStyleListBox();//;CAknDoubleNumberStyleListBox() ////  CAknDoubleStyleListBox  EAknListBoxMarkableList
   // construct listbox
   list->ConstructL(this,EAknListBoxLoopScrolling | EAknListBoxSelectionList); /* |0 EAknListBoxMenuList| EAknListBoxSelectionList| EAknListBoxMarkableList | EAknListBoxMultiselectionList| EAknListBoxMarkableList */
   
   list->SetListBoxObserver( this );

   list->SetContainerWindowL(*this);

   list->CreateScrollBarFrameL(ETrue);
   
   list->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto );
    TInt index;
    //list->SetListBoxObserver( this );
// change for not using Icons
/*  starts here

   CArrayPtr<CGulIcon>* iconList = new (ELeave) CAknIconArray(iCount);

   // push to stack
   
   CleanupStack::PushL(iconList);
   list->ItemDrawer()->ColumnData()->SetIconArray( iconList );

   for(index=0;index<iCount;index++)
   {
      iconList->AppendL( iEikonEnv->CreateIconL( KIconFile, EMbmListimages2listboximage) );    
      //   iconList->AppendL( iEikonEnv->CreateIconL( KIconFile, EMbmHttpappimages2listboximage, EMbmHttpappimages2listboximagem) );    
   }

   CleanupStack::Pop(); // iconList
   
   Ã‚  ends here
*/   

   //---------------------------------------------------------------

   // list only is here

   //---------------------------------------------------------------
   
   // construct listbox item    array
   CDesCArray *itemList = new (ELeave) CDesCArrayFlat(iCount);
   TBuf<80> item;

      TBuf<20> number;
      TBuf<256> Data;
   
   // first listbox item, graphic salt, heading "head1"
   for(index=0;index<iCount;index++)
   {      
      //_LIT(KIconFile1, "c:\\HttpAppImages.mbm");
      number=_L("size    128KB");
      Data=_L("Images ");

      item.Format(KListItemFormat,&Data,&number /*index*/  ); //index+1,
      
      //item.Copy(number);
      itemList->AppendL(item);

      number=_L("size   15KB");
      Data=_L("Audio ");

      index++;
      item.Format(KListItemFormat,&Data,&number /*index,*/); //, index+1
      
      //item.Copy(number);
      itemList->AppendL(item);

      number=_L("size   125KB");
      Data=_L("Docs");

      index++;
      item.Format(KListItemFormat,&Data,&number /*index,*/); //, index+1
      
      //item.Copy(number);
      itemList->AppendL(item);

      number=_L("size   153KB");
      Data=_L("Videos");

      index++;
      item.Format(KListItemFormat,&Data,&number /*index,*/); //, index+1
      
      //item.Copy(number);
      itemList->AppendL(item);

      number=_L("size   115KB");
      Data=_L("Games");

      index++;
      item.Format(KListItemFormat,&Data,&number /*index,*/); //, index+1
      
      //item.Copy(number);
      itemList->AppendL(item);

   }
   // set items and ownership

   list->Model()->SetItemTextArray(itemList);

   //iEikonEnv->AlertWin(_L("be"));

   list->Model()->SetOwnershipType(ELbmOwnsItemArray);       
   
   // construct icon array with granularity 3
   // update listbox
   
   list->HandleItemAdditionL();
   list->SetRect(Rect());
   list->DrawNow();

}


void CV_DriveContainer::CreateMyListInside()
{

   
   TInt iCount =5;

   _LIT(KListItemFormat,"\t%S\t%S\t" ); //"%d\t%S\t%S\t"

   list = new (ELeave)CAknDoubleStyleListBox();//;CAknDoubleNumberStyleListBox() ////  CAknDoubleStyleListBox  EAknListBoxMarkableList
   // construct listbox
   list->ConstructL(this,EAknListBoxLoopScrolling | EAknListBoxSelectionList); /* |0 EAknListBoxMenuList| EAknListBoxSelectionList| EAknListBoxMarkableList | EAknListBoxMultiselectionList| EAknListBoxMarkableList */


//   list->SetListBoxObserver( this );

   list->SetContainerWindowL(*this);

   list->CreateScrollBarFrameL(ETrue);
   
   list->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto );
    TInt index;
   
//   list->DrawNow();
    //list->SetListBoxObserver( this );
// change for not using Icons
/*  starts here

   CArrayPtr<CGulIcon>* iconList = new (ELeave) CAknIconArray(iCount);

   // push to stack
   
   CleanupStack::PushL(iconList);
   list->ItemDrawer()->ColumnData()->SetIconArray( iconList );

   for(index=0;index<iCount;index++)
   {
      iconList->AppendL( iEikonEnv->CreateIconL( KIconFile, EMbmListimages2listboximage) );    
      //   iconList->AppendL( iEikonEnv->CreateIconL( KIconFile, EMbmHttpappimages2listboximage, EMbmHttpappimages2listboximagem) );    
   }

   CleanupStack::Pop(); // iconList
   
   Ã‚  ends here
*/   

   //---------------------------------------------------------------

   // list only is here

   //---------------------------------------------------------------
   
   // construct listbox item    array
   CDesCArray *itemList = new (ELeave) CDesCArrayFlat(iCount);
   TBuf<80> item;

      TBuf<20> number;
      TBuf<256> Data;
   
   // first listbox item, graphic salt, heading "head1"
   for(index=0;index<iCount;index++)
   {      
      //_LIT(KIconFile1, "c:\\HttpAppImages.mbm");
      number=_L("size    128KB");
      Data=_L("Images inside");

      item.Format(KListItemFormat,&Data,&number /*index*/  ); //index+1,
      
      //item.Copy(number);
      itemList->AppendL(item);

      number=_L("size   15KB");
      Data=_L("Audio inside");

      index++;
      item.Format(KListItemFormat,&Data,&number /*index,*/); //, index+1
      
      //item.Copy(number);
      itemList->AppendL(item);

      number=_L("size   125KB");
      Data=_L("Docs inside");

      index++;
      item.Format(KListItemFormat,&Data,&number /*index,*/); //, index+1
      
      //item.Copy(number);
      itemList->AppendL(item);

      number=_L("size   153KB");
      Data=_L("Videos inside");

      index++;
      item.Format(KListItemFormat,&Data,&number /*index,*/); //, index+1
      
      //item.Copy(number);
      itemList->AppendL(item);

      number=_L("size   115KB");
      Data=_L("Games inside");

      index++;
      item.Format(KListItemFormat,&Data,&number /*index,*/); //, index+1
      
      //item.Copy(number);
      itemList->AppendL(item);

   }
   // set items and ownership

   list->Model()->SetItemTextArray(itemList);

   //iEikonEnv->AlertWin(_L("be"));

   list->Model()->SetOwnershipType(ELbmOwnsItemArray);       
   
   // construct icon array with granularity 3
   // update listbox
   
   list->HandleItemAdditionL();
   list->SetRect(Rect());
//   list->DrawNow();

}




//-----------------------------------------------------------
// Selected List item module
//
//-----------------------------------------------------------

TInt CV_DriveContainer::SelectedItems()
{
   if(list)
   {

    TInt num_sel =  list->CurrentItemIndex();
   /*   CTextListBoxModel * model = list->Model();
      if(model->NumberOfItems()>0)
      {
         const CListBoxView::CSelectionIndexArray* selectionIndices =list->SelectionIndexes();
      Ã‚    TInt num_sel = selectionIndices->Count();
         if (num_sel ==1 )
         {
            TInt  selected =  selectionIndices->At(0);
      return selected ;
            }
      Ã‚    else
         {
            if(num_sel==2)
            {
            return num_sel;
            }
            else
               return -1;
      selectionIndices->At(1);
         }
      }*/

      return num_sel;
   }
}



void CV_DriveContainer::HandleListBoxEventL(CEikListBox*  /*alistbox*/, TListBoxEvent aListBoxEvent)
   {
   // if the Select Key has been pressed MEikListBoxObserver::
   //if (list)
    if (  aListBoxEvent == (MEikListBoxObserver::EEventEnterKeyPressed) )
      {
       // SelectedItems();
         
       CreateMyListInside();
       list->DrawNow();
       //CAknInformationNote* informationNote = new (ELeave)CAknInformationNote;
       //informationNote->ExecuteLD(_L("Item Selected ."));
     
      }
   }


// ---------------------------------------------------------
// CStockContainer2::SizeChanged()
// Called by framework when the view size is changed
// ---------------------------------------------------------
//
void CV_DriveContainer::SizeChanged()
    {
   // TODO: Add here control resize code etc.
      if(list)
      list->SetRect(Rect());
    }

// ---------------------------------------------------------
// CStockContainer2::CountComponentControls() const
// ---------------------------------------------------------
//
TInt CV_DriveContainer::CountComponentControls() const
    {
    if(list)
      return 1;
     
   return 0;  // return nbr of controls inside this container
    }

// ---------------------------------------------------------
// CStockContainer2::ComponentControl(TInt aIndex) const
// ---------------------------------------------------------
//

CCoeControl* CV_DriveContainer::ComponentControl(TInt aIndex) const
    {
    switch ( aIndex )
        {
        case 0:
            return list;
       
        default:
            return NULL;
        }
    }

// ---------------------------------------------------------
// CStockContainer2::Draw(const TRect& aRect) const
// ---------------------------------------------------------
//

void CV_DriveContainer::Draw(const TRect& aRect) const
    {
    CWindowGc& gc = SystemGc();
    // TODO: Add your drawing code here
    // example code...
   // draw background
   MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
    AknsDrawUtils::Background( skin, cc, this, gc, aRect );
    }



//=======================================
//this is used to move up and down
//========================================

TKeyResponse CV_DriveContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
{
   if(list)
   //   SelectedItems();
      return list->OfferKeyEventL( aKeyEvent, aType);
       
   return EKeyWasNotConsumed ;
}


// ---------------------------------------------------------
// CStockContainer2::HandleControlEventL(
//     CCoeControl* aControl,TCoeEvent aEventType)
// ---------------------------------------------------------
//

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

// ---------------------------------------------------------
// CStockContainer2::MopSupplyObject()
// Pass skin information if needed.
// ---------------------------------------------------------
//

TTypeUid::Ptr CV_DriveContainer::MopSupplyObject(TTypeUid aId)
    {
      /*
      Ã‚    if(aId.iUid == MAknsControlContext::ETypeId && iBackGround)
         {
         return MAknsControlContext::SupplyMopObject( aId, iBackGround);
         }

         */
    return CCoeControl::MopSupplyObject( aId );
    }

// End of File 



 
  • Login to reply to this topic.