void CGUIWindowBoxeeWizardNetwork::GetUserConfiguration(CStdString& interfaceName, CStdString& essId, CStdString& key, EncMode& enc)
{
  // Get current settings from the GUI components
   CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), CONTROL_INTERFACES);
   OnMessage(msg);
   int iItem = msg.GetParam1();
   CNetworkInterface* interface = m_interfaces[iItem]; 
   interfaceName = interface->GetName();
   
   if (interface->IsWireless())
   {
      CGUIMessage msg2(GUI_MSG_ITEM_SELECTED, GetID(), CONTROL_WIRELESS);
      OnMessage(msg2);
      int iItem = msg2.GetParam1();
      essId = m_networkItems[iItem]->GetLabel();
            
      CGUIButtonControl* passwordButton = (CGUIButtonControl*) GetControl(CONTROL_PASSWORD);
      key = passwordButton->GetLabel();
       
      CGUIButtonControl* encSelectionButton = (CGUIButtonControl*) GetControl(CONTROL_ENC_SELECTION);
      CStdString encStr = encSelectionButton->GetLabel();
      for (int i = 0; i < 5; i++)
      {
         if (strcasecmp(encStr.c_str(), ENC_LABELS[i]) == 0)
         {
            enc = ENC_MODES[i];
            break;
         }
      }
   }
}
示例#2
0
  CGUIControl* ControlButton_Create(ControlButton* pControl)
  {
    CLabelInfo label;
    label.font = g_fontManager.GetFont(pControl->strFont);
    label.textColor = pControl->textColor;
    label.disabledColor = pControl->disabledColor;
    label.shadowColor = pControl->shadowColor;
    label.focusedColor = pControl->focusedColor;
    label.align = pControl->align;
    label.offsetX = (float)pControl->textOffsetX;
    label.offsetY = (float)pControl->textOffsetY;
    label.angle = (float)-pControl->iAngle;
    pControl->pGUIControl = new CGUIButtonControl(
      pControl->iParentId,
      pControl->iControlId,
      (float)pControl->dwPosX,
      (float)pControl->dwPosY,
      (float)pControl->dwWidth,
      (float)pControl->dwHeight,
      (CStdString)pControl->strTextureFocus,
      (CStdString)pControl->strTextureNoFocus,
      label);

    CGUIButtonControl* pGuiButtonControl =
      (CGUIButtonControl*)pControl->pGUIControl;

    pGuiButtonControl->SetLabel(pControl->strText);
    pGuiButtonControl->SetLabel2(pControl->strText2);

    return pControl->pGUIControl;
  }
示例#3
0
int CGUIDialogContextMenu::AddButton(const CStdString &strLabel)
{ // add a button to our control
  CGUIButtonControl *pButtonTemplate = (CGUIButtonControl *)GetFirstFocusableControl(BUTTON_TEMPLATE);
  if (!pButtonTemplate) pButtonTemplate = (CGUIButtonControl *)GetControl(BUTTON_TEMPLATE);
  if (!pButtonTemplate) return 0;
  CGUIButtonControl *pButton = new CGUIButtonControl(*pButtonTemplate);
  if (!pButton) return 0;
  // set the button's ID and position
  m_iNumButtons++;
  int id = BUTTON_TEMPLATE + m_iNumButtons;
  pButton->SetID(id);
  pButton->SetPosition(pButtonTemplate->GetXPosition(), (m_iNumButtons - 1)*(pButtonTemplate->GetHeight() + SPACE_BETWEEN_BUTTONS));
  pButton->SetVisible(true);
  pButton->SetNavigation(id - 1, id + 1, id, id);
  pButton->SetLabel(strLabel);
  AddControl(pButton);
  // and update the size of our menu
  CGUIControl *pControl = (CGUIControl *)GetControl(BACKGROUND_IMAGE);
  if (pControl)
  {
    pControl->SetHeight(m_iNumButtons*(pButtonTemplate->GetHeight() + SPACE_BETWEEN_BUTTONS));
    CGUIControl *pControl2 = (CGUIControl *)GetControl(BACKGROUND_BOTTOM);
    if (pControl2)
      pControl2->SetPosition(pControl2->GetXPosition(), pControl->GetYPosition() + pControl->GetHeight());
  }
  return m_iNumButtons;
}
示例#4
0
    CGUIControl* ControlButton::Create()
    {
      CLabelInfo label;
      label.font = g_fontManager.GetFont(strFont);
      label.textColor = textColor;
      label.disabledColor = disabledColor;
      label.shadowColor = shadowColor;
      label.focusedColor = focusedColor;
      label.align = align;
      label.offsetX = (float)textOffsetX;
      label.offsetY = (float)textOffsetY;
      label.angle = (float)-iAngle;
      pGUIControl = new CGUIButtonControl(
        iParentId,
        iControlId,
        (float)dwPosX,
        (float)dwPosY,
        (float)dwWidth,
        (float)dwHeight,
        CTextureInfo(strTextureFocus),
        CTextureInfo(strTextureNoFocus),
        label);

      CGUIButtonControl* pGuiButtonControl =
        (CGUIButtonControl*)pGUIControl;

      pGuiButtonControl->SetLabel(strText);
      pGuiButtonControl->SetLabel2(strText2);

      return pGUIControl;
    }
