List Item

  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View List Item as PDF for free.

More details

  • Words: 2,679
  • Pages: 23
//================================================================= // // File : NPsinglelistitem.cpp // Version : 1.0 // Author : Rahul Sharma. (Endeavour Software Technologies (P) Ltd. 2006-2007) // Date : 2007-11-27 // Description : Source file for NPsinglelistitem // // History // ======================================================== // sr.No. Name Title Date // ======================================================== // 01. Rahul Sharma Initial version 2008-01-23 // // ======================================================== // // SYSTEM INCLUDE #include <eikenv.h> fonts. #include #include <deezer.mbg> #include //#include "log.h" // USER INCLUDE #include "deezer.hrh" #include "npsinglelistitem.h" #include "npmymusiccontainer.h"

// Give access to device-independent

#define KBitmapFilePath _L("\\Resource\\Apps\\deezer.mbm") #define KMaxChars 22 // ---------------------------------------------------------------------------// CNPSingleListItem::CNPSingleListItem(CFbsBitmap* aSelectedBitmap, CFbsBitmap* aUnselectedBitmap) // Default constructor. // ---------------------------------------------------------------------------// CNPSingleListItem::CNPSingleListItem(MNPSingleListObserver& aSingleListObserver) : iSingleListObserver(aSingleListObserver), iItemIndex(0), iCount(0), iNoOfImage(0)/*, iCallback(&MoveLabel, this)*/ { } // ---------------------------------------------------------------------------// CNPSingleListItem::~CNPSingleListItem() // Freeup memory // ---------------------------------------------------------------------------// CNPSingleListItem::~CNPSingleListItem() { if (iBackgroundImage != NULL) { delete iBackgroundImage; iBackgroundImage = NULL; } if (iTextArray.Count() > 0) { for (TInt index = 0; index < iTextArray.Count(); index++)

{ delete iTextArray[index]; iTextArray[index] = NULL; }

} iTextArray.Close(); if (iRatingArray.Count() > 0) { for (TInt index = 0; index < iRatingArray.Count(); index++) { delete iRatingArray[index]; iRatingArray[index] = NULL; } } iRatingArray.Close(); if (iDisplayText != NULL) { delete iDisplayText; iDisplayText = NULL; } if (iMenuText != NULL) { delete iMenuText; iMenuText = NULL; } if (iInboxValue != NULL) { delete iInboxValue; iInboxValue = NULL; } if (iFileImage != NULL) { delete iFileImage; iFileImage = NULL; } if (iAlarm!=NULL) { if (iAlarm->IsActive()) { iAlarm->Cancel(); } delete iAlarm; iAlarm = NULL; } } // ---------------------------------------------------------------------------// CNPSingleListItem::CNPSingleListItem* NewL(const TRect& aRect, const CCoeControl* aParent) // Two-phase contructors may leave. // ---------------------------------------------------------------------------// CNPSingleListItem* CNPSingleListItem::NewL(const TRect& aRect, const CCoeControl* aParent, MNPSingleListObserver& aSingleListObserver, TInt aId) { CNPSingleListItem* self = NewLC(aRect, aParent, aSingleListObserver, aId); CleanupStack::Pop(self);

return self; } // ---------------------------------------------------------------------------// CNPSingleListItem::CNPSingleListItem* NewLC(const TRect& aRect, const CCoeControl* aParent) // Two-phase constructors may leave. Keeps object on cleanup stack while return and calling function has to take care of removing object from cleanup stack. // ---------------------------------------------------------------------------// CNPSingleListItem* CNPSingleListItem::NewLC(const TRect& aRect, const CCoeControl* aParent, MNPSingleListObserver& aSingleListObserver, TInt aId) { CNPSingleListItem* self = new (ELeave)CNPSingleListItem(aSingleListObserver); CleanupStack::PushL(self); self->ConstructL(aRect, aParent, aId); return self; } // ---------------------------------------------------------------------------// void CNPSingleListItem::ConstructL(const TRect& aRect, const CCoeControl* aParent) // Two-phase constructor. Contains all initialization that may leave. // ---------------------------------------------------------------------------// void CNPSingleListItem::ConstructL(const TRect& aRect, const CCoeControl* aParent, TInt aId) { SetContainerWindowL(*aParent); SetRect(aRect); SetUniqueHandle(aId); iRect = aRect; iBackgroundImage = iEikonEnv>CreateBitmapL(KBitmapFilePath,EMbmDeezerBackground); iFileImage = iEikonEnv->CreateBitmapL(KBitmapFilePath,EMbmDeezerSynchrobar); iAlarm = CPeriodic::New(EPriorityLow); //iFlgHelp is true if the single list item is used for help screen iFlgHelp = EFalse; ActivateL(); } // ---------------------------------------------------------------------------// void CNPSingleListItem::Draw() // Draw the list item // ---------------------------------------------------------------------------// void CNPSingleListItem::Draw(const TRect& aRect) const { TPoint imageDrawPosition(0, 0); TPoint textDrawPosition(0, 0); TPoint scrollDrawPosition(0, 0); TPoint playIconDrawPosition(0, 0); TPoint headerIconPosition(0, 0);

TPoint TPoint TPoint TPoint

ratingIconPosition(0, 0); ratingValuePosition(0, 0); inboxImagePosition(0, 0); inboxTextPosition(0, 0);

TRect inboxRect(TRect(TPoint(0, 0), TPoint(0, 0))); TRect iconRect(TRect(TPoint(0, 0), TPoint(0, 0))); TInt Count = 0; HBufC* temp= NULL;//HBufC::NewL(20); HBufC* ratingValueTemp= NULL;//HBufC::NewL(20); HBufC* scrollTemp = HBufC::NewL(30); TInt TInt TInt TInt

arrlength = 0; noOfImages = 0; textWidth = 0; length = 0;

HBufC* text1 = HBufC::NewL(_L("**EMPTY**").Length()); text1->Des().Copy(_L("**EMPTY**")); CWindowGc& gc = SystemGc(); gc.SetBrushStyle(CGraphicsContext::ENullBrush); gc.Clear(aRect); gc.SetPenStyle(CGraphicsContext::ENullPen); gc.UseBrushPattern(iBackgroundImage); gc.SetBrushStyle(CGraphicsContext::EPatternedBrush); gc.DrawRect(aRect); arrlength = iTextArray.Count(); if (arrlength == 0 || iSelectedBitmap == NULL || iUnselectedBitmap == NULL) return; TSize ImageSize = iSelectedBitmap->SizeInPixels(); TSize imageSize = iSelectedBitmap->SizeInPixels(); // //

const CFont* font = CEikonEnv::Static()->LegendFont(); gc.UseFont(font);

_LIT( KMyFontName, "Arial" ); TFontSpec FontSpec(KMyFontName, 300); CFont* font = iCoeEnv->CreateScreenFontL(FontSpec); gc.UseFont(font); // //

gc.SetBrushStyle( CGraphicsContext::ESolidBrush); gc.SetPenColor(KRgbRed);

TRect sourceRect(TPoint(0, 0), iSelectedBitmap->SizeInPixels()); // //

if(iRightIconImage == NULL) return;

if (iRightIconImage != NULL) iconRect = TRect((TPoint(0, 0), iRightIconImage->SizeInPixels()));

if (iInboxImage != NULL) inboxRect = TRect(TPoint(0, 0), iInboxImage->SizeInPixels()); imageDrawPosition.iX = aRect.iTl.iX; imageDrawPosition.iY = aRect.iTl.iY; textDrawPosition.iX = aRect.iTl.iX + 15; textDrawPosition.iY = imageDrawPosition.iY + imageSize.iHeight/2 + font->HeightInPixels()/2 - 1; // inboxTextPosition.iX = aRect.iTl.iX + 65; //headerIconPosition.iX + font->TextWidthInPixels(iTextArray[5]->Des()) + 10;

// inboxTextPosition.iY = imageDrawPosition.iY + imageSize.iHeight/2 + font->HeightInPixels()/2; if (iInboxImage != NULL) { inboxTextPosition.iX = textDrawPosition.iX + font->TextWidthInPixels(iTextArray[5]->Des()) + 2; inboxTextPosition.iY = imageDrawPosition.iY + imageSize.iHeight/2 + font->HeightInPixels()/2 - 1; inboxImagePosition.iX = inboxTextPosition.iX + font->TextWidthInPixels(iInboxValue->Des()) + 2; inboxImagePosition.iY = imageDrawPosition.iY + imageSize.iHeight/2 - iInboxImage->SizeInPixels().iHeight/2 + 2; } if (iRightIconImage != NULL) { // playIconDrawPosition.iX = aRect.iBr.iX - (12*aRect.iBr.iX)/100; playIconDrawPosition.iX = aRect.iBr.iX - (aRect.iBr.iX * 0.14 ); playIconDrawPosition.iY = imageDrawPosition.iY + imageSize.iHeight/2 - iRightIconImage->SizeInPixels().iHeight/2; } if (iRatingIcon != NULL) { ratingIconPosition.iX = aRect.iBr.iX - (aRect.iBr.iX * 0.14 ); ratingIconPosition.iY = imageDrawPosition.iY + imageSize.iHeight/2 - iRatingIcon->SizeInPixels().iHeight/2; } gc.DrawRect(aRect); ratingValuePosition.iX = aRect.iBr.iX - 45; ratingValuePosition.iY = imageDrawPosition.iY + imageSize.iHeight/2 + font->HeightInPixels()/2; //+ 36; // calculating number of images that can be drawn on a screen and // subtracting 1 because count start from 0 to print them. noOfImages = ((aRect.iBr.iY - imageDrawPosition.iY)/imageSize.iHeight) - 1; gc.SetPenColor(iNormalTextColor);

