Friday, March 31, 2006

List Box Construction

Here is how we construct a list box


TInt flags( CEikListBox::EPopout | CEikListBox::ELeftDownInViewRect );
iListBox = new( ELeave ) CEikColumnListBox;
iListBox->ConstructL( this, flags );

iListBox->SetListBoxObserver( iHandler );
iListBox->SetBorder( TGulBorder::EShallowRaised );
iListBox->CreateScrollBarFrameL( ETrue );
iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );

// Creates list items
CDesCArray* textArray = iCoeEnv->ReadDesCArrayResourceL( resourceId );
iListBox->Model()->SetItemTextArray( textArray );
iListBox->Model()->SetOwnershipType( ELbmOwnsItemArray );

// Sets pixel values of width.
TRect rect(TPoint(KAknExQueryListBoxRectPointX,
KAknExQueryListBoxRectPointY),
TSize(KAknExQueryListBoxRectWidth,
KAknExQueryListBoxRectHeight) );

CColumnListBoxData* columnData = iListBox->ItemDrawer()->ColumnData();
columnData->SetColumnWidthPixelL( KAknExQueryNameColumnIndex,
rect.Width() );
columnData->SetColumnWidthPixelL( KAknExQueryNameGapColumnIndex,
rect.Width() );

// Gets current number of list box items.
TInt numberOfItems( iListBox->Model()->NumberOfItems() );
// Gets new height of list box.
TInt height( iListBox->CalcHeightBasedOnNumOfItems( numberOfItems ) );
// If new height is less than defined height of list box
// sets new height to list box height.
if ( height < rect.Height() )
{
rect.SetHeight( height );
}

iListBox->SetRect( rect ); // Sets rectangle of list box.
ActivateL();

Simple Debugging Hints

1. iEikonEnv->InfoMsg(_L("Confirmation Query"));

Tuesday, March 28, 2006

Query Example

This example details various types of query dialogs. I will do following assignments on basis of this example.

1. Single view with a list control which is populated from file on the FS
2. Multiple view app from the scratch. Will keep adding views until it resemples the actual app.

The second part is in progress. I have an app with 2 views. The second view has a data query and the filled data appears on a label on 2nd view. It isn't the most optimized thingy but it works.

Here are some of the observations..

1. iCoeEnv->ReadResource() isn't working but I know how to make it.
2. If a .rsg file cannot be opened, it may be because the file has not been created in the first place because of errors in the file.
3. Compile error incase header uses a component without including the component's header. Error shows in corresponding .cpp file though.
4. "Illegal use of incomplete struct/union/class" error occurs if corresponding header isn't included.
5. "Undefined Symbol" error of some old function can be resolved by cleaning and rebuilding.
6. Buffers are used as literals. They are interchangeable.