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

📄 megcontainer.cpp

📁 symbian系统上的记事本程序
💻 CPP
字号:
/*
* ============================================================================
*  Name     : CMegContainer from CCoeControl, MCoeControlObserver
*  Part of  : Hello
*  Copyright (c) 2003 Nokia. All rights reserved.
* ============================================================================
*/

// INCLUDE FILES


#include <EveryDay.rsg>
#include "EveryDay.hrh"
#include "MegContainer.h"
#include <barsread.h>
#include <aknnotewrappers.h>
#include "EveryDayAppUi.h"
#include "common.h"
#include <aknlists.h> 


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

// C++ default constructor can NOT contain any code, that
// might leave.
//
CMegContainer::CMegContainer()
{
	m_pList = NULL;
}

// EPOC default constructor can leave.
void CMegContainer::ConstructL(const TRect& aRect)
{
    CreateWindowL();
	
	m_pList = new( ELeave ) CAknDoubleLargeStyleListBox();
	CleanupStack::PushL(m_pList);
	m_pList->SetContainerWindowL(*this);
	TResourceReader rReader;
	iCoeEnv->CreateResourceReaderLC(rReader, R_MESSAGE_LISTBOX);
	m_pList->ConstructFromResourceL(rReader);
	m_pList->CreateScrollBarFrameL( ETrue );
    m_pList->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
	CleanupStack::PopAndDestroy();
	
	CArrayPtr<CGulIcon>* icons = new( ELeave ) CAknIconArray(4);
	CleanupStack::PushL(icons);
	CEveryDayAppUi* pApp = (CEveryDayAppUi*)CEikonEnv::Static()->AppUi();
	icons->AppendL(pApp->LoadGraphicsL(10));
	icons->AppendL(pApp->LoadGraphicsL(11));
	icons->AppendL(pApp->LoadGraphicsL(12));
	icons->AppendL(pApp->LoadGraphicsL(13));
	CleanupStack::Pop(icons);
	
	m_pList->ItemDrawer()->ColumnData()->SetIconArrayL(icons);
	
	m_pList->ActivateL();	
	CleanupStack::Pop(m_pList);
	m_pList->SetFocus(ETrue);
    SetRect(aRect);
    ActivateL();
}

// Destructor
CMegContainer::~CMegContainer()
{
	MEM_FREE(m_pList);
}

// ---------------------------------------------------------
// CMegContainer::FocusTo(TInt aCommand)
// Change foccused control.
// (other items were commented in a header).
// ---------------------------------------------------------
//

void CMegContainer::FocusTo(TInt aCommand)
{
}

// ---------------------------------------------------------
// CMegContainer::SizeChanged()
// Called by framework when the view size is changed
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CMegContainer::SizeChanged()
{
	if( NULL != m_pList )
	{
		m_pList->SetRect(Rect());
	}
}

// ---------------------------------------------------------
// CMegContainer::CountComponentControls() const
// (other items were commented in a header).
// ---------------------------------------------------------
//
TInt CMegContainer::CountComponentControls() const
{
	return 1; // return nbr of controls inside this container
}

// ---------------------------------------------------------
// CMegContainer::ComponentControl(TInt aIndex) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
CCoeControl* CMegContainer::ComponentControl(TInt aIndex) const
{
	return m_pList;
}

// ---------------------------------------------------------
// CMegContainer::Draw(const TRect& aRect) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CMegContainer::Draw(const TRect& aRect) const
{
    CWindowGc& gc = SystemGc();
    gc.SetPenStyle(CGraphicsContext::ENullPen);
    gc.SetBrushColor(KRgbYellow);
    gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
    gc.DrawRect(aRect);
}

// ---------------------------------------------------------
// CMegContainer::OfferKeyEventL(...)
// Notify key events to editors.
// (other items were commented in a header).
// ---------------------------------------------------------
//
TKeyResponse CMegContainer::OfferKeyEventL(
										   const TKeyEvent& aKeyEvent, TEventCode aType)
{
	if(m_pList != NULL)
	{
		if((aType == EEventKey) && (aKeyEvent.iCode == EKeyDownArrow))
		{
			return m_pList->OfferKeyEventL(aKeyEvent, aType);
		}
		else if((aType == EEventKey) && (aKeyEvent.iCode == EKeyUpArrow))
		{
			return m_pList->OfferKeyEventL(aKeyEvent, aType);
		}
		return EKeyWasConsumed;
	}
	else
	{
		return EKeyWasNotConsumed;
	}
}


// ---------------------------------------------------------
// CMegContainer::HandleControlEventL(
//     CCoeControl* aControl,TCoeEvent aEventType)
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CMegContainer::HandleControlEventL(
										CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
{
}

TInt CMegContainer::GetIndex()
{
	TInt nIndex = m_pList->CurrentItemIndex();
	
	return nIndex;	
}


// End of File  

⌨️ 快捷键说明

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