bool CGUIDialogKeyboardGeneric::OnAction(const CAction &action)
{
  bool handled = true;
  if (action.GetID() == (KEY_VKEY | XBMCVK_BACK))
    Backspace();
  else if (action.GetID() == ACTION_ENTER || (m_isKeyboardNavigationMode && action.GetID() == ACTION_SELECT_ITEM))
    OnOK();
  else if (action.GetID() == ACTION_SHIFT)
    OnShift();
  else if (action.GetID() == ACTION_SYMBOLS)
    OnSymbols();
  // don't handle move left/right and select in the edit control
  else if (!m_isKeyboardNavigationMode &&
           (action.GetID() == ACTION_MOVE_LEFT ||
           action.GetID() == ACTION_MOVE_RIGHT ||
           action.GetID() == ACTION_SELECT_ITEM))
    handled = false;
  else
  {
    handled = false;
    wchar_t unicode = action.GetUnicode();
    if (unicode)
    {
      std::wstring wch = L"";
      wch.insert(wch.begin(), unicode);
      std::string ch;
      g_charsetConverter.wToUTF8(wch, ch);
      handled = CodingCharacter(ch);
      if (!handled)
      {
        // send action to edit control
        CGUIControl *edit = GetControl(CTL_EDIT);
        if (edit)
          handled = edit->OnAction(action);
        if (!handled && action.GetID() >= KEY_VKEY && action.GetID() < KEY_ASCII)
        {
          BYTE b = action.GetID() & 0xFF;
          if (b == XBMCVK_TAB)
          {
            // Toggle left/right key mode
            m_isKeyboardNavigationMode = !m_isKeyboardNavigationMode;
            if (m_isKeyboardNavigationMode)
            {
              m_previouslyFocusedButton = GetFocusedControlID();
              SET_CONTROL_FOCUS(edit->GetID(), 0);
            }
            else
              SET_CONTROL_FOCUS(m_previouslyFocusedButton, 0);
            handled = true;
          }
        }
      }
    }
  }

  if (!handled) // unhandled by us - let's see if the baseclass wants it
    handled = CGUIDialog::OnAction(action);

  return handled;
}
Beispiel #2
0
bool CGUIWindow::OnAction(const CAction &action)
{
  if (action.IsMouse() || action.IsGesture())
    return EVENT_RESULT_UNHANDLED != OnMouseAction(action);

  CGUIControl *focusedControl = GetFocusedControl();
  if (focusedControl)
  {
    if (focusedControl->OnAction(action))
      return true;
  }
  else
  {
    // no control has focus?
    // set focus to the default control then
    CGUIMessage msg(GUI_MSG_SETFOCUS, GetID(), m_defaultControl);
    OnMessage(msg);
  }

  // default implementations
  if (action.GetID() == ACTION_NAV_BACK || action.GetID() == ACTION_PREVIOUS_MENU)
    return OnBack(action.GetID());

  return false;
}
void CGUIDialogKeyboardGeneric::Backspace()
{
    // send action to edit control
    CGUIControl *edit = GetControl(CTL_EDIT);
    if (edit)
        edit->OnAction(CAction(ACTION_BACKSPACE));
}
void CGUIDialogKeyboardGeneric::Backspace()
{
  if (m_codingtable && m_hzcode.length() > 0)
  {
    std::wstring tmp;
    g_charsetConverter.utf8ToW(m_hzcode, tmp);
    tmp.erase(tmp.length() - 1, 1);
    g_charsetConverter.wToUTF8(tmp, m_hzcode);
    
    switch (m_codingtable->GetType())
    {
    case IInputCodingTable::TYPE_WORD_LIST:
      SetControlLabel(CTL_LABEL_HZCODE, m_hzcode);
      ChangeWordList(0);
      break;

    case IInputCodingTable::TYPE_CONVERT_STRING:
      SetEditText(m_codingtable->ConvertString(m_hzcode));
      break;
    }
  }
  else
  {
    // send action to edit control
    CGUIControl *edit = GetControl(CTL_EDIT);
    if (edit)
      edit->OnAction(CAction(ACTION_BACKSPACE));

    if (m_codingtable && m_codingtable->GetType() == IInputCodingTable::TYPE_CONVERT_STRING)
      m_codingtable->SetTextPrev(GetText());
  }
}
bool CGUIDialogKeyboardGeneric::OnAction(const CAction &action)
{
  bool handled = true;
  if (action.GetID() == ACTION_ENTER)
    OnOK();
  else if (action.GetID() == ACTION_SHIFT)
    OnShift();
  else if (action.GetID() == ACTION_SYMBOLS)
    OnSymbols();
  // don't handle move left/right and select in the edit control
  else if (action.GetID() == ACTION_MOVE_LEFT ||
           action.GetID() == ACTION_MOVE_RIGHT ||
           action.GetID() == ACTION_SELECT_ITEM)
    handled = false;
  else
  {
    handled = false;
    // send action to edit control
    CGUIControl *edit = GetControl(CTL_EDIT);
    if (edit)
      handled = edit->OnAction(action);
  }

  if (!handled) // unhandled by us - let's see if the baseclass wants it
    handled = CGUIDialog::OnAction(action);

  return handled;
}
Beispiel #6
0
bool CGUIWindow::OnAction(const CAction &action)
{
  if (action.IsMouse() || action.IsGesture())
    return EVENT_RESULT_UNHANDLED != OnMouseAction(action);

  CGUIControl *focusedControl = GetFocusedControl();
  if (focusedControl)
  {
    if (focusedControl->OnAction(action))
      return true;
  }
  else
  {
    // no control has focus?
    // set focus to the default control then
    CGUIMessage msg(GUI_MSG_SETFOCUS, GetID(), m_defaultControl);
    OnMessage(msg);
  }

  // default implementations
  switch(action.GetID())
  {
    case ACTION_NAV_BACK:
    case ACTION_PREVIOUS_MENU:
      return OnBack(action.GetID());
    case ACTION_SHOW_INFO:
      return OnInfo(action.GetID());
    case ACTION_MENU:
      if (m_menuControlID > 0)
      {
        CGUIControl *menu = GetControl(m_menuControlID);
        if (menu)
        {
          int focusControlId;
          if (!menu->HasFocus())
          {
            // focus the menu control
            focusControlId = m_menuControlID;
            // To support a toggle behaviour we store the last focused control id
            // to restore (focus) this control if the menu control has the focus
            // while you press the menu button again.
            m_menuLastFocusedControlID = GetFocusedControlID();
          }
          else
          {
            // restore the last focused control or if not exists use the default control
            focusControlId = m_menuLastFocusedControlID > 0 ? m_menuLastFocusedControlID : m_defaultControl;
          }

          CGUIMessage msg = CGUIMessage(GUI_MSG_SETFOCUS, GetID(), focusControlId);
          return OnMessage(msg);
        }
      }
      break;
  }

  return false;
}
void CGUIDialogKeyboardGeneric::MoveCursor(int iAmount)
{
  if (m_codingtable && m_words.size())
    ChangeWordList(iAmount);
  else
  {
    CGUIControl *edit = GetControl(CTL_EDIT);
    if (edit)
      edit->OnAction(CAction(iAmount < 0 ? ACTION_CURSOR_LEFT : ACTION_CURSOR_RIGHT));
  }
}
void CGUIDialogKeyboardGeneric::NormalCharacter(const std::string &ch)
{
  // send text to edit control
  CGUIControl *edit = GetControl(CTL_EDIT);
  if (edit)
  {
    CAction action(ACTION_INPUT_TEXT);
    action.SetText(ch);
    edit->OnAction(action);
  }
}
Beispiel #9
0
bool CGUIWindow::OnAction(const CAction &action)
{
  if (action.IsMouse() || action.IsGesture())
    return EVENT_RESULT_UNHANDLED != OnMouseAction(action);

  CGUIControl *focusedControl = GetFocusedControl();
  if (focusedControl)
    return focusedControl->OnAction(action);

  // no control has focus?
  // set focus to the default control then
  CGUIMessage msg(GUI_MSG_SETFOCUS, GetID(), m_defaultControl);
  OnMessage(msg);
  return false;
}
void CGUIDialogKeyboardGeneric::Backspace()
{
  if (m_codingtable && m_hzcode.length() > 0)
  {
    m_hzcode.erase(m_hzcode.length() - 1, 1);
    SetControlLabel(CTL_LABEL_HZCODE, m_hzcode);
    ChangeWordList(0);
  }
  else
  {
    // send action to edit control
    CGUIControl *edit = GetControl(CTL_EDIT);
    if (edit)
      edit->OnAction(CAction(ACTION_BACKSPACE));
  }
}
bool CGUIDialogKeyboardGeneric::OnAction(const CAction &action)
{
    bool handled = true;
    if (action.GetID() == ACTION_ENTER || (m_isKeyboardNavigationMode && action.GetID() == ACTION_SELECT_ITEM))
        OnOK();
    else if (action.GetID() == ACTION_SHIFT)
        OnShift();
    else if (action.GetID() == ACTION_SYMBOLS)
        OnSymbols();
    // don't handle move left/right and select in the edit control
    else if (!m_isKeyboardNavigationMode &&
             (action.GetID() == ACTION_MOVE_LEFT ||
              action.GetID() == ACTION_MOVE_RIGHT ||
              action.GetID() == ACTION_SELECT_ITEM))
        handled = false;
    else
    {
        handled = false;
        // send action to edit control
        CGUIControl *edit = GetControl(CTL_EDIT);
        if (edit)
            handled = edit->OnAction(action);
        if (!handled && action.GetID() >= KEY_VKEY && action.GetID() < KEY_ASCII)
        {
            BYTE b = action.GetID() & 0xFF;
            if (b == XBMCVK_TAB)
            {
                // Toggle left/right key mode
                m_isKeyboardNavigationMode = !m_isKeyboardNavigationMode;
                if (m_isKeyboardNavigationMode)
                {
                    m_previouslyFocusedButton = GetFocusedControlID();
                    SET_CONTROL_FOCUS(edit->GetID(), 0);
                }
                else
                    SET_CONTROL_FOCUS(m_previouslyFocusedButton, 0);
                handled = true;
            }
        }
    }

    if (!handled) // unhandled by us - let's see if the baseclass wants it
        handled = CGUIDialog::OnAction(action);

    return handled;
}
Beispiel #12
0
bool CGUIDialogKeyboardGeneric::OnAction(const CAction &action)
{
  bool handled(true);
  if (action.GetID() == ACTION_BACKSPACE)
  {
    Backspace();
  }
  else if (action.GetID() == ACTION_ENTER)
  {
    OnOK();
  }
  else if (action.GetID() == ACTION_CURSOR_LEFT)
  {
    MoveCursor( -1);
  }
  else if (action.GetID() == ACTION_CURSOR_RIGHT)
  {
    MoveCursor(1);
  }
  else if (action.GetID() == ACTION_SHIFT)
  {
    OnShift();
  }
  else if (action.GetID() == ACTION_SYMBOLS)
  {
    OnSymbols();
  }
  else if (action.GetID() >= KEY_ASCII)
  { // send action to the edit control
    CGUIControl *edit = GetControl(CTL_EDIT);
    if (edit)
      edit->OnAction(action);
  }
  else // unhandled by us - let's see if the baseclass wants it
    handled = CGUIDialog::OnAction(action);

  return handled;
}
void CGUIDialogKeyboardGeneric::MoveCursor(int iAmount)
{
    CGUIControl *edit = GetControl(CTL_EDIT);
    if (edit)
        edit->OnAction(CAction(iAmount < 0 ? ACTION_CURSOR_LEFT : ACTION_CURSOR_RIGHT));
}
Beispiel #14
0
bool CGUIWindowVisualisation::OnAction(const CAction &action)
{
  bool passToVis = false;
  switch (action.GetID())
  {
  case ACTION_VIS_PRESET_NEXT:
  case ACTION_VIS_PRESET_PREV:
  case ACTION_VIS_PRESET_RANDOM:
  case ACTION_VIS_RATE_PRESET_PLUS:
  case ACTION_VIS_RATE_PRESET_MINUS:
    passToVis = true;
    break;

  case ACTION_SHOW_INFO:
    {
      m_initTimer.Stop();
      g_settings.m_bMyMusicSongThumbInVis = g_infoManager.ToggleShowInfo();
      return true;
    }
    break;

  case ACTION_SHOW_GUI:
    // save the settings
    g_settings.Save();
    g_windowManager.PreviousWindow();
    return true;
    break;

  case ACTION_VIS_PRESET_LOCK:
    { // show the locked icon + fall through so that the vis handles the locking
      if (!m_bShowPreset)
      {
        m_lockedTimer.StartZero();
        g_infoManager.SetShowCodec(true);
      }
      passToVis = true;
    }
    break;
  case ACTION_VIS_PRESET_SHOW:
    {
      if (!m_lockedTimer.IsRunning() || m_bShowPreset)
        m_bShowPreset = !m_bShowPreset;
      g_infoManager.SetShowCodec(m_bShowPreset);
      return true;
    }
    break;

  case ACTION_DECREASE_RATING:
  case ACTION_INCREASE_RATING:
    {
      // actual action is taken care of in CApplication::OnAction()
      m_initTimer.StartZero();
      g_infoManager.SetShowInfo(true);
    }
    break;
    // TODO: These should be mapped to it's own function - at the moment it's overriding
    // the global action of fastforward/rewind and OSD.
/*  case KEY_BUTTON_Y:
    g_application.m_CdgParser.Pause();
    return true;
    break;

    case ACTION_ANALOG_FORWARD:
    // calculate the speed based on the amount the button is held down
    if (action.GetAmount())
    {
      float AVDelay = g_application.m_CdgParser.GetAVDelay();
      g_application.m_CdgParser.SetAVDelay(AVDelay - action.GetAmount() / 4.0f);
      return true;
    }
    break;*/
  }

  if (passToVis)
  {
    CGUIControl *control = (CGUIControl *)GetControl(CONTROL_VIS);
    if (control)
      return control->OnAction(action);
  }

  return CGUIWindow::OnAction(action);
}
Beispiel #15
0
bool CGUIWindowVisualisation::OnAction(const CAction &action)
{
  bool passToVis = false;
  switch (action.GetID())
  {
  case ACTION_VIS_PRESET_NEXT:
  case ACTION_VIS_PRESET_PREV:
  case ACTION_VIS_PRESET_RANDOM:
  case ACTION_VIS_RATE_PRESET_PLUS:
  case ACTION_VIS_RATE_PRESET_MINUS:
    passToVis = true;
    break;

  case ACTION_SHOW_INFO:
    {
      m_initTimer.Stop();
      CServiceBroker::GetSettings().SetBool(CSettings::SETTING_MYMUSIC_SONGTHUMBINVIS,
                                            CServiceBroker::GetGUI()->GetInfoManager().GetInfoProviders().GetPlayerInfoProvider().ToggleShowInfo());
      return true;
    }
    break;

  case ACTION_SHOW_OSD:
    CServiceBroker::GetGUI()->GetWindowManager().ActivateWindow(WINDOW_DIALOG_MUSIC_OSD);
    return true;

  case ACTION_SHOW_GUI:
    // save the settings
    CServiceBroker::GetSettings().Save();
    CServiceBroker::GetGUI()->GetWindowManager().PreviousWindow();
    return true;
    break;

  case ACTION_VIS_PRESET_LOCK:
    { // show the locked icon + fall through so that the vis handles the locking
      if (!m_bShowPreset)
      {
        m_lockedTimer.StartZero();
      }
      passToVis = true;
    }
    break;
  case ACTION_VIS_PRESET_SHOW:
    {
      if (!m_lockedTimer.IsRunning() || m_bShowPreset)
        m_bShowPreset = !m_bShowPreset;
      return true;
    }
    break;

  case ACTION_DECREASE_RATING:
  case ACTION_INCREASE_RATING:
    {
      // actual action is taken care of in CApplication::OnAction()
      m_initTimer.StartZero();
      CServiceBroker::GetGUI()->GetInfoManager().GetInfoProviders().GetPlayerInfoProvider().SetShowInfo(true);
    }
    break;
    //! @todo These should be mapped to its own function - at the moment it's overriding
    //! the global action of fastforward/rewind and OSD.
/*  case KEY_BUTTON_Y:
    g_application.m_CdgParser.Pause();
    return true;
    break;

    case ACTION_ANALOG_FORWARD:
    // calculate the speed based on the amount the button is held down
    if (action.GetAmount())
    {
      float AVDelay = g_application.m_CdgParser.GetAVDelay();
      g_application.m_CdgParser.SetAVDelay(AVDelay - action.GetAmount() / 4.0f);
      return true;
    }
    break;*/
  }

  if (passToVis)
  {
    CGUIControl *control = GetControl(CONTROL_VIS);
    if (control)
      return control->OnAction(action);
  }

  return CGUIWindow::OnAction(action);
}