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

📄 esimgroupusercontainer.cpp

📁 基于SIP协议的即时消息聊天功能设计,Symbian平台下实现
💻 CPP
字号:
/*
============================================================================
 Name        : CESIMGroupUserContainer from ESIMContainer.h
 Author      : 
 Version     :
 Copyright   : Your copyright notice
 Description : 点对点和组群消息选择界面
============================================================================
*/

// INCLUDE FILES
#include "ESIMGroupUserContainer.h"
#include  "ESIMGroupUserView.h"
#include "ESIMItemEngine.h" 
#include "ESIMGroupItem.h"
#include "ESIMUserItem.h"

#include <eiklabel.h>  // for example label control
#include <barsread.h> // TResource Reader
#include <eikclbd.h> // CColumnListBoxData
#include <aknlists.h> //CAknSingleGraphicHeadingStyleListBox
#include <AknQueryDialog.h>//CAknQueryDialog
#include <ESIM.rsg>
#include "ESIM.hrh"


#define KListPosition TPoint(0,0) 

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


// ---------------------------------------------------------
// CESIMGroupUserContainer::ConstructL(const TRect& aRect)
// EPOC two phased constructor
// ---------------------------------------------------------
//
void CESIMGroupUserContainer::ConstructL(const TRect& aRect,CESIMGroupUserView* aView)
    {
    CreateWindowL();
	iView = aView;

	// Create the list
	CreateListL();	

	// Observe the list
	iGroupUserListBox->SetListBoxObserver(this);

	iGroupName = iEngine->ReturnCurrentGroupName();

	//设置标签
	CEikStatusPane *sp =((CAknAppUi*)iEikonEnv->EikAppUi())->StatusPane();
    iNaviPane =(CAknNavigationControlContainer*)sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi));
	iNaviDecorator=iNaviPane->CreateNavigationLabelL(iGroupName);//_L("Setting")//
	iNaviPane->PushL(*iNaviDecorator);

    SetRect(aRect);
    ActivateL();
    }

// Destructor
CESIMGroupUserContainer::~CESIMGroupUserContainer()
    {
	iNaviPane->Pop(iNaviDecorator);
	if(NULL!=iNaviDecorator)
	{

	delete iNaviDecorator;
	iNaviDecorator=NULL;
	}

    delete iGroupUserListBox;
    }

// ---------------------------------------------------------
// CESIMGroupUserContainer::SizeChanged()
// Called by framework when the view size is changed
// ---------------------------------------------------------
//
void CESIMGroupUserContainer::SizeChanged()
    {
    // TODO: Add here control resize code etc.
    iGroupUserListBox->SetExtent (KListPosition, iGroupUserListBox->MinimumSize());
	//iGroupUserListBox->SetExtent (KListPosition, TSize(100,100));
    }

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

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

// ---------------------------------------------------------
// CESIMGroupUserContainer::Draw(const TRect& aRect) const
// ---------------------------------------------------------
//
void CESIMGroupUserContainer::Draw(const TRect& aRect) const
    {
    CWindowGc& gc = SystemGc();
    // TODO: Add your drawing code here
    // example code...
/*   gc.SetPenStyle( CGraphicsContext::ENullPen );
    gc.SetBrushColor( KRgbGray );
    gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
    gc.DrawRect( aRect );
*/
	gc.Clear(aRect);
    }

// ---------------------------------------------------------
// CESIMGroupUserContainer::HandleControlEventL(
//     CCoeControl* aControl,TCoeEvent aEventType)
// ---------------------------------------------------------
//
void CESIMGroupUserContainer::HandleControlEventL(
    CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
    {
    // TODO: Add your control event handler code here
    }

//CHUZX ADD
	/**
* Constructs the iSavedGamesList, setting its window.
*/
void CESIMGroupUserContainer::CreateListL()
	{
	// First phase construction
	iGroupUserListBox = new (ELeave) CAknSingleStyleListBox;
	iGroupUserListBox->SetContainerWindowL(*this);
	
	// Second Phase Construction
	TResourceReader reader;
	iEikonEnv->CreateResourceReaderLC(reader, R_ESIM_GROUPUSER_LISTBOX);
	iGroupUserListBox->ConstructFromResourceL(reader);
	CleanupStack::PopAndDestroy(); // reader

	SetupListItemsL();

	//create scroll bar
    iGroupUserListBox->CreateScrollBarFrameL( ETrue );
    iGroupUserListBox->ScrollBarFrame()->SetScrollBarVisibilityL( 
            CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
/**/
	}

/**
* Populates the list model's item array with a list of saved games
*/
void CESIMGroupUserContainer::SetupListItemsL()
{
//	CDesCArray *contacts = iEngine->GetContactsFromSelectedGroupL();
	CTextListBoxModel* model = iGroupUserListBox->Model();  // not taking ownership
	CDesCArray* items = STATIC_CAST(CDesCArray*, model->ItemTextArray());
	// Strings will be of the format "2\tSaved Game i", where i is a number from 1 to 10
	_LIT (KStringHeader, "\t%S");
	TBuf <40> aString;
	for (TInt i = 0; i< iEngine->GroupItem(iEngine->GetCurrentGrouuIndex())->ItemList().Count(); i++)
	{
		TPtrC ptr = (iEngine->GroupItem(iEngine->GetCurrentGrouuIndex())->ItemList()[i]->Name())->Des();
		aString.Format(KStringHeader, &ptr );
		items->AppendL (aString);
	}
}

/**
* Called by the framework whenever a key event occurs.	
* Passes the key event to the saved games list if it is not null, otherwise returns
* EKeyWasNotConsumed
* @param aKeyEvent the Key event which occured, e.g. select key pressed
* @param aType the type of Key event which occurred, e.g. key up, key down
* @return TKeyResponse EKeyWasNotConsumed if the key was not processed, EKeyWasConsumed if it was
*/
TKeyResponse CESIMGroupUserContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
	{
	if (iGroupUserListBox)
		return iGroupUserListBox->OfferKeyEventL (aKeyEvent, aType);
	else
		return EKeyWasNotConsumed;
	}

/**
* Called by the framework whenever a list event occurs for which this container
* is an observer.
* @param aListBoxEvent The type of event which occured
*
*/
void CESIMGroupUserContainer::HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aListBoxEvent)
	{
	// if the Select Key has been pressed
	if (aListBoxEvent == MEikListBoxObserver::EEventEnterKeyPressed) 
		{
		//iEngine->GetUserInfo(aListBox);
		//iView->HandleCommandL(EESIMCmdActiveView2);
		}
	}
/**/
CEikColumnListBox* CESIMGroupUserContainer::ListBox() const
	{
	return iGroupUserListBox;
	}
 
/**
* Deletes all currently marked games
*/
/**/
void CESIMGroupUserContainer::DeleteSelectedL()
	{
	//create a confirmation query
	CAknQueryDialog* DeleteSelectQuery = CAknQueryDialog::NewL();	
	if (DeleteSelectQuery->ExecuteLD(R_ESIM_CONFIRMATION_QUERY))
		{
		TInt currentGroupIndex = iEngine->GetCurrentGrouuIndex();
		TInt currentUserIndex = iGroupUserListBox->CurrentItemIndex();
		iEngine->RemoveUserFromGroup(currentUserIndex, currentGroupIndex);	    
		}
	}

void CESIMGroupUserContainer::RefreshListL()
{
	//清空列表
	CTextListBoxModel* model = iGroupUserListBox->Model();  // not taking ownership
	CDesCArray* items = STATIC_CAST(CDesCArray*, model->ItemTextArray());
	items->Delete(0, items->Count());

	//再将新的列表全部加入
	SetupListItemsL();
    iGroupUserListBox->HandleItemAdditionL();
	iGroupUserListBox->SetCurrentItemIndexAndDraw( 0 );
    SizeChanged();
    DrawNow();
}

TBool CESIMGroupUserContainer::IsContactsOnListBox()
	{
    TInt listboxcount(0);
	listboxcount = iGroupUserListBox->Model()->NumberOfItems();
	if (0 == listboxcount)
	    return ETrue;
	else
	    return EFalse;
	}

⌨️ 快捷键说明

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