if (arrlength <= noOfImages) noOfImages = arrlength - 1; for (Count = iCount; Count <= noOfImages + iCount; Count++) { temp = iTextArray[Count]; if (iItemIndex== Count) { if(iFlgHelp) { if(iItemIndex == 0 ||iItemIndex == 4 ||iItemIndex == 11 || iItemIndex == 15 || iItemIndex == 17 ) { gc.BitBlt(imageDrawPosition, iUnselectedBitmap); gc.DrawText(temp->Des(), textDrawPosition); } else gc.BitBlt(imageDrawPosition, iSelectedBitmap); } else { gc.SetPenColor(iFocusTextColor); gc.SetBrushStyle(CGraphicsContext::ENullBrush); if (temp->Des() != text1->Des()) gc.BitBlt(imageDrawPosition, iSelectedBitmap); else if (iTextArray.Count() <= 1 && temp->Des() == text1->Des()) gc.BitBlt(imageDrawPosition, iFileImage); if (iRightIconImage != NULL && temp->Des() != text1->Des()) gc.BitBltMasked(playIconDrawPosition, iRightIconImage, iconRect, iRightIconImageMask, ETrue); } // gc.DrawText(temp->Des(), textDrawPosition); textWidth = font->TextWidthInPixels(temp->Des()); 24);

TRect box(15, imageDrawPosition.iY, 130, imageDrawPosition.iY + TInt baseline =(box.Height() /2) +(font->AscentInPixels()/2); // added by Laila for text rotation /* if (iAlarm!=NULL) { if (iAlarm->IsActive()) { TChar first=(tmpBuf->Des())[0]; tmpBuf->Des().Delete(0, 1); tmpBuf->Des().Append(first); } } ///end if (tmpBuf != NULL)

gc.DrawText(tmpBuf->Des(), box, baseline, CGraphicsContext::ELeft, 0);*/ if (textWidth < (aRect.iBr.iX * 0.85)) { gc.DrawText(temp->Des(), textDrawPosition); } else if (textWidth >= (aRect.iBr.iX - (aRect.iBr.iX * 0.15) )) { length = (temp->Length()*116) /textWidth; length = length - 2; scrollTemp->Des().Copy(temp->Mid(0, length)); scrollTemp->Des().Append(_L("..")); gc.DrawText(scrollTemp->Des(), textDrawPosition); } if (iInboxImage != NULL) { if (Count == (iTextArray.Count() - 1)) { _LIT(bracket, ")"); gc.DrawText(iInboxValue->Des(), inboxTextPosition); gc.BitBltMasked(inboxImagePosition, iInboxMaskImage, iconRect, iInboxImage, ETrue); gc.DrawText(bracket, TPoint(inboxImagePosition.iX + iInboxImage->SizeInPixels().iWidth + 3, inboxTextPosition.iY - 1)); } } imageDrawPosition.iY = imageDrawPosition.iY + iSelectedBitmap->SizeInPixels().iHeight; //+24; textDrawPosition.iY = imageDrawPosition.iY + imageSize.iHeight/2 + font->HeightInPixels()/2 - 2; if (iRightIconImage != NULL) playIconDrawPosition.iY = imageDrawPosition.iY + imageSize.iHeight/2 - iRightIconImage>SizeInPixels().iHeight/2; if (iRatingIcon != NULL) { ratingIconPosition.iY = imageDrawPosition.iY + imageSize.iHeight/2 - iRatingIcon>SizeInPixels().iHeight/2;

>HeightInPixels()/2;

ratingValuePosition.iY = imageDrawPosition.iY + imageSize.iHeight/2 + font-

} if (iInboxImage != NULL) { inboxImagePosition.iY = imageDrawPosition.iY + imageSize.iHeight/2 - iInboxImage>SizeInPixels().iHeight/2 + 2; inboxTextPosition.iY = imageDrawPosition.iY +

imageSize.iHeight /2 + font->HeightInPixels()/2; // // >SizeInPixels().iHeight/2; // imageSize.iHeight // } else

inboxImagePosition.iY = imageDrawPosition.iY + 8; + imageSize.iHeight/2 - iInboxImageinboxTextPosition.iY = imageDrawPosition.iY + /2 + font->HeightInPixels()/2;

} if (iItemIndex!= Count) { if (iRatingArray.Count() > 0) ratingValueTemp = (iRatingArray)[Count]; gc.SetBrushStyle(CGraphicsContext::ENullBrush); gc.BitBlt(imageDrawPosition, iUnselectedBitmap); gc.SetPenColor(iNormalTextColor); if (iFlgHelp) { if (Count==0||Count==4||Count==11 ||Count==15||

Count==17)

gc.BitBlt(imageDrawPosition,

iUnselectedBitmap);

} else

gc.BitBlt(imageDrawPosition, iUnselectedBitmap);

textWidth = font->TextWidthInPixels(temp->Des()); if (textWidth < (aRect.iBr.iX * 0.85)) { gc.DrawText(temp->Des(), textDrawPosition); } else if (textWidth >= (aRect.iBr.iX * 0.85)) { length = (temp->Length()*116) /textWidth; length = length - 2; scrollTemp->Des().Copy(temp->Mid(0, length)); scrollTemp->Des().Append(_L("..")); gc.DrawText(scrollTemp->Des(), textDrawPosition); } //

gc.DrawText(temp->Des(), textDrawPosition);

if (iInboxImage != NULL) { if (Count == (iTextArray.Count() - 1)) { _LIT(bracket, ")");

gc.DrawText(iInboxValue->Des(), inboxTextPosition);

gc.BitBltMasked(inboxImagePosition,

iInboxMaskImage,

inboxRect, iInboxImage, ETrue); gc.DrawText(bracket,

TPoint(inboxImagePosition.iX

+ iInboxImage>SizeInPixels().iWidth + 3, inboxTextPosition.iY - 1)); } } if (iRatingIcon != NULL) { gc.BitBltMasked(ratingIconPosition, iRatingIcon, iconRect, ratingValuePosition);

iRatingIconMask, ETrue); gc.DrawText(ratingValueTemp->Des(), } imageDrawPosition.iY = imageDrawPosition.iY + iSelectedBitmap->SizeInPixels().iHeight; //

+24; imageSize.iHeight

textDrawPosition.iY = imageDrawPosition.iY + /2 + font->HeightInPixels()/2 - 2;

if (iRightIconImage != NULL) playIconDrawPosition.iY = imageDrawPosition.iY + imageSize.iHeight/2 - iRightIconImage>SizeInPixels().iHeight/2; if (iRatingIcon != NULL) { ratingIconPosition.iY = imageDrawPosition.iY + imageSize.iHeight/2 - iRatingIcon>SizeInPixels().iHeight/2; ratingValuePosition.iY = imageDrawPosition.iY + imageSize.iHeight/2 + font>HeightInPixels()/2; //+ 16; } if (iInboxImage != NULL) { inboxImagePosition.iY = imageDrawPosition.iY + imageSize.iHeight/2 - iInboxImage>SizeInPixels().iHeight/2 + 2; inboxTextPosition.iY = imageDrawPosition.iY + imageSize.iHeight /2 + font>HeightInPixels()/2; } } } if (scrollTemp != NULL) { delete scrollTemp; scrollTemp = NULL;

} if (text1 != NULL) { delete text1; text1 = NULL; } iCoeEnv->ReleaseScreenFont(font); } // ---------------------------------------------------------------------------// void CNPSingleListItem::SizeChanged() // Called by framework when screen size is changed // ---------------------------------------------------------------------------// void CNPSingleListItem::SizeChanged() { } // ---------------------------------------------------------------------------// void CNPSingleListItem::FocusChanged(TDrawNow aDrawNow) // Function gets called by framework when control focus gets changed // ---------------------------------------------------------------------------// void CNPSingleListItem::FocusChanged(TDrawNow /*DrawNow*/) { } // ---------------------------------------------------------------------------// void CNPSingleListItem::SetTextL(const TDesC& aDisplayText) // Set control text. // ---------------------------------------------------------------------------// void CNPSingleListItem::SetTextL(const TDesC& aDisplayText) { const CFont* font = CEikonEnv::Static()->LegendFont(); HBufC* Buf1 = HBufC::NewL(aDisplayText.Length() ); Buf1->Des().Copy(aDisplayText); iTextArray.Append(Buf1); // tmpBuf = iTextArray[0]; /* if (font->TextWidthInPixels(tmpBuf->Des()) > 130) { iAlarm->Start(0, 50000, TCallBack(ScrollStart__, this)); }*/ //StartTimer(1); } // ---------------------------------------------------------------------------// TPtrC CNPSingleListItem::GetText() // Get display text // ---------------------------------------------------------------------------// TPtrC CNPSingleListItem::GetText() { return iDisplayText->Des(); }

// ---------------------------------------------------------------------------// TInt CNPSingleListItem::GetItemIndex() // ---------------------------------------------------------------------------// TInt CNPSingleListItem::GetItemIndex() { return iItemIndex; } // ---------------------------------------------------------------------------// void CNPSingleListItem::EnableMarquee(TBool aEnable) // Sets marquee enabled/disabled // ---------------------------------------------------------------------------// void CNPSingleListItem::EnableMarquee(TBool /*aEnable*/) { } // ---------------------------------------------------------------------------// TBool CNPSingleListItem::IsMarqueeEnabled() // ---------------------------------------------------------------------------// TBool CNPSingleListItem::IsMarqueeEnabled() { TSize imageSize = iSelectedBitmap->SizeInPixels(); // calculating the item image size. TInt totalHeight = (iTextArray.Count())*(imageSize.iHeight); // array length + 1 is for space left in the rectangle if (totalHeight > (iRect.iBr.iY - iRect.iTl.iY)) iMarqueeEnabled = true; else { if (totalHeight <= (iRect.iBr.iY - iRect.iTl.iY)) iMarqueeEnabled = false; } // iNoOfImage = (iRect.iBr.iY/imageSize.iHeight); return iMarqueeEnabled; } void CNPSingleListItem::SetCheckBoxTrack(TBool /*aFlag*/) { // iCheckArray.Append(aFlag); } // ---------------------------------------------------------------------------// void CNPSingleListItem::SetRatingValue(TInt aRatingValue) // Set rating value // ---------------------------------------------------------------------------// void CNPSingleListItem::SetRatingValue(TInt aRatingValue) { if (aRatingValue < 0) aRatingValue = 0;

TBuf<16> Buf1; Buf1.Zero(); Buf1.AppendNum(aRatingValue); HBufC* Buf = HBufC::NewL(Buf1.Length()); Buf->Des().Copy(Buf1); iRatingArray.Append(Buf); } // ---------------------------------------------------------------------------// void CNPSingleListItem::SetRatingIcon(CFbsBitmap* aRatingIcon) // Set rating icon // ---------------------------------------------------------------------------// void CNPSingleListItem::SetRatingIcon(CFbsBitmap* aRatingIcon, CFbsBitmap* aRatingIconMask) { iRatingIcon = aRatingIcon; iRatingIconMask = aRatingIconMask; } // ---------------------------------------------------------------------------// void CNPSingleListItem::SetRatingIcon(CFbsBitmap* aRatingIcon) // Set rating icon // ---------------------------------------------------------------------------// void CNPSingleListItem::SetRightPlayIcon(CFbsBitmap* aRightIcon, CFbsBitmap* aRightIconMask) { iRightIconImage = aRightIcon; iRightIconImageMask = aRightIconMask; } void CNPSingleListItem::SetListImages(CFbsBitmap* aSelectBarImage, CFbsBitmap* aUnselectBarImage, CFbsBitmap* aBarMaskImage) { iSelectedBitmap = aSelectBarImage; iUnselectedBitmap = aUnselectBarImage; iBarMask = aBarMaskImage; } void CNPSingleListItem::SetSelectedMenuText(const TDesC& aMenuText) { iMenuText = HBufC::NewL(aMenuText.Length()); iMenuText->Des().Copy(aMenuText); } void CNPSingleListItem::SetCheckBoxImage(CFbsBitmap* aCheckBoxImage, CFbsBitmap* aCheckBoxFocusImage) { iCheckBoxImage = aCheckBoxImage; iCheckBoxFocusImage = aCheckBoxFocusImage; } // ---------------------------------------------------------------------------// TInt CNPSingleListItem::GetRatingValue() // ---------------------------------------------------------------------------// TInt CNPSingleListItem::GetRatingValue()

{ return 0; } // ---------------------------------------------------------------------------// CNPSingleListItem::SetSelectedListItem() // ---------------------------------------------------------------------------// void CNPSingleListItem::SetSelectedListItem(TInt aIncrementValue) { TSize imageSize = iSelectedBitmap->SizeInPixels(); iNoOfImage = ((iRect.iBr.iY - iRect.iTl.iY)/imageSize.iHeight); TBool Flag = EFalse; const CFont* font = CEikonEnv::Static()->LegendFont(); if (aIncrementValue == 1 || aIncrementValue == 2) { if (iItemIndex <= (iTextArray.Count() - 1)) { if (iItemIndex == -1) iCount = 0; iItemIndex= iItemIndex+aIncrementValue; if (iItemIndex >= iNoOfImage + iCount) iCount++; if (iFlgHelp) { if (iNoOfImage+iCount== 11 || iNoOfImage+iCount== 15 || iNoOfImage+iCount== 17) iCount++; } if (iItemIndex >= (iTextArray.Count())) { if (iFlgHelp) iItemIndex = 1; else iItemIndex = 0; iCount = 0; }

} else

