⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 trycontainer.cpp

📁 显示avkon2.mbm全部的图片,附注ID,大小
💻 CPP
字号:
/*
* ============================================================================
*  Name     : CtryContainer from tryContainer.h
*  Part of  : try
*  Created  : 15.08.2006 by 
*  Implementation notes:
*     Initial content was generated by Series 60 Application Wizard.
*  Version  :
*  Copyright: 
* ============================================================================
*/

// INCLUDE FILES
#include "tryContainer.h"
#include <eikenv.h>
#include <TXTGLOBL.H>
#include <avkon.mbg>
#include <FBS.H>
#include <aknutils.h>
#include <gulicon.h>
#include <aknconsts.h>//KAvkonBitmapFile
#include <akniconutils.h>
#include <akntitle.h>
#include <aknappui.h>

#define SH	16

// ================= MEMBER FUNCTIONS =======================

// ---------------------------------------------------------
// CtryContainer::ConstructL(const TRect& aRect)
// EPOC two phased constructor
// ---------------------------------------------------------
//
_LIT(path,"z:\\resource\\apps\\avkon2.mbm");

void CtryContainer::ConstructL(const TRect& aRect)
    {
    CreateWindowL();

	TICON icon;
	int w,h,y;
	int i,j;
	y=2;
	j=0;
	for(i=EMbmAvkonQgn_graf_tab_21;i<=EMbmAvkonLastElement;i++){
		icon.bmp=AknIconUtils::CreateIconL(path, i);
		if(icon.bmp){
			h=icon.bmp->SizeInPixels().iHeight;
			w=icon.bmp->SizeInPixels().iWidth;
			if(h && w){
				icon.id=i;
				h+=2;		
				if(h<SH)h=SH;
				if(y+h>aRect.iBr.iY-60){
					y=2;
					iPageArray.Append(j);
				}
				icon.y=y;
				y+=h;
				iArray.Append(icon);
				j++;
			}
		}else break;
	}
	if(y<aRect.iBr.iY-60){
		iPageArray.Append(j);
	}

	iPageCur=0;

	TBuf<32> buf;
	buf.Num(j);
	CAknTitlePane *title=(CAknTitlePane *)iAvkonAppUi->StatusPane()->ControlL(TUid::Uid(EEikStatusPaneUidTitle));
	title->SetTextL(buf);


    SetRect(aRect);
    ActivateL();
    }

// Destructor
CtryContainer::~CtryContainer()
{
	for(int i=0;i<iArray.Count();i++){
		delete iArray[i].bmp;
	}
	iArray.Close();
	iPageArray.Close();
}

// ---------------------------------------------------------
// CtryContainer::SizeChanged()
// Called by framework when the view size is changed
// ---------------------------------------------------------
//
void CtryContainer::SizeChanged()
    {
    // TODO: Add here control resize code etc.
    }

// ---------------------------------------------------------
// CtryContainer::CountComponentControls() const
// ---------------------------------------------------------
//
TInt CtryContainer::CountComponentControls() const
    {
    return 0; // return nbr of controls inside this container
    }

// ---------------------------------------------------------
// CtryContainer::ComponentControl(TInt aIndex) const
// ---------------------------------------------------------
//
CCoeControl* CtryContainer::ComponentControl(TInt aIndex) const
    {
    switch ( aIndex )
        {
        case 0:
        case 1:
//			return ;
        default:
            return NULL;
        }
    }

// ---------------------------------------------------------
// CtryContainer::Draw(const TRect& aRect) const
// ---------------------------------------------------------
//

void CtryContainer::Draw(const TRect& aRect) const
{
    CWindowGc& gc = SystemGc();
    // TODO: Add your drawing code here
    // example code...
    gc.Clear();
    const CFont* font = iCoeEnv->NormalFont();
    gc.UseFont( font );

	TBuf<32> buf;
	CFbsBitmap *bmp;
	int i,j;
	i=0;
	if(iPageCur)i=iPageArray[iPageCur-1];

	j=iPageArray[iPageCur];
	for(;i<j;i++){
		bmp=iArray[i].bmp;
		gc.BitBlt(TPoint(2,iArray[i].y),bmp);
		buf.Format(_L("%d %d*%d"),iArray[i].id,bmp->SizeInPixels().iWidth,bmp->SizeInPixels().iHeight);
		gc.DrawText(buf,TPoint(bmp->SizeInPixels().iWidth+4,iArray[i].y+16));
	}
}

TKeyResponse CtryContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ){
	if(aType == EEventKey){
		if(aKeyEvent.iCode == EKeyUpArrow){
			if(iPageCur){
				iPageCur--;
				DrawNow();
			}
		}else
		if(aKeyEvent.iCode == EKeyDownArrow){
			if(iPageCur+1<iPageArray.Count()){
				iPageCur++;
				DrawNow();
			}
		}else
		if(aKeyEvent.iCode == EKeyLeftArrow){
			if(iPageCur){
				iPageCur=0;
				DrawNow();
			}
		}else
		if(aKeyEvent.iCode == EKeyRightArrow){
			int i=iPageArray.Count();
			if(iPageCur+1<i){
				iPageCur=i-1;
				DrawNow();
			}
		}
	}

	return EKeyWasNotConsumed;
}

// End of File  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -