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; }
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; }