dirscracccontainer2.cpp

来自「symbian平台上如何在屏幕上快速的显示图片」· C++ 代码 · 共 138 行

CPP
138
字号
/*
* ============================================================================
*  Name     : CDirScrAccContainer2 from DirScrAccContainer2.cpp
*  Part of  : DirScrAcc
*  Created  : 06/11/2003 by Forum Nokia
*  Implementation notes:
*     Initial content was generated by Nokia Series 60 AppWizard.
*  Version  :
*  Copyright: Nokia Corporation
* ============================================================================
*/

// INCLUDE FILES
#include "DirScrAccContainer2.h"

#include <eiklabel.h>  // for example label control
#include <eikenv.h>

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

// ---------------------------------------------------------
// CDirScrAccContainer::ConstructL(const TRect& aRect)
// Symbiantwo phased constructor
// ---------------------------------------------------------
//
void CDirScrAccContainer2::ConstructL(const TRect& aRect)
    {
    CreateWindowL();

    iLabel = new (ELeave) CEikLabel;
    iLabel->SetContainerWindowL( *this );
    iLabel->SetTextL(_L(
        "Select Start\nfrom Options\nto start \nfull screen DSA \nusing \nGraphics Context\n\nNavigate left or right\nfor other views"));

    SetRect(aRect);    

	// Set up our engine
	iEng = CDirScrAccEng::NewL(iEikonEnv->WsSession(), 
                               *(CCoeEnv::Static()->ScreenDevice()), 
					           Window());
		
    ActivateL();
    }

// Destructor
CDirScrAccContainer2::~CDirScrAccContainer2()
    {
    delete iLabel;    
    if(iEng && iEng->Drawing())
		iEng->StopDrawing();
	delete iEng;
    iEng = NULL;
    }

// ---------------------------------------------------------
// CDirScrAccContainer::SizeChanged()
// Called by framework when the view size is changed
// ---------------------------------------------------------
//
void CDirScrAccContainer2::SizeChanged()
    {
    // TODO: Add here control resize code etc.
    iLabel->SetExtent(TPoint(10,10), iLabel->MinimumSize());
    }

// ---------------------------------------------------------
// CDirScrAccContainer::CountComponentControls() const
// ---------------------------------------------------------
//
TInt CDirScrAccContainer2::CountComponentControls() const
    {    
    return iEng->Drawing() ? 0 : 1;
    }

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

// ---------------------------------------------------------
// CDirScrAccContainer::Draw(const TRect& aRect) const
// ---------------------------------------------------------
//
void CDirScrAccContainer2::Draw(const TRect& aRect) const
    {
    // if the engine is running, no need to draw any controls    
    if(iEng->Drawing())
        return;

    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);
    }

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


void CDirScrAccContainer2::StartDrawingL()
	{    
	iEng->StartDrawingL();
	}

void CDirScrAccContainer2::StopDrawing()
	{    
	iEng->StopDrawing();    
	}

TBool CDirScrAccContainer2::IsDrawing()
	{    
	return iEng->Drawing();	
	}


// End of File  

⌨️ 快捷键说明

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