// DrawNow(); Flag = ETrue; }

if (aIncrementValue == -1|| aIncrementValue == -2) { if (iItemIndex == -1) { iItemIndex = iTextArray.Count() - 2; // DrawNow();

} else

iCount==4)

if (iItemIndex >= 0) { if (iItemIndex == iCount) iCount--; if (iFlgHelp) { if (iCount==17 || iCount ==15 ||iCount==11 || }

iCount--;

// iItemIndex--; iItemIndex=iItemIndex+aIncrementValue; if (iItemIndex == -1) { iItemIndex = iTextArray.Count() - 1; if (iTextArray.Count() <= iNoOfImage) { iCount = 0; } else if (iTextArray.Count() > iNoOfImage) iCount = iTextArray.Count() iNoOfImage;

} // DrawNow(); Flag = ETrue; } if (iFlgHelp) if (iItemIndex==0) iItemIndex = 1; }

/* if (iItemIndex > -1) { tmpBuf = iTextArray[iItemIndex]; if (font->TextWidthInPixels(tmpBuf->Des()) > 130) { iSingleListObserver.MenuClicked(EStdKeyDevice3, -1); } else iSingleListObserver.MenuClicked(EStdKeyDownArrow, iItemIndex); }*/ //added by Laila for text scrolling if it does not fit in the screen /* if (iItemIndex>-1) { tmpBuf = iTextArray[iItemIndex]; if (font->TextWidthInPixels(tmpBuf->Des()) > 130) { //tmpBuf = (iTextArray[iItemIndex])->Alloc(); iAlarm->Start(0, 50000, TCallBack(ScrollStart__, this));

//

StartTimer(1);

} else { StartTimer(0); } }*/ /*else if (iItemIndex==-1 && (iTextArray[0])->Des().Length()>KMaxChars) { tmpBuf = (iTextArray[0])->Alloc(); StartTimer(1); }*/ //end DrawNow(); } void CNPSingleListItem::SetInboxValue(TInt aValue) { TBuf<16> Buf1; Buf1.Zero(); Buf1.AppendNum(aValue); iInboxValue = HBufC::NewL(Buf1.Length()); iInboxValue->Des().Copy(Buf1); } void CNPSingleListItem::SetInboxImage(CFbsBitmap* aInboxImage, CFbsBitmap* aInboxMaskImage) { iInboxImage = aInboxImage; iInboxMaskImage = aInboxMaskImage; } void CNPSingleListItem::SetTextColor(TRgb aFocusTextColor, TRgb aNormalTextColor) { iFocusTextColor = aFocusTextColor; iNormalTextColor = aNormalTextColor; } // ---------------------------------------------------------------------------// CNPSingleListItem::GetTotalSteps() // Gets total steps to move scroll bar // ---------------------------------------------------------------------------TInt CNPSingleListItem::GetTotalSteps() { TSize imageSize = iSelectedBitmap->SizeInPixels(); iNoOfImage = ((iRect.iBr.iY - iRect.iTl.iY)/imageSize.iHeight); return (iTextArray.Count() - iNoOfImage); } // ---------------------------------------------------------------------------// CNPSingleListItem::GetTotalItems() // Get the total items

