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

📄 outcallview.cpp

📁 symbian 2rd下可以获取并显示来电号码
💻 CPP
字号:
// INCLUDES

//  Class include
#include "OutCallView.h"
#include "CegoAppUi.h"
#include "CegoViewManager.h"

// System includes
#include <eiklabel.h>  // for example label control
#include <aknlists.h> // CAknSingleStyleListBox
#include <barsread.h> // TResource Reader
#include <eikmenub.h> // CEikMenuBar
#include <Cego.rsg> // R_CONTEXTMENU_SAVED_GAMES_LISTBOX
#include <uikon.hrh> // TKeyCode #defines

// User includes

// CONSTANTS

// ================= MEMBER FUNCTIONS =======================
void COutCallView::ConstructL(const TRect& aRect)
    {
    CreateWindowL();

    iTopCtrl = new (ELeave) CEikLabel;
    iTopCtrl->SetContainerWindowL( *this );
    iTopCtrl->SetTextL( _L("Out going Call Display Page") );

    iBottomCtrl = new (ELeave) CEikLabel;
    iBottomCtrl->SetContainerWindowL( *this );
    iBottomCtrl->SetTextL( _L("Phone Number...") );
    
    SetRect(aRect);
    ActivateL();
    }

/**
* Symbian OS 2 phase constructor.
* Constructs the COutCallView using the NewLC method, popping
* the constructed object from the CleanupStack before returning it.
* 
* @param aRect The rectangle for this window
* @return The newly constructed CCompoundControl
*/
COutCallView* COutCallView::NewL(const TRect & aRect, const CCoeControl * aParent)
    {
    COutCallView* self = COutCallView::NewLC(aRect, aParent);
    CleanupStack::Pop(self);
    return self;
    }

/**
* Symbian OS 2 phase constructor.
* Constructs the COutCallView using the constructor and ConstructL 
* method, leaving the constructed object on the CleanupStack before returning it.
* 
* @param aRect The rectangle for this window
* @return The newly constructed CCompoundControl
*/
COutCallView* COutCallView::NewLC(const TRect & aRect, const CCoeControl * aParent)
    {
    COutCallView* self = new (ELeave) COutCallView;
    CleanupStack::PushL(self);
    self->ConstructL(aRect, aParent);
    return self;
    }

/**
* Symbian OS 2nd phase constructor.  Creates a Window for the controls, which it contains.
* Constructs a label and adds it to the window, which it then activates.
* @param aRect The rectangle for this window
*/ 
void COutCallView::ConstructL(const TRect & aRect, const CCoeControl * aParent)
    {
    if (aParent == NULL)
        {
        CreateWindowL();
        }
    else
        {
        SetContainerWindowL(*aParent);
        }
    CalculateRects();

    iTopCtrl = new (ELeave) CEikLabel;
    iTopCtrl->SetContainerWindowL( *this );
    iTopCtrl->SetTextL( _L("Out going Call Display Page") );

    iBottomCtrl = new (ELeave) CEikLabel;
    iBottomCtrl->SetContainerWindowL( *this );
    iBottomCtrl->SetTextL( _L("Phone Number...") );
    
    SetRect(aRect);
    ActivateL();
    }

/**
* Called by the framework in compound controls	
* @return The number of controls in this COutCallView
*/
TInt COutCallView::CountComponentControls() const
	{
	return ENumberOfControls;
	}

/**
* Called by the framework in compound controls	
* @param The index of the control to return
* @return The control for aIndex
*/
CCoeControl* COutCallView::ComponentControl(TInt aIndex) const
	{
	switch (aIndex)
		{
		case ETop:
			return iTopCtrl;
        case EBottom:
            return iBottomCtrl;
		default:
			return NULL;
		}
	}

/** 
* Destructor.  Frees up memory for the iLabel.
*/
COutCallView::~COutCallView()
    {
    delete iTopCtrl;
    iTopCtrl = NULL;
    delete iBottomCtrl;
    iBottomCtrl = NULL;
    if (iPhoneNumber != NULL)
        {
        delete iPhoneNumber;
        iPhoneNumber = NULL;
        }
    }

/**
* Called by the framework to draw this control.  Clears the area in 
* aRect.
* @param aRect in which to draw
*/
void COutCallView::Draw(const TRect& aRect) const
	{
	CWindowGc& gc = SystemGc();
	gc.Clear(aRect);
	}

/**
*
* Called by framework when the view size is changed.  Resizes the
* iLabel accordingly.
*
*/
void COutCallView::SizeChanged()
    {
    CalculateRects();
    iTopCtrl->SetRect(iTopRect);
    iBottomCtrl->SetRect(iBottomRect);
    }


void COutCallView::CalculateRects()
    {
    TRect outerRect = Rect();

    // Calculate dimensions of inner rectangles
    const TInt innerRectWidth = outerRect.Width();
    const TInt innerRectHeight = outerRect.Height() / 2;

    // Set rectangle for top control
    iTopRect.SetRect(outerRect.iTl, TSize(innerRectWidth, innerRectHeight));
    
    // Set bottom rectangle. Easiest way is to copy the top
    // rectangle then move it down by innerRectHeight:
    iBottomRect = iTopRect;
    iBottomRect.Move(0, innerRectHeight);
    }

void COutCallView::HandleCallChangeL(const RCall::TStatus& aStatus)
    {
    STATIC_CAST(CCegoAppUi*, iCoeEnv->AppUi())->BringAppToFront();
    if (IsVisible() == EFalse)
        {
        MakeVisible(ETrue);
        }
    if(aStatus == RCall::EStatusConnected)
        {
        }
    else
        {
        }
    }

void COutCallView::ShowPhoneNumber(HBufC * aPhoneNumber)
    {
    if (iViewManager!=NULL && iViewManager->GetViewById(EOutCallViewId) != NULL)
        {
        iViewManager->MakeVisible(EOutCallViewId);
        }
    iBottomCtrl->SetTextL(*aPhoneNumber);
    }

void COutCallView::SetViewManager(CCegoViewManager* aViewManager)
    {
    iViewManager = aViewManager;
    }

void COutCallView::HandleControlEventL(
    CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
    {
    }

TKeyResponse COutCallView::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
    {
    TBool selectKeyPressed = (aType == EEventKey) && (aKeyEvent.iCode == EKeyOK);
    
    if (selectKeyPressed)
        {
        CEikMenuBar* parentMenuBar = iEikonEnv->AppUiFactory()->MenuBar();
        parentMenuBar->SetMenuTitleResourceId(R_CONTEXTMENU_OUT_CALL_VIEW_MENU_BAR);
        if (parentMenuBar != NULL)
            {
            parentMenuBar->TryDisplayMenuBarL();
            }
        parentMenuBar->SetMenuTitleResourceId(R_CEGO_MENUBAR);
        return EKeyWasConsumed;
        }
    else 
        {
        return EKeyWasNotConsumed;
        }
    }

void COutCallView::MakeCallL(const TDesC& aNumber)
    {
    iCallEngine->MakeCallL(aNumber);
    // iPhoneNumber.Set(aNumber);
    iPhoneNumber = aNumber.AllocL();
    }

void COutCallView::DisplayView()
    {
    iViewManager->MakeVisible(EOutCallViewId); 
    }

void COutCallView::ShowCalleePage()
    {
    iBottomCtrl->SetTextL(*iPhoneNumber);
    }

⌨️ 快捷键说明

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