- 0
- 0
- 约2.71万字
- 约 79页
- 2022-04-23 发布于四川
- 举报
CCoeControl对按键事件的处理 TKeyResponse OfferKeyEventL(const TKeyEvent aEvent, TEventCode aType) TKeyResponse CMyGameView::OfferKeyEventL(const TKeyEvent aKeyEvent,TEventCode aType) { switch(aType) { case EEventKey: if(aKeyEvent.iScanCode == EStdKeyNkp5 || aKeyEvent.iScanCode == EStdKeyDevice3) { iMyGameEngine-Fire(); return EKeyWasConsumed; } break; case EEventKeyDown: … case EEventKeyUp: … } return EKeyWasNotConsumed; } 点击事件的处理 60系列并不支持笔写输入 但模拟器支持笔的点击 void HandlePointerEventL(const TPointerEvent) 复合控件 compound control 包含其它控件的控件 有时也称container,容器 为什么要用复合控件 共享主控件的现有窗口 重用控件 系统控件(CEikLabel) 自己的控件(CMyInfoControl) 可以选择性地重绘子控件 容器(主控件)的责任 创建窗口 只为主控件创建窗口 子控件重用该窗口 创建和删除子控件 在主控件中定义成员变量 在析构函数中删除子控件 摆放子控件 设置自己的大小 摆放子控件 CCoeControl Windows 创建一个新窗口 CreateWindowL() 为主控件所拥有 为子控件所共享 重用现有的窗口 SetContainerWindowL(const CCoeControl aContainer) 子控件调用该函数 减少与window server的c/s交互} 创建子控件 在容器的第二阶段构造函数中创建子控件,并让它们重用容器的窗口 void CtestContainer::ConstructL(const TRect aRect) { CreateWindowL();//创建主窗口 iLabel = new (ELeave) CEikLabel; iLabel-SetContainerWindowL( *this ); iLabel-SetTextL( _L(Example View) ); iToDoLabel = new (ELeave) CEikLabel; iToDoLabel-SetContainerWindowL( *this ); iToDoLabel-SetTextL( _L(Add Your controls\n here) ); SetRect(aRect); ActivateL(); } 通告给CONE相应的信息 告诉CONE拥有的子控件的数目 TInt CtestContainer::CountComponentControls() const 缺省的实现返回0 返回子控件的指针 CCoeControl* CtestContainer::ComponentControl(TInt aIndex) const 用来依次对所有的子控件执行操作 第一个控件的index为0,顺序通常不是很重要 如果忘记重载上述两个函数,则子控件依然存在,但无法显示,因为CONE不知道我们的容器有几个子控件 复合控件的绘图 重绘容器时也重绘了子控件 首先调用容器的Draw() 然后调用子控件的Draw() CONE利用CountComponentControls() 和ComponentControl(TInt aIndex) 依次调用自控件的Draw() 防止闪烁 如果子控件覆盖了整个容器的区域,则无须为容器提供Draw(),否则会重绘两次同一区域,产生闪烁 只重绘没有被子控件覆盖的区域 设置裁剪区域 void SetClippingRect(const TRectaRect) Tint SetClippingRegion(const TRegion aClippingRegion) TRegionFix10 clippingRegion; clippingRegi
原创力文档

文档评论(0)