// ---------------------------------------------------------------------------TInt CNPSingleListItem::GetTotalItems() { TInt iT = iTextArray.Count(); return (iTextArray.Count()); } // ---------------------------------------------------------------------------// CNPSingleListItem::GetNumberOfImage() // Gets number of images that can be drawn on a screen // ---------------------------------------------------------------------------TInt CNPSingleListItem::GetNumberOfImage() { return iNoOfImage; } // ---------------------------------------------------------------------------// CNPSingleListItem::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) // Gets control call at key event // ---------------------------------------------------------------------------TKeyResponse CNPSingleListItem::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType) { #if defined(__WINSCW__) switch (aKeyEvent.iCode) { case EKeyDevice5: // Device code for down arrow key if (aType == EEventKeyDown) { else

} if (aType == EEventKey/*Up*/) { if (iFlgHelp) { if (iItemIndex==3 || iItemIndex==10 ||

iItemIndex==14

{

|| iItemIndex ==16)

CNPSingleListItem::SetSelectedListItem(2); } else CNPSingleListItem::SetSelectedListItem(1); } else CNPSingleListItem::SetSelectedListItem(1); } break; case EKeyDevice4: // device code for up arrow key if (aType == EEventKeyDown) { } else

if (aType == EEventKey/*Up*/) { if (iFlgHelp) { if (iItemIndex==5 || iItemIndex ==12 || iItemIndex==16

|| iItemIndex ==18) { CNPSingleListItem::SetSelectedListItem(-

2);

} else

1);

CNPSingleListItem::SetSelectedListItem(-

} else CNPSingleListItem::SetSelectedListItem(-1); }

