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

📄 labletestappappview.cpp

📁 多个标签的示例 symbian c++ for s60 v3
💻 CPP
字号:
/*
 ============================================================================
 Name		: LableTestAppAppView.cpp
 Author	  : lemonhat
 Copyright   : Your copyright notice
 Description : Application view implementation
 ============================================================================
 */

// INCLUDE FILES
#include <coemain.h>
#include "LableTestAppAppView.h"

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

// -----------------------------------------------------------------------------
// CLableTestAppAppView::NewL()
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
CLableTestAppAppView* CLableTestAppAppView::NewL(const TRect& aRect)
	{
	CLableTestAppAppView* self = CLableTestAppAppView::NewLC(aRect);
	CleanupStack::Pop(self);
	return self;
	}

// -----------------------------------------------------------------------------
// CLableTestAppAppView::NewLC()
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
CLableTestAppAppView* CLableTestAppAppView::NewLC(const TRect& aRect)
	{
	CLableTestAppAppView* self = new (ELeave) CLableTestAppAppView;
	CleanupStack::PushL(self);
	self->ConstructL(aRect);
	return self;
	}

// -----------------------------------------------------------------------------
// CLableTestAppAppView::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CLableTestAppAppView::ConstructL(const TRect& aRect)
	{
	// Create a window for this application view
	CreateWindowL();
	//TDesC* aaa;
    _LIT(aaa, "hello world hehe");
    iLabel = new (ELeave) CEikLabel();
    iLabel->SetContainerWindowL( *this );
    iLabel->SetTextL(aaa);
   // SetRect(TRect(10,10,90,30));
    
    
//    CEikLabel* iLabel1;
    
    iLabel0 = new (ELeave) CEikLabel();
    iLabel0->SetContainerWindowL( *this );
    iLabel0->SetTextL(aaa);
    iLabel0->OverrideColorL(EColorLabelText,KRgbBlue);
    iLabel0->OverrideColorL(EColorControlBackground,KRgbRed);
    
    
    
    

//    SetRect(TRect(10,100,90,130));
//    iLabel0->SetFocusing(ETrue);
    
    iRichText = new (ELeave) CEikRichTextEditor();
    //以下是有流动条的
//    iRichText->SetAknEditorFlags(EAknEditorFlagEnableScrollBars);
    
    iRichText->SetContainerWindowL( *this );
    iRichText->SetAvkonWrap(ETrue);
    iRichText->ConstructL(this, 10, 100, 
    		EEikEdwinLineCursor, EGulFontControlAll, EGulNoSymbolFonts);
    
    iRichText->SetAknEditorAllowedInputModes(EAknEditorAllInputModes);
    //set the default input mode
    iRichText->SetAknEditorInputMode(EAknEditorNumericInputMode);

    iRichText->SetFocus(ETrue);
    iRichText->EnableCcpuSupportL(ETrue);
    iRichText->SetCursorPosL(0,EFalse);
    
    iRichText->SetBorder(10);
    iRichText->SetBackgroundColorL(TRgb(0x00000000));
    iRichText->SetExtent(TPoint(0,60),TSize(60,20));
//    iRichText->SetAknEditorAllowedInputModes(1);
    iRichText->RichText()->InsertL(0,aaa);
    
//    iEdwin = new (ELeave) CEikEdwin();
//    iEdwin->SetContainerWindowL(*this);
//    iEdwin->SetMaxLength(511);
//    iEdwin->SetAknEditorCase(EAknEditorTextCase);
//    iEdwin->SetAknEditorInputMode(EAknEditorTextInputMode);
//    iEdwin->SetExtent(TPoint(0,90),TSize(80,20));
//    iEdwin->Text()->InsertL(0,aaa);


    
    



    

    /**
     * 如果有多个label,在显示时只显示最后一个label,那该如何做多个label呢?     */
    
//    for(TInt i = 0;i<10;i++){
//    CEikLabel* lable = new(ELeave)CEikLabel;
//    lable->SetContainerWindowL(*this);
//    lable->SetTextL(aaa);
//    SetRect(TRect(10,(i+2)*10,90,(i+2)*10+20));
//		
//    }
    
	// Set the windows size  是设置视图的窗口大小
	SetRect(aRect);

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

// -----------------------------------------------------------------------------
// CLableTestAppAppView::CLableTestAppAppView()
// C++ default constructor can NOT contain any code, that might leave.
// -----------------------------------------------------------------------------
//
CLableTestAppAppView::CLableTestAppAppView()
	{
	// No implementation required
	}

// -----------------------------------------------------------------------------
// CLableTestAppAppView::~CLableTestAppAppView()
// Destructor.
// -----------------------------------------------------------------------------
//
CLableTestAppAppView::~CLableTestAppAppView()
	{
	// No implementation required
	delete iLabel;
	delete iLabel0;
	delete iRichText;
	delete iEdwin;
	}

// -----------------------------------------------------------------------------
// CLableTestAppAppView::Draw()
// Draws the display.
// -----------------------------------------------------------------------------
//
void CLableTestAppAppView::Draw(const TRect& /*aRect*/) const
	{
	// Get the standard graphics context
	CWindowGc& gc = SystemGc();

	// Gets the control's extent
	TRect drawRect(Rect());

	// Clears the screen
	gc.Clear(drawRect);

	}

// -----------------------------------------------------------------------------
// CLableTestAppAppView::SizeChanged()
// Called by framework when the view size is changed.
// -----------------------------------------------------------------------------
//
void CLableTestAppAppView::SizeChanged() 
	{
	//在这里表明空间的起始位置和它的大小,也可以在ConstructL中定义
	 iLabel->SetExtent( TPoint(0,0), iLabel->MinimumSize());
	    iLabel0->SetExtent( TPoint(30,30),iLabel0->MinimumSize());
	//DrawNow();
	}

// -----------------------------------------------------------------------------
// CLableTestAppAppView::HandlePointerEventL()
// Called by framework to handle pointer touch events.
// Note: although this method is compatible with earlier SDKs, 
// it will not be called in SDKs without Touch support.
// -----------------------------------------------------------------------------
//
void CLableTestAppAppView::HandlePointerEventL(
		const TPointerEvent& aPointerEvent)
	{

	// Call base class HandlePointerEventL()
	CCoeControl::HandlePointerEventL(aPointerEvent);
	}

TInt CLableTestAppAppView::CountComponentControls() const
{
    return 3;
}
 
CCoeControl* CLableTestAppAppView::ComponentControl(TInt aIndex) const
{
switch ( aIndex )
    {
    case 0:
        return iLabel;
    case 1:
    	return iLabel0;
    case 2:
    	return iRichText;
//    case 3:
//    	return iEdwin;
    default:
        return NULL;
    }
}
 
//Call this function to change value of Label
void CLableTestAppAppView::SetTextL(const TDesC& aText)
{
   iLabel->SetTextL(aText);
   iLabel0->SetTextL(aText);
}


//TKeyResponse CLableTestAppAppView::OfferKeyEventL(const TKeyEvent& aKeyEvent,
//TEventCode aType)
//{
//	TKeyResponse Ret(EKeyWasNotConsumed);
//	
//	if (iRichText)
//	{
//		Ret = iRichText->OfferKeyEventL(aKeyEvent, aType);	
//	}
// 
//	return Ret;

//if(iRichText)   
//    return iRichText->OfferKeyEventL(aKeyEvent,aType);   
//else   
//    return CCoeControl::OfferKeyEventL(aKeyEvent,aType); 

//}
// End of File

⌨️ 快捷键说明

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