// ---------------------------------------------------------
// CSymTorrentSearchContainer::ConstructL
// EPOC two phased constructor
// ---------------------------------------------------------
//
void CSymTorrentSearchContainer::ConstructL(const TRect& aRect, 
	CSymTorrentAppUi* aAppUi, CSTTorrentManager* aTorrentMgr)
{
	iAppUi=aAppUi;
	iTorrentMgr=aTorrentMgr;
    CreateWindowL();

    iListBox = new (ELeave) CAknDoubleGraphicStyleListBox();
    iListBox->SetMopParent(this);
	iListBox->ConstructL(this, EAknListBoxSelectionList);
	iListBox->SetContainerWindowL(*this);
	
	iListBox->View()->SetListEmptyTextL(_L("(empty)"));

	//create scrollbar
	iListBox->CreateScrollBarFrameL();
	iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
		CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
	
	CArrayPtr<CGulIcon>* icons = new (ELeave) CAknIconArray(1);  // must be initialized with the number of icons used by the list!
	CleanupStack::PushL(icons);

	#ifdef EKA2
	{
		CGulIcon* chainLinkIcon = CGulIcon::NewL();
		CleanupStack::PushL(chainLinkIcon);
		
		CFbsBitmap* chainLinkBmp = NULL;
		CFbsBitmap* chainLinkMask = NULL;
		AknIconUtils::CreateIconLC(chainLinkBmp, chainLinkMask, KBitmapFile,
			EMbmSymtorrentChainlink, EMbmSymtorrentChainlink_mask);	
		chainLinkIcon->SetBitmap(chainLinkBmp);
		chainLinkIcon->SetMask(chainLinkMask);
		CleanupStack::Pop(2);
		icons->InsertL(0, chainLinkIcon);
		CleanupStack::Pop();				
	}
	#else
	{
		CEikonEnv* eikEnv = CEikonEnv::Static();
		
		icons->AppendL(eikEnv->CreateIconL(KBitmapFile, 
			EMbmSymtorrentChainlink, EMbmSymtorrentChainlink_mask));	
	}
	#endif
			
	CleanupStack::Pop(icons); // icons
	iListBox->ItemDrawer()->ColumnData()->SetIconArray(icons);

    SetRect(aRect);
    
    CDesCArray* itemArray = static_cast<CDesCArray*>
		(iListBox->Model()->ItemTextArray());
	itemArray->InsertL(0, _L("0\tFirst line\tSecond line"));			
    
   
    ActivateL();
}
// ---------------------------------------------------------
// CDisconnectDlgDialog::PreLayoutDynInitL
// ---------------------------------------------------------
//
void CDisconnectDlgDialog::PreLayoutDynInitL()
    {
    CLOG_ENTERFN("CDisconnectDlgDialog::PreLayoutDynInitL");    
    
    CAknListQueryDialog::PreLayoutDynInitL();
    
    STATIC_CAST( CEikServAppUi*, 
                CCoeEnv::Static()->AppUi() )->SuppressAppSwitching( ETrue );
    
    CConnectionCArray* connArray = iConnModel->GetConnArray();

    // items: application and IAP names
    CDesCArrayFlat* items = new( ELeave )CDesCArrayFlat( connArray->Count() );
    CleanupStack::PushL( items );
    // icons: application icons
    CArrayPtr< CGulIcon >* icons = new( ELeave )CAknIconArray( 
                                                        connArray->Count() );
    CleanupStack::PushL( icons );

    CGulIcon* iconTemp = NULL;
    CGulIcon* icon = NULL;

    TInt count = connArray->Count();
    CLOG_WRITEF(_L( "count: %d" ), count );     

    // Get the info of every connection and initialize the list of dialog
    for( TInt i = 0; i < count; i++ )
        {
        CConnectionInfo* info = connArray->At( i );

        TBool useSharedIcon = EFalse;
        // Application and IAP name
        HBufC* listItem = HBufC::NewLC( KListItemTextBuf );
        TPtrC iap = info->GetIapNameL();
        
        TPtrC app = info->GetAppNameL( useSharedIcon ); 

        // Application icon
        iconTemp = info->GetAppIconL( useSharedIcon );
        icon = CGulIcon::NewL();
        icon->SetBitmapsOwnedExternally( ETrue );
        icon->SetBitmap( iconTemp->Bitmap() );
        icon->SetMask( iconTemp->Mask() );

        icons->AppendL( icon );

        listItem->Des().Format( KFormat, i, &iap, &app );
        items->AppendL( listItem->Des() );

        CleanupStack::PopAndDestroy( listItem ); // listItem
        }

    // set new item list
    SetItemTextArray( items );
    // set icon list
    SetIconArrayL( icons );
    // we don't have to take care of delete items
    SetOwnershipType( ELbmOwnsItemArray );

    CleanupStack::Pop( icons );
    CleanupStack::Pop( items );
    
    iExpiryTimer = CExpiryTimer::NewL( *this );
    iExpiryTimer->Start();

    CLOG_LEAVEFN("CDisconnectDlgDialog::PreLayoutDynInitL");
    }