break; case EKeyDevice8: //device code for ok key if (aType == EEventKeyDown) { } else if (aType == EEventKey/*Up*/) { if (iCheckBoxImage == NULL && iCheckBoxFocusImage == NULL)

else

{ iSingleListObserver.MenuClicked(EStdKeyDevice3, iItemIndex); }

if (iCheckBoxImage != NULL) { // iCheckArray.Insert(ETrue,iItemIndex); DrawNow(); } } break; case EKeyDevice7: // Device Key code for Right Arrow Key if (aType == EEventKeyDown) { } else if (aType == EEventKey /*Up*/) { iSingleListObserver.MenuClicked(EKeyRightArrow, iItemIndex); } break; case EKeyDevice6: //EStdKeyLeftArrow: if (aType == EEventKeyDown) { } else if (aType == EEventKey /*Up*/)

{ iSingleListObserver.MenuClicked( EKeyLeftArrow/*EStdKeyLeftArrow*/, iItemIndex);

} break; case EStdKeyDevice0: // On Selecting Left Option if (aType == EEventKeyDown) { } else if (aType == EEventKey/*Up*/) { iSingleListObserver.MenuClicked(EStdKeyDevice0, iItemIndex); } break; case EStdKeyDevice1: // On selecting Right Option if (aType == EEventKeyDown) { } else if (aType == EEventKey/*Up*/) { iSingleListObserver.MenuClicked(EStdKeyDevice1, iItemIndex); } break; default: break; } #else { switch ( aKeyEvent.iScanCode) { case EStdKeyDevice2 : // device code for down arrow key if (aType == EEventKeyDown) { } else if (aType == EEventKey/*Up*/) { if (iFlgHelp) { if (iItemIndex==3 || iItemIndex==10 || iItemIndex==14 || iItemIndex ==16) { CNPSingleListItem::SetSelectedListItem(2); } else CNPSingleListItem::SetSelectedListItem(1); } else CNPSingleListItem::SetSelectedListItem(1); } break;

iItemIndex==16

case EStdKeyDevice1: // device code for up arrow key if (aType == EEventKeyDown) { } else if (aType == EEventKey/*Up*/) { if (iFlgHelp) { if (iItemIndex==5 || iItemIndex ==12 || || iItemIndex ==18) { CNPSingleListItem::SetSelectedListItem(-2); } else else

CNPSingleListItem::SetSelectedListItem(-1);

}

