void CGUIWindowSettingsCategory::FocusElement(const std::string& elementId)
{
  for (size_t i = 0; i < m_categories.size(); ++i)
  {
    if (m_categories[i]->GetId() == elementId)
    {
      SET_CONTROL_FOCUS(CONTROL_SETTINGS_START_BUTTONS + i, 0);
      return;
    }
    for (const auto& group: m_categories[i]->GetGroups())
    {
      for (const auto& setting : group->GetSettings())
      {
        if (setting->GetId() == elementId)
        {
          SET_CONTROL_FOCUS(CONTROL_SETTINGS_START_BUTTONS + i, 0);

          auto control = GetSettingControl(elementId);
          if (control)
            SET_CONTROL_FOCUS(control->GetID(), 0);
          else
            CLog::Log(LOGERROR, "CGUIWindowSettingsCategory: failed to get control for setting '%s'.", elementId.c_str());
          return;
        }
      }
    }
  }
  CLog::Log(LOGERROR, "CGUIWindowSettingsCategory: failed to set focus. unknown category/setting id '%s'.", elementId.c_str());
}
bool CGUIWindowFirstTimeUseCalibration::OnMessage(CGUIMessage& message)
{
    bool retVal = CGUIWindowSettingsScreenCalibration::OnMessage(message);

    switch (message.GetMessage())
    {
    case GUI_MSG_CLICKED:
    {
        switch(message.GetSenderId())
        {
        case TOP_LEFT_MOVER:
        {
            SetProperty("setting-state",SETTING_BOTTOM_RIGHT);
            CLog::Log(LOGDEBUG,"CGUIWindowFirstTimeUseCalibration::OnMessage - GUI_MSG_CLICKED - Finish set TOP_LEFT_MOVER. Set property [setting-state=%d=SETTING_BOTTOM_RIGHT] (ftu)",GetPropertyInt("setting-state"));
            SET_CONTROL_FOCUS(BOTTOM_RIGHT_MOVER,0);
        }
        break;
        case BOTTOM_RIGHT_MOVER:
        {
            SetProperty("setting-state",VALIDATE_STATE);
            CLog::Log(LOGDEBUG,"CGUIWindowFirstTimeUseCalibration::OnMessage - GUI_MSG_CLICKED - Finish set BOTTOM_RIGHT_MOVER. Set property [setting-state=%d=VALIDATE_STATE] (ftu)",GetPropertyInt("setting-state"));

            SET_CONTROL_VISIBLE(TRY_AGAIN_BUTTON);
            SET_CONTROL_VISIBLE(DONE_BUTTON);
            SET_CONTROL_FOCUS(DONE_BUTTON,0);
        }
        break;
        case TRY_AGAIN_BUTTON:
        {
            SET_CONTROL_FOCUS(TOP_LEFT_MOVER,0);
            SetProperty("setting-state",SETTING_TOP_LEFT);
            CLog::Log(LOGDEBUG,"CGUIWindowFirstTimeUseCalibration::OnMessage - GUI_MSG_CLICKED - click on TRY_AGAIN_BUTTON. Set property [setting-state=%d=SETTING_TOP_LEFT] (ftu)",GetPropertyInt("setting-state"));
        }
        break;
        case DONE_BUTTON:
        {
            CLog::Log(LOGDEBUG,"CGUIWindowFirstTimeUseCalibration::OnMessage - GUI_MSG_CLICKED - click on DONE_BUTTON. Call Login() (ftu)");

            g_stSettings.m_doneFTU2 = true;
            g_settings.Save();

            /////////////////////////////////////////////
            // DONE_BUTTON was clicked -> call Login() //
            /////////////////////////////////////////////

            bool loginWasDone = g_application.GetBoxeeLoginManager().Login();
            return loginWasDone;
        }
        break;
        }
    }
    break;
    }

    return retVal;
}
示例#3
0
bool CGUIDialogMusicOSD::OnMessage(CGUIMessage &message)
{
  switch (message.GetMessage())
  {
  case GUI_MSG_CLICKED:
    {
      unsigned int iControl = message.GetSenderId();
      if (iControl == CONTROL_VIS_CHOOSER)
      {
        CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), iControl);
        OnMessage(msg);
        CStdString strLabel = msg.GetLabel();
        if (msg.GetParam1() == 0)
          g_guiSettings.SetString("mymusic.visualisation", "None");
        else
          g_guiSettings.SetString("mymusic.visualisation", strLabel + ".vis");
        // hide the control and reset focus
        SET_CONTROL_HIDDEN(CONTROL_VIS_CHOOSER);
        SET_CONTROL_FOCUS(CONTROL_VIS_BUTTON, 0);
        return true;
      }
      else if (iControl == CONTROL_VIS_BUTTON)
      {
        SET_CONTROL_VISIBLE(CONTROL_VIS_CHOOSER);
        SET_CONTROL_FOCUS(CONTROL_VIS_CHOOSER, 0);
        // fire off an event that we've pressed this button...
        CAction action;
        action.wID = ACTION_SELECT_ITEM;
        OnAction(action);
      }
      else if (iControl == CONTROL_LOCK_BUTTON)
      {
        CGUIMessage msg(GUI_MSG_VISUALISATION_ACTION, 0, 0, ACTION_VIS_PRESET_LOCK);
        g_graphicsContext.SendMessage(msg);
      }
      return true;
    }
    break;
  case GUI_MSG_WINDOW_DEINIT:
  case GUI_MSG_VISUALISATION_UNLOADING:
    {
      m_pVisualisation = NULL;
    }
    break;
  case GUI_MSG_VISUALISATION_LOADED:
    {
      if (message.GetLPVOID())
        m_pVisualisation = (CVisualisation *)message.GetLPVOID();
    }
  }
  return CGUIDialog::OnMessage(message);
}
bool CGUIDialogVisualisationSettings::OnMessage(CGUIMessage &message)
{
  switch (message.GetMessage())
  {
  case GUI_MSG_CLICKED:
    {
      unsigned int iControl = message.GetSenderId();
      if (iControl >= CONTROL_START && iControl < CONTROL_PAGE)
        OnClick(iControl);
      return true;
    }
    break;
  case GUI_MSG_WINDOW_DEINIT:
  case GUI_MSG_VISUALISATION_UNLOADING:
    {
      FreeControls();
      m_pVisualisation = NULL;
      m_pSettings = NULL;
    }
    break;
  case GUI_MSG_VISUALISATION_LOADED:
    {
      SetVisualisation((CVisualisation *)message.GetLPVOID());
      SetupPage();
      SET_CONTROL_FOCUS(CONTROL_START, 0);
    }
  }
  return CGUIDialog::OnMessage(message);
}
示例#5
0
void CGUIWindowSettings::OnInitWindow()
{
  CGUIWindow::OnInitWindow();

  if (m_iSelectedControl != 0)
    SET_CONTROL_FOCUS(m_iSelectedControl, m_iSelectedItem);
}
void CGUIWindowSettingsScreenCalibration::EnableControl(int iControl)
{
  SET_CONTROL_VISIBLE(CONTROL_TOP_LEFT);
  SET_CONTROL_VISIBLE(CONTROL_BOTTOM_RIGHT);
  SET_CONTROL_VISIBLE(CONTROL_SUBTITLES);
  SET_CONTROL_VISIBLE(CONTROL_PIXEL_RATIO);
  SET_CONTROL_FOCUS(iControl, 0);
}
示例#7
0
void CGUIDialogProgress::OnInitWindow()
{
  SET_CONTROL_HIDDEN(CONTROL_YES_BUTTON);
  SET_CONTROL_HIDDEN(CONTROL_CUSTOM_BUTTON);
  SET_CONTROL_FOCUS(CONTROL_NO_BUTTON, 0);

  CGUIDialogBoxBase::OnInitWindow();
}
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;
}
示例#9
0
void CGUIDialogYesNo::OnInitWindow()
{
  SET_CONTROL_HIDDEN(CONTROL_CUSTOM_BUTTON);
  SET_CONTROL_HIDDEN(CONTROL_PROGRESS_BAR);
  SET_CONTROL_FOCUS(CONTROL_NO_BUTTON, 0);

  CGUIDialogBoxBase::OnInitWindow();
}
void CGUIWindowFirstTimeUseCalibration::OnInitWindow()
{
    CGUIWindowSettingsScreenCalibration::OnInitWindow();

    SET_CONTROL_FOCUS(TOP_LEFT_MOVER,0);
    SetProperty("setting-state",SETTING_TOP_LEFT);

    CLog::Log(LOGDEBUG,"CGUIWindowFirstTimeUseCalibration::OnInitWindow - Exit function. [setting-state=%d=SETTING_TOP_LEFT] (ftu)",GetPropertyInt("setting-state"));
}
示例#11
0
void CGUIDialogBoxeeLiveTvCtx::OnDeinitWindow(int nextWindowID)
{
  DVBManager::GetInstance().GetEpgServerLoader().NotifyEpgVisibilityChange(false);

  m_model.SetCurrentTimeSlot(0);

  SET_CONTROL_FOCUS(CONTROL_LIST_EPG,0);

  CGUIDialog::OnDeinitWindow(nextWindowID);
}
示例#12
0
void CGUIDialogBoxeeLiveTvInfo::OnInitWindow()
{
  CFileItemList list;
  list.Add(m_item);

  CGUIMessage msgBind(GUI_MSG_LABEL_BIND, GetID(), CONTROL_FAKE_LIST, 0, 0, &list);
  OnMessage(msgBind);

  SET_CONTROL_FOCUS(CONTROL_BUTTON_LIST, 0);
}
void CGUIDialogBoxeeOTAZipcodeLocationConfiguration::OnInitWindow()
{
  CGUIDialog::OnInitWindow();

  CGUIEditControl *editControl = (CGUIEditControl *)GetControl(CONTROL_ZIP_CODE_EDIT);
  if (editControl)
    editControl->SetLabel2(CBoxeeOTAConfigurationManager::GetInstance().GetConfigurationData().GetZipCode());

  SET_CONTROL_FOCUS(CONTROL_ZIP_CODE_EDIT, 0);
}
示例#14
0
void CGUIDialogYesNo::OnInitWindow()
{
  if (!m_strChoices[2].empty())
    SET_CONTROL_VISIBLE(CONTROL_CUSTOM_BUTTON);
  else
    SET_CONTROL_HIDDEN(CONTROL_CUSTOM_BUTTON);
  SET_CONTROL_HIDDEN(CONTROL_PROGRESS_BAR);
  SET_CONTROL_FOCUS(CONTROL_NO_BUTTON, 0);

  CGUIDialogBoxBase::OnInitWindow();
}
void CGUIDialogBoxeeOTAZipcodeLocationConfiguration::HandleInvalidZipCode()
{
  CGUIDialogOK2 *dialog = (CGUIDialogOK2 *)g_windowManager.GetWindow(WINDOW_DIALOG_OK_2);
  if(dialog)
  {
    dialog->SetHeading(g_localizeStrings.Get(257));
    dialog->SetLine(0,g_localizeStrings.Get(58031));
    dialog->DoModal();
  }

  SET_CONTROL_FOCUS(CONTROL_ZIP_CODE_EDIT, 0);
}
void CGUIWindowSettingsCategory::FocusCategory(const std::string& categoryId)
{
  auto category = std::find_if(m_categories.cbegin(), m_categories.cend(),
    [&categoryId](const CSettingCategory* category) { return category->GetId() == categoryId; });
  if (category == m_categories.end())
  {
    CLog::Log(LOGERROR, "CGUIWindowSettingsCategory: asked to focus unknown category '%s'.", categoryId.c_str());
    return;
  }

  SET_CONTROL_FOCUS(CONTROL_SETTINGS_START_BUTTONS + std::distance(m_categories.cbegin(), category), 0);
}
void CGUIDialogBoxeeOTAFacebookConnect::OnInitWindow()
{
  CGUIDialogBoxeeWizardBase::OnInitWindow();

  if (g_application.GetBoxeeSocialUtilsManager().IsConnected(FACEBOOK_SERVICE_ID, true) &&
      g_application.GetBoxeeSocialUtilsManager().RequiresReconnect(FACEBOOK_SERVICE_ID))
  {
    SET_CONTROL_LABEL(LEFT_SIDE_LABEL, g_localizeStrings.Get(58058));
    SET_CONTROL_HIDDEN(FACEBOOK_BUTTON1);
    SET_CONTROL_VISIBLE(FACEBOOK_BUTTON2);
    SET_CONTROL_FOCUS(FACEBOOK_BUTTON2, 0);
  }
}
示例#18
0
bool CGUIDialogFirstTimeUseAudio::HandleClickNext()
{
  if (m_audioOutputType == CAudioOutputType::NONE)
  {
    CLog::Log(LOGERROR,"CGUIDialogFirstTimeUseAudio::HandleClickNext - [AudioOutputType=%d] wasn't set (initbox)",m_audioOutputType);

    CGUIDialogOK2::ShowAndGetInput(54647,54648);

    SET_CONTROL_FOCUS(HAS_HDMI, 0);

    return false;
  }

  if (m_hasDolbyDigitalDts == 0)
  {
    CLog::Log(LOGERROR,"CGUIDialogFirstTimeUseAudio::HandleClickNext - [HasDolbyDigitalDts=%d] wasn't set (initbox)",m_hasDolbyDigitalDts);

    CGUIDialogOK2::ShowAndGetInput(54647,54649);

    SET_CONTROL_FOCUS(HAS_DDD, 0);

    return false;
  }

  // TODO: run audio test

  if (CGUIDialogYesNo2::ShowAndGetInput(54647,54651,106,107))
  {
    CLog::Log(LOGDEBUG,"CGUIDialogFirstTimeUseAudio::HandleClickNext - Res is OK (initbox)");
    m_finishSetAudio = true;
  }
  else
  {
    CLog::Log(LOGDEBUG,"CGUIDialogFirstTimeUseAudio::HandleClickNext - Res NOT OK. Show dialog again (initbox)");
    m_finishSetAudio = false;
  }

  return m_finishSetAudio;
}
示例#19
0
void CGUIWindowJukeboxSongs::DoScan(const CStdString &strPath) {
  CGUIDialogMusicScan *musicScan = (CGUIDialogMusicScan *) g_windowManager.GetWindow(WINDOW_DIALOG_MUSIC_SCAN);
  if (musicScan && musicScan->IsScanning()) {
    musicScan->StopScanning();
    return;
  }

  // Start background loader
  int iControl = GetFocusedControlID();
  if (musicScan) musicScan->StartScanning(strPath);
  SET_CONTROL_FOCUS(iControl, 0);
  UpdateButtons();

  return;
}
void CGUIDialogSmartPlaylistEditor::OnRuleRemove(int item)
{
  if (item < 0 || item >= (int)m_playlist.m_ruleCombination.m_rules.size()) return;
  m_playlist.m_ruleCombination.m_rules.erase(m_playlist.m_ruleCombination.m_rules.begin() + item);

  UpdateButtons();
  if (item >= m_ruleLabels->Size())
    HighlightItem(m_ruleLabels->Size() - 1);
  else
    HighlightItem(item);
  if (m_ruleLabels->Size() <= 1)
  {
    SET_CONTROL_FOCUS(CONTROL_RULE_ADD, 0);
  }
}
示例#21
0
void CGUIDialogBoxeeLiveTvCtx::OnInitWindow()
{
  g_infoManager.SetShowCodec(false);
  g_infoManager.SetShowInfo(false);

  CGUIDialog::OnInitWindow();

  // initialize visibility
  DVBManager::GetInstance().GetEpgServerLoader().NotifyEpgVisibilityChange(true);

  LoadTimeSlot();

  int selectedItem = LoadEPG();
  SET_CONTROL_FOCUS(CONTROL_LIST_EPG, selectedItem);
}
bool CGUIDialogFirstTimeUseLang::UpdateLanguage()
{
    ///////////////////////////////
    // update to chosen language //
    ///////////////////////////////

    bool succeeded = true;

    if (!m_selectedItem.get())
    {
        // no language was chosen
        CGUIDialogOK2::ShowAndGetInput(54615,54616);
        SET_CONTROL_FOCUS(LIST_CTRL, 0);
        succeeded = false;
    }
    else
    {
        CStdString currentLang = g_guiSettings.GetString("locale.language");
        CStdString choosenLang = m_selectedItem->GetProperty("lang_dirName");

        if (stricmp(currentLang.c_str(),choosenLang.c_str()) != 0)
        {
            CLog::Log(LOGDEBUG,"CGUIDialogFirstTimeUseLang::UpdateLanguage - [currentLang=%s != %s=choosenLang] -> going to reload skin (initbox)",currentLang.c_str(),choosenLang.c_str());

            CGUIWindowSettingsCategory* pWindow = (CGUIWindowSettingsCategory*)g_windowManager.GetWindow(WINDOW_SETTINGS_MYPICTURES);
            if (pWindow)
            {
                pWindow->SetNewLanguage(choosenLang);
                if (!pWindow->LoadNewLanguage())
                {
                    CGUIDialogOK2::ShowAndGetInput(54615,54617);
                    succeeded = false;
                }
            }
            else
            {
                CGUIDialogOK2::ShowAndGetInput(54615,54617);
                succeeded = false;
            }
        }
        else
        {
            CLog::Log(LOGDEBUG,"CGUIDialogFirstTimeUseLang::UpdateLanguage - [choosenLang=%s] is the [currentLang=%s] -> no need to reload (initbox)",choosenLang.c_str(),currentLang.c_str());
        }
    }

    return succeeded;
}
示例#23
0
void CGUIWindowMusicSongs::DoScan(const CStdString &strPath)
{
  if (g_application.IsMusicScanning())
  {
    g_application.StopMusicScan();
    return;
  }

  // Start background loader
  int iControl=GetFocusedControlID();
  g_application.StartMusicScan(strPath);
  SET_CONTROL_FOCUS(iControl, 0);
  UpdateButtons();

  return;
}
bool CGUIDialogFirstTimeUseConfWireless::HandleClickNext()
{
    if (m_buttonSelected == 0)
    {
        CLog::Log(LOGERROR,"CGUIDialogFirstTimeUseConfWireless::HandleHitNextButton - No buton was chose (initbox)");

        CGUIDialogOK2::ShowAndGetInput(54679,54668);

        SET_CONTROL_FOCUS(AUTOMATIC_CONF, 0);

        return false;
    }

    m_password = ((CGUIEditControl*)GetControl(CONTROL_PASSWORD_EDIT))->GetLabel2();

    CLog::Log(LOGDEBUG,"CGUIDialogFirstTimeUseConfWireless::HandleHitNextButton - After set [Password=%s] (initbox)",m_password.c_str());

    return true;
}
void CGUIDialogFirstTimeUseConfNetwork::OnInitWindow()
{
  CGUIDialogFirstTimeUseBase::OnInitWindow();

  ((CGUIEditControl*)GetControl(CONTROL_IP_ADDRESS_EDIT))->SetInputType(CGUIEditControl::INPUT_TYPE_IPADDRESS,0);
  ((CGUIEditControl*)GetControl(CONTROL_IP_ADDRESS_EDIT))->SetLabel2(m_ipAddress);
  CLog::Log(LOGDEBUG,"CGUIDialogFirstTimeUseConfNetwork::OnInitWindow - After set control with [IpAddress=%s] (initbox)",m_ipAddress.c_str());

  ((CGUIEditControl*)GetControl(CONTROL_NETMASK_EDIT))->SetInputType(CGUIEditControl::INPUT_TYPE_IPADDRESS,0);
  ((CGUIEditControl*)GetControl(CONTROL_NETMASK_EDIT))->SetLabel2(m_netmask);
  CLog::Log(LOGDEBUG,"CGUIDialogFirstTimeUseConfNetwork::OnInitWindow - After set control with [Netmask=%s] (initbox)",m_netmask.c_str());

  ((CGUIEditControl*)GetControl(CONTROL_GATEWAY_EDIT))->SetInputType(CGUIEditControl::INPUT_TYPE_IPADDRESS,0);
  ((CGUIEditControl*)GetControl(CONTROL_GATEWAY_EDIT))->SetLabel2(m_gateway);
  CLog::Log(LOGDEBUG,"CGUIDialogFirstTimeUseConfNetwork::OnInitWindow - After set control with [Gateway=%s] (initbox)",m_gateway.c_str());

  ((CGUIEditControl*)GetControl(CONTROL_DNS_EDIT))->SetInputType(CGUIEditControl::INPUT_TYPE_IPADDRESS,0);
  ((CGUIEditControl*)GetControl(CONTROL_DNS_EDIT))->SetLabel2(m_dns);
  CLog::Log(LOGDEBUG,"CGUIDialogFirstTimeUseConfNetwork::OnInitWindow - After set control with [DNS=%s] (initbox)",m_dns.c_str());

  SET_CONTROL_FOCUS(CONTROL_IP_ADDRESS_EDIT, 0);
}
示例#26
0
void CGUIWindowFullScreen::ChangetheTVGroup(bool next)
{
  CGUISelectButtonControl* pButton = (CGUISelectButtonControl*)GetControl(CONTROL_GROUP_CHOOSER);
  if (!pButton)
    return;

  if (!m_bGroupSelectShow)
  {
    SET_CONTROL_VISIBLE(CONTROL_GROUP_CHOOSER);
    SET_CONTROL_FOCUS(CONTROL_GROUP_CHOOSER, 0);

    // fire off an event that we've pressed this button...
    OnAction(CAction(ACTION_SELECT_ITEM));

    m_bGroupSelectShow = true;
  }
  else
  {
    if (next)
      pButton->OnRight();
    else
      pButton->OnLeft();
  }
}
示例#27
0
bool CGUIDialogSelect::OnMessage(CGUIMessage& message)
{
    switch ( message.GetMessage() )
    {
    case GUI_MSG_WINDOW_DEINIT:
    {
        CGUIDialog::OnMessage(message);
        m_viewControl.Clear();

        m_bButtonEnabled = false;
        m_useDetails = false;
        m_multiSelection = false;

        // construct selected items list
        m_selectedItems.clear();
        m_iSelected = -1;
        for (int i = 0 ; i < m_vecList->Size() ; i++)
        {
            CFileItemPtr item = m_vecList->Get(i);
            if (item->IsSelected())
            {
                m_selectedItems.push_back(i);
                if (m_iSelected == -1)
                    m_iSelected = i;
            }
        }

        m_vecList->Clear();

        m_buttonString = -1;
        SET_CONTROL_LABEL(CONTROL_BUTTON, "");
        return true;
    }
    break;

    case GUI_MSG_WINDOW_INIT:
    {
        m_bButtonPressed = false;
        m_bConfirmed = false;
        CGUIDialog::OnMessage(message);
        return true;
    }
    break;


    case GUI_MSG_CLICKED:
    {
        int iControl = message.GetSenderId();
        if (m_viewControl.HasControl(CONTROL_LIST))
        {
            int iAction = message.GetParam1();
            if (ACTION_SELECT_ITEM == iAction || ACTION_MOUSE_LEFT_CLICK == iAction)
            {
                int iSelected = m_viewControl.GetSelectedItem();
                if(iSelected >= 0 && iSelected < (int)m_vecList->Size())
                {
                    CFileItemPtr item(m_vecList->Get(iSelected));
                    if (m_multiSelection)
                        item->Select(!item->IsSelected());
                    else
                    {
                        for (int i = 0 ; i < m_vecList->Size() ; i++)
                            m_vecList->Get(i)->Select(false);
                        item->Select(true);
                        m_bConfirmed = true;
                        Close();
                    }
                }
            }
        }
        if (CONTROL_BUTTON == iControl)
        {
            m_iSelected = -1;
            m_bButtonPressed = true;
            if (m_multiSelection)
                m_bConfirmed = true;
            Close();
        }
    }
    break;
    case GUI_MSG_SETFOCUS:
    {
        // make sure the additional button is focused in case the list is empty
        // (otherwise it is impossible to navigate to the additional button)
        if (m_vecList->IsEmpty() && m_bButtonEnabled &&
                m_viewControl.HasControl(message.GetControlId()))
        {
            SET_CONTROL_FOCUS(CONTROL_BUTTON, 0);
            return true;
        }
        if (m_viewControl.HasControl(message.GetControlId()) && m_viewControl.GetCurrentControl() != message.GetControlId())
        {
            m_viewControl.SetFocused();
            return true;
        }
    }
    break;
    }

    return CGUIDialog::OnMessage(message);
}
示例#28
0
bool CGUIDialogSelect::OnMessage(CGUIMessage& message)
{
  switch (message.GetMessage())
  {
  case GUI_MSG_WINDOW_DEINIT:
    {
      CGUIDialogBoxBase::OnMessage(message);

      m_bButtonEnabled = false;
      m_useDetails = false;
      m_multiSelection = false;

      // construct selected items list
      m_selectedItems.clear();
      m_selectedItem = nullptr;
      for (int i = 0 ; i < m_vecList->Size() ; i++)
      {
        CFileItemPtr item = m_vecList->Get(i);
        if (item->IsSelected())
        {
          m_selectedItems.push_back(i);
          if (!m_selectedItem)
            m_selectedItem = item;
        }
      }
      m_vecList->Clear();
      return true;
    }
    break;

  case GUI_MSG_WINDOW_INIT:
    {
      m_bButtonPressed = false;
      m_bConfirmed = false;
      CGUIDialogBoxBase::OnMessage(message);
      return true;
    }
    break;


  case GUI_MSG_CLICKED:
    {
      int iControl = message.GetSenderId();
      if (m_viewControl.HasControl(CONTROL_SIMPLE_LIST))
      {
        int iAction = message.GetParam1();
        if (ACTION_SELECT_ITEM == iAction || ACTION_MOUSE_LEFT_CLICK == iAction)
        {
          int iSelected = m_viewControl.GetSelectedItem();
          if (iSelected >= 0 && iSelected < m_vecList->Size())
          {
            CFileItemPtr item(m_vecList->Get(iSelected));
            if (m_multiSelection)
              item->Select(!item->IsSelected());
            else
            {
              for (int i = 0 ; i < m_vecList->Size() ; i++)
                m_vecList->Get(i)->Select(false);
              item->Select(true);
              OnSelect(iSelected);
            }
          }
        }
      }
      if (iControl == CONTROL_EXTRA_BUTTON)
      {
        m_selectedItem = nullptr;
        m_bButtonPressed = true;
        if (m_multiSelection)
          m_bConfirmed = true;
        Close();
      }
      else if (iControl == CONTROL_CANCEL_BUTTON)
      {
        m_selectedItem = nullptr;
        m_vecList->Clear();
        m_selectedItems.clear();
        m_bConfirmed = false;
        Close();
      }
    }
    break;
  case GUI_MSG_SETFOCUS:
    {
      if (m_viewControl.HasControl(message.GetControlId()))
      {
        if (m_vecList->IsEmpty())
        {
          if (m_bButtonEnabled)
            SET_CONTROL_FOCUS(CONTROL_EXTRA_BUTTON, 0);
          else
            SET_CONTROL_FOCUS(CONTROL_CANCEL_BUTTON, 0);
          return true;
        }
        if (m_viewControl.GetCurrentControl() != message.GetControlId())
        {
          m_viewControl.SetFocused();
          return true;
        }
      }
    }
    break;
  }

  return CGUIDialogBoxBase::OnMessage(message);
}
示例#29
0
bool CGUIDialogSettingsBase::OnMessage(CGUIMessage &message)
{
  switch (message.GetMessage())
  {
    case GUI_MSG_WINDOW_INIT:
    {
      m_delayedSetting.reset();
      if (message.GetParam1() != WINDOW_INVALID)
      { // coming to this window first time (ie not returning back from some other window)
        // so we reset our section and control states
        m_iCategory = 0;
        ResetControlStates();
      }

      if (AllowResettingSettings())
      {
        m_resetSetting = new CSettingAction(SETTINGS_RESET_SETTING_ID);
        m_resetSetting->SetLabel(10041);
        m_resetSetting->SetHelp(10045);
        m_resetSetting->SetControl(CreateControl("button"));
      }

      m_dummyCategory = new CSettingCategory(SETTINGS_EMPTY_CATEGORY_ID);
      m_dummyCategory->SetLabel(10046);
      m_dummyCategory->SetHelp(10047);
      break;
    }

    case GUI_MSG_WINDOW_DEINIT:
    {
      // cancel any delayed changes
      if (m_delayedSetting != NULL)
      {
        m_delayedTimer.Stop();
        CGUIMessage message(GUI_MSG_UPDATE_ITEM, GetID(), m_delayedSetting->GetID());
        OnMessage(message);
      }
      
      CGUIDialog::OnMessage(message);
      FreeControls();
      return true;
    }
    
    case GUI_MSG_FOCUSED:
    {
      CGUIDialog::OnMessage(message);
      int focusedControl = GetFocusedControlID();

      // cancel any delayed changes
      if (m_delayedSetting != NULL && m_delayedSetting->GetID() != focusedControl)
      {
        m_delayedTimer.Stop();
        CGUIMessage message(GUI_MSG_UPDATE_ITEM, GetID(), m_delayedSetting->GetID(), 1); // param1 = 1 for "reset the control if it's invalid"
        g_windowManager.SendThreadMessage(message, GetID());
      }
      // update the value of the previous setting (in case it was invalid)
      else if (m_iSetting >= CONTROL_SETTINGS_START_CONTROL && m_iSetting < (int)(CONTROL_SETTINGS_START_CONTROL + m_settingControls.size()))
      {
        BaseSettingControlPtr control = GetSettingControl(m_iSetting);
        if (control != NULL && control->GetSetting() != NULL && !control->IsValid())
        {
          CGUIMessage message(GUI_MSG_UPDATE_ITEM, GetID(), m_iSetting, 1); // param1 = 1 for "reset the control if it's invalid"
          g_windowManager.SendThreadMessage(message, GetID());
        }
      }

      CVariant description;

      // check if we have changed the category and need to create new setting controls
      if (focusedControl >= CONTROL_SETTINGS_START_BUTTONS && focusedControl < (int)(CONTROL_SETTINGS_START_BUTTONS + m_categories.size()))
      {
        int categoryIndex = focusedControl - CONTROL_SETTINGS_START_BUTTONS;
        const CSettingCategory* category = m_categories.at(categoryIndex);
        if (categoryIndex != m_iCategory)
        {
          if (!category->CanAccess())
          {
            // unable to go to this category - focus the previous one
            SET_CONTROL_FOCUS(CONTROL_SETTINGS_START_BUTTONS + m_iCategory, 0);
            return false;
          }

          m_iCategory = categoryIndex;
          CreateSettings();
        }

        description = category->GetHelp();
      }
      else if (focusedControl >= CONTROL_SETTINGS_START_CONTROL && focusedControl < (int)(CONTROL_SETTINGS_START_CONTROL + m_settingControls.size()))
      {
        m_iSetting = focusedControl;
        CSetting *setting = GetSettingControl(focusedControl)->GetSetting();
        if (setting != NULL)
          description = setting->GetHelp();
      }

      // set the description of the currently focused category/setting
      if (description.isInteger() ||
          (description.isString() && !description.empty()))
        SetDescription(description);

      return true;
    }

    case GUI_MSG_CLICKED:
    {
      int iControl = message.GetSenderId();
      if (iControl == CONTROL_SETTINGS_OKAY_BUTTON)
      {
        OnOkay();
        Close();
        return true;
      }

      if (iControl == CONTROL_SETTINGS_CANCEL_BUTTON)
      {
        OnCancel();
        Close();
        return true;
      }

      BaseSettingControlPtr control = GetSettingControl(iControl);
      if (control != NULL)
        OnClick(control);

      break;
    }
    
    case GUI_MSG_UPDATE_ITEM:
    {
      if (m_delayedSetting != NULL && m_delayedSetting->GetID() == message.GetControlId())
      {
        // first get the delayed setting and reset its member variable
        // to avoid handling the delayed setting twice in case the OnClick()
        // performed later causes the window to be deinitialized (e.g. when
        // changing the language)
        BaseSettingControlPtr delayedSetting = m_delayedSetting;
        m_delayedSetting.reset();

        // if updating the setting fails and param1 has been specifically set
        // we need to call OnSettingChanged() to restore a valid value in the
        // setting control
        if (!delayedSetting->OnClick() && message.GetParam1() != 0)
          OnSettingChanged(delayedSetting->GetSetting());
        return true;
      }

      if (message.GetControlId() >= CONTROL_SETTINGS_START_CONTROL && message.GetControlId() < (int)(CONTROL_SETTINGS_START_CONTROL + m_settingControls.size()))
      {
        BaseSettingControlPtr settingControl = GetSettingControl(message.GetControlId());
        if (settingControl.get() != NULL && settingControl->GetSetting() != NULL)
        {
          settingControl->Update();
          return true;
        }
      }
      break;
    }
    
    case GUI_MSG_UPDATE:
    {
      if (IsActive() && HasID(message.GetSenderId()))
      {
        int focusedControl = GetFocusedControlID();
        CreateSettings();
        SET_CONTROL_FOCUS(focusedControl, 0);
      }
      break;
    }

    default:
      break;
  }

  return CGUIDialog::OnMessage(message);
}