|
发表于 2011-12-9 11:52:51
|
显示全部楼层
手电筒UI
#ifdef __MAIN_FLASHLIGHT__
VFX_IMPLEMENT_CLASS("VapppenFlashLightpage", VapppenFlashLightpage, VfxPage);
void VapppenFlashLightpage::onInit()
{
setStatusBar(VFX_FALSE);
VfxPage::onInit();
setAlignParent(VFX_FRAME_ALIGNER_MODE_NONE, VFX_FRAME_ALIGNER_MODE_NONE, VFX_FRAME_ALIGNER_MODE_NONE, VFX_FRAME_ALIGNER_MODE_NONE);
VFX_OBJ_CREATE(m_imageFrame1, VfxImageFrame, this);
m_imageFrame1->setImgContent(VfxImageSrc(IMG_ID_VAPP_FLASHLIGHT_BG));
m_imageFrame1->setPos(0, 0);
VFX_OBJ_CREATE(m_imageFrame2, VfxImageFrame, this);
m_imageFrame2->setImgContent(VfxImageSrc(IMG_ID_VAPP_FLASHLIGHT_BACK));
m_imageFrame2->setPos(245, 405);
}
VfxBool VapppenFlashLightpage::handlePenDown(const VfxPoint &touchDownPos)
{
if(((touchDownPos.x>=130)&&(touchDownPos.x<195))&&((touchDownPos.y>=335)&&(touchDownPos.y<=415)))
{
VFX_OBJ_CREATE(m_imageFrame3, VfxImageFrame, this);
m_imageFrame3->setImgContent(VfxImageSrc(IMG_ID_VAPP_FLASHLIGHT_DOWN));
m_imageFrame3->setPos(141, 347);
if(m_status_light)
{
VFX_OBJ_CREATE(m_imageFrame5, VfxImageFrame, this);
m_imageFrame5->setImgContent(VfxImageSrc(IMG_ID_VAPP_FLASHLIGHT_ON));
m_imageFrame5->setPos(0, 0);
custom_start_flashlight(1, 1, 0, 50);
}
else
{
VFX_OBJ_CREATE(m_imageFrame6, VfxImageFrame, this);
m_imageFrame6->setImgContent(VfxImageSrc(IMG_ID_VAPP_FLASHLIGHT_BG_OFF));
m_imageFrame6->setPos(0, 0);
custom_stop_flashlight();
}
m_status_light=!m_status_light;
}
else if(((touchDownPos.x>=240)&&(touchDownPos.x<320))&&((touchDownPos.y>=400)&&(touchDownPos.y<=480)))
{
VFX_OBJ_CREATE(m_imageFrame7, VfxImageFrame, this);
m_imageFrame7->setImgContent(VfxImageSrc(IMG_ID_VAPP_FLASHLIGHT_BACK_DOWN));
m_imageFrame7->setPos(245, 405);
}
return VFX_TRUE;
}
VfxBool VapppenFlashLightpage::handlePenUp(const VfxPoint &touchDownPos)
{
if(((touchDownPos.x>=130)&&(touchDownPos.x<195))&&((touchDownPos.y>=335)&&(touchDownPos.y<=415)))
{
VFX_OBJ_CREATE(m_imageFrame3, VfxImageFrame, this);
m_imageFrame3->setImgContent(VfxImageSrc(IMG_ID_VAPP_FLASHLIGHT_UP));
m_imageFrame3->setPos(141, 347);
// m_imageFrame3->setHidden(VFX_TRUE);
}
else if(((touchDownPos.x>=240)&&(touchDownPos.x<320))&&((touchDownPos.y>=400)&&(touchDownPos.y<=480)))
{
m_signalCancel.postEmit();
VfxPage::exit();
}
return VFX_TRUE;
}
VfxBool VapppenFlashLightpage::onPenInput(VfxPenEvent &event)
{
if (event.type == VFX_PEN_EVENT_TYPE_DOWN)
{
return handlePenDown(event.getRelPos(this) );
}
else if(event.type == VFX_PEN_EVENT_TYPE_UP)
{
/*VFX_OBJ_CREATE(m_imageFrame4, VfxImageFrame, this);
m_imageFrame4->setImgContent(VfxImageSrc(IMG_ID_VAPP_FLASHLIGHT_UP));
m_imageFrame4->setPos(141, 347);*/
// m_imageFrame3->setHidden(VFX_TRUE);
return handlePenUp(event.getRelPos(this) );
}
return VFX_TRUE; //VfxControl::onKeyInput(event);
}
VfxBool VapppenFlashLightpage::onKeyInput(VfxKeyEvent &event)
{
if ((event.keyCode == VFX_KEY_CODE_HOME ||
event.keyCode == VFX_KEY_CODE_BACK)&&
event.type == VFX_KEY_EVENT_TYPE_DOWN )
{
{
m_signalCancel.postEmit();
if (event.keyCode == VFX_KEY_CODE_HOME || event.keyCode == VFX_KEY_CODE_END||event.keyCode==VFX_KEY_CODE_BACK)
{
return VfxPage::onKeyInput(event);
}
return VFX_TRUE;
}
}
return VfxPage::onKeyInput(event);
}
/*******************************************
******flashlightcui
*******************************************/
VFX_IMPLEMENT_CLASS("VapppenFlashLightCui", VapppenFlashLightCui, VfxCui);
void VapppenFlashLightCui::onRun(void* args, VfxU32 argSize)
{
VFX_OBJ_CREATE(m_mainScr, VfxMainScr, this);
m_mainScr->setBgColor(VFX_COLOR_BLACK);
if(!m_currpage)
{
VFX_OBJ_CREATE(m_currpage, VapppenFlashLightpage, m_mainScr);
m_currpage->m_signalTap.connect(this, &VapppenFlashLightCui::onPenTapped);
m_mainScr->pushPage(0, m_currpage);
}
m_mainScr->show();
}
void VapppenFlashLightCui::onPenTapped()
{
lightoff = !lightoff;
m_currpage->setState(lightoff);
}
void VapppenFlashLightCui::onDeinit()
{
lightoff=VFX_FALSE;
VfxAppLauncher::terminate(getGroupId());
custom_stop_flashlight();
}
#endif
<img src="attachments/dvbbs/2011-12/201112911524142052.jpg" border="0" onclick="zoom(this)" onload="if(this.width>document.body.clientWidth*0.5) {this.resized=true;this.width=document.body.clientWidth*0.5;this.style.cursor='pointer';} else {this.onclick=null}" alt="" /> |
|