×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Regular Contributor
    Join Date
    Apr 2009
    Location
    Delhi
    Posts
    136

    UI design Listbox creation

    hello
    i m new at ui design.i m useing carbide developers version.m trying to create list box containing inbbox,outbox n all for sms.i have done the part of ui view just by drag n drop but unable to undestand code in listbox.cpp.(e.g where should i add code to do perticular task so list box item accesable with event key n show msg or do perticular task)
    here is my some part of listbox.cpp file
    Code:
    /*
    
    
    CKkListBox::CKkListBox()
    	{
    	// [[[ begin generated region: do not modify [Generated Contents]
    	iListBox = NULL;
    	// ]]] end generated region [Generated Contents]
    	
    	}
    CKkListBox::~CKkListBox()
    	{
    	// [[[ begin generated region: do not modify [Generated Contents]
    	delete iListBox;
    	iListBox = NULL;
    	// ]]] end generated region [Generated Contents]
    	
    	}
    				
    CKkListBox* CKkListBox::NewL( 
    		const TRect& aRect, 
    		const CCoeControl* aParent, 
    		MEikCommandObserver* aCommandObserver )
    	{
    	CKkListBox* self = CKkListBox::NewLC( 
    			aRect, 
    			aParent, 
    			aCommandObserver );
    	CleanupStack::Pop( self );
    	return self;
    	}
    
    /**
     * Construct the control (first phase).
      */
    CKkListBox* CKkListBox::NewLC( 
    		const TRect& aRect, 
    		const CCoeControl* aParent, 
    		MEikCommandObserver* aCommandObserver )
    	{
    	CKkListBox* self = new ( ELeave ) CKkListBox();
    	CleanupStack::PushL( self );
    	self->ConstructL( aRect, aParent, aCommandObserver );
    	return self;
    	}
    			
    /**
     * Construct the control (second phase).
      */ 
    void CKkListBox::ConstructL( 
    		const TRect& aRect, 
    		const CCoeControl* aParent, 
    		MEikCommandObserver* aCommandObserver )
    	{
    	if ( aParent == NULL )
    	    {
    		CreateWindowL();
    	    }
    	else
    	    {
    	    SetContainerWindowL( *aParent );
    	    }
    	iFocusControl = NULL;
    	iCommandObserver = aCommandObserver;
    	InitializeControlsL();
    	SetRect( aRect );
    	ActivateL();
    		
    	}
    TInt CKkListBox::CountComponentControls() const
    	{
    	return ( int ) ELastControl;
    	}			
    /**
    Get the control with the given index (override)
    */
    CCoeControl* CKkListBox::ComponentControl( TInt aIndex ) const
    	{
    	// [[[ begin generated region: do not modify [Generated Contents]
    	switch ( aIndex )
    		{
    	case EListBox:
    		return iListBox;
    		}
    	return NULL;
    	}		
    				
    // [[[ begin generated function: do not modify
    
    void CKkListBox::LayoutControls()
    	{
    	iListBox->SetExtent( TPoint( 0, 0 ), iListBox->MinimumSize() );
    	}	
    TKeyResponse CKkListBox::OfferKeyEventL( 
    		const TKeyEvent& aKeyEvent, 
    		TEventCode aType )
    	{
    	// [[[ begin generated region: do not modify [Generated Contents]
    	if ( aKeyEvent.iCode == EKeyLeftArrow 
    		|| aKeyEvent.iCode == EKeyRightArrow )
    		{
    		// Listbox takes all events even if it doesn't use them
    		return EKeyWasNotConsumed;
    		}
    	
    	// ]]] end generated region [Generated Contents]
    	
    	if ( iFocusControl != NULL
    		&& iFocusControl->OfferKeyEventL( aKeyEvent, aType ) == EKeyWasConsumed )
    		{
    		return EKeyWasConsumed;
    		}
    	return CCoeControl::OfferKeyEventL( aKeyEvent, aType );
    	}
    				
    // [[[ begin generated function: do not modify
    /*
     *	Initialize each control upon creation.
     */				
    void CKkListBox::InitializeControlsL()
    	{
    	iListBox = new ( ELeave ) CAknSingleLargeStyleListBox;
    	iListBox->SetContainerWindowL( *this );
    		{
    		TResourceReader reader;
    		iEikonEnv->CreateResourceReaderLC( reader, R_KK_LIST_BOX_LIST_BOX );
    		iListBox->ConstructFromResourceL( reader );
    		CleanupStack::PopAndDestroy(); // reader internal state
    		}
    	// the listbox owns the items in the list and will free them
    	iListBox->Model()->SetOwnershipType( ELbmOwnsItemArray );
    	
    	// setup the icon array so graphics-style boxes work
    	SetupListBoxIconsL();
    	// add list items
    	AddListBoxResourceArrayItemL( R_KK_LIST_BOX_NEW_SMS,
    			EListBoxKkKIndex );
    	AddListBoxResourceArrayItemL( R_KK_LIST_BOX_INBOX,
    			EListBoxKkList_iconIndex );
    	AddListBoxResourceArrayItemL( R_KK_LIST_BOX_OUTBOX,
    			EListBoxKkList_iconIndex );
    	AddListBoxResourceArrayItemL( R_KK_LIST_BOX_SENT,
    			EListBoxKkList_iconIndex );	
    	iListBox->SetFocus( ETrue );
    	iFocusControl = iListBox;
    	
    	}
    /** 
     * Handle global resource changes, such as scalable UI or skin events (override)
     */
    void CKkListBox::HandleResourceChange( TInt aType )
    	{
    	CCoeControl::HandleResourceChange( aType );
    	SetRect( iAvkonViewAppUi->View( TUid::Uid( EKkListBoxViewId ) )->ClientRect() );
    	// [[[ begin generated region: do not modify [Generated Contents]
    	// ]]] end generated region [Generated Contents]
    	
    	}
    /**
     *	Add a list box item to a list.
     */
    void CKkListBox::AddListBoxItemL( 
    		CEikTextListBox* aListBox,
    		const TDesC& aString )
    	{
    	CTextListBoxModel* model = aListBox->Model();
    	CDesCArray* itemArray = static_cast< CDesCArray* > ( model->ItemTextArray() );
    	itemArray->AppendL( aString );
    	aListBox->HandleItemAdditionL();
    	}
    // [[[ begin generated function: do not modify
    RArray< TInt >* CKkListBox::GetSelectedListBoxItemsLC( CEikTextListBox* aListBox )
    	{
    	CAknFilteredTextListBoxModel* model = 
    		static_cast< CAknFilteredTextListBoxModel *> ( aListBox->Model() );
    	if ( model->NumberOfItems() == 0 )
    		return NULL;	
    	// get currently selected indices
    	const CListBoxView::CSelectionIndexArray* selectionIndexes =
    		aListBox->SelectionIndexes();
    	TInt selectedIndexesCount = selectionIndexes->Count();
    	if ( selectedIndexesCount == 0 )
    		return NULL;	
    	RArray<TInt>* orderedSelectedIndices = 
    		new (ELeave) RArray< TInt >( selectedIndexesCount );
    	// push the allocated array
    	CleanupStack::PushL( orderedSelectedIndices );
    	// dispose the array resource
    	CleanupClosePushL( *orderedSelectedIndices );
    	// see if the search field is enabled
    	CAknListBoxFilterItems* filter = model->Filter();
    	if ( filter != NULL )
    		{
    		// when filtering enabled, translate indices back to underlying model
    		for ( TInt idx = 0; idx < selectedIndexesCount; idx++ )
    			{
    			TInt filteredItem = ( *selectionIndexes ) [ idx ];
    			TInt actualItem = filter->FilteredItemIndex ( filteredItem );
    			orderedSelectedIndices->InsertInOrder( actualItem );
    			}
    		}
    	else
    		{
    		// the selection indices refer directly to the model
    		for ( TInt idx = 0; idx < selectedIndexesCount; idx++ )
    			orderedSelectedIndices->InsertInOrder( ( *selectionIndexes ) [ idx ] );
    		}	
    		
    	return orderedSelectedIndices;
    	}
    void CKkListBox::DeleteSelectedListBoxItemsL( CEikTextListBox* aListBox )
    	{
    	CAknFilteredTextListBoxModel* model = 
    		static_cast< CAknFilteredTextListBoxModel *> ( aListBox->Model() );
    	if ( model->NumberOfItems() == 0 )
    		return;
    	
    	RArray< TInt >* orderedSelectedIndices = GetSelectedListBoxItemsLC( aListBox );		
    	if ( !orderedSelectedIndices )
    		return;
    		
    	// Delete selected items from bottom up so indices don't change on us
    	CDesCArray* itemArray = static_cast< CDesCArray* > ( model->ItemTextArray() );
    	TInt currentItem = 0;
    	
    	for ( TInt idx = orderedSelectedIndices->Count(); idx-- > 0; ) 
    		{
    		currentItem = ( *orderedSelectedIndices )[ idx ];
    		itemArray->Delete ( currentItem );
    		}
    	
    	// dispose the array resources
    	CleanupStack::PopAndDestroy();
    	
    	// dispose the array pointer
    	CleanupStack::PopAndDestroy( orderedSelectedIndices );
    	
    	// refresh listbox's cursor now that items are deleted
    	AknListBoxUtils::HandleItemRemovalAndPositionHighlightL(
    		aListBox, currentItem, ETrue );
    	}
    
    // ]]] end generated function
    
    // [[[ begin generated function: do not modify
    
    CAknSingleLargeStyleListBox* CKkListBox::ListBox()
    	{
    	return iListBox;
    	}
    
    // ]]] end generated function
    
    // [[[ begin generated function: do not modify
    /**
     *	Create a list box item with the given column values.
     */
    void CKkListBox::CreateListBoxItemL( TDes& aBuffer, 
    		TInt aIconIndex,
    		const TDesC& aMainText )
    	{
    	_LIT ( KStringHeader, "%d\t%S" );
    	
    	aBuffer.Format( KStringHeader(), aIconIndex, &aMainText );
    	} 
    				
    // ]]] end generated function
    
    // [[[ begin generated function: do not modify
    /**
     *	Add an item to the list by reading the text items from the array resource
     *	and setting a single image property (if available) from an index
     *	in the list box's icon array.
     *	@param aResourceId id of an ARRAY resource containing the textual
     *	items in the columns
     *	@param aIconIndex the index in the icon array, or -1
     */
    void CKkListBox::AddListBoxResourceArrayItemL( TInt aResourceId, TInt aIconIndex )
    	{
    	CDesCArray* array = iCoeEnv->ReadDesCArrayResourceL( aResourceId );
    	CleanupStack::PushL( array );
    	// This is intended to be large enough, but if you get 
    	// a USER 11 panic, consider reducing string sizes.
    	TBuf<512> listString; 
    	CreateListBoxItemL( listString, aIconIndex, ( *array ) [ 0 ] );
    	AddListBoxItemL( iListBox, listString );
    	CleanupStack::PopAndDestroy( array );
    	} 
    				
    // ]]] end generated function
    
    // [[[ begin generated function: do not modify
    /**
     *	Set up the list's icon array.
     */
    
    // ]]] end generated function
    
    // [[[ begin generated function: do not modify
    /** 
     *	Handle commands relating to markable lists.
     */
    TBool CKkListBox::HandleMarkableListCommandL( TInt aCommand )
    	{
    	return EFalse;
    	}
    
    // ]]] end generated function
    
    // [[[ begin generated function: do not modify
    /**
     *	This routine loads and scales a bitmap or icon.
     *
     *	@param aFileName the MBM or MIF filename
     *	@param aBitmapId the bitmap id
     *	@param aMaskId the mask id or -1 for none
     *	@param aSize the TSize for the icon, or NULL to use real size
     *	@param aScaleMode one of the EAspectRatio* enums when scaling
     *
     */
    CGulIcon* CKkListBox::LoadAndScaleIconL( 
    		const TDesC& aFileName,
    		TInt aBitmapId, 
    		TInt aMaskId, 
    		TSize* aSize, 
    		TScaleMode aScaleMode )
    	{
    	CFbsBitmap* bitmap;
    	CFbsBitmap* mask;
    	//
    its basic i know but i havent worked befor on ui design so help me guys.

    regards
    kapnkore

  2. #2
    Super Contributor
    Join Date
    Jul 2007
    Location
    Beijing, China
    Posts
    538

    Re: UI design Listbox creation

    Open SDK and search "Using Lists API"

Similar Threads

  1. UI Design
    By hudarsono in forum Symbian
    Replies: 3
    Last Post: 2009-05-16, 19:19
  2. how to display the Listbox
    By arungupta_2jan in forum Symbian
    Replies: 4
    Last Post: 2009-03-03, 21:10
  3. UI design.
    By Antony52 in forum Mobile Java General
    Replies: 0
    Last Post: 2004-12-04, 02:15

Posting Permissions

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