示例#1
0
//----------------------------------初始化函数---------------------------------
//返回是否成功初始化
signed char TImeMng_Init(struct _TImeMng *pIme,  //带入的输入法结构缓冲
                         TWin_t *pWin,             //当前挂接的窗口
                         char *pString,            //用户已存在的字符串,必须以'\0'结尾
                         TIme_String_t Size,     //字符串缓冲区允许大小+1
                         unsigned char DefaultType,   //默认输入法<4
                         unsigned char TypeMask,      //可使用的输入法类型 
                         const char *pSignTbl) //挂接的符号表,为空时使用默认
{
  unsigned char Data;
  //检查窗口是否够显示
  if(TWin_GetW(pWin) < 16) return -1;//不够显示
  if(TWin_GetH(pWin) < 4) return -1;//不够显示
  
  memset(pIme, 0, sizeof(struct _TImeMng));
  //有效宽度初始化
  Data = TWin_GetW(pWin);
  if(Data >= 18) Data-= 2;//去除左右边界符号"|"
  pIme->w = Data;
  //有效高度初始化
  Data = TWin_GetH(pWin);
  pIme->h = Data;
  //初始化除Data区域的成员
  pIme->pWin = pWin;
  TImeEdit_Init(&pIme->Edit,pString,Size,pIme->w);//初始化编辑器  
  pIme->pSignTbl = pSignTbl;  
  if(DefaultType >= 4) DefaultType = 0;//强制纠错
  pIme->TypeMask = TypeMask;
  
  _SwitchIme(pIme,DefaultType);//根据默认输入法类型初始化Data区
  
  //最后控制窗口显示

  _Refresh(pIme);      //更新显示
  return 0;
}
示例#2
0
//----------------------------按键处理函数---------------------------------
//用户按数字键区与导航键区时调用此函数
//返回值定义为: 0正常状态,-1:退出键直接退出;-2:确认键退出
signed char TImeMng_Key(struct _TImeMng *pIme,
                        char Key)          //键值
{
  //只要不是数字键,均强制停止大小写定时器
  if((Key < '0') || (Key > '9'))  pIme->CapitalTimer = 0;
  
  if(!(pIme->Flag & TIME_FLAG_STATE)){//在编辑状态,进行编辑字符串操作
    switch(Key){
    case TGUI_KEY_LEFT:  TImeEdit_CursorLeft(&pIme->Edit); break;
    case TGUI_KEY_RIGHT: TImeEdit_CursorRight(&pIme->Edit); break;
    case TGUI_KEY_DELETE:TImeEdit_Clr(&pIme->Edit); break;
    case TGUI_KEY_ENTER:  return-2;//确认键退出编辑状态
    case TGUI_KEY_ESCAPE: return-1;//退出键直接退出编辑状态
    case '*': //切换到符号输入模式,并进入其内部
      _SwitchIme(pIme, TIME_TYPE_SIGN);
      pIme->Flag |= TIME_FLAG_STATE;
      break;
    case '#'://仅切换输入法
      _SwitchIme(pIme, _SwitchType(pIme));
    default:
      //数字键输入法响应
      if((Key >= '0') && (Key <= '9')){
        switch(_NumKeyInEdit(pIme, Key)){
        //case 0:break;// 0未响应
        case 1://进入输入法内部,置标志
          pIme->Flag |= TIME_FLAG_STATE;
          break;
        case 2: _GetImeChar(pIme);//有结果返回,取得结果
          break;
        default:break;
        }
      }
      break;
    }
  }
  else{//在输入法内部时
    switch(_KeyInType(pIme, Key)){
        //case 0:break;// 0未响应
        case 1: //1:输入法内部不退出,有结果返回
          _GetImeChar(pIme);
          break;
        case 2: //输入法内部退出,有结果返回
          _GetImeChar(pIme);
        case 3: //输入法内部退出,无效返回
          pIme->Flag &= ~TIME_FLAG_STATE;
          //若为符号输入法退出,则强制退到进入前输入法状态
          if(pIme->Type == TIME_TYPE_SIGN)
            _SwitchIme(pIme, pIme->Flag & TIME_PRV_TYPE_MASK);
          break;
        default:break;
    }
  }
  
  _Refresh(pIme);      //更新显示
  return 0;
}
示例#3
0
//--------------------------任务函数---------------------------------
//在有输入法时调用此函数实现时间要求
void TImeMng_Task(struct _TImeMng *pIme)
{
  if(!pIme->CapitalTimer) return ;//定时器停止状态
  pIme->CapitalTimer--;
  if(pIme->CapitalTimer) return;//进行中
  //定时时间到时:
  if((pIme->Type == TIME_TYPE_LOWERCASE) || //防止异常操作
     (pIme->Type == TIME_TYPE_CAPITAL)){
       TImeCapital_SampReset(&pIme->Data.Capital);//同键值时复位
       _Refresh(pIme);//重新刷新显示
  }
}
示例#4
0
void QtOSGViewer::_CreateActions()
{
    exitAct = new QAction(tr("E&xit"), this);
    exitAct->setShortcut(tr("Ctrl+Q"));
    connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));

    loadAct = new QAction(QIcon(":/images/open.png"),tr("L&oad..."), this);
    loadAct->setShortcut(tr("Ctrl+L"));
    connect(loadAct, SIGNAL(triggered()), this, SLOT(LoadEnvironment()));

    importAct = new QAction(QIcon(":/images/Import.png"),tr("I&mport..."), this);
    importAct->setShortcut(tr("Ctrl+I"));
    connect(importAct, SIGNAL(triggered()), this, SLOT(ImportEnvironment()));

    saveAct = new QAction(QIcon(":/images/save.png"),tr("S&ave..."), this);
    saveAct->setShortcut(tr("Ctrl+S"));
    connect(saveAct, SIGNAL(triggered()), this, SLOT(SaveEnvironment()));

    viewCamAct = new QAction(tr("View Camera Params"), this);

    viewColAct = new QAction(tr("View Collision Word"), this);

    pubilshAct = new QAction(tr("Pubilsh Bodies Anytimes"), this);

    printAct = new QAction(tr("Print Debug Output"), this);

    showAct = new QAction(tr("Show Framerate"), this);

    playAct = new QAction(QIcon(":/images/play.png"),tr("Play"), this);

    stopAct = new QAction(QIcon(":/images/stop.png"),tr("Stop"), this);

    recordAct = new QAction(tr("Record V&ideo"), this);

    odeAct = new QAction(tr("ODE Dynamic Simulation"), this);
    odeAct->setCheckable(true);

    selfAct = new QAction(tr("Self Collision"), this);
    selfAct->setCheckable(true);

    applyAct = new QAction(tr("Apply Gravity"), this);
    applyAct->setCheckable(true);
    applyAct->setChecked(true);

    aboutAct = new QAction(tr("About"), this);

    pauseAct = new QAction(QIcon(":/images/pause.png"),tr("Pause"), this);

    puntAct = new QAction(QIcon(":/images/no_edit.png"),tr("Pointer"), this);

    AxesAct = new QAction(QIcon(":/images/axes.png"),tr("Axes"), this);
    AxesAct->setCheckable(true);
    connect(AxesAct, SIGNAL(triggered()), this, SLOT(axes()));

    houseAct = new QAction(QIcon(":/images/house.png"),tr("Home"), this);
    connect(houseAct, SIGNAL(triggered()),this,SLOT(ResetViewToHome()));

    smoothAct = new QAction(QIcon(":/images/smooth.png"),tr("Smooth"), this);
    connect(smoothAct, SIGNAL(triggered()), this, SLOT(polygonMode()));

    flatAct = new QAction(QIcon(":/images/flat.png"),tr("Flat"), this);
    connect(flatAct, SIGNAL(triggered()), this, SLOT(polygonMode()));

    lightAct = new QAction(QIcon(":/images/lighton.png"),tr("Light"), this);
    lightAct->setCheckable(true);
    connect(lightAct, SIGNAL(triggered()), this, SLOT(_ProcessLightChange()));

    wireAct = new QAction(QIcon(":/images/wire.png"),tr("Wire"), this);
    connect(wireAct, SIGNAL(triggered()), this, SLOT(polygonMode()));

    facesAct = new QAction(QIcon(":/images/faces.png"),tr("Cull face"), this);
    facesAct->setCheckable(true);
    connect(facesAct, SIGNAL(triggered()), this, SLOT(_ProcessFacesModeChange()));

    bboxAct = new QAction(QIcon(":/images/bbox.png"),tr("Poligon"), this);
    bboxAct->setCheckable(true);
    connect(bboxAct, SIGNAL(triggered()), this, SLOT(_ProcessBoundingBox()));

    connect(&_timer, SIGNAL(timeout()), this, SLOT(_Refresh()));
    _timer.start(1000/60); // ms
}