横竖屏切换

symbian 2008-11-03 14:06:53 阅读223 评论1 字号:大中小
1:HandleScreenDeviceChangedL 重写UI的这个方法

2.Please use the following function to get the event:

void CMyAppUi::HandleResourceChangeL( TInt aType )
{
CAknViewAppUi::HandleResourceChangeL( aType );

if ( aType == KAknsMessageSkinChange ||
aType == KEikDynamicLayoutVariantSwitch )

....
}

 

C 对于UIQ可以用如下方式设置屏幕显示方式:(可以在视图下执行)

 CQUiConfigClient::Static().SetCurrentConfigL(KQikPenStyleTouchLandscape);       //决定为横屏方式
 TQikViewMode viewMode;
 viewMode.SetFullscreen();                                                       //设置为全屏
 SetViewModeL(viewMode);


 //CQUiConfigClient::Static().SetTouchScreenL(EQikUiConfigTouchScreenYes);
 //CQUiConfigClient::Static().SetScreenModeL(EQikUiConfigLandscape);               //可以不要

 

a 对于CEikDialog(经过验证可行)
继承TBool ShutL(),返回Mfalse可解决系统强制关闭对话框的问题
(特别注意:ShutL在父类中是私有的,所以在子类中必须要私有继承,而不是保护或者公有继承!否则调用不起效果)

b 对于CQikSimpleDialog 提供了一个接口SetCanForcedExit(),可以解决系统强制关闭对话框的问题
  (还没完全经过验证)
 
 CQikSimpleDialog* dialog = new (ELeave) CQikSimpleDialog;  dialog->PrepareLC(R_CONFIRM_DIALOG);
 dialog->SetCanForcedExit(EFalse);
 if (pDialog)
  *pDialog = dialog;
 // Launches the dialog and will be destroyed when it's dismissed.
 return dialog->RunLD();

c 对于CQikViewDialog
  (经过验证可行,但要注意:iQikAppUi是#include <QikAppUi.h>里的应该要加上)
//.h:
    void ViewActivatedL(const TVwsViewId& aPrevViewId,TUid aCustomMessageId,const TDesC8& aCustomMessage);
    void ViewDeactivated();

TVwsViewId iDefaultViewId;

//.CPP:
#include <QikAppUi.h>
void CSettingColorDialog::ViewActivatedL(const TVwsViewId&/* aPrevViewId*/,TUid/* aCustomMessageId*/,const TDesC8&/* aCustomMessage*/)
{
    iQikAppUi.GetDefaultViewId(iDefaultViewId);
    iQikAppUi.SetDefaultViewL(*this);
}

void CSettingColorDialog::ViewDeactivated()
{
    iQikAppUi.SetDefaultViewL(*(iQikAppUi.QikView(iDefaultViewId)));
}


注意:CSettingColorDialog的阻塞函数不能放在父视图的ViewActivatedL里,否则会出问题


d 最后:或者参考Now4/Doc1/20080604/合盖后dialog自动消失的处理(改用view)
  依照上面的修改后,使用时:
  (经过验证可行)

//CTextView是CSettingColorDialog的父类,以下先是消除CSettingColorDialog对象,然后做原先dialog阻塞时的最后续操作
void CTextView::ViewActivatedL(const TVwsViewId& /*aPrevViewId*/,TUid/*aCustomMessageId*/,const TDesC8& /*aCustomMessage*/)
{
 CSettingColorDialog* pStoryboardView = (CSettingColorDialog*)iQikAppUi.QikView(TVwsViewId(KUidPhotoEditorApp, KUidSetColorView));
 if(MNull != pStoryboardView) 
 {
  CQikViewSwitcher &switcher = iQikAppUi.ViewSwitcher();
  iQikAppUi.RemoveView(*pStoryboardView);
  switcher.Delete(pStoryboardView);


  MCOLORREF colorNew = MAKERGBA(m_colorText.Red(), m_colorText.Green(), m_colorText.Blue(), 0);
  if(m_TextType.color != colorNew)
  {
   m_TextType.color = colorNew;
   SetCurText(&m_TextType);
  }
  ChangeMenuStatus();
  DrawNow();
 
  return;
 }

 TRect rcClient = Rect();
 TSize size = rcClient.Size();
 MRESULT res = 0;

注意:using EEikDialogFlagWait in your resource file (this makes the dialog modal)

e 注意:可以用ViewScreenDeviceChangedL/HandleScreenDeviceChangedL/HandleUiConfigChangedL来处理翻盖合盖事件。
void ExampleAppUi::HandleScreenDeviceChangedL()
   {
      CWsScreenDevice& screenDevice = *(iCoeEnv->ScreenDevice());
      isFlipOpen = (screenDevice.CurrentScreenMode() == 0) ? ETrue : EFalse;


      if(!isFlipOpen)
         {
         iEikonEnv->InfoMsg(_L("Flip Closed.."));
         TPixelsAndRotation sizeAndRotation;
         CEikonEnv::Static()->ScreenDevice()->GetDefaultScreenSizeAndRotation(sizeAndRotation);
         CEikonEnv::Static()->ScreenDevice()->SetScreenSizeAndRotation(sizeAndRotation);
         iCurrentView = EMainuiFlipView;
         AddToStackL(iViews[EMainuiFlipView]);
        
         }
         else{                    
            iEikonEnv->InfoMsg(_L("Flip Open.."));
            RemoveFromStack(iViews[EMainuiFlipView]);
            AddToStackL(iViews[EMainuiNumLoginView]);
            iCurrentView = EMainuiNumLoginView;
         }

}
或者:
void CSettingColorDialog::HandleUiConfigChangedL()
{
 CQikViewBase::HandleUiConfigChangedL();
 
 TQikUiConfig config = CQUiConfigClient::Static().CurrentConfig();
 switch(config.ScreenMode())
    {
    case EQikUiConfigPortrait :           //flip open
  break;
 
    case EQikUiConfigSmallPortrait:        //flip close
  CQikCommand *aCmd = CQikCommand::NewL(EQikCmdGoBack);
  HandleCommandL(*aCmd);
  delete aCmd;
  break;
 
    default :
  break;
    }
}

实际总结:
void ExampleAppUi::HandleScreenDeviceChangedL()这个函数可以捕捉到合盖事件,但是翻盖事件没有响应,可能跟我们程序切换到后台有关系.
在View中继承了HandleUiConfigChangedL()这个函数,没有响应任何事件.但在dialog中继承的时候能响应两个事件

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值