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

📄 s60testappui.cpp

📁 《基于symbian手机开发与应用》一书的源代码
💻 CPP
字号:
#include <avkon.hrh>
#include <aknnotewrappers.h>
#include <eikmenup.h> 

#include "S60Test.pan"
#include "S60TestDocument.h"
#include "S60TestAppUi.h"
#include "S60TestAppView.h"
#include "S60Test.hrh"
#include "Step6.rsg"

void CS60TestAppUi::ConstructL()
{
  BaseConstructL();

  iEngine=CS60TestEngine::NewL(iDoc);
  iAppView=CS60TestAppView::NewL(ClientRect(), iDoc, iEngine);
  AddToStackL(iAppView);
}

CS60TestAppUi::CS60TestAppUi(CS60TestDocument *aDoc)
:iEngine(NULL)
{
  iDoc=aDoc;
}

CS60TestAppUi::~CS60TestAppUi()
{
  if (iAppView)
  {
    RemoveFromStack(iAppView);
    delete iAppView;
    iAppView = NULL;
  }
  delete iEngine;
}

void CS60TestAppUi::UpdateBoard()
{
  iAppView->DrawDeferred();
}

void CS60TestAppUi::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane *aMenuPane)
{
  if (aResourceId==R_S60TEST_MENU)
  {
    if (iEngine->iPauseRef>0)
      aMenuPane->SetItemTextL(ES60TestPause, R_MENU_UNPAUSE_TITLE);
      else aMenuPane->SetItemTextL(ES60TestPause, R_MENU_PAUSE_TITLE);
  }
}

// handle any menu commands
void CS60TestAppUi::HandleCommandL(TInt aCommand)
{
  switch(aCommand)
  {
    case EEikCmdExit:
    case EAknSoftkeyExit:
      Exit();
      break;

    case ES60TestNewGame:
      iDoc->Reset();
      iEngine->Reset();
      UpdateBoard();
      break;

    case ES60TestPause:
      if (iEngine->iPauseRef>0) iEngine->Unpause();
        else iEngine->Pause();
      break;

    default:
      Panic(ES60TestBasicUi);
      break;
  }
}

TKeyResponse CS60TestAppUi::HandleKeyEventL(const TKeyEvent &aKeyEvent,
    TEventCode aType)
{
  if (aType==EEventKey)
  {
    if (aKeyEvent.iCode==EKeyUpArrow)
      iEngine->KeyRotate(1);

    if (aKeyEvent.iCode==EKeyDownArrow)
      iEngine->KeyDrop();

    if (aKeyEvent.iCode==EKeyLeftArrow)
      iEngine->KeyLeft();

    if (aKeyEvent.iCode==EKeyRightArrow)
      iEngine->KeyRight();

    if (aKeyEvent.iCode=='1')
      iEngine->KeyRotate(-1);

    if (aKeyEvent.iCode=='0' || aKeyEvent.iCode=='3')
      iEngine->KeyRotate(1);
  }
  return EKeyWasNotConsumed;
}

⌨️ 快捷键说明

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