第8天 Symbian学习之开发实践:简单控件和复合控件的使用
2008-04-03 19:30
633 查看
Symbian学习笔记
日期:2008/4/3
学习目标: 掌握简单控件与复合控件的显示和操作方法
学习内容: 简单控件和复合控件
练习: 多一个复合控件的的程序,要求复合控件中有三个子控件,且三个子控件用不同的颜色进行填充
一、简单控件
简单控件派生于CCoeControl,主要方法有:
初始化方法;
void setRect(TRect& aRect)/void SizeChanged();//区域大小及遇到变化时处理
void Draw(const TRect& aRect) const;//绘制
void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType);//事件处理
二、复合控件
复合控件也成为容器,即多个控件的一个所有者,这些个子控件就摆放在这个复合控件上。复合控件一般只有一个窗口对象,所有的子控件共享这个窗口。
子控件可以是简单控件也可以是复合控件。
子控件相关函数方法:
SetContainerWindowL(constCCoeControl&aContainer)//设置窗口
OfferKeyEventL()//按键消息事件
复合控件相关函数方法:
CreateWindowL()//创建主窗口。
TInt CCoecontrol::CountComponentControls() const//返回子控件的个数
CCoeControl* CCoeControl::ComponentControl(TIntaIndex) const//子控件的一个枚举
三、总结
所有的屏幕操作都在控件上执行,所有的控件又都派生于CCoeControl。
控件包含:初始化,绘画/重新绘制,处理输入 3个过程;
需要的注意的是:初始化时,需要先给控件确定一个窗口,再进行设计大小等操作。
即在子控件的构造方法ConstructL里需要进行SetContainerWindowL。
四、附件代码
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* ============================================================================
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Name : CMyControlViewsContainer from MyControlViewsContainer.h
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Part of : MyControlViews
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Created : 03.04.2008 by
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Description:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Declares container control for application.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Version :
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Copyright:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* ============================================================================
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#ifndef MYCONTROLVIEWSCONTAINER_H
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#define MYCONTROLVIEWSCONTAINER_H
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// INCLUDES
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#include <coecntrl.h>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#include "CFirstControl.h"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#include "CSecondControl.h"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#include "ThirdControl.h"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// FORWARD DECLARATIONS
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
class CEikLabel; // for example labels
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
class CFirstControl;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
class CSecondControl;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
class CThirdControl;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// CLASS DECLARATION
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* CMyControlViewsContainer container control class.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
class CMyControlViewsContainer : public CCoeControl, MCoeControlObserver
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public: // Constructors and destructor
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* EPOC default constructor.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param aRect Frame rectangle for container.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
void ConstructL(const TRect& aRect);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Destructor.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
~CMyControlViewsContainer();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public: // New functions
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public: // Functions from base classes
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private: // Functions from base classes
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* From CoeControl,SizeChanged.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
void SizeChanged();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* From CoeControl,CountComponentControls.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
TInt CountComponentControls() const;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* From CCoeControl,ComponentControl.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
CCoeControl* ComponentControl(TInt aIndex) const;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* From CCoeControl,Draw.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
void Draw(const TRect& aRect) const;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* From MCoeControlObserver
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Acts upon changes in the hosted control's state.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param aControl The control changing its state
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param aEventType The type of control event
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private: //data
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
CEikLabel* iLabel; // example label
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
CFirstControl* iFc;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
CEikLabel* iToDoLabel; // example label
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
CSecondControl* iSc;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
CThirdControl* iTc;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
};
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#endif
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// End of File
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* ============================================================================
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Name : CMyControlViewsContainer from MyControlViewsContainer.h
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Part of : MyControlViews
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Created : 03.04.2008 by
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Implementation notes:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Initial content was generated by Series 60 Application Wizard.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Version :
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Copyright:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* ============================================================================
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// INCLUDE FILES
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#include "MyControlViewsContainer.h"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#include <eiklabel.h> // for example label control
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// ================= MEMBER FUNCTIONS =======================
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// ---------------------------------------------------------
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// CMyControlViewsContainer::ConstructL(const TRect& aRect)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// EPOC two phased constructor
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// ---------------------------------------------------------
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
//
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
void CMyControlViewsContainer::ConstructL(const TRect& aRect)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
CreateWindowL();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
iLabel = new (ELeave) CEikLabel;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
iLabel->SetContainerWindowL( *this );
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
iLabel->SetTextL( _L("") );
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
iFc = CFirstControl::NewL(TRect(10,20,30,40),this);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
iSc = CSecondControl::NewL(TRect(20,20,30,40),this);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
iTc = CThirdControl::NewL(TRect(20,20,30,40),this);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
iToDoLabel = new (ELeave) CEikLabel;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
iToDoLabel->SetContainerWindowL( *this );
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
iToDoLabel->SetTextL( _L("iToDoLabel: here") );
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
SetRect(aRect);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ActivateL();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// Destructor
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
CMyControlViewsContainer::~CMyControlViewsContainer()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
delete iLabel;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
delete iFc;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
delete iToDoLabel;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
delete iSc;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
delete iTc;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// ---------------------------------------------------------
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// CMyControlViewsContainer::SizeChanged()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// Called by framework when the view size is changed
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// ---------------------------------------------------------
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
//
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
void CMyControlViewsContainer::SizeChanged()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// TODO: Add here control resize code etc.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
iLabel->SetExtent( TPoint(10,10), TSize(100,10)/**//*iLabel->MinimumSize() */);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
iFc->SetExtent( TPoint(10,30), TSize(200,200) );
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
iToDoLabel->SetExtent( TPoint(10,100), iToDoLabel->MinimumSize());
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// ---------------------------------------------------------
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// CMyControlViewsContainer::CountComponentControls() const
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// ---------------------------------------------------------
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
//
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
TInt CMyControlViewsContainer::CountComponentControls() const
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return 5; // return nbr of controls inside this container
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// ---------------------------------------------------------
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// CMyControlViewsContainer::ComponentControl(TInt aIndex) const
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// ---------------------------------------------------------
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
//
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
CCoeControl* CMyControlViewsContainer::ComponentControl(TInt aIndex) const
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
switch ( aIndex )
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
case 0:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return iLabel;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
case 1:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return iFc;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
case 2:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return iToDoLabel;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
case 3:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return iSc;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
case 4:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return iTc;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
default:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return NULL;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// ---------------------------------------------------------
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// CMyControlViewsContainer::Draw(const TRect& aRect) const
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// ---------------------------------------------------------
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
//
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
void CMyControlViewsContainer::Draw(const TRect& aRect) const
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
CWindowGc& gc = SystemGc();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// TODO: Add your drawing code here
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// example code...
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
gc.Clear(aRect);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
gc.SetPenStyle( CGraphicsContext::ENullPen );
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
gc.SetBrushColor( KRgbGray );
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
gc.DrawRect( aRect );
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// ---------------------------------------------------------
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// CMyControlViewsContainer::HandleControlEventL(
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// CCoeControl* aControl,TCoeEvent aEventType)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// ---------------------------------------------------------
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
//
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
void CMyControlViewsContainer::HandleControlEventL(
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
CCoeControl* /**//*aControl*/,TCoeEvent /**//*aEventType*/)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// TODO: Add your control event handler code here
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// End of File
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// CFirstControl.h: interface for the CFirstControl class.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
//
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**///////////////////////////////////////////////////////////////////////
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#if !defined(AFX_CFIRSTCONTROL_H__2533836F_568A_4F35_824A_11B2D8EB84DC__INCLUDED_)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#define AFX_CFIRSTCONTROL_H__2533836F_568A_4F35_824A_11B2D8EB84DC__INCLUDED_
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#if _MSC_VER > 1000
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#pragma once
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#endif // _MSC_VER > 1000
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#include <coecntrl.h>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
class CFirstControl : public CCoeControl
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
CFirstControl();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
static CFirstControl* NewL(const TRect& aRect,CCoeControl* aParrent);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
virtual ~CFirstControl();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
void ContructL(const TRect& aRect,CCoeControl* aParrent);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
void SizeChanged();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
void Draw(const TRect& aRect) const;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
};
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#endif // !defined(AFX_CFIRSTCONTROL_H__2533836F_568A_4F35_824A_11B2D8EB84DC__INCLUDED_)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// CFirstControl.cpp: implementation of the CFirstControl class.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
//
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**///////////////////////////////////////////////////////////////////////
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#include "CFirstControl.h"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**///////////////////////////////////////////////////////////////////////
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// Construction/Destruction
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**///////////////////////////////////////////////////////////////////////
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
CFirstControl::CFirstControl()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//ContructL(TRect(30,30,50,50));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
CFirstControl* CFirstControl::NewL(const TRect& aRect,CCoeControl* aParrent)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
CFirstControl* self = new (ELeave) CFirstControl();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
CleanupStack::PushL(self);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
self->ContructL(aRect,aParrent);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
CleanupStack::Pop(self);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return self;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
CFirstControl::~CFirstControl()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
void CFirstControl::ContructL(const TRect& aRect,CCoeControl* aParrent)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//CreateWindowL();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
SetContainerWindowL(*aParrent);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
SetRect(aRect);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ActivateL();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
void CFirstControl::SizeChanged()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//this->SetRect()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
void CFirstControl::Draw(const TRect& /**//*aRect*/)const
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
CWindowGc& gc = SystemGc();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//gc.Clear(aRect);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
gc.SetPenStyle( CGraphicsContext::ESolidPen);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
gc.SetPenColor(KRgbGreen);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
gc.SetBrushStyle( CGraphicsContext::ESolidBrush);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
gc.SetBrushColor(KRgbGreen);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
TRect t;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
t.SetRect(20,20,100,300) ;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
gc.DrawEllipse(t);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
日期:2008/4/3
学习目标: 掌握简单控件与复合控件的显示和操作方法
学习内容: 简单控件和复合控件
练习: 多一个复合控件的的程序,要求复合控件中有三个子控件,且三个子控件用不同的颜色进行填充
一、简单控件
简单控件派生于CCoeControl,主要方法有:
初始化方法;
void setRect(TRect& aRect)/void SizeChanged();//区域大小及遇到变化时处理
void Draw(const TRect& aRect) const;//绘制
void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType);//事件处理
二、复合控件
复合控件也成为容器,即多个控件的一个所有者,这些个子控件就摆放在这个复合控件上。复合控件一般只有一个窗口对象,所有的子控件共享这个窗口。
子控件可以是简单控件也可以是复合控件。
子控件相关函数方法:
SetContainerWindowL(constCCoeControl&aContainer)//设置窗口
OfferKeyEventL()//按键消息事件
复合控件相关函数方法:
CreateWindowL()//创建主窗口。
TInt CCoecontrol::CountComponentControls() const//返回子控件的个数
CCoeControl* CCoeControl::ComponentControl(TIntaIndex) const//子控件的一个枚举
三、总结
所有的屏幕操作都在控件上执行,所有的控件又都派生于CCoeControl。
控件包含:初始化,绘画/重新绘制,处理输入 3个过程;
需要的注意的是:初始化时,需要先给控件确定一个窗口,再进行设计大小等操作。
即在子控件的构造方法ConstructL里需要进行SetContainerWindowL。
四、附件代码
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* ============================================================================
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Name : CMyControlViewsContainer from MyControlViewsContainer.h
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Part of : MyControlViews
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Created : 03.04.2008 by
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Description:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Declares container control for application.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Version :
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Copyright:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* ============================================================================
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#ifndef MYCONTROLVIEWSCONTAINER_H
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#define MYCONTROLVIEWSCONTAINER_H
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// INCLUDES
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#include <coecntrl.h>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#include "CFirstControl.h"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#include "CSecondControl.h"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#include "ThirdControl.h"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// FORWARD DECLARATIONS
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
class CEikLabel; // for example labels
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
class CFirstControl;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
class CSecondControl;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
class CThirdControl;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// CLASS DECLARATION
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* CMyControlViewsContainer container control class.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
class CMyControlViewsContainer : public CCoeControl, MCoeControlObserver
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public: // Constructors and destructor
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* EPOC default constructor.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param aRect Frame rectangle for container.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
void ConstructL(const TRect& aRect);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Destructor.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
~CMyControlViewsContainer();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public: // New functions
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public: // Functions from base classes
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private: // Functions from base classes
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* From CoeControl,SizeChanged.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
void SizeChanged();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* From CoeControl,CountComponentControls.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
TInt CountComponentControls() const;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* From CCoeControl,ComponentControl.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
CCoeControl* ComponentControl(TInt aIndex) const;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* From CCoeControl,Draw.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
void Draw(const TRect& aRect) const;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* From MCoeControlObserver
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Acts upon changes in the hosted control's state.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param aControl The control changing its state
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param aEventType The type of control event
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private: //data
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
CEikLabel* iLabel; // example label
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
CFirstControl* iFc;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
CEikLabel* iToDoLabel; // example label
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
CSecondControl* iSc;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
CThirdControl* iTc;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
};
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#endif
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// End of File
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* ============================================================================
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Name : CMyControlViewsContainer from MyControlViewsContainer.h
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Part of : MyControlViews
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Created : 03.04.2008 by
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Implementation notes:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Initial content was generated by Series 60 Application Wizard.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Version :
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Copyright:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* ============================================================================
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// INCLUDE FILES
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#include "MyControlViewsContainer.h"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#include <eiklabel.h> // for example label control
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// ================= MEMBER FUNCTIONS =======================
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// ---------------------------------------------------------
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// CMyControlViewsContainer::ConstructL(const TRect& aRect)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// EPOC two phased constructor
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// ---------------------------------------------------------
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
//
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
void CMyControlViewsContainer::ConstructL(const TRect& aRect)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
CreateWindowL();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
iLabel = new (ELeave) CEikLabel;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
iLabel->SetContainerWindowL( *this );
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
iLabel->SetTextL( _L("") );
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
iFc = CFirstControl::NewL(TRect(10,20,30,40),this);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
iSc = CSecondControl::NewL(TRect(20,20,30,40),this);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
iTc = CThirdControl::NewL(TRect(20,20,30,40),this);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
iToDoLabel = new (ELeave) CEikLabel;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
iToDoLabel->SetContainerWindowL( *this );
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
iToDoLabel->SetTextL( _L("iToDoLabel: here") );
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
SetRect(aRect);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ActivateL();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// Destructor
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
CMyControlViewsContainer::~CMyControlViewsContainer()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
delete iLabel;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
delete iFc;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
delete iToDoLabel;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
delete iSc;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
delete iTc;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// ---------------------------------------------------------
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// CMyControlViewsContainer::SizeChanged()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// Called by framework when the view size is changed
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// ---------------------------------------------------------
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
//
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
void CMyControlViewsContainer::SizeChanged()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// TODO: Add here control resize code etc.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
iLabel->SetExtent( TPoint(10,10), TSize(100,10)/**//*iLabel->MinimumSize() */);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
iFc->SetExtent( TPoint(10,30), TSize(200,200) );
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
iToDoLabel->SetExtent( TPoint(10,100), iToDoLabel->MinimumSize());
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// ---------------------------------------------------------
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// CMyControlViewsContainer::CountComponentControls() const
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// ---------------------------------------------------------
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
//
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
TInt CMyControlViewsContainer::CountComponentControls() const
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return 5; // return nbr of controls inside this container
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// ---------------------------------------------------------
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// CMyControlViewsContainer::ComponentControl(TInt aIndex) const
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// ---------------------------------------------------------
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
//
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
CCoeControl* CMyControlViewsContainer::ComponentControl(TInt aIndex) const
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
switch ( aIndex )
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
case 0:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return iLabel;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
case 1:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return iFc;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
case 2:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return iToDoLabel;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
case 3:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return iSc;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
case 4:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return iTc;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
default:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return NULL;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// ---------------------------------------------------------
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// CMyControlViewsContainer::Draw(const TRect& aRect) const
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// ---------------------------------------------------------
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
//
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
void CMyControlViewsContainer::Draw(const TRect& aRect) const
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
CWindowGc& gc = SystemGc();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// TODO: Add your drawing code here
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// example code...
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
gc.Clear(aRect);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
gc.SetPenStyle( CGraphicsContext::ENullPen );
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
gc.SetBrushColor( KRgbGray );
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
gc.DrawRect( aRect );
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// ---------------------------------------------------------
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// CMyControlViewsContainer::HandleControlEventL(
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// CCoeControl* aControl,TCoeEvent aEventType)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// ---------------------------------------------------------
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
//
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
void CMyControlViewsContainer::HandleControlEventL(
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
CCoeControl* /**//*aControl*/,TCoeEvent /**//*aEventType*/)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// TODO: Add your control event handler code here
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// End of File
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// CFirstControl.h: interface for the CFirstControl class.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
//
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**///////////////////////////////////////////////////////////////////////
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#if !defined(AFX_CFIRSTCONTROL_H__2533836F_568A_4F35_824A_11B2D8EB84DC__INCLUDED_)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#define AFX_CFIRSTCONTROL_H__2533836F_568A_4F35_824A_11B2D8EB84DC__INCLUDED_
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#if _MSC_VER > 1000
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#pragma once
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#endif // _MSC_VER > 1000
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#include <coecntrl.h>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
class CFirstControl : public CCoeControl
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
CFirstControl();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
static CFirstControl* NewL(const TRect& aRect,CCoeControl* aParrent);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
virtual ~CFirstControl();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
void ContructL(const TRect& aRect,CCoeControl* aParrent);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
void SizeChanged();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
void Draw(const TRect& aRect) const;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
};
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#endif // !defined(AFX_CFIRSTCONTROL_H__2533836F_568A_4F35_824A_11B2D8EB84DC__INCLUDED_)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// CFirstControl.cpp: implementation of the CFirstControl class.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
//
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**///////////////////////////////////////////////////////////////////////
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
#include "CFirstControl.h"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**///////////////////////////////////////////////////////////////////////
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// Construction/Destruction
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**///////////////////////////////////////////////////////////////////////
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
CFirstControl::CFirstControl()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//ContructL(TRect(30,30,50,50));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
CFirstControl* CFirstControl::NewL(const TRect& aRect,CCoeControl* aParrent)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
CFirstControl* self = new (ELeave) CFirstControl();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
CleanupStack::PushL(self);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
self->ContructL(aRect,aParrent);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
CleanupStack::Pop(self);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return self;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
CFirstControl::~CFirstControl()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
void CFirstControl::ContructL(const TRect& aRect,CCoeControl* aParrent)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//CreateWindowL();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
SetContainerWindowL(*aParrent);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
SetRect(aRect);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ActivateL();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
void CFirstControl::SizeChanged()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//this->SetRect()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
void CFirstControl::Draw(const TRect& /**//*aRect*/)const
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
CWindowGc& gc = SystemGc();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//gc.Clear(aRect);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
gc.SetPenStyle( CGraphicsContext::ESolidPen);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
gc.SetPenColor(KRgbGreen);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
gc.SetBrushStyle( CGraphicsContext::ESolidBrush);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
gc.SetBrushColor(KRgbGreen);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
TRect t;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
t.SetRect(20,20,100,300) ;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
gc.DrawEllipse(t);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
相关文章推荐
- iOS开发UI篇—使用picker View控件完成一个简单的选餐应用
- iOS开发UI篇—使用picker View控件完成一个简单的选餐应用
- iOS学习之UIPickerView控件的简单使用
- iOS学习笔记—— UItableView 控件的简单使用
- ArcGIS Server9.2学习开发(4)——使用Toc控件
- 我们物联网专业的嵌入式实习-day07(开发智能家居系统-QT简单的学习使用及分配项目)
- 通过一个简单的SWING日历BEAN开发学习Calendar类的使用(2)JCalendar源代码
- iOS学习之UIPickerView控件的简单使用
- 安卓开发_复选按钮控件(CheckBox)的简单使用
- Android学习Scroller(三)——控件平移划过屏幕 (Scroller简单使用)
- [原创]java WEB学习笔记40:简单标签概述(背景,使用一个标签,标签库的API,SimpleTag接口,创建一个自定义的标签的步骤 和简单实践)
- Java-使用Callable实现多线程的之JDK源码简单学习实践
- iOS学习笔记—— UISegmentedControl 控件的简单使用
- Delphi开发学习三:TdataSource 控件与 TDBGrid 控件使用实例
- 安卓开发_单选按钮控件(RadioButton)的简单使用
- marsAndroid学习——常见控件ExpandableListActivityh和SimpleExpandableListAdapter的简单使用
- iOS开发UI篇—使用picker View控件完成一个简单的选餐应用
- IOS开发学习第四章---使用更多的UI控件
- iOS学习之UIPickerView控件的简单使用
- iOS开发UI篇—使用picker View控件完成一个简单的选餐应用