CNPSingleListItem::SetSelectedListItem(-1); } break; default: break; } switch( aKeyEvent.iCode) { case EKeyDevice8: if (aType == EEventKeyDown) { } else if (aType == EEventKey/*Up*/) { if (iCheckBoxImage == NULL && iCheckBoxFocusImage == NULL) { iSingleListObserver.MenuClicked(EKeyDevice8, iItemIndex); } else if (iCheckBoxImage != NULL) { // iCheckArray.Insert(ETrue,iItemIndex); DrawNow(); } } break;

}

default: break; }

#endif return EKeyWasConsumed;

} TInt CNPSingleListItem::MoveLabel(TAny *obj) { CNPSingleListItem *self = (CNPSingleListItem*)obj; /*self->iLabelText.Delete(0,1); self->iLabelText.Append(first);*/ // self->iLabel->SetTextL(self->iLabelText); self->DrawNow(); return 1; } void CNPSingleListItem::StartTimer(TInt aStatus) { /* if (aStatus == 1) { if ( !iAlarm) { //start the alarm iAlarm = CPeriodic::New(EPriorityLow); if (iAlarm) { iSingleListObserver.MenuClicked(EStdKeyDownArrow, scrolldown); iAlarm->Start(500000, 200000, iCallback); iSingleListObserver.MenuClicked(EStdKeyDownArrow, scrolldown); } }; } else { if (iAlarm!=NULL) if (iAlarm->IsActive()) { iAlarm->Cancel(); delete iAlarm; iAlarm = NULL; } }*/ } TInt CNPSingleListItem::ScrollStart__(TAny* aObject) { ((CNPSingleListItem*)aObject)->ScrollStart_(); // cast, and call non-static function return 1; } void CNPSingleListItem::ScrollStart_() { // TBool Flag = EFalse; //

TInt textWidth = 0;

// //

const CFont* font = CEikonEnv::Static()->LegendFont(); textWidth = font->TextWidthInPixels(*scrollText);

//

ixt--;

// //

if (ixt == -textWidth) ixt = 176;

DrawNow(); // if (scrollText != NULL) // { // delete scrollText; // scrollText = NULL; // } } void CNPSingleListItem::ScrollText() { iAlarm->Start(0, 50000, TCallBack(ScrollStart__, this)); } TInt CNPSingleListItem::GetSelected(TPoint aCurrentPos) { iItemIndex = ((aCurrentPos.iY)/(iSelectedBitmap->SizeInPixels().iHeight)); iItemIndex+= iCount; DrawNow(); return iItemIndex; } void CNPSingleListItem::DrawItem(TInt aValue) { if (aValue == 1) { iItemIndex+=iNoOfImage; // iCount+=iNoOfImage; // increase the iCount by iNoOfImage (no.of image that can display at a time) DrawNow(); } if (aValue ==-1) { iItemIndex-=iNoOfImage; iCount-=iNoOfImage; DrawNow(); } } void CNPSingleListItem::SetItems(TInt aMoveMent) { if (aMoveMent == PointDown) { iCount=GetTotalItems()-iNoOfImage; iItemIndex = iCount; } if (aMoveMent == PointUp) { iCount = 0; iItemIndex = iCount; }

DrawNow(); } void CNPSingleListItem::CallDraw(TInt aMovement) { switch (aMovement) { case PointDown: iItemIndex+=iNoOfImage; iCount+=iNoOfImage; break; case PointUp: iItemIndex-=iNoOfImage; iCount-=iNoOfImage; break; case DragDown: iCount++; iItemIndex = iCount; break; case DragUp: iCount--; iItemIndex = iCount; break; } DrawNow(); } // method returns starting index of the screen TInt CNPSingleListItem::GetStartIndex_Screen() { return iCount; } void CNPSingleListItem::GetConstant(TInt aCons) { iConst = aCons; } //function called if the single list item is called from the help screen void CNPSingleListItem::IsHelpScreen(TBool aFlgHelp) { iFlgHelp = aFlgHelp; if (iFlgHelp) { if (iItemIndex==0) iItemIndex = 1; } }

// End of File.

Related Documents

List Item
June 2020 19
Item List
November 2019 30
Store Item List - Akwb.pdf
December 2019 21
Item
April 2020 44
Item
November 2019 56
Item
June 2020 37