Need help on Custom Listbox using custom Itemdrawer

Login to reply to this topic.
Sun, 2008-01-20 06:15
Joined: 2008-01-04
Forum posts: 5

I have downloaded the multilist example of dreambox and am trying to add a custom Item drawer to it to extend its functionality with a custom itemdrawer class .
Puzzled ????????????????? Shocked


void CDreamColumnListBoxSub::ConstructL(CDreamColumnListBox* aParent,TInt aFlags,const CFont* aFont) {
////////////////////////////////////////////////////////////For some instance this line refuses to compile////////////////////////////
  CEikColumnListBox::ConstructL(aParent,aFlags,aFont);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  iParent=aParent;
CreateItemDrawerL();

}

void CDreamColumnListBoxSub::HandleScrollEventL(CEikScrollBar* aScrollBar, TEikScrollEvent aEventType) {
  CEikColumnListBox::HandleScrollEventL(aScrollBar,aEventType);

  // now report this scroll event "up" to the parent list box so that
  // the header can be "scrolled as well
  iParent->HandleScrollEventL(aScrollBar,aEventType);
}
void CDreamColumnListBoxSub::CreateItemDrawerL()
	{ 
//////////////////[="Red"][="3"]Kern Exec 3 Panic Error after this line[/][/]//////////////////
	iItemDrawer = new (ELeave) CMultiColumnItemDrawer(Model(),iListFont,CColumnListBoxData::NewL(),this);
////////////////////////////////////////////////////////
	}

#ifndef MULTICOLUMNITEMDRAWER_H_
#define MULTICOLUMNITEMDRAWER_H_

#include <eikclb.h>
#include <eikclbd.h>
#include <eiklbm.h> 
#include  <gdi.h>
#include <e32def.h>
#include <e32std.h>

#include "CDreamColumnListBoxSub.h"
//FORWARD DECLARATION
class CDreamColumnListBoxSub;
class CFont;
//CLASS DECLARATION
class CMultiColumnItemDrawer : public CColumnListBoxItemDrawer
{
public:

    CMultiColumnItemDrawer(MTextListBoxModel *aTextListBoxModel, const CFont *aFont,
    		CColumnListBoxData *aColumnData, CDreamColumnListBoxSub * aListBox);
   virtual ~CMultiColumnItemDrawer();
   
private: // CListItemDrawer
void DrawActualItem(TInt aItemIndex, const TRect& aActualItemRect,TBool aItemIsCurrent,
		TBool aViewIsEmphasized, TBool aViewIsDimmed,TBool aItemIsSelected) const;

private:
     CDreamColumnListBoxSub* iListBox;
     //const CFont * iFont;
     TInt iCurPos;  // starting position for the next column, and at the
     // same time total width of the control
     TInt iCurOffset;
};

#endif /*MULTICOLUMNITEMDRAWER_H_*/

#include "MultiColumnItemDrawer.h"

 CMultiColumnItemDrawer::CMultiColumnItemDrawer(MTextListBoxModel *aTextListBoxModel, const CFont *aFont, CColumnListBoxData *aColumnData,  CDreamColumnListBoxSub * aListBox)
:CColumnListBoxItemDrawer(aTextListBoxModel,aFont, aColumnData),
iListBox(aListBox)
{
iGc = &CCoeEnv::Static()->SystemGc();
SetGc(iGc);
//iFont=aFont;
iCurPos=0;  // starting position for the next column, and at the
// same time total width of the control
iCurOffset=0;
}

 CMultiColumnItemDrawer::~CMultiColumnItemDrawer()
{
}
 
void CMultiColumnItemDrawer::DrawActualItem(TInt aItemIndex,
        const TRect& aActualItemRect, TBool /*aItemIsCurrent*/,
        TBool /*aViewIsEmphasized*/, TBool /*aViewIsDimmed*/,
        TBool aItemIsSelected) const
        {
        // Sets all the attributes, like font, text color and background color.
       const CFont* iFont = CEikonEnv::Static()->NormalFont();
        iGc->UseFont(iFont);
        iGc->SetPenColor(iTextColor);
        iGc->SetPenStyle(CGraphicsContext::ESolidPen);
        if(aItemIsSelected)
        iGc->SetBrushColor(TRgb(105,215,215));
        else
        iGc->SetBrushColor(TRgb(215,0,0));
        iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
        iGc->DrawRect(aActualItemRect);
        // Draws the item text.
        TPtrC itemText = iListBox->Model()->ItemText(aItemIndex);            
        TInt tabPosition1 = itemText.Locate('\t');
        iGc->SetPenColor(KRgbGray);//itemText.Mid(0,tabPosition1)
//        HBufC text=;
//        text.Copy(itemText.Mid(0,tabPosition1),itemText.Length()); 
        TInt start=0;
        TInt width=20;//font.TextWidthInPixels(text);
        TRect textRect1 =TRect(aActualItemRect.iTl.iX,aActualItemRect.iTl.iY+8,width,aActualItemRect.iBr.iY-3);
        TInt baseline1 =(textRect1.iBr.iY - textRect1.iTl.iY - iFont->HeightInPixels()) / 2 + iFont->AscentInPixels();
        iGc->DrawText(itemText.Mid(0,tabPosition1), textRect1, baseline1,CGraphicsContext::ELeft, 1);
        TInt tabPosition2 = itemText.Mid(tabPosition1 + 1).Locate('\t');
        iGc->SetPenColor(KRgbBlue);
        start=width+2;
        width=100;
        TRect textRect2 =TRect(aActualItemRect.iTl.iX+start,aActualItemRect.iTl.iY+8,aActualItemRect.iTl.iX+start+width,aActualItemRect.iBr.iY-3);
        TInt baseline2 =(textRect2.iBr.iY - textRect2.iTl.iY - iFont->HeightInPixels()) / 2 + iFont->AscentInPixels();
        iGc->DrawText(itemText.Mid(tabPosition1+1,tabPosition2), textRect2, baseline2,CGraphicsContext::ELeft, 1);
//        if (tabPosition2 >= 0)
//           {
//           // We need to add tabPosition1 because the return value of
//           // Locate() is relative to tabPosition1.
//           tabPosition2 += tabPosition1 + 1;
//           }
//        
////        TInt baseline = (aActualItemRect.Height() - iFont->HeightInPixels()) / 2
//                                + iFont->AscentInPixels();
//        iGc->DrawText(itemText, aActualItemRect, baseline);
        }