示例#5
0
bool CGUIDialogAudioDSPManager::OnClickListActive(CGUIMessage &message)
{
    if (!m_bMovingMode)
    {
        int iAction = message.GetParam1();
        int iItem = m_activeViewControl.GetSelectedItem();

        /* Check file item is in list range and get his pointer */
        if (iItem < 0 || iItem >= (int)m_activeItems[m_iCurrentType]->Size()) return true;

        /* Process actions */
        if (iAction == ACTION_SELECT_ITEM || iAction == ACTION_CONTEXT_MENU || iAction == ACTION_MOUSE_LEFT_CLICK || iAction == ACTION_MOUSE_RIGHT_CLICK)
        {
            /* Show Contextmenu */
            OnPopupMenu(iItem, LIST_ACTIVE);

            return true;
        }
    }
    else
    {
        CFileItemPtr pItem = m_activeItems[m_iCurrentType]->Get(m_iSelected[LIST_ACTIVE]);
        if (pItem)
        {
            pItem->Select(false);
            pItem->SetProperty("Changed", true);
            m_bMovingMode = false;
            m_bContainsChanges = true;

            if (m_bContinousSaving)
            {
                SaveList();
            }

            CGUIListContainer *modeList = dynamic_cast<CGUIListContainer*>(GetControl(CONTROL_LIST_MODE_SELECTION));
            CGUIButtonControl *applyButton = dynamic_cast<CGUIButtonControl*>(GetControl(CONTROL_BUTTON_APPLY_CHANGES));
            CGUIButtonControl *clearActiveModesButton = dynamic_cast<CGUIButtonControl*>(GetControl(CONTROL_BUTTON_CLEAR_ACTIVE_MODES));
            if (!modeList || !applyButton || !clearActiveModesButton)
            {
                helper_LogError(__FUNCTION__);
                return false;
            }

            // reenable all buttons and mode selection list
            modeList->SetEnabled(true);
            clearActiveModesButton->SetEnabled(true);
            if (!m_bContinousSaving)
            {
                applyButton->SetEnabled(true);
            }

            return true;
        }
    }

    return false;
}
示例#6
0
void CGUIDialogButtonMenu::FrameMove()
{
  // get the label control
  CGUILabelControl *pLabel = (CGUILabelControl *)GetControl(CONTROL_BUTTON_LABEL);
  if (pLabel)
  {
    // get the active window, and put it's label into the label control
    const CGUIControl *pControl = GetFocusedControl();
    if (pControl && (pControl->GetControlType() == CGUIControl::GUICONTROL_BUTTON || pControl->GetControlType() == CGUIControl::GUICONTROL_TOGGLEBUTTON))
    {
      CGUIButtonControl *pButton = (CGUIButtonControl *)pControl;
      pLabel->SetLabel(pButton->GetLabel());
    }
  }
  CGUIDialog::FrameMove();
}
示例#7
0
void Interface_GUIControlButton::GetLabel(void* kodiBase, void* handle, char &label, unsigned int &iMaxStringSize)
{
  CAddonDll* addon = static_cast<CAddonDll*>(kodiBase);
  if (!addon)
  {
    CLog::Log(LOGERROR, "ADDON::Interface_GUIControlButton::%s - invalid data", __FUNCTION__);
    return;
  }

  if (!handle)
  {
    CLog::Log(LOGERROR, "ADDON::Interface_GUIControlButton::%s - invalid handler data on addon '%s'", __FUNCTION__, addon->ID().c_str());
    return;
  }

  CGUIButtonControl* pButton = static_cast<CGUIButtonControl *>(handle);
  std::string text = pButton->GetLabel();
  strncpy(&label, text.c_str(), iMaxStringSize);
  iMaxStringSize = text.length();
}
示例#8
0
void CGUIDialogAddonSettings::CreateSections()
{
  CGUIControlGroupList *group = dynamic_cast<CGUIControlGroupList *>(GetControl(CONTROL_SECTION_AREA));
  CGUIButtonControl *originalButton = dynamic_cast<CGUIButtonControl *>(GetControl(CONTROL_DEFAULT_SECTION_BUTTON));
  if (!m_addon)
    return;

  if (originalButton)
    originalButton->SetVisible(false);

  // clear the category group
  FreeSections();

  // grab our categories
  const TiXmlElement *category = m_addon->GetSettingsXML()->FirstChildElement("category");
  if (!category) // add a default one...
    category = m_addon->GetSettingsXML();
 
  int buttonID = CONTROL_START_SECTION;
  while (category)
  { // add a category
    CGUIButtonControl *button = originalButton ? originalButton->Clone() : NULL;

    std::string label = GetString(category->Attribute("label"));
    if (label.empty())
      label = g_localizeStrings.Get(128);

    if (buttonID >= CONTROL_START_SETTING)
    {
      CLog::Log(LOGERROR, "%s - cannot have more than %d categories - simplify your addon!", __FUNCTION__, CONTROL_START_SETTING - CONTROL_START_SECTION);
      break;
    }

    // add the category button
    if (button && group)
    {
      button->SetID(buttonID++);
      button->SetLabel(label);
      button->SetVisible(true);
      group->AddControl(button);
    }

    // grab a local copy of all the settings in this category
    const TiXmlElement *setting = category->FirstChildElement("setting");
    while (setting)
    {
      const std::string id = XMLUtils::GetAttribute(setting, "id");
      if (!id.empty())
        m_settings[id] = m_addon->GetSetting(id);
      setting = setting->NextSiblingElement("setting");
    }
    category = category->NextSiblingElement("category");
  }
  m_totalSections = buttonID - CONTROL_START_SECTION;
}
示例#9
0
void CGUIDialogAudioDSPManager::OnInitWindow()
{
    CGUIDialog::OnInitWindow();

    m_iSelected[LIST_AVAILABLE] = 0;
    m_iSelected[LIST_ACTIVE]    = 0;
    m_bMovingMode               = false;
    m_bContainsChanges          = false;

    CGUIRadioButtonControl *radioButton = dynamic_cast<CGUIRadioButtonControl*>(GetControl(CONTROL_RADIO_BUTTON_CONTINUOUS_SAVING));
    CGUIButtonControl *applyButton = dynamic_cast<CGUIButtonControl*>(GetControl(CONTROL_BUTTON_APPLY_CHANGES));
    if (!radioButton || !applyButton)
    {
        helper_LogError(__FUNCTION__);
        return;
    }

    SET_CONTROL_SELECTED(GetID(), CONTROL_RADIO_BUTTON_CONTINUOUS_SAVING, m_bContinousSaving);
    applyButton->SetEnabled(!m_bContinousSaving);

    Update();
    SetSelectedModeType();
}
示例#10
0
bool CGUIDialogAudioDSPManager::OnClickRadioContinousSaving(CGUIMessage &message)
{
    CGUIRadioButtonControl *radioButton = dynamic_cast<CGUIRadioButtonControl*>(GetControl(CONTROL_RADIO_BUTTON_CONTINUOUS_SAVING));
    CGUIButtonControl *applyChangesButton = dynamic_cast<CGUIButtonControl*>(GetControl(CONTROL_BUTTON_APPLY_CHANGES));

    if (!radioButton || !applyChangesButton)
    {
        helper_LogError(__FUNCTION__);
        return false;
    }

    if (!radioButton->IsSelected())
    {
        applyChangesButton->SetEnabled(true);
        m_bContinousSaving = false;
    }
    else
    {
        m_bContinousSaving = true;
        applyChangesButton->SetEnabled(false);
    }

    return true;
}
示例#11
0
void CGUIWindowSettingsCategory::SetupControls(bool createSettings /* = true */)
{
  // cleanup first, if necessary
  FreeControls();

  m_pOriginalSpin = (CGUISpinControlEx*)GetControl(CONTROL_DEFAULT_SPIN);
  m_pOriginalRadioButton = (CGUIRadioButtonControl *)GetControl(CONTROL_DEFAULT_RADIOBUTTON);
  m_pOriginalCategoryButton = (CGUIButtonControl *)GetControl(CONTROL_DEFAULT_CATEGORY_BUTTON);
  m_pOriginalButton = (CGUIButtonControl *)GetControl(CONTROL_DEFAULT_BUTTON);
  m_pOriginalImage = (CGUIImage *)GetControl(CONTROL_DEFAULT_SEPARATOR);
  if (!m_pOriginalCategoryButton || !m_pOriginalSpin || !m_pOriginalRadioButton || !m_pOriginalButton)
    return ;
  m_pOriginalEdit = (CGUIEditControl *)GetControl(CONTROL_DEFAULT_EDIT);
  if (!m_pOriginalEdit || m_pOriginalEdit->GetControlType() != CGUIControl::GUICONTROL_EDIT)
  {
    delete m_pOriginalEdit;
    m_pOriginalEdit = new CGUIEditControl(*m_pOriginalButton);
    newOriginalEdit = true;
  }

  m_pOriginalSpin->SetVisible(false);
  m_pOriginalRadioButton->SetVisible(false);
  m_pOriginalButton->SetVisible(false);
  m_pOriginalCategoryButton->SetVisible(false);
  m_pOriginalEdit->SetVisible(false);
  if (m_pOriginalImage) m_pOriginalImage->SetVisible(false);

  // setup our control groups...
  CGUIControlGroupList *group = (CGUIControlGroupList *)GetControl(CATEGORY_GROUP_ID);
  if (!group)
    return;

  CSettingSection *section = GetSection(m_iSection);
  if (section == NULL)
    return;
  
  // update the screen string
  SET_CONTROL_LABEL(CONTROL_SETTINGS_LABEL, section->GetLabel());
  
  SET_CONTROL_LABEL(CONTRL_BTN_LEVELS, 10036 + (int)CViewStateSettings::Get().GetSettingLevel());

  // get the categories we need
  m_categories = section->GetCategories(CViewStateSettings::Get().GetSettingLevel());
  if (m_categories.empty())
    m_categories.push_back(m_dummyCategory);

  // go through the categories and create the necessary buttons
  int buttonIdOffset = 0;
  for (SettingCategoryList::const_iterator category = m_categories.begin(); category != m_categories.end(); ++category)
  {
    CGUIButtonControl *pButton = NULL;
    if (m_pOriginalCategoryButton->GetControlType() == CGUIControl::GUICONTROL_TOGGLEBUTTON)
      pButton = new CGUIToggleButtonControl(*(CGUIToggleButtonControl *)m_pOriginalCategoryButton);
    else
      pButton = new CGUIButtonControl(*m_pOriginalCategoryButton);
    pButton->SetLabel(g_localizeStrings.Get((*category)->GetLabel()));
    pButton->SetID(CONTROL_START_BUTTONS + buttonIdOffset);
    pButton->SetVisible(true);
    pButton->AllocResources();

    group->AddControl(pButton);
    buttonIdOffset++;
  }

  if (createSettings)
    CreateSettings();

  // set focus correctly
  m_defaultControl = CONTROL_START_BUTTONS;
}
示例#12
0
void CGUIDialogContextMenu::SetupButtons()
{
  if (!m_buttons.size())
    return;

  // disable the template button control
  CGUIButtonControl *pButtonTemplate = dynamic_cast<CGUIButtonControl *>(GetFirstFocusableControl(BUTTON_TEMPLATE));
  if (!pButtonTemplate)
    pButtonTemplate = dynamic_cast<CGUIButtonControl *>(GetControl(BUTTON_TEMPLATE));
  if (!pButtonTemplate)
    return;
  pButtonTemplate->SetVisible(false);

  CGUIControlGroupList* pGroupList = dynamic_cast<CGUIControlGroupList *>(GetControl(GROUP_LIST));

  // add our buttons
  for (unsigned int i = 0; i < m_buttons.size(); i++)
  {
    CGUIButtonControl *pButton = new CGUIButtonControl(*pButtonTemplate);
    if (pButton)
    { // set the button's ID and position
      int id = BUTTON_START + i;
      pButton->SetID(id);
      pButton->SetVisible(true);
      pButton->SetLabel(m_buttons[i].second);
      if (pGroupList)
      {
        pButton->SetPosition(pButtonTemplate->GetXPosition(), pButtonTemplate->GetYPosition());
        // try inserting context buttons at position specified by template
        // button, if template button is not in grouplist fallback to adding
        // new buttons at the end of grouplist
        if (!pGroupList->InsertControl(pButton, pButtonTemplate))
          pGroupList->AddControl(pButton);
      }
    }
  }

  // fix up background images placement and size
  CGUIControl *pControl = (CGUIControl *)GetControl(BACKGROUND_IMAGE);
  if (pControl)
  {
    // first set size of background image
    if (pGroupList)
    {
      if (pGroupList->GetOrientation() == VERTICAL)
      {
        // keep gap between bottom edges of grouplist and background image
        pControl->SetHeight(m_backgroundImageSize - pGroupList->Size() + pGroupList->GetHeight());
      }
      else
      {
        // keep gap between right edges of grouplist and background image
        pControl->SetWidth(m_backgroundImageSize - pGroupList->Size() + pGroupList->GetWidth());
      }
    }
  }

  // update our default control
  if (pGroupList)
    m_defaultControl = pGroupList->GetID();
}
示例#13
0
void CGUIDialogPluginSettings::CreateControls()
{
  CGUISpinControlEx *pOriginalSpin = (CGUISpinControlEx*)GetControl(CONTROL_DEFAULT_SPIN);
  CGUIRadioButtonControl *pOriginalRadioButton = (CGUIRadioButtonControl *)GetControl(CONTROL_DEFAULT_RADIOBUTTON);
  CGUIButtonControl *pOriginalButton = (CGUIButtonControl *)GetControl(CONTROL_DEFAULT_BUTTON);
  CGUIImage *pOriginalImage = (CGUIImage *)GetControl(CONTROL_DEFAULT_SEPARATOR);
  CGUILabelControl *pOriginalLabel = (CGUILabelControl *)GetControl(CONTROL_DEFAULT_LABEL_SEPARATOR);

  if (!pOriginalSpin || !pOriginalRadioButton || !pOriginalButton || !pOriginalImage)
    return;

  pOriginalSpin->SetVisible(false);
  pOriginalRadioButton->SetVisible(false);
  pOriginalButton->SetVisible(false);
  pOriginalImage->SetVisible(false);
  if (pOriginalLabel)
    pOriginalLabel->SetVisible(false);

  // clear the category group
  CGUIControlGroupList *group = (CGUIControlGroupList *)GetControl(CONTROL_AREA);
  if (!group)
    return;

  // set our dialog heading
  SET_CONTROL_LABEL(CONTROL_HEADING_LABEL, m_strHeading);

  // Create our base path, used for type "fileenum" settings
  CStdString basepath = "Q:\\plugins\\";
  CUtil::AddFileToFolder(basepath, m_url.GetHostName(), basepath);
  CUtil::AddFileToFolder(basepath, m_url.GetFileName(), basepath);

  CGUIControl* pControl = NULL;
  int controlId = CONTROL_START_CONTROL;
  TiXmlElement *setting = m_settings.GetPluginRoot()->FirstChildElement("setting");
  while (setting)
  {
    const char *type = setting->Attribute("type");
    const char *option = setting->Attribute("option");
    const char *id = setting->Attribute("id");
    CStdString values;
    if (setting->Attribute("values"))
      values = setting->Attribute("values");
    CStdString lvalues;
    if (setting->Attribute("lvalues"))
      lvalues = setting->Attribute("lvalues");
    CStdString entries;
    if (setting->Attribute("entries"))
      entries = setting->Attribute("entries");
    CStdString label;
    if (setting->Attribute("label") && atoi(setting->Attribute("label")) > 0)
      label.Format("$LOCALIZE[%s]", setting->Attribute("label"));
    else
      label = setting->Attribute("label");

    if (type)
    {
      if (strcmpi(type, "text") == 0 || strcmpi(type, "ipaddress") == 0 ||
        strcmpi(type, "integer") == 0 || strcmpi(type, "video") == 0 ||
        strcmpi(type, "music") == 0 || strcmpi(type, "pictures") == 0 ||
        strcmpi(type, "folder") == 0 || strcmpi(type, "programs") == 0 ||
        strcmpi(type, "files") == 0 || strcmpi(type, "action") == 0)
      {
        pControl = new CGUIButtonControl(*pOriginalButton);
        if (!pControl) return;
        ((CGUIButtonControl *)pControl)->SettingsCategorySetTextAlign(XBFONT_CENTER_Y);
        ((CGUIButtonControl *)pControl)->SetLabel(label);
        if (id)
          ((CGUIButtonControl *)pControl)->SetLabel2(m_settings.Get(id));
        
        if (option && strcmpi(option, "hidden") == 0)
          ((CGUIButtonControl *)pControl)->SetHidden(true);
      }
      else if (strcmpi(type, "bool") == 0)
      {
        pControl = new CGUIRadioButtonControl(*pOriginalRadioButton);
        if (!pControl) return;
        ((CGUIRadioButtonControl *)pControl)->SetLabel(label);
        ((CGUIRadioButtonControl *)pControl)->SetSelected(m_settings.Get(id) == "true");
      }
      else if (strcmpi(type, "enum") == 0 || strcmpi(type, "labelenum") == 0)
      {
        vector<CStdString> valuesVec;
        vector<CStdString> entryVec;

        pControl = new CGUISpinControlEx(*pOriginalSpin);
        if (!pControl) return;
        ((CGUISpinControlEx *)pControl)->SetText(label);

        if (!lvalues.IsEmpty())
          CUtil::Tokenize(lvalues, valuesVec, "|");
        else
          CUtil::Tokenize(values, valuesVec, "|");
        if (!entries.IsEmpty())
          CUtil::Tokenize(entries, entryVec, "|");
        for (unsigned int i = 0; i < valuesVec.size(); i++)
        {
          int iAdd = i;
          if (entryVec.size() > i)
            iAdd = atoi(entryVec[i]);
          if (!lvalues.IsEmpty())
          {
            CStdString replace = g_localizeStringsTemp.Get(atoi(valuesVec[i]));
            if (replace.IsEmpty())
              replace = g_localizeStrings.Get(atoi(valuesVec[i]));
            ((CGUISpinControlEx *)pControl)->AddLabel(replace, iAdd);
          }
          else
            ((CGUISpinControlEx *)pControl)->AddLabel(valuesVec[i], iAdd);
        }
        if (strcmpi(type, "labelenum") == 0)
        { // need to run through all our settings and find the one that matches
          ((CGUISpinControlEx*) pControl)->SetValueFromLabel(m_settings.Get(id));
        }
        else
          ((CGUISpinControlEx*) pControl)->SetValue(atoi(m_settings.Get(id)));

      }
      else if (strcmpi(type, "fileenum") == 0)
      {
        pControl = new CGUISpinControlEx(*pOriginalSpin);
        if (!pControl) return;
        ((CGUISpinControlEx *)pControl)->SetText(label);

        //find Folders...
        CFileItemList items;
        CStdString enumpath;
        CUtil::AddFileToFolder(basepath, values, enumpath);
        CStdString mask;
        if (setting->Attribute("mask"))
          mask = setting->Attribute("mask");
        if (!mask.IsEmpty())
          CDirectory::GetDirectory(enumpath, items, mask);
        else
          CDirectory::GetDirectory(enumpath, items);

        int iItem = 0;
        for (int i = 0; i < items.Size(); ++i)
        {
          CFileItemPtr pItem = items[i];
          if ((mask.Equals("/") && pItem->m_bIsFolder) || !pItem->m_bIsFolder)
          {
            ((CGUISpinControlEx *)pControl)->AddLabel(pItem->GetLabel(), iItem);
            if (pItem->GetLabel().Equals(m_settings.Get(id)))
              ((CGUISpinControlEx *)pControl)->SetValue(iItem);
            iItem++;
          }
        }
      }
      else if (strcmpi(type, "lsep") == 0 && pOriginalLabel)
      {
        pControl = new CGUILabelControl(*pOriginalLabel);
        if (pControl)
          ((CGUILabelControl *)pControl)->SetLabel(label);
      }
      else if ((strcmpi(type, "sep") == 0 || strcmpi(type, "lsep") == 0) && pOriginalImage)
        pControl = new CGUIImage(*pOriginalImage);
    }

    if (pControl)
    {
      pControl->SetWidth(group->GetWidth());
      pControl->SetVisible(true);
      pControl->SetID(controlId);
      pControl->AllocResources();
      group->AddControl(pControl);
      pControl = NULL;
    }

    setting = setting->NextSiblingElement("setting");
    controlId++;
  }
  EnableControls();
}
示例#14
0
void CGUIDialogSettings::OnClick(int iID)
{
  if (iID == CONTROL_OKAY_BUTTON)
  {
    OnOkay();
    Close();
    return;
  }
  if (iID == CONTROL_CANCEL_BUTTON)
  {
    OnCancel();
    Close();
    return;
  }
  unsigned int settingNum = iID - CONTROL_START;
  if (settingNum >= m_settings.size()) return;
  SettingInfo &setting = m_settings.at(settingNum);
  if (setting.type == SettingInfo::SPIN)
  {
    CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(iID);
    if (setting.data) *(int *)setting.data = pControl->GetValue();
  }
  else if (setting.type == SettingInfo::BUTTON_DIALOG)
  {
    CGUIButtonControl *pControl = (CGUIButtonControl *)GetControl(iID);
    if (setting.data) *(CStdString *)setting.data = pControl->GetLabel2();
  }
  else if (setting.type == SettingInfo::EDIT)
  {
    CGUIEditControl *pControl = (CGUIEditControl *)GetControl(iID);
    if (setting.data) *(CStdString *)setting.data = pControl->GetLabel2();
  }
  else if (setting.type == SettingInfo::EDIT_NUM)
  {
    CGUIEditControl *pControl = (CGUIEditControl *)GetControl(iID);
    if (setting.data) {
        CStdString strIndex = pControl->GetLabel2();
        *(int *)setting.data = atol(strIndex.c_str());
    }
  }
  else if (setting.type == SettingInfo::CHECK)
  {
    CGUIRadioButtonControl *pControl = (CGUIRadioButtonControl *)GetControl(iID);
    if (setting.data) *(bool *)setting.data = pControl->IsSelected();
  }
  else if (setting.type == SettingInfo::CHECK_UCHAR)
  {
    CGUIRadioButtonControl *pControl = (CGUIRadioButtonControl *)GetControl(iID);
    if (setting.data) *(unsigned char*)setting.data = pControl->IsSelected() ? 1 : 0;
  }
  else if (setting.type == SettingInfo::SLIDER)
  {
    CGUISettingsSliderControl *pControl = (CGUISettingsSliderControl *)GetControl(iID);
    if (setting.data) *(float *)setting.data = pControl->GetFloatValue();
    if (setting.formatFunction) pControl->SetTextValue(setting.formatFunction(pControl->GetFloatValue(), setting.interval));
  }
  else if (setting.type == SettingInfo::BUTTON && m_usePopupSliders && setting.data)
  { // we're using popup sliders
    CGUIDialogSlider::ShowAndGetInput(setting.name, *(float *)setting.data, setting.min, setting.interval, setting.max, this, &setting);
    if (setting.formatFunction)
      SET_CONTROL_LABEL2(iID, setting.formatFunction(*(float *)setting.data, setting.interval));
  }
  OnSettingChanged(setting);
}
示例#15
0
void CGUIDialogSettings::UpdateSetting(unsigned int id)
{
  unsigned int settingNum = (unsigned int)-1;
  for (unsigned int i = 0; i < m_settings.size(); i++)
  {
    if (m_settings[i].id == id)
    {
      settingNum = i;
      break;
    }
  }
  if(settingNum == (unsigned int)-1)
    return;

  SettingInfo &setting = m_settings.at(settingNum);
  unsigned int controlID = settingNum + CONTROL_START;
  if (setting.type == SettingInfo::SPIN)
  {
    CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(controlID);
    if (pControl && setting.data) pControl->SetValue(*(int *)setting.data);
  }
  else if (setting.type == SettingInfo::CHECK)
  {
    CGUIRadioButtonControl *pControl = (CGUIRadioButtonControl *)GetControl(controlID);
    if (pControl && setting.data) pControl->SetSelected(*(bool *)setting.data);
  }
  else if (setting.type == SettingInfo::CHECK_UCHAR)
  {
    CGUIRadioButtonControl *pControl = (CGUIRadioButtonControl *)GetControl(controlID);
    if (pControl && setting.data) pControl->SetSelected(*(unsigned char*)setting.data ? true : false);
  }
  else if (setting.type == SettingInfo::SLIDER)
  {
    CGUISettingsSliderControl *pControl = (CGUISettingsSliderControl *)GetControl(controlID);
    float value = *(float *)setting.data;
    if (pControl && setting.data)
    {
      pControl->SetFloatValue(value);
      if (setting.formatFunction) pControl->SetTextValue(setting.formatFunction(value, setting.interval));
    }
  }
  else if (setting.type == SettingInfo::BUTTON_DIALOG)
  {
    SET_CONTROL_LABEL(controlID,setting.name);
    CGUIButtonControl *pControl = (CGUIButtonControl *)GetControl(controlID);
    if (pControl && setting.data) pControl->SetLabel2(*(CStdString *)setting.data);
  }
  else if (setting.type == SettingInfo::EDIT)
  {
    CGUIEditControl *pControl = (CGUIEditControl *)GetControl(controlID);
    if (pControl && setting.data) pControl->SetLabel2(*(CStdString *)setting.data);
  }
  else if (setting.type == SettingInfo::EDIT_NUM)
  {
    CGUIEditControl *pControl = (CGUIEditControl *)GetControl(controlID);
    if (pControl && setting.data) {
      CStdString strIndex;
      strIndex.Format("%i", *(int *)setting.data);
      pControl->SetLabel2(strIndex);
    }
  }

  if (setting.enabled)
  {
    CONTROL_ENABLE(controlID);
  }
  else
  {
    CONTROL_DISABLE(controlID);
  }
}
示例#16
0
bool CGUIDialogAudioDSPManager::OnContextButton(int itemNumber, CONTEXT_BUTTON button, int listType)
{
    CFileItemPtr pItem;
    int listSize = 0;
    if (listType == LIST_ACTIVE)
    {
        pItem = m_activeItems[m_iCurrentType]->Get(itemNumber);
        listSize = m_activeItems[m_iCurrentType]->Size();
    }
    else if (listType == LIST_AVAILABLE)
    {
        pItem = m_availableItems[m_iCurrentType]->Get(itemNumber);
        listSize = m_availableItems[m_iCurrentType]->Size();
    }

    /* Check file item is in list range and get his pointer */
    if (!pItem || itemNumber < 0 || itemNumber >= listSize)
    {
        return false;
    }

    if (button == CONTEXT_BUTTON_HELP)
    {
        /*!
        * Open audio dsp addon mode help text dialog
        */
        AE_DSP_ADDON addon;
        if (CServiceBroker::GetADSP().GetAudioDSPAddon((int)pItem->GetProperty("AddonId").asInteger(), addon))
        {
            CGUIDialogTextViewer* pDlgInfo = (CGUIDialogTextViewer*)g_windowManager.GetWindow(WINDOW_DIALOG_TEXT_VIEWER);
            pDlgInfo->SetHeading(g_localizeStrings.Get(15062) + " - " + pItem->GetProperty("Name").asString());
            pDlgInfo->SetText(g_localizeStrings.GetAddonString(addon->ID(), (uint32_t)pItem->GetProperty("Help").asInteger()));
            pDlgInfo->Open();
        }
    }
    else if (button == CONTEXT_BUTTON_ACTIVATE)
    {
        /*!
        * Deactivate selected processing mode
        */
        if (pItem->GetProperty("ActiveMode").asBoolean())
        {
            // remove mode from active mode list and add it to available mode list
            CFileItemPtr newItem(dynamic_cast<CFileItem*>(pItem->Clone()));
            newItem->SetProperty("ActiveMode", false);
            newItem->SetProperty("Changed", true);
            m_activeItems[m_iCurrentType]->Remove(itemNumber);
            m_availableItems[m_iCurrentType]->Add(newItem);
        }
        else
        {
            /*!
            * Activate selected processing mode
            */
            if ((m_iCurrentType == AE_DSP_MODE_TYPE_INPUT_RESAMPLE || m_iCurrentType == AE_DSP_MODE_TYPE_OUTPUT_RESAMPLE) && m_activeItems[m_iCurrentType]->Size() > 0)
            {   // if there is already an active resampler, now we remove it
                CFileItemPtr activeResampler = m_activeItems[m_iCurrentType]->Get(0);
                if (activeResampler)
                {
                    CFileItemPtr newItem(dynamic_cast<CFileItem*>(activeResampler->Clone()));
                    newItem->SetProperty("ActiveMode", false);
                    newItem->SetProperty("Changed", true);

                    m_availableItems[m_iCurrentType]->Add(newItem);
                    // clear active list, because only one active resampling mode is supported by ActiveAEDSP
                    m_activeItems[m_iCurrentType]->Clear();
                }
            }

            // remove mode from available mode list and add it to active mode list
            CFileItemPtr newItem(dynamic_cast<CFileItem*>(pItem->Clone()));

            newItem->SetProperty("Number", (int)m_activeItems[m_iCurrentType]->Size() +1);
            newItem->SetProperty("Changed", true);
            newItem->SetProperty("ActiveMode", true);

            m_availableItems[m_iCurrentType]->Remove(itemNumber);
            m_activeItems[m_iCurrentType]->Add(newItem);
        }

        m_bContainsChanges = true;
        if (m_bContinousSaving)
        {
            SaveList();
        }

        // reorder available mode list, so that the mode order is always consistent
        m_availableItems[m_iCurrentType]->ClearSortState();
        m_availableItems[m_iCurrentType]->Sort(SortByLabel, SortOrderAscending);

        // update active and available mode list
        Renumber();
        m_availableViewControl.SetItems(*m_availableItems[m_iCurrentType]);
        m_activeViewControl.SetItems(*m_activeItems[m_iCurrentType]);
    }
    else if (button == CONTEXT_BUTTON_MOVE)
    {
        m_bMovingMode = true;
        pItem->Select(true);

        CGUIListContainer *modeList = dynamic_cast<CGUIListContainer*>(GetControl(CONTROL_LIST_MODE_SELECTION));
        CGUIButtonControl *applyButton = dynamic_cast<CGUIButtonControl*>(GetControl(CONTROL_BUTTON_APPLY_CHANGES));
        CGUIButtonControl *clearActiveModesButton = dynamic_cast<CGUIButtonControl*>(GetControl(CONTROL_BUTTON_CLEAR_ACTIVE_MODES));
        if (!modeList || !applyButton || !clearActiveModesButton)
        {
            helper_LogError(__FUNCTION__);
            return false;
        }

        // if we are in MovingMode all buttons and mode selection list will be disabled!
        modeList->SetEnabled(false);
        clearActiveModesButton->SetEnabled(false);
        if (!m_bContinousSaving)
        {
            applyButton->SetEnabled(false);
        }
    }
    else if (button == CONTEXT_BUTTON_SETTINGS)
    {
        int hookId = (int)pItem->GetProperty("SettingsDialog").asInteger();
        if (hookId > 0)
        {
            AE_DSP_ADDON addon;
            if (CServiceBroker::GetADSP().GetAudioDSPAddon((int)pItem->GetProperty("AddonId").asInteger(), addon))
            {
                AE_DSP_MENUHOOK       hook;
                AE_DSP_MENUHOOK_DATA  hookData;

                hook.category           = AE_DSP_MENUHOOK_ALL;
                hook.iHookId            = hookId;
                hook.iRelevantModeId    = (unsigned int)pItem->GetProperty("AddonModeNumber").asInteger();
                hookData.category       = AE_DSP_MENUHOOK_ALL;
                hookData.data.iStreamId = -1;

                /*!
                 * @note the addon dialog becomes always opened on the back of Kodi ones for this reason a
                 * "<animation effect="fade" start="100" end="0" time="400" condition="Window.IsVisible(Addon)">Conditional</animation>"
                 * on skin is needed to hide dialog.
                 */
                addon->CallMenuHook(hook, hookData);
            }
        }
        else
        {
            CGUIDialogOK::ShowAndGetInput(19033, 0, 15040, 0);
        }
    }

    return true;
}
void CGUIDialogContextMenu::SetupButtons()
{
  if (!m_buttons.size())
    return;

  // disable the template button control
  CGUIButtonControl *pButtonTemplate = (CGUIButtonControl *)GetFirstFocusableControl(BUTTON_TEMPLATE);
  if (!pButtonTemplate) pButtonTemplate = (CGUIButtonControl *)GetControl(BUTTON_TEMPLATE);
  if (!pButtonTemplate)
    return;
  pButtonTemplate->SetVisible(false);

  CGUIControlGroupList* pGroupList = NULL;
  {
    const CGUIControl* pControl = GetControl(GROUP_LIST);
    if (pControl && pControl->GetControlType() == GUICONTROL_GROUPLIST)
      pGroupList = (CGUIControlGroupList*)pControl;
  }

  // add our buttons
  for (unsigned int i = 0; i < m_buttons.size(); i++)
  {
    CGUIButtonControl *pButton = new CGUIButtonControl(*pButtonTemplate);
    if (pButton)
    { // set the button's ID and position
      int id = BUTTON_START + i;
      pButton->SetID(id);
      pButton->SetVisible(true);
      pButton->SetLabel(m_buttons[i].second);
      if (pGroupList)
      {
        pButton->SetPosition(pButtonTemplate->GetXPosition(), pButtonTemplate->GetYPosition());
        pGroupList->AddControl(pButton);
      }
#if PRE_SKIN_VERSION_11_COMPATIBILITY
      else
      {
        pButton->SetPosition(pButtonTemplate->GetXPosition(), i*(pButtonTemplate->GetHeight() + SPACE_BETWEEN_BUTTONS));
        pButton->SetNavigation(id - 1, id + 1, id, id);
        AddControl(pButton);
      }
#endif
    }
  }

  CGUIControl *pControl = NULL;
#if PRE_SKIN_VERSION_11_COMPATIBILITY
  if (!pGroupList)
  {
    // if we don't have grouplist update the navigation of the first and last buttons
    pControl = (CGUIControl *)GetControl(BUTTON_START);
    if (pControl)
      pControl->SetNavigation(BUTTON_END, pControl->GetControlIdDown(), pControl->GetControlIdLeft(), pControl->GetControlIdRight());
    pControl = (CGUIControl *)GetControl(BUTTON_END);
    if (pControl)
      pControl->SetNavigation(pControl->GetControlIdUp(), BUTTON_START, pControl->GetControlIdLeft(), pControl->GetControlIdRight());
  }
#endif

  // fix up background images placement and size
  pControl = (CGUIControl *)GetControl(BACKGROUND_IMAGE);
  if (pControl)
  {
    // first set size of background image
    if (pGroupList)
    {
      if (pGroupList->GetOrientation() == VERTICAL)
      {
        // keep gap between bottom edges of grouplist and background image
        pControl->SetHeight(pControl->GetHeight() - pGroupList->Size() + pGroupList->GetHeight());
      }
      else
      {
        // keep gap between right edges of grouplist and background image
        pControl->SetWidth(pControl->GetWidth() - pGroupList->Size() + pGroupList->GetWidth());
      }
    }
#if PRE_SKIN_VERSION_11_COMPATIBILITY
    else
      pControl->SetHeight(m_buttons.size() * (pButtonTemplate->GetHeight() + SPACE_BETWEEN_BUTTONS));

    if (pGroupList && pGroupList->GetOrientation() == HORIZONTAL)
    {
      // if there is grouplist control with horizontal orientation - adjust width of top and bottom background
      CGUIControl* pControl2 = (CGUIControl *)GetControl(BACKGROUND_TOP);
      if (pControl2)
        pControl2->SetWidth(pControl->GetWidth());

      pControl2 = (CGUIControl *)GetControl(BACKGROUND_BOTTOM);
      if (pControl2)
        pControl2->SetWidth(pControl->GetWidth());
    }
    else
    {
      // adjust position of bottom background
      CGUIControl* pControl2 = (CGUIControl *)GetControl(BACKGROUND_BOTTOM);
      if (pControl2)
        pControl2->SetPosition(pControl2->GetXPosition(), pControl->GetYPosition() + pControl->GetHeight());
    }
#endif
  }

  // update our default control
  if (m_defaultControl < BUTTON_START || m_defaultControl > BUTTON_END)
    m_defaultControl = BUTTON_START;
  while (m_defaultControl <= BUTTON_END && !(GetControl(m_defaultControl)->CanFocus()))
    m_defaultControl++;
}
示例#18
0
void CGUIDialogAddonSettings::CreateControls()
{
  FreeControls();

  CGUISpinControlEx *pOriginalSpin = dynamic_cast<CGUISpinControlEx*>(GetControl(CONTROL_DEFAULT_SPIN));
  CGUIRadioButtonControl *pOriginalRadioButton = dynamic_cast<CGUIRadioButtonControl *>(GetControl(CONTROL_DEFAULT_RADIOBUTTON));
  CGUIButtonControl *pOriginalButton = dynamic_cast<CGUIButtonControl *>(GetControl(CONTROL_DEFAULT_BUTTON));
  CGUIImage *pOriginalImage = dynamic_cast<CGUIImage *>(GetControl(CONTROL_DEFAULT_SEPARATOR));
  CGUILabelControl *pOriginalLabel = dynamic_cast<CGUILabelControl *>(GetControl(CONTROL_DEFAULT_LABEL_SEPARATOR));
  CGUISettingsSliderControl *pOriginalSlider = dynamic_cast<CGUISettingsSliderControl *>(GetControl(CONTROL_DEFAULT_SLIDER));

  if (!m_addon || !pOriginalSpin || !pOriginalRadioButton || !pOriginalButton || !pOriginalImage
               || !pOriginalLabel || !pOriginalSlider)
    return;

  pOriginalSpin->SetVisible(false);
  pOriginalRadioButton->SetVisible(false);
  pOriginalButton->SetVisible(false);
  pOriginalImage->SetVisible(false);
  pOriginalLabel->SetVisible(false);
  pOriginalSlider->SetVisible(false);

  CGUIControlGroupList *group = dynamic_cast<CGUIControlGroupList *>(GetControl(CONTROL_SETTINGS_AREA));
  if (!group)
    return;

  // set our dialog heading
  SET_CONTROL_LABEL(CONTROL_HEADING_LABEL, m_strHeading);

  CGUIControl* pControl = NULL;
  int controlId = CONTROL_START_SETTING;
  const TiXmlElement *setting = GetFirstSetting();
  while (setting)
  {
    const std::string       type = XMLUtils::GetAttribute(setting, "type");
    const std::string         id = XMLUtils::GetAttribute(setting, "id");
    const std::string     values = XMLUtils::GetAttribute(setting, "values");
    const std::string    lvalues = XMLUtils::GetAttribute(setting, "lvalues");
    const std::string    entries = XMLUtils::GetAttribute(setting, "entries");
    const std::string defaultVal = XMLUtils::GetAttribute(setting, "default");
    const std::string subsetting = XMLUtils::GetAttribute(setting, "subsetting");
    const std::string      label = GetString(setting->Attribute("label"), subsetting == "true");

    bool bSort = XMLUtils::GetAttribute(setting, "sort") == "yes";
    if (!type.empty())
    {
      bool isAddonSetting = false;
      if (type == "text"   || type == "ipaddress"
       || type == "number" || type == "video"
       || type == "audio"  || type == "image"
       || type == "folder" || type == "executable"
       || type == "file"   || type == "action"
       || type == "date"   || type == "time"
       || type == "select" || (isAddonSetting = type == "addon"))
      {
        pControl = new CGUIButtonControl(*pOriginalButton);
        if (!pControl) return;
        ((CGUIButtonControl *)pControl)->SetLabel(label);
        if (!id.empty())
        {
          std::string value = m_settings[id];
          m_buttonValues[id] = value;
          // get any option to test for hidden
          const std::string option = XMLUtils::GetAttribute(setting, "option");
          if (option == "urlencoded")
            value = CURL::Decode(value);
          else if (option == "hidden")
          {
            std::string hiddenText;
            hiddenText.append(value.size(), L'*');
            ((CGUIButtonControl *)pControl)->SetLabel2(hiddenText);
          }
          else
          {
            if (isAddonSetting)
              ((CGUIButtonControl *)pControl)->SetLabel2(GetAddonNames(value));
            else if (type == "select" && !lvalues.empty())
            {
              vector<string> valuesVec = StringUtils::Split(lvalues, '|');
              int selected = atoi(value.c_str());
              if (selected >= 0 && selected < (int)valuesVec.size())
              {
                std::string label = m_addon->GetString(atoi(valuesVec[selected].c_str()));
                if (label.empty())
                  label = g_localizeStrings.Get(atoi(valuesVec[selected].c_str()));
                ((CGUIButtonControl *)pControl)->SetLabel2(label);
              }
            }
            else
              ((CGUIButtonControl *)pControl)->SetLabel2(value);
          }
        }
        else
          ((CGUIButtonControl *)pControl)->SetLabel2(defaultVal);
      }
      else if (type == "bool" && !id.empty())
      {
        pControl = new CGUIRadioButtonControl(*pOriginalRadioButton);
        if (!pControl) return;
        ((CGUIRadioButtonControl *)pControl)->SetLabel(label);
        ((CGUIRadioButtonControl *)pControl)->SetSelected(m_settings[id] == "true");
      }
      else if ((type == "enum" || type == "labelenum") && !id.empty())
      {
        vector<std::string> valuesVec;
        vector<std::string> entryVec;

        pControl = new CGUISpinControlEx(*pOriginalSpin);
        if (!pControl) return;
        ((CGUISpinControlEx *)pControl)->SetText(label);

       if (!lvalues.empty())
          StringUtils::Tokenize(lvalues, valuesVec, "|");
        else if (values == "$HOURS")
        {
          for (unsigned int i = 0; i < 24; i++)
          {
            CDateTime time(2000, 1, 1, i, 0, 0);
            valuesVec.push_back(g_infoManager.LocalizeTime(time, TIME_FORMAT_HH_MM_XX));
          }
        }
        else
          StringUtils::Tokenize(values, valuesVec, "|");
        if (!entries.empty())
          StringUtils::Tokenize(entries, entryVec, "|");

        if(bSort && type == "labelenum")
          std::sort(valuesVec.begin(), valuesVec.end(), sortstringbyname());

        for (unsigned int i = 0; i < valuesVec.size(); i++)
        {
          int iAdd = i;
          if (entryVec.size() > i)
            iAdd = atoi(entryVec[i].c_str());
          if (!lvalues.empty())
          {
            std::string replace = m_addon->GetString(atoi(valuesVec[i].c_str()));
            if (replace.empty())
              replace = g_localizeStrings.Get(atoi(valuesVec[i].c_str()));
            ((CGUISpinControlEx *)pControl)->AddLabel(replace, iAdd);
          }
          else
            ((CGUISpinControlEx *)pControl)->AddLabel(valuesVec[i], iAdd);
        }
        if (type == "labelenum")
        { // need to run through all our settings and find the one that matches
          ((CGUISpinControlEx*) pControl)->SetValueFromLabel(m_settings[id]);
        }
        else
          ((CGUISpinControlEx*) pControl)->SetValue(atoi(m_settings[id].c_str()));

      }
      else if (type == "fileenum" && !id.empty())
      {
        pControl = new CGUISpinControlEx(*pOriginalSpin);
        if (!pControl) return;
        ((CGUISpinControlEx *)pControl)->SetText(label);
        ((CGUISpinControlEx *)pControl)->SetFloatValue(1.0f);

        vector<std::string> items = GetFileEnumValues(values, XMLUtils::GetAttribute(setting, "mask"), XMLUtils::GetAttribute(setting, "option"));
        for (unsigned int i = 0; i < items.size(); ++i)
        {
          ((CGUISpinControlEx *)pControl)->AddLabel(items[i], i);
          if (StringUtils::EqualsNoCase(items[i], m_settings[id]))
            ((CGUISpinControlEx *)pControl)->SetValue(i);
        }
      }
      // Sample: <setting id="mysettingname" type="rangeofnum" label="30000" rangestart="0" rangeend="100" elements="11" valueformat="30001" default="0" />
      // in strings.xml: <string id="30001">%2.0f mp</string>
      // creates 11 piece, text formated number labels from 0 to 100
      else if (type == "rangeofnum" && !id.empty())
      {
        pControl = new CGUISpinControlEx(*pOriginalSpin);
        if (!pControl)
          return;
        ((CGUISpinControlEx *)pControl)->SetText(label);
        ((CGUISpinControlEx *)pControl)->SetFloatValue(1.0f);

        double rangestart = 0, rangeend = 1;
        setting->Attribute("rangestart", &rangestart);
        setting->Attribute("rangeend", &rangeend);

        int elements = 2;
        setting->Attribute("elements", &elements);

        std::string valueformat;
        if (setting->Attribute("valueformat"))
          valueformat = m_addon->GetString(atoi(setting->Attribute("valueformat")));
        for (int i = 0; i < elements; i++)
        {
          std::string valuestring;
          if (elements < 2)
            valuestring = StringUtils::Format(valueformat.c_str(), rangestart);
          else
            valuestring = StringUtils::Format(valueformat.c_str(), rangestart+(rangeend-rangestart)/(elements-1)*i);
          ((CGUISpinControlEx *)pControl)->AddLabel(valuestring, i);
        }
        ((CGUISpinControlEx *)pControl)->SetValue(atoi(m_settings[id].c_str()));
      }
      // Sample: <setting id="mysettingname" type="slider" label="30000" range="5,5,60" option="int" default="5"/>
      // to make ints from 5-60 with 5 steps
      else if (type == "slider" && !id.empty())
      {
        pControl = new CGUISettingsSliderControl(*pOriginalSlider);
        if (!pControl) return;
        ((CGUISettingsSliderControl *)pControl)->SetText(label);

        float fMin = 0.0f;
        float fMax = 100.0f;
        float fInc = 1.0f;
        vector<std::string> range = StringUtils::Split(XMLUtils::GetAttribute(setting, "range"), ',');
        if (range.size() > 1)
        {
          fMin = (float)atof(range[0].c_str());
          if (range.size() > 2)
          {
            fMax = (float)atof(range[2].c_str());
            fInc = (float)atof(range[1].c_str());
          }
          else
            fMax = (float)atof(range[1].c_str());
        }

        std::string option = XMLUtils::GetAttribute(setting, "option");
        int iType=0;

        if (option.empty() || StringUtils::EqualsNoCase(option, "float"))
          iType = SLIDER_CONTROL_TYPE_FLOAT;
        else if (StringUtils::EqualsNoCase(option, "int"))
          iType = SLIDER_CONTROL_TYPE_INT;
        else if (StringUtils::EqualsNoCase(option, "percent"))
          iType = SLIDER_CONTROL_TYPE_PERCENTAGE;

        ((CGUISettingsSliderControl *)pControl)->SetType(iType);
        ((CGUISettingsSliderControl *)pControl)->SetFloatRange(fMin, fMax);
        ((CGUISettingsSliderControl *)pControl)->SetFloatInterval(fInc);
        ((CGUISettingsSliderControl *)pControl)->SetFloatValue((float)atof(m_settings[id].c_str()));
      }
      else if (type == "lsep")
      {
        pControl = new CGUILabelControl(*pOriginalLabel);
        if (pControl)
          ((CGUILabelControl *)pControl)->SetLabel(label);
      }
      else if (type == "sep")
        pControl = new CGUIImage(*pOriginalImage);
    }

    if (pControl)
    {
      pControl->SetWidth(group->GetWidth());
      pControl->SetVisible(true);
      pControl->SetID(controlId);
      pControl->AllocResources();
      group->AddControl(pControl);
      pControl = NULL;
    }

    setting = setting->NextSiblingElement("setting");
    controlId++;
  }
  EnableControls();
}
示例#19
0
bool CGUIWindowBoxeeWizardNetwork::OnAction(const CAction &action)
{
   int iControl = GetFocusedControlID();

   if (action.wID == ACTION_PREVIOUS_MENU || (action.wID == ACTION_SELECT_ITEM && iControl == CONTROL_BACK))
   {
      Close();
   }
   else if (action.wID == ACTION_SELECT_ITEM && iControl == CONTROL_INTERFACES)
   {  
     ShowWirelessNetworksIfNeeded();
     CGUIListContainer *pList = (CGUIListContainer *)GetControl(CONTROL_INTERFACES);
     if (pList)
       pList->SetSingleSelectedItem();

     return true;
   }
   else if (action.wID == ACTION_MOVE_LEFT && iControl == CONTROL_WIRELESS)
   {
     ShowInterfaces();
     SET_CONTROL_FOCUS(CONTROL_INTERFACES, 0);
     CGUIListContainer *pList = (CGUIListContainer *)GetControl(CONTROL_WIRELESS);
     if (pList)
       pList->SetSingleSelectedItem();

      return true;
   }
   else if (action.wID == ACTION_SELECT_ITEM && iControl == CONTROL_WIRELESS)
   {      
      ShowPasswordIfNeeded();
      CGUIListContainer *pList = (CGUIListContainer *)GetControl(CONTROL_WIRELESS);
      if (pList)
        pList->SetSingleSelectedItem();
      return true;
   }
   else if (action.wID == ACTION_SELECT_ITEM && iControl == CONTROL_PASSWORD)   
   {      
      CGUIButtonControl* passwordButton = (CGUIButtonControl*) GetControl(iControl);
      CStdString password = passwordButton->GetLabel();
      if (CGUIDialogKeyboard::ShowAndGetInput(password, g_localizeStrings.Get(789), false))
      {         
         passwordButton->SetLabel(password);
         CONTROL_ENABLE(CONTROL_NEXT);                        
         SET_CONTROL_FOCUS(CONTROL_NEXT, 0);
      }
      return true;
   }
   else if (action.wID == ACTION_SELECT_ITEM && iControl == CONTROL_ENC)
   {      
      CGUIButtonControl* encSelectionButton = (CGUIButtonControl*) GetControl(CONTROL_ENC_SELECTION);
   
      CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), CONTROL_ENC);
      OnMessage(msg);
      int iItem = msg.GetParam1();
      encSelectionButton->SetLabel(ENC_LABELS[iItem]);
      
      SET_CONTROL_HIDDEN(CONTROL_ENC);
      
      if (iItem == ENC_NONE)
      {
         SET_CONTROL_HIDDEN(CONTROL_PASSWORD_GROUP);
         SET_CONTROL_FOCUS(CONTROL_NEXT, 0);
      }
      else
      {
         SET_CONTROL_FOCUS(CONTROL_PASSWORD, 0);
      }
      return true;
   }
   else if (action.wID == ACTION_MOVE_LEFT && (iControl == CONTROL_ENC_SELECTION || iControl == CONTROL_PASSWORD))
   {
      SET_CONTROL_HIDDEN(CONTROL_ENC_GROUP);
      SET_CONTROL_HIDDEN(CONTROL_PASSWORD_GROUP);
      SET_CONTROL_FOCUS(CONTROL_WIRELESS, 0);
      return true;
   }
   else if (action.wID == ACTION_MOVE_DOWN && iControl == CONTROL_ENC_SELECTION)
   {
      if (GetControl(CONTROL_PASSWORD_GROUP)->IsVisible())
      {
         SET_CONTROL_FOCUS(CONTROL_PASSWORD, 0);
      }
      else if (!GetControl(CONTROL_NEXT)->IsDisabled())
      {
         SET_CONTROL_FOCUS(CONTROL_NEXT, 0);
      }
      return true;     
   }
   else if (action.wID == ACTION_MOVE_UP && (iControl == CONTROL_NEXT || iControl == CONTROL_BACK))
   {
      if (GetControl(CONTROL_PASSWORD_GROUP)->IsVisible())
      {
         SET_CONTROL_FOCUS(CONTROL_PASSWORD, 0);
      }
      else if (GetControl(CONTROL_ENC_GROUP)->IsVisible())
      {
         SET_CONTROL_FOCUS(CONTROL_ENC_SELECTION, 0);
      }
      else 
      {
         SET_CONTROL_FOCUS(CONTROL_INTERFACES, 0);
      }
      return true;     
   }
   else if (action.wID == ACTION_SELECT_ITEM && iControl == CONTROL_NEXT)
   {
      if (GetControl(CONTROL_ENC_SELECTION)->IsVisible() && GetControl(CONTROL_PASSWORD)->IsVisible())
      {
        CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), CONTROL_ENC);
        OnMessage(msg);
        int iItem = msg.GetParam1();
        
        CGUIButtonControl* passwordButton = (CGUIButtonControl*) GetControl(CONTROL_PASSWORD);
        CStdString password = passwordButton->GetLabel();
    
        if (ENC_MODES[iItem] == ENC_WEP_HEX && !IsHexString(password))
        {
          CGUIDialogOK *pDialogOK = (CGUIDialogOK *)m_gWindowManager.GetWindow(WINDOW_DIALOG_OK);
          pDialogOK->SetHeading("");
          pDialogOK->SetLine(0, 51018);
          pDialogOK->SetLine(1, 51019);
          pDialogOK->DoModal();

          return true;
        }
      }
               
      if (SaveConfiguration())
      {
         // Close all wizard dialogs
         Close();
         CGUIDialog* dialog = (CGUIDialog*) m_gWindowManager.GetWindow(WINDOW_BOXEE_WIZARD_AUDIO);
         dialog->Close();
         dialog = (CGUIDialog*) m_gWindowManager.GetWindow(WINDOW_BOXEE_WIZARD_RESOLUTION);
         dialog->Close();
      }
      
      return true;
   }
   
   return CGUIWindow::OnAction(action);
}
示例#20
0
bool CGUIDialogAudioDSPManager::OnContextButton(int itemNumber, CONTEXT_BUTTON button, int listType)
{
  CFileItemPtr pItem;
  int listSize = 0;
  if (listType == LIST_ACTIVE)
  {
    pItem = m_activeItems[m_iCurrentType]->Get(itemNumber);
    listSize = m_activeItems[m_iCurrentType]->Size();
  }
  else if (listType == LIST_AVAILABLE)
  {
    pItem = m_availableItems[m_iCurrentType]->Get(itemNumber);
    listSize = m_availableItems[m_iCurrentType]->Size();
  }

  /* Check file item is in list range and get his pointer */
  if (!pItem || itemNumber < 0 || itemNumber >= listSize)
  {
    return false;
  }

  if (button == CONTEXT_BUTTON_ACTIVATE)
  {
    /*!
    * Deactivate selected processing mode
    */
    if (pItem->GetProperty("ActiveMode").asBoolean())
    {
      // remove mode from active mode list and add it to available mode list
      CFileItemPtr newItem(dynamic_cast<CFileItem*>(pItem->Clone()));
      newItem->SetProperty("ActiveMode", false);
      newItem->SetProperty("Changed", true);
      m_activeItems[m_iCurrentType]->Remove(itemNumber);
      m_availableItems[m_iCurrentType]->Add(newItem);
    }
    else
    {
      /*!
      * Activate selected processing mode
      */
      if ((m_iCurrentType == AE_DSP_MODE_TYPE_INPUT_RESAMPLE || m_iCurrentType == AE_DSP_MODE_TYPE_OUTPUT_RESAMPLE) && m_activeItems[m_iCurrentType]->Size() > 0)
      { // if there is already an active resampler, now we remove it
        CFileItemPtr activeResampler = m_activeItems[m_iCurrentType]->Get(0);
        if (activeResampler)
        {
          CFileItemPtr newItem(dynamic_cast<CFileItem*>(activeResampler->Clone()));
          newItem->SetProperty("ActiveMode", false);
          newItem->SetProperty("Changed", true);

          m_availableItems[m_iCurrentType]->Add(newItem);
          // clear active list, because only one active resampling mode is supported by ActiveAEDSP
          m_activeItems[m_iCurrentType]->Clear();
        }
      }

      // remove mode from available mode list and add it to active mode list
      CFileItemPtr newItem(dynamic_cast<CFileItem*>(pItem->Clone()));

      newItem->SetProperty("Number", (int)m_activeItems[m_iCurrentType]->Size() +1);
      newItem->SetProperty("Changed", true);
      newItem->SetProperty("ActiveMode", true);

      m_availableItems[m_iCurrentType]->Remove(itemNumber);
      m_activeItems[m_iCurrentType]->Add(newItem);
    }

    m_bContainsChanges = true;
    if (m_bContinuousSaving)
    {
      SaveList();
    }

    // reorder available mode list, so that the mode order is always consistent
    m_availableItems[m_iCurrentType]->ClearSortState();
    m_availableItems[m_iCurrentType]->Sort(SortByLabel, SortOrderAscending);

    // update active and available mode list
    Renumber();
    m_availableViewControl.SetItems(*m_availableItems[m_iCurrentType]);
    m_activeViewControl.SetItems(*m_activeItems[m_iCurrentType]);
  }
  else if (button == CONTEXT_BUTTON_MOVE)
  {
    m_bMovingMode = true;
    pItem->Select(true);

    CGUIListContainer *modeList = dynamic_cast<CGUIListContainer*>(GetControl(CONTROL_LIST_MODE_SELECTION));
    CGUIButtonControl *applyButton = dynamic_cast<CGUIButtonControl*>(GetControl(CONTROL_BUTTON_APPLY_CHANGES));
    CGUIButtonControl *clearActiveModesButton = dynamic_cast<CGUIButtonControl*>(GetControl(CONTROL_BUTTON_CLEAR_ACTIVE_MODES));
    if (!modeList || !applyButton || !clearActiveModesButton)
    {
      helper_LogError(__FUNCTION__);
      return false;
    }

    // if we are in MovingMode all buttons and mode selection list will be disabled!
    modeList->SetEnabled(false);
    clearActiveModesButton->SetEnabled(false);
    if (!m_bContinuousSaving)
    {
      applyButton->SetEnabled(false);
    }
  }
  else if (button == CONTEXT_BUTTON_SETTINGS)
  {
    HELPERS::ShowOKDialogLines(CVariant{19033}, CVariant{0}, CVariant{15040}, CVariant{0});
  }

  return true;
}
示例#21
0
void CGUIWindowBoxeeWizardNetwork::ShowPasswordIfNeeded()
{
   int iItem;
   NetworkAssignment assignment;
   CStdString ipAddress;
   CStdString networkMask;
   CStdString defaultGateway;
   CStdString essId;
   CStdString key;
   EncMode encryptionMode;   
   
   // Get the interface information
   {
      CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), CONTROL_INTERFACES);
      OnMessage(msg);
      iItem = msg.GetParam1();
   }      
   
   if (!m_interfaces[iItem]->IsWireless())
      return;
      
   m_interfaces[iItem]->GetSettings(assignment, ipAddress, networkMask, defaultGateway, essId, key, encryptionMode);
   if (key != "")
   {
      CGUIButtonControl* passwordButton = (CGUIButtonControl*) GetControl(CONTROL_PASSWORD);
      passwordButton->SetLabel(key);
   }
      
   {
      CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), CONTROL_WIRELESS);
      OnMessage(msg);
      iItem = msg.GetParam1();
   }

   if (iItem == (int) m_aps.size())
   {
      // Last item was selected, show the keyboard to get input
      CStdString essId = m_networkItems[m_networkItems.size()-1]->GetLabel();
      if (essId == "Other...")
         essId = "";
         
      if (CGUIDialogKeyboard::ShowAndGetInput(essId, g_localizeStrings.Get(789), false))
      {
         m_networkItems[m_networkItems.size()-1]->SetLabel(essId);

         SET_CONTROL_VISIBLE(CONTROL_SEP2);
         SET_CONTROL_VISIBLE(CONTROL_PASSWORD_GROUP);
         SET_CONTROL_VISIBLE(CONTROL_ENC_GROUP);
         SET_CONTROL_FOCUS(CONTROL_ENC_SELECTION, 0);
      }
   }
   else
   {
      CGUIButtonControl* encSelectionButton = (CGUIButtonControl*) GetControl(CONTROL_ENC_SELECTION);
      encSelectionButton->SetLabel(ENC_LABELS[m_aps[iItem].getEncryptionMode()]);
      
      SET_CONTROL_VISIBLE(CONTROL_SEP2);
      SET_CONTROL_VISIBLE(CONTROL_ENC_GROUP);
      if (m_aps[iItem].getEncryptionMode() == ENC_NONE)
      {
         SET_CONTROL_HIDDEN(CONTROL_PASSWORD_GROUP);
         CONTROL_ENABLE(CONTROL_NEXT);               
         SET_CONTROL_FOCUS(CONTROL_NEXT, 0);
      }
      else
      {
         SET_CONTROL_VISIBLE(CONTROL_PASSWORD_GROUP);
         SET_CONTROL_FOCUS(CONTROL_PASSWORD, 0);
      }
    }
}
示例#22
0
void CGUIDialogSettingsBase::SetupControls(bool createSettings /* = true */)
{
  // cleanup first, if necessary
  FreeControls();

  // get the section
  CSettingSection *section = GetSection();
  if (section == NULL)
    return;
  
  // update the screen string
  SetHeading(section->GetLabel());

  // get the categories we need
  m_categories = section->GetCategories((SettingLevel)GetSettingLevel());
  if (m_categories.empty())
    m_categories.push_back(m_dummyCategory);

  // get all controls
  m_pOriginalSpin = dynamic_cast<CGUISpinControlEx*>(GetControl(CONTROL_DEFAULT_SPIN));
  m_pOriginalSlider = dynamic_cast<CGUISettingsSliderControl*>(GetControl(CONTROL_DEFAULT_SLIDER));
  m_pOriginalRadioButton = dynamic_cast<CGUIRadioButtonControl *>(GetControl(CONTROL_DEFAULT_RADIOBUTTON));
  m_pOriginalCategoryButton = dynamic_cast<CGUIButtonControl *>(GetControl(CONTROL_DEFAULT_CATEGORY_BUTTON));
  m_pOriginalButton = dynamic_cast<CGUIButtonControl *>(GetControl(CONTROL_DEFAULT_BUTTON));
  m_pOriginalImage = dynamic_cast<CGUIImage *>(GetControl(CONTROL_DEFAULT_SEPARATOR));
  m_pOriginalEdit = dynamic_cast<CGUIEditControl *>(GetControl(CONTROL_DEFAULT_EDIT));

  if (!m_pOriginalEdit && m_pOriginalButton)
  {
    m_pOriginalEdit = new CGUIEditControl(*m_pOriginalButton);
    m_newOriginalEdit = true;
  }

  if (m_pOriginalSpin) m_pOriginalSpin->SetVisible(false);
  if (m_pOriginalSlider) m_pOriginalSlider->SetVisible(false);
  if (m_pOriginalRadioButton) m_pOriginalRadioButton->SetVisible(false);
  if (m_pOriginalButton) m_pOriginalButton->SetVisible(false);
  if (m_pOriginalCategoryButton) m_pOriginalCategoryButton->SetVisible(false);
  m_pOriginalEdit->SetVisible(false);
  if (m_pOriginalImage) m_pOriginalImage->SetVisible(false);

  if (m_pOriginalCategoryButton != NULL)
  {
    // setup our control groups...
    CGUIControlGroupList *group = dynamic_cast<CGUIControlGroupList *>(GetControl(CATEGORY_GROUP_ID));
    if (!group)
      return;

    // go through the categories and create the necessary buttons
    int buttonIdOffset = 0;
    for (SettingCategoryList::const_iterator category = m_categories.begin(); category != m_categories.end(); category++)
    {
      CGUIButtonControl *pButton = NULL;
      if (m_pOriginalCategoryButton->GetControlType() == CGUIControl::GUICONTROL_TOGGLEBUTTON)
        pButton = new CGUIToggleButtonControl(*(CGUIToggleButtonControl *)m_pOriginalCategoryButton);
      else
        pButton = new CGUIButtonControl(*m_pOriginalCategoryButton);
      pButton->SetLabel(GetLocalizedString((*category)->GetLabel()));
      pButton->SetID(CONTROL_SETTINGS_START_BUTTONS + buttonIdOffset);
      pButton->SetVisible(true);
      pButton->AllocResources();

      group->AddControl(pButton);
      buttonIdOffset++;
    }
  }

  if (createSettings)
    CreateSettings();

  // set focus correctly depending on whether there are categories visible or not
  m_defaultControl = m_pOriginalCategoryButton != NULL ? CATEGORY_GROUP_ID : SETTINGS_GROUP_ID;
}
示例#23
0
void CGUIDialogContextMenu::SetupButtons()
{
  if (!m_buttons.size())
    return;

  // disable the template button control
  CGUIButtonControl *pButtonTemplate = (CGUIButtonControl *)GetFirstFocusableControl(BUTTON_TEMPLATE);
  if (!pButtonTemplate) pButtonTemplate = (CGUIButtonControl *)GetControl(BUTTON_TEMPLATE);
  if (!pButtonTemplate)
    return;
  pButtonTemplate->SetVisible(false);

  // add our buttons
  for (unsigned int i = 0; i < m_buttons.size(); i++)
  {
    CGUIButtonControl *pButton = new CGUIButtonControl(*pButtonTemplate);
    if (pButton)
    { // set the button's ID and position
      int id = BUTTON_START + i;
      pButton->SetID(id);
      pButton->SetPosition(pButtonTemplate->GetXPosition(), i*(pButtonTemplate->GetHeight() + SPACE_BETWEEN_BUTTONS));
      pButton->SetVisible(true);
      pButton->SetNavigation(id - 1, id + 1, id, id);
      pButton->SetLabel(m_buttons[i].second);
      AddControl(pButton);
    }
  }

  // update the navigation of the first and last buttons
  CGUIControl *pControl = (CGUIControl *)GetControl(BUTTON_START);
  if (pControl)
    pControl->SetNavigation(BUTTON_END, pControl->GetControlIdDown(), pControl->GetControlIdLeft(), pControl->GetControlIdRight());
  pControl = (CGUIControl *)GetControl(BUTTON_END);
  if (pControl)
    pControl->SetNavigation(pControl->GetControlIdUp(), BUTTON_START, pControl->GetControlIdLeft(), pControl->GetControlIdRight());

  // fix up the height of the background image
  pControl = (CGUIControl *)GetControl(BACKGROUND_IMAGE);
  if (pControl)
  {
    pControl->SetHeight(m_buttons.size() * (pButtonTemplate->GetHeight() + SPACE_BETWEEN_BUTTONS));
    CGUIControl *pControl2 = (CGUIControl *)GetControl(BACKGROUND_BOTTOM);
    if (pControl2)
      pControl2->SetPosition(pControl2->GetXPosition(), pControl->GetYPosition() + pControl->GetHeight());
  }

  // update our default control
  if (m_defaultControl < BUTTON_START || m_defaultControl > BUTTON_END)
    m_defaultControl = BUTTON_START;
  while (m_defaultControl <= BUTTON_END && !(GetControl(m_defaultControl)->CanFocus()))
    m_defaultControl++;
}