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

📄 bluetoothengine_extensiblepluginappview.cpp

📁 Symbian C++ 蓝牙例程
💻 CPP
字号:
/* ====================================================================
 * File: BluetoothEngine_ExtensiblePlugInAppView.cpp
 * Created: 23/08/07
 * Author: 
 * Copyright (c): , All rights reserved
 * ==================================================================== */

#include <coemain.h>
#include <aknlists.h> 
#include <badesca.h>
#include <BluetoothEngine_ExtensiblePlugIn.rsg>

#include "BluetoothEngine_ExtensiblePlugInAppView.h"

// Standard construction sequence
CBluetoothEngine_ExtensiblePlugInAppView* CBluetoothEngine_ExtensiblePlugInAppView::NewL(const TRect& aRect)
    {
    CBluetoothEngine_ExtensiblePlugInAppView* self = CBluetoothEngine_ExtensiblePlugInAppView::NewLC(aRect);
    CleanupStack::Pop(self);
    return self;
    }

CBluetoothEngine_ExtensiblePlugInAppView* CBluetoothEngine_ExtensiblePlugInAppView::NewLC(const TRect& aRect)
    {
    CBluetoothEngine_ExtensiblePlugInAppView* self = new (ELeave) CBluetoothEngine_ExtensiblePlugInAppView;
    CleanupStack::PushL(self);
    self->ConstructL(aRect);
    return self;
    }

CBluetoothEngine_ExtensiblePlugInAppView::CBluetoothEngine_ExtensiblePlugInAppView()
    {
	// no implementation required
    }

CBluetoothEngine_ExtensiblePlugInAppView::~CBluetoothEngine_ExtensiblePlugInAppView()
    {
	if ( iListBox )
		{
		delete iListBox;
		iListBox = NULL;
		}
    }

void CBluetoothEngine_ExtensiblePlugInAppView::ConstructL(const TRect& aRect)
    {
    // Create a window for this application view
    CreateWindowL();
    
    iListBox = new (ELeave) CAknSingleStyleListBox();
    iListBox->ConstructL(this);
    iListBox->SetContainerWindowL(*this);
    
	// add scrollbars to listbox 
    iListBox->CreateScrollBarFrameL(ETrue); 
    iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( 
     						   CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto ); 
	
	
    // Set the windows size
    SetRect(aRect);

    // Activate the window, which makes it ready to be drawn
    ActivateL();
    }

// Draw this application's view to the screen
void CBluetoothEngine_ExtensiblePlugInAppView::Draw(const TRect& /*aRect*/) const
    {
    // Get the standard graphics context 
    CWindowGc& gc = SystemGc();
    
    // Gets the control's extent
    TRect rect = Rect();
    
    // Clears the screen
    gc.Clear(rect);
    }

TKeyResponse CBluetoothEngine_ExtensiblePlugInAppView::OfferKeyEventL(const TKeyEvent &aKeyEvent, TEventCode aType)
	{
	if ( iListBox )
		{
		if(aType==EEventKey)
			{
			return iListBox->OfferKeyEventL( aKeyEvent, aType );
			}
		else
			{
			return EKeyWasNotConsumed;
			}
		}
	else
		{
		return EKeyWasNotConsumed;
		}
	}
	
TInt CBluetoothEngine_ExtensiblePlugInAppView::CountComponentControls() const
	{
	if ( iListBox )
		{
		return 1;
		}
	else
		{
		return 0;
		}
	}

CCoeControl* CBluetoothEngine_ExtensiblePlugInAppView::ComponentControl(TInt aIndex) const	
	{
	switch( aIndex )
		{
		case 0:
			return iListBox;
		default:
			return NULL;
		}
	}
	
void CBluetoothEngine_ExtensiblePlugInAppView::UpdateListBoxItems(CBTDeviceArray& aSelectedDeviceArray)
	{
	TBuf<50> deviceName;
	
	CDesCArray *itemList = new (ELeave) CDesCArrayFlat(aSelectedDeviceArray.Count()); 		
	CleanupStack::PushL(itemList);
	for(TInt i = 0 ; i<aSelectedDeviceArray.Count();i++)
		{
		deviceName.Copy((aSelectedDeviceArray.At(i))->DeviceName());
		
		TBuf<50> lItemListFormat;
		
		lItemListFormat.Append(_L("\t"));
		lItemListFormat.Append(deviceName);
		lItemListFormat.Append(_L("\t\t"));
		itemList->AppendL(lItemListFormat);
		
		deviceName.Zero();
		lItemListFormat.Zero();
		}
	iListBox->Model()->SetItemTextArray(itemList); 
	iListBox->Model()->SetOwnershipType(ELbmOwnsItemArray); 
	
	iListBox->HandleItemAdditionL();
	
	iListBox->ActivateL();
	
	CleanupStack::Pop();
	
	}

void CBluetoothEngine_ExtensiblePlugInAppView::SizeChanged()
    {
    iListBox->SetRect(Rect());
    }	

⌨️ 快捷键说明

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