Beispiel #3
0
/*
 * Landmark objects will make use of an SVG file for rendering (demo purposes)
 */
void CLMXObject::ConstructL()
{
    _LIT(KIconFile, "\\resource\\apps\\Landmarks_0x2002E1AF.mif");

    CGulIcon* icon = CreateIconL(KIconFile, EMbmLandmarks_0x2002e1afIcon, EMbmLandmarks_0x2002e1afIcon_mask);
    CleanupStack::PushL(icon);

    CFbsBitmap* bitmap = icon->Bitmap();    // Ownership NOT transferred
    CFbsBitmap* mask   = icon->Mask();      // Ownership NOT transferred

    // Always expect 16M bitmap to make conversion to GL_RGBA easier 
    if (bitmap->DisplayMode() != EColor16M)
    {
        bitmap = new(ELeave) CFbsBitmap;
        CleanupStack::PushL(bitmap);

        User::LeaveIfError(bitmap->Create(icon->Bitmap()->SizeInPixels(), EColor16M));

        CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(bitmap);
        CleanupStack::PushL(bitmapDevice);

        CFbsBitGc* bitmapContext = 0;
        User::LeaveIfError(bitmapDevice->CreateContext(bitmapContext));
        CleanupStack::PushL(bitmapContext);

        bitmapContext->BitBlt(TPoint(0, 0), icon->Bitmap());

        CleanupStack::PopAndDestroy(2, bitmapDevice);

        icon->SetBitmap(bitmap);    // Ownership transferred

        CleanupStack::Pop(bitmap);
    }

    // Always expect 256 mask to make conversion to GL_RGBA easier 
    if (mask->DisplayMode() != EGray256)
    {
        mask = new(ELeave) CFbsBitmap;
        CleanupStack::PushL(mask);

        User::LeaveIfError(mask->Create(icon->Mask()->SizeInPixels(), EGray256));

        CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(mask);
        CleanupStack::PushL(bitmapDevice);

        CFbsBitGc* bitmapContext = 0;
        User::LeaveIfError(bitmapDevice->CreateContext(bitmapContext));
        CleanupStack::PushL(bitmapContext);

        bitmapContext->BitBlt(TPoint(0, 0), icon->Mask());

        CleanupStack::PopAndDestroy(2, bitmapDevice);

        icon->SetMask(mask);    // Ownership transferred

        CleanupStack::Pop(mask);
    }

    // Now bitmap and mask point to either original or converted bitmaps, 
    // and ownership belongs to icon

    const TSize bitmapSize = bitmap->SizeInPixels();

    // sizeof(TUint32) == sizeof(RGBA)
    const TInt dataSize = bitmapSize.iWidth * bitmapSize.iHeight * sizeof(TUint32);
    TUint8* data = new(ELeave) TUint8[dataSize];

    // Perform copy and conversion from BGR(A) to RGB(A)
    bitmap->LockHeap();
    mask->LockHeap();

    // TODO: Alpha component removed, as it seems to be corrupted from
    // subsequent reads from SVG file

    TUint8* rgb = reinterpret_cast<TUint8*>(bitmap->DataAddress());
//    TUint8* alpha = reinterpret_cast<TUint8*>(mask->DataAddress());

    for(TInt i = 0, j = 0; i < dataSize; i += 4, j += 3)
    {
        data[i + 0] = rgb[j + 2];
        data[i + 1] = rgb[j + 1];
        data[i + 2] = rgb[j + 0];
        data[i + 3] = 0xc0; //alpha[i / 4];
    }

    // Generate OpenGL texture
    ::glGenTextures(1, &iTextureId); 
    ::glBindTexture(GL_TEXTURE_2D, iTextureId);

    ::glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    ::glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    ::glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    ::glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

    ::glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, bitmapSize.iWidth, bitmapSize.iHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);

    mask->UnlockHeap();
    bitmap->UnlockHeap();

    delete data;

    CleanupStack::PopAndDestroy(icon);
}