void CPreviewPopUpContent::InitialiseL(const TRect& aRect,
                                      const TDesC& aMbmName,
                                      TInt aNbrOfRows, 
                                      TInt aImageId,
                                      TInt aMaskId)
{
   // Do not call CreateWindowL() as parent CAknPreviewPopUpController owns window
   
   InitComponentArrayL();
   
   iMbmName = aMbmName.AllocL();

   MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   TRgb fgcolor(0,0,0);
   AknsUtils::GetCachedColor(skin, fgcolor, KAknsIIDQsnTextColors, 
                             EAknsCIQsnTextColorsCG55);

   if (aImageId != -1 && aMaskId != -1) {
      AknIconUtils::CreateIconL(iBitmap, iMask, *iMbmName, aImageId, aMaskId);
      AknIconUtils::SetSize(iBitmap, TSize(10, 10), 
                            EAspectRatioPreservedAndUnusedSpaceRemoved);
   }

   iStringLengths = new (ELeave) CArrayFixFlat<TInt>(aNbrOfRows);
   iLabelContainer.Reset();
 
   // Create one label with standard font size.
   iStringLengths->AppendL(aRect.Width());
   CEikLabel* label = new (ELeave) CEikLabel();
   label->SetContainerWindowL(*this);
   Components().AppendLC(label);
   label->OverrideColorL(EColorLabelText, fgcolor);
   label->SetTextL(KDefaultText);
   CleanupStack::Pop(label);
   iLabelContainer.AppendL(TLabelData(label));
   // The rest of the labels with a smaller font.
   const CFont* font = AknLayoutUtils::FontFromId(EAknLogicalFontSecondaryFont);
   for (TInt i = 0; i < aNbrOfRows-1; ++i) {
      iStringLengths->AppendL(aRect.Width());
      CEikLabel* label = new (ELeave) CEikLabel();
      label->SetContainerWindowL(*this);
      Components().AppendLC(label);
      label->SetFont(font);
      label->OverrideColorL(EColorLabelText, fgcolor);
      label->SetTextL(KDefaultText);
      CleanupStack::Pop(label);
      iLabelContainer.AppendL(TLabelData(label));
   }
   //CEikonEnv::Static()->ScreenDevice()->ReleaseFont(font);
   Components().SetControlsOwnedExternally(EFalse);

   // Set the windows size
   SetRect(aRect);

   // Activate the window, which makes it ready to be drawn
   ActivateL();
}
示例#2
0
void CMainMenuListContainer::ConstructL(const TRect& aRect,
                                        CMainMenuListView* aView,
                                        const TInt* aMbmImageIds,
                                        const TInt* aMbmMaskIds,
                                        const TInt* aMainMenuCommandIds,
                                        const TInt* aMainMenuFirstLabelIds,
                                        const TInt* aMainMenuSecondLabelIds)
{
    CreateWindowL();

    InitComponentArrayL();

    iBgContext =
        CAknsBasicBackgroundControlContext::NewL(KAknsIIDQsnBgAreaMain,
                aRect, ETrue);

    iView = aView;
    iMainMenuCommandIds = aMainMenuCommandIds;

    MAknsSkinInstance* skin = AknsUtils::SkinInstance();
    TRgb fgcolor(0,0,0);
    AknsUtils::GetCachedColor(skin, fgcolor, KAknsIIDQsnTextColors,
                              EAknsCIQsnTextColorsCG6);

    CEikLabel* label = new (ELeave) CEikLabel();

    label->SetContainerWindowL(*this);
    Components().AppendLC(label, ETitleLabel);
    label->OverrideColorL(EColorLabelText, fgcolor);
    label->SetTextL(KDefaultTitle());
    label->SetLabelAlignment(ELayoutAlignCenter);
    HBufC* titleText = CEikonEnv::Static()->AllocReadResourceLC(R_MM_TITLE_TEXT);
    label->SetTextL(*titleText);
    CleanupStack::PopAndDestroy(titleText);
    CleanupStack::Pop(label);

    // Create and populate the listbox
    iListBox = new( ELeave ) CAknDoubleLargeStyleListBox();
    Components().AppendLC(iListBox, EListBox);

    iListBox->SetContainerWindowL(*this);
    iListBox->SetMopParent(this);
    {
        TResourceReader reader;
        iEikonEnv->CreateResourceReaderLC( reader, R_WAYFINDER_MAIN_MENU_LIST_VIEW_LISTBOX );
        iListBox->ConstructFromResourceL( reader );
        CleanupStack::PopAndDestroy(); // reader internal state
    }

    iListBox->SetFocus(ETrue);
    iListBox->SetListBoxObserver(this);

    iListBox->ItemDrawer()->FormattedCellData()->SetMarqueeParams(5, 3, 1000000, 200000);
    iListBox->ItemDrawer()->FormattedCellData()->EnableMarqueeL(ETrue);

    for (TInt i = 0; iMainMenuCommandIds[i] != -1; ++i) {
        AddItemL(aMbmImageIds[i], aMbmMaskIds[i],
                 aMainMenuFirstLabelIds[i],
                 aMainMenuSecondLabelIds[i]);
    }
    iListBox->CreateScrollBarFrameL(ETrue);
    iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,
            CEikScrollBarFrame::EOff);
    iListBox->UpdateScrollBarsL();

    iListBox->SetCurrentItemIndex(0);
    iListBox->DrawNow();
    CleanupStack::Pop(iListBox);

    //Activate view
    SetRect(aRect);
    ActivateL();
}