Mon, 2008-01-21 06:34
Joined: 2007-08-31
Forum posts: 54
Re: Need help on Custom Listbox using custom Itemdrawer

Hi giglie

i did not get what is your problem but i customized the list box so i am giving code in attachments, you just follow this format for customizing Listbox for your requirement

Regards

Praveenvlm

AttachmentSize
CustomListBox.h1.61 KB
CustomListBox.cpp5.31 KB
Tue, 2008-01-22 08:03
Joined: 2008-01-04
Forum posts: 5
Re: Need help on Custom Listbox using custom Itemdrawer

Hey I used that one too Sad but the exception I am getting is from stack is

Thread [Thread id: 3132] (Suspended: Signal 'Exception 5' received. Description: Access Violation.)	
	27 0xAA65C64( EIKCOCTL.DLL )()  0x0aa65c64	
	26 0xAA661D2( EIKCOCTL.DLL )()  0x0aa661d2	
	25 0xAB21DF5( EIKCTL.DLL )()  0x0ab21df5	
	24 CDreamColumnListBoxSub::ConstructL() C:\SymbianCarbideworkspace\PortfolioManager\src\CDreamColumnListBoxSub.cpp:13 0x18e1426b	
	23 CDreamColumnListBox::ConstructL() C:\SymbianCarbideworkspace\PortfolioManager\src\CDreamColumnListBox.cpp:17 0x18e13973	
	22 CMultiColumnList::ConstructL() C:\SymbianCarbideworkspace\PortfolioManager\src\MultiColumnList.cpp:24 0x18e15620	
	21 CAknExGridAppUi::ShowMultiList() C:\SymbianCarbideworkspace\PortfolioManager\src\aknexgridappui.cpp:234 0x18e11858	
	20 CAknExGridAppUi::HandleCommandL() C:\SymbianCarbideworkspace\PortfolioManager\src\aknexgridappui.cpp:136 0x18e11312	
	19 0xA560C47( AVKON.DLL )()  0x0a560c47	
	18 0xAA76E44( EIKCOCTL.DLL )()  0x0aa76e44	
	17 0xAA774BF( EIKCOCTL.DLL )()  0x0aa774bf	
	16 0xAA719D3( EIKCOCTL.DLL )()  0x0aa719d3	
	15 0xAA3BF1C( EIKCOCTL.DLL )()  0x0aa3bf1c	
	14 0xAA41D95( EIKCOCTL.DLL )()  0x0aa41d95	
	13 0x406010BF( CONE.DLL )()  0x406010bf	
	12 0x40601BB0( CONE.DLL )()  0x40601bb0	
	11 0x753041C6( EIKCORE.DLL )()  0x753041c6	
	10 0xA496EA0( AVKON.DLL )()  0x0a496ea0	
	9 0x40608F89( CONE.DLL )()  0x40608f89	
	8 0x60007231( EUSER.DLL )()  0x60007231	
	7 0x6000704C( EUSER.DLL )()  0x6000704c	
	6 0x40608E75( CONE.DLL )()  0x40608e75	
	5 0x7530658A( EIKCORE.DLL )()  0x7530658a	
	4 0x753065EA( EIKCORE.DLL )()  0x753065ea	
	3 0x6001C9FD( EUSER.DLL )()  0x6001c9fd	
	2 0x5B0105F7( EKERN2.DLL )()  0x5b0105f7	
	1 0x7C80B50B( KERNEL32.dll )()  0x7c80b50b	


immediatly after successfull execution of CreateItemDrawerL .

Tue, 2008-01-22 09:14
NewLC AdministratorSymbian AccreditedForum Nokia Champion
Joined: 2003-01-14
Forum posts: 2009
Re: Need help on Custom Listbox using custom Itemdrawer

What is in your CDreamColumnListBoxSub::ConstructL() ?


Eric Bustarret
NewLC Founder & CEO / Professional Symbian OS Consultant

  • Login to reply to this topic.