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

📄 keyboardappui.cpp

📁 On screen keyboard source code in Linux
💻 CPP
字号:
/* $Id: KeyboardAppUi.cpp,v 1.9 2003/11/11 21:24:44 chrisf Exp $ */

/* Copyright (c) 2003 Chris Faherty */

/* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. */

#include <eikenv.h>
#include <eikmenup.h>
#include <eikgted.h>
#include <Keyboard.rsg>
#include "Keyboard.pan"
#include "KeyboardAppUi.h"
#include "KeyboardAppView.h"
#include "Keyboard.hrh"
#include "KeyboardAppModel.h"

// ConstructL is called by the application framework
void CKeyboardAppUi::ConstructL() {
  BaseConstructL();

  // Create view
  iAppView = CKeyboardAppView::NewL(ClientRect());
  AddToStackL(iAppView);

  // Create engine
  iAppModel = CKeyboardAppModel::NewL();
  iAppView->SetModel(iAppModel);
  iAppModel->SetView(iAppView);
}

CKeyboardAppUi::CKeyboardAppUi() {
}

CKeyboardAppUi::~CKeyboardAppUi() {
  delete iAppModel;
  iAppModel = NULL;

  if(iAppView) {
    RemoveFromStack(iAppView);
    delete iAppView;
    iAppView = NULL;
  }
}

// handle any menu commands
void CKeyboardAppUi::HandleCommandL(TInt aCommand) {
  switch(aCommand) {
    case EKeyboardCmdOn:
      iAppView->Init();
      iAppModel->Start();
      break;

	case ELayoutUS:
	  iAppView->setKeyboardLayout(US_LAYOUT);
	  break;
	  
	case ELayoutFR:
	  iAppView->setKeyboardLayout(FR_LAYOUT);
	  break;
	
	case ELayoutDE:
	  iAppView->setKeyboardLayout(DE_LAYOUT);
	  break;

	case ELayoutNO:
	  iAppView->setKeyboardLayout(NO_LAYOUT);
	  break;

	case ELayoutPT:
	  iAppView->setKeyboardLayout(PT_LAYOUT);
	  break;

	case EThinkoutside:
	  iAppView->setKeyboardModel(THINKOUTSIDE_MODEL);
	  break;
	
	case EPocketop:
	  iAppView->setKeyboardModel(POCKETOP_MODEL);
	  break;

 	case ETargus:
	  iAppView->setKeyboardModel(TARGUS_MODEL);
	  break;
	
    case EKeyboardCmdOff:
      iAppModel->Cancel();
      iAppModel->Stop();
      break;

    case EEikCmdExit:
        Exit();
        break;

    default:
      //User::Panic(KPanicKeyboard, EKeyboardBasicUi);
      break;
  }
}

void CKeyboardAppUi::DynInitMenuPaneL(TInt aMenuId, CEikMenuPane* aMenuPane) {
  if(aMenuId == R_KEYBOARD_MENU) {
    bool connected = iAppModel->Connected();
    aMenuPane->SetItemDimmed(EKeyboardCmdOn, connected);
    aMenuPane->SetItemDimmed(EKeyboardCmdOff, !connected);
  }
  if(aMenuId == R_KEYBOARD_I18N) {
  	int layout = iAppView->getKeyboardLayout(); 
  	aMenuPane->SetItemButtonState(ELayoutUS, layout == US_LAYOUT ? EEikMenuItemSymbolOn : EEikMenuItemSymbolIndeterminate);
  	aMenuPane->SetItemButtonState(ELayoutFR, layout == FR_LAYOUT ? EEikMenuItemSymbolOn : EEikMenuItemSymbolIndeterminate);
	aMenuPane->SetItemButtonState(ELayoutDE, layout == DE_LAYOUT ? EEikMenuItemSymbolOn : EEikMenuItemSymbolIndeterminate);
    aMenuPane->SetItemButtonState(ELayoutNO, layout == NO_LAYOUT ? EEikMenuItemSymbolOn : EEikMenuItemSymbolIndeterminate);
    aMenuPane->SetItemButtonState(ELayoutNO, layout == PT_LAYOUT ? EEikMenuItemSymbolOn : EEikMenuItemSymbolIndeterminate);
  }

  if(aMenuId == R_KEYBOARD_MODEL) {
  	int model = iAppView->getKeyboardModel();
	bool connected = iAppModel->Connected();
	aMenuPane->SetItemDimmed(EThinkoutside, connected);
    aMenuPane->SetItemDimmed(EPocketop, connected);
    aMenuPane->SetItemDimmed(ETargus, connected);
	
  	aMenuPane->SetItemButtonState(EThinkoutside, model == THINKOUTSIDE_MODEL ? EEikMenuItemSymbolOn : EEikMenuItemSymbolIndeterminate);
  	aMenuPane->SetItemButtonState(EPocketop, model == POCKETOP_MODEL ? EEikMenuItemSymbolOn : EEikMenuItemSymbolIndeterminate);
  	aMenuPane->SetItemButtonState(ETargus, model == TARGUS_MODEL ? EEikMenuItemSymbolOn : EEikMenuItemSymbolIndeterminate);
  }
  
}

TKeyResponse CKeyboardAppUi::HandleKeyEventL(const TKeyEvent & aKeyEvent, TEventCode aType) {
  return EKeyWasNotConsumed;
}

⌨️ 快捷键说明

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