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

📄 mycontrol.cpp

📁 上载的代码是symbian手机开发练习项目的文件
💻 CPP
字号:


#include "mycontrol.h"
#include <gdi.h>
#include <e32math.h>

const TRgb CMyControl::iColor[3] = {TRgb(255, 0, 0),TRgb(0, 255, 0), TRgb(0, 0, 255)};
CMyControl::CMyControl()
{
  // No implementation required
}

CMyControl::~CMyControl()
{
}

CMyControl*
CMyControl::NewLC(TRect aRect)
{
  CMyControl* self = new (ELeave) CMyControl();
  CleanupStack::PushL(self);
  self->ConstructL(aRect);
  return self;
}

CMyControl*
CMyControl::NewL(TRect aRect)
{
  CMyControl* self = CMyControl::NewLC(aRect);
  CleanupStack::Pop(); // self;
  return self;
}

void
CMyControl::ConstructL(TRect& aRect)
{
  SetRect(aRect);
  iColorIndex = Math::Random() % iMaxColorNum;
}
_LIT(KHello, "Hello world!");
void
CMyControl::Draw(const TRect& aRect) const
{
  CWindowGc& gc = SystemGc();
  gc.SetBrushColor(iColor[iColorIndex]);
  gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
  gc.DrawRect(aRect);
}

void CMyControl::HandlePointerEventL(const TPointerEvent &aPointerEvent)
{
  if(aPointerEvent.iType == TPointerEvent::EButton1Up)
    {
      iColorIndex = (iColorIndex + 1) % iMaxColorNum;
      DrawDeferred();
    }
}

⌨️ 快捷键说明

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