exelaunchercontainer.cpp

来自「一个symbian中执行exe程序的实例」· C++ 代码 · 共 153 行

CPP
153
字号
/*
* ============================================================================
*  Name     : CExeLauncherContainer from ExeLauncherContainer.h
*  Part of  : ExeLauncher
*  Created  : 01.09.2005 by Artem Marchenko
*  Implementation notes:
*     Container of the file list control
*  Version  : 1.0
*  Copyright: Artem Marchenko 2005
* ============================================================================
*/

// INCLUDE FILES
#include "ExeLauncherContainer.h"
#include <ExeLauncher.rsg>

#include <eiklabel.h>  // for example label control
#include <aknsettingitemlist.h> 
#include "ExeLauncher.hrh"
#include "ExeLauncher.loc"


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

// ---------------------------------------------------------
// CExeLauncherContainer::ConstructL(const TRect& aRect)
// EPOC two phased constructor
// ---------------------------------------------------------
//
void CExeLauncherContainer::ConstructL(const TRect& aRect)
    {
    CreateWindowL();

	iFileList = new (ELeave) CSettingItemList;
	iFileList->ConstructFromResourceL( R_EXELAUNCHER_FILE_LIST );
	// Fills file list with the default values
	iFileList->LoadSettingsL();
	iFileList->ActivateL();

    SetRect(aRect);
    ActivateL();
    }

// Destructor
CExeLauncherContainer::~CExeLauncherContainer()
    {
	delete iFileList;
    }

// ---------------------------------------------------------
// CExeLauncherContainer::CountComponentControls() const
// ---------------------------------------------------------
//
TInt CExeLauncherContainer::CountComponentControls() const
    {
    return 1; // return number of controls inside this container
    }

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


// ---------------------------------------------------------
// CExeLauncherContainer::HandleControlEventL(
//     CCoeControl* aControl,TCoeEvent aEventType)
// ---------------------------------------------------------
//
void CExeLauncherContainer::HandleControlEventL(
    CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
    {
	// nothing
    }

TKeyResponse CExeLauncherContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode /*aType*/)
	{
	RDebug::Print( _L( "CExeLauncherContainer::OfferKeyEventL iCode [%d]" ), aKeyEvent.iCode );
	TKeyResponse result = EKeyWasNotConsumed;
	TInt current = iFileList->ListBox()->CurrentItemIndex();
	const TInt bottomIndex = iFileList->ListBox()->BottomItemIndex();
	const TInt topIndex = iFileList->ListBox()->TopItemIndex();
	switch ( aKeyEvent.iCode )
		{
		case EKeyOK:
			iFileList->EditItemL(current, ETrue);
			result = EKeyWasConsumed;
			break;
		case EKeyUpArrow:
			RDebug::Print( _L( "CExeLauncherContainer::OfferKeyEventL DOWN iCode [%d]" ), aKeyEvent.iCode );
			current = current - 1 < topIndex ? topIndex : current - 1;
			iFileList->ListBox()->SetCurrentItemIndexAndDraw( current );
			break;
		case EKeyDownArrow:
			RDebug::Print( _L( "CExeLauncherContainer::OfferKeyEventL UP iCode [%d]" ), aKeyEvent.iCode );
			current = current + 1 > bottomIndex ? bottomIndex : current + 1;
			iFileList->ListBox()->SetCurrentItemIndexAndDraw( current );
			break;
		}
	return result;
	}


// This is the main function to create editors for each item
// in the settings item list. We are setting default values for
// filenames here
CAknSettingItem* CSettingItemList::CreateSettingItemL(TInt aIdentifier)
{
	CAknSettingItem* settingitem = NULL;
	
	switch ( aIdentifier )
	{
		case EELFileItem1:
		{
			settingitem = new (ELeave) CAknTextSettingItem( aIdentifier, iText1 );
		}
		break;
		case EELFileItem2:
		{
			settingitem = new (ELeave) CAknTextSettingItem( aIdentifier, iText2 );
		}
		break;
		case EELFileItem3:
		{
			settingitem = new (ELeave) CAknTextSettingItem( aIdentifier, iText3 );
		}
		break;
	}
	
	return settingitem;
}

CSettingItemList::CSettingItemList()
{
	// Read default file names from resources
	iEikonEnv->ReadResource( iText1, R_EXEL_ITEM1_TEXT );
	iEikonEnv->ReadResource( iText2, R_EXEL_ITEM2_TEXT );
	iEikonEnv->ReadResource( iText3, R_EXEL_ITEM3_TEXT );
}


// End of File  

⌨️ 快捷键说明

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