📄 bluetoothpmpexampleappui.cpp
字号:
/*
* ============================================================================
* Name : CBluetoothPMPExampleAppUi from BluetoothPMPExampleAppUi.cpp
* Part of : BluetoothPMPExample
* Created : 14.01.2004 by Forum Nokia
* Implementation notes:
* Initial content was generated by Series 60 AppWizard.
* Version :
* Copyright: Nokia Corporation
* ============================================================================
*/
// INCLUDE FILES
#include <avkon.hrh>
#include <eikmenup.h>
#include <BluetoothPMPExample.rsg>
#include "BluetoothPMPExampleAppUi.h"
#include "BluetoothPMPExampleContainer.h"
#include "bluetoothpmpexample.hrh"
#include "BluetoothPMPExampleEngine.h"
// ----------------------------------------------------------------------------
// CBluetoothExampleAppUi::ConstructL()
//
// standard EPOC 2nd phase constructor
// ----------------------------------------------------------------------------
void CBluetoothPMPExampleAppUi::ConstructL()
{
BaseConstructL();
iEngine = CBluetoothPMPExampleEngine::NewL( this );
iAppContainer = CBluetoothPMPExampleContainer::NewL(ClientRect());
iAppContainer->SetMopParent(this);
// add view to control stack
AddToStackL( iAppContainer );
}
// ----------------------------------------------------------------------------
// CBluetoothPMPExampleAppUi::~CBluetoothPMPExampleAppUi()
//
// destructor
// ----------------------------------------------------------------------------
CBluetoothPMPExampleAppUi::~CBluetoothPMPExampleAppUi()
{
RemoveFromStack( iAppContainer );
delete iAppContainer;
iAppContainer=NULL;
delete iEngine;
iEngine=NULL;
}
// ----------------------------------------------------------------------------
// CBluetoothPMPExampleAppUi::DynInitMenuPaneL(TInt aResourceId,
// CEikMenuPane* aMenuPane)
//
// this function is called by the EIKON framework just before it displays
// a menu pane. Its default implementation is empty, and by overriding it,
// the application can set the state of menu items dynamically according
// to the state of application data.
// ----------------------------------------------------------------------------
void CBluetoothPMPExampleAppUi::DynInitMenuPaneL(TInt aResourceId,
CEikMenuPane* aMenuPane)
{
if (aResourceId == R_BLUETOOTHPMPEXAMPLE_MENU)
{
if (iEngine->iIsSlave)
{
// slave mode
aMenuPane->SetItemDimmed(EBTCmdDiscoverDevices, ETrue);
aMenuPane->SetItemDimmed(EBTCmdDiscoverServices, ETrue);
aMenuPane->SetItemDimmed(EBTCmdConnectDevices, ETrue);
aMenuPane->SetItemDimmed(EBTCmdShowConnectedDevices, ETrue);
aMenuPane->SetItemDimmed(EBTCmdStartSlave, ETrue);
if ( iEngine->iListener->IsConnected() )
{
aMenuPane->SetItemDimmed(EBTCmdSendMessage, EFalse);
}
else
{
aMenuPane->SetItemDimmed(EBTCmdSendMessage, ETrue);
}
}
else
{
// master mode
aMenuPane->SetItemDimmed(EBTCmdDiscoverDevices, EFalse);
aMenuPane->SetItemDimmed(EBTCmdDiscoverServices, EFalse);
aMenuPane->SetItemDimmed(EBTCmdConnectDevices, EFalse);
aMenuPane->SetItemDimmed(EBTCmdShowConnectedDevices, EFalse);
if ( iEngine->iDeviceDiscoverer->HasDevices() )
{
// we have found devices, show discover services item
aMenuPane->SetItemDimmed(EBTCmdDiscoverServices, EFalse);
// disable slave option, entered master mode
aMenuPane->SetItemDimmed(EBTCmdStartSlave, ETrue);
}
else
{
// disconnected
aMenuPane->SetItemDimmed(EBTCmdDiscoverServices, ETrue);
}
if ( iEngine->iServiceDiscoverer->HasServices() )
{
// we have found services, show connect item
aMenuPane->SetItemDimmed(EBTCmdConnectDevices, EFalse);
}
else
{
// no services
aMenuPane->SetItemDimmed(EBTCmdConnectDevices, ETrue);
}
if ( iEngine->HasConnections() )
{
// we are connected, show send message item
aMenuPane->SetItemDimmed(EBTCmdSendMessage, EFalse);
aMenuPane->SetItemDimmed(EBTCmdShowConnectedDevices, EFalse);
}
else
{
// disconnected
aMenuPane->SetItemDimmed(EBTCmdSendMessage, ETrue);
aMenuPane->SetItemDimmed(EBTCmdShowConnectedDevices, ETrue);
}
}
}
}
// ----------------------------------------------------------------------------
// CBluetoothPMPExampleAppUi::HandleKeyEventL(
// const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
//
// takes care of key event handling
// ----------------------------------------------------------------------------
TKeyResponse CBluetoothPMPExampleAppUi::HandleKeyEventL(
const TKeyEvent& /*aKeyEvent*/,TEventCode /*aType*/)
{
return EKeyWasNotConsumed;
}
// ----------------------------------------------------------------------------
// CBluetoothPMPExampleAppUi::HandleCommandL(TInt aCommand)
//
// takes care of command handling
// ----------------------------------------------------------------------------
void CBluetoothPMPExampleAppUi::HandleCommandL(TInt aCommand)
{
switch ( aCommand )
{
case EAknSoftkeyBack:
case EEikCmdExit:
{
Exit();
break;
}
case EBTCmdStartSlave:
{
if ( !iEngine->iIsSlave )
iEngine->StartSlaveL();
break;
}
case EBTCmdDiscoverDevices:
{
if ( !iEngine->iIsSlave )
iEngine->DiscoverDevicesL();
break;
}
case EBTCmdDiscoverServices:
{
if ( !iEngine->iIsSlave )
iEngine->DiscoverServicesL();
break;
}
case EBTCmdConnectDevices:
{
if ( !iEngine->iIsSlave )
iEngine->ConnectDevicesL();
break;
}
case EBTCmdShowConnectedDevices:
{
if ( !iEngine->iIsSlave )
iEngine->ShowConnectedDevicesL();
break;
}
case EBTCmdSendMessage:
{
iEngine->SendMessage();
break;
}
default:
break;
}
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -