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

📄 myviews.cpp

📁 一个uiq界面设计的例子~~
💻 CPP
字号:


#include <eiklabel.h>
#include <coeaui.h>
#include <eikenv.h>
#include <qikappui.h>
#include <eikmenub.h>
#include <MyApp.rsg>

#include "MyViews.h"
#include "MyEngine.h"
#include "MyAppUi.h"
#include "MyApp.h"

CMyViewOne::CMyViewOne()
	{
	}

void CMyViewOne::ConstructL(const TRect& aRect)
    {
    CreateWindowL();

    iLabel = new (ELeave) CEikLabel;
	CMyEngine* engine = static_cast<CMyAppUi*>(CEikonEnv::Static()->AppUi())->GetEngine();
	iLabel->SetTextL(engine->GetViewOneData());    
	iLabel->SetContainerWindowL( *this );

    SetRect(aRect);
    ActivateL();
    }



CMyViewOne::~CMyViewOne()
	{
	delete iLabel;
	}
void CMyViewOne::SizeChanged()
    {
    // TODO: Add here control resize code etc.
    iLabel->SetExtent( TPoint(10,10), iLabel->MinimumSize() );
    }

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

CCoeControl* CMyViewOne::ComponentControl(TInt aIndex) const
    {
    switch ( aIndex )
        {
        case 0:
            return iLabel;
        default:
            return NULL;
        }
    }

void CMyViewOne::Draw(const TRect& aRect) const
    {
    CWindowGc& gc = SystemGc();
    gc.SetPenStyle(CGraphicsContext::ENullPen);
    gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
    gc.DrawRect(aRect);
    }



void CMyViewOne::ViewDeactivated()
	{
	MakeVisible(EFalse);
	}

void CMyViewOne::ViewActivatedL(const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,const TDesC8& /*aCustomMessage*/)
	{
    CEikMenuBar* menuBar = iEikonEnv->AppUiFactory()->MenuBar();
    menuBar->ChangeMenuBarL(0, R_MYAPP_MENUBAR, EFalse);


	MakeVisible(ETrue);
	}

TVwsViewId CMyViewOne::ViewId() const
	{
	return TVwsViewId(KUidMyApp,KUidMyAppViewOne);
	}

//////////////////////////////////////////////////////////




CMyViewTwo::CMyViewTwo()
	{
	}

void CMyViewTwo::ConstructL(const TRect& aRect)
    {

    CreateWindowL();

    iLabel = new (ELeave) CEikLabel;
	CMyEngine* engine = static_cast<CMyAppUi*>(CEikonEnv::Static()->AppUi())->GetEngine();
	iLabel->SetTextL(engine->GetViewTwoData());

    iLabel->SetContainerWindowL( *this );
    SetRect(aRect);
    ActivateL();
    }



CMyViewTwo::~CMyViewTwo()
	{
	delete iLabel;
	}
void CMyViewTwo::SizeChanged()
    {
    // TODO: Add here control resize code etc.
    iLabel->SetExtent( TPoint(10,10), iLabel->MinimumSize() );
    }

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

CCoeControl* CMyViewTwo::ComponentControl(TInt aIndex) const
    {
    switch ( aIndex )
        {
        case 0:
            return iLabel;
        default:
            return NULL;
        }
    }

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

void CMyViewTwo::ViewConstructL()
	{
	ConstructL(static_cast<CQikAppUi*>(CEikonEnv::Static()->AppUi())->ClientRect());
	(static_cast<CQikAppUi*>(iCoeEnv->AppUi()))->AddToStackL(*this,this);
	}

void CMyViewTwo::ViewDeactivated()
	{
	MakeVisible(EFalse);
	}

void CMyViewTwo::ViewActivatedL(const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,const TDesC8& /*aCustomMessage*/)
	{
    CEikMenuBar* menuBar = iEikonEnv->AppUiFactory()->MenuBar();
    menuBar->ChangeMenuBarL(0, R_MYAPP_VIEW2_MENUBAR, EFalse);

	MakeVisible(ETrue);
	}

TVwsViewId CMyViewTwo::ViewId() const
	{
	return TVwsViewId(KUidMyApp,KUidMyAppViewTwo);
	}

⌨️ 快捷键说明

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