本文整理汇总了C++中CSetting::GetParent方法的典型用法代码示例。如果您正苦于以下问题:C++ CSetting::GetParent方法的具体用法?C++ CSetting::GetParent怎么用?C++ CSetting::GetParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSetting
的用法示例。
在下文中一共展示了CSetting::GetParent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddSetting
CGUIControl* CGUIDialogSettingsBase::AddSetting(CSetting *pSetting, float width, int &iControlID)
{
if (pSetting == NULL)
return NULL;
BaseSettingControlPtr pSettingControl;
CGUIControl *pControl = NULL;
// determine the label and any possible indentation in case of sub settings
string label = GetLocalizedString(pSetting->GetLabel());
int parentLevels = 0;
CSetting *parentSetting = GetSetting(pSetting->GetParent());
while (parentSetting != NULL)
{
parentLevels++;
parentSetting = GetSetting(parentSetting->GetParent());
}
if (parentLevels > 0)
{
// add additional 2 spaces indentation for anything past one level
string indentation;
for (int index = 1; index < parentLevels; index++)
indentation.append(" ");
label = StringUtils::Format(g_localizeStrings.Get(168).c_str(), indentation.c_str(), label.c_str());
}
// create the proper controls
if (!pSetting->GetControl())
return NULL;
std::string controlType = pSetting->GetControl()->GetType();
if (controlType == "toggle")
{
if (m_pOriginalRadioButton != NULL)
pControl = new CGUIRadioButtonControl(*m_pOriginalRadioButton);
if (pControl == NULL)
return NULL;
((CGUIRadioButtonControl *)pControl)->SetLabel(label);
pSettingControl.reset(new CGUIControlRadioButtonSetting((CGUIRadioButtonControl *)pControl, iControlID, pSetting));
}
else if (controlType == "spinner")
{
if (m_pOriginalSpin != NULL)
pControl = new CGUISpinControlEx(*m_pOriginalSpin);
if (pControl == NULL)
return NULL;
((CGUISpinControlEx *)pControl)->SetText(label);
pSettingControl.reset(new CGUIControlSpinExSetting((CGUISpinControlEx *)pControl, iControlID, pSetting));
}
else if (controlType == "edit")
{
if (m_pOriginalEdit != NULL)
pControl = new CGUIEditControl(*m_pOriginalEdit);
if (pControl == NULL)
return NULL;
((CGUIEditControl *)pControl)->SetLabel(label);
pSettingControl.reset(new CGUIControlEditSetting((CGUIEditControl *)pControl, iControlID, pSetting));
}
else if (controlType == "list")
{
if (m_pOriginalButton != NULL)
pControl = new CGUIButtonControl(*m_pOriginalButton);
if (pControl == NULL)
return NULL;
((CGUIButtonControl *)pControl)->SetLabel(label);
pSettingControl.reset(new CGUIControlListSetting((CGUIButtonControl *)pControl, iControlID, pSetting));
}
else if (controlType == "button" || controlType == "slider")
{
if (controlType == "button" ||
static_cast<const CSettingControlSlider*>(pSetting->GetControl())->UsePopup())
{
if (m_pOriginalButton != NULL)
pControl = new CGUIButtonControl(*m_pOriginalButton);
if (pControl == NULL)
return NULL;
((CGUIButtonControl *)pControl)->SetLabel(label);
pSettingControl.reset(new CGUIControlButtonSetting((CGUIButtonControl *)pControl, iControlID, pSetting));
}
else
{
if (m_pOriginalSlider != NULL)
pControl = new CGUISettingsSliderControl(*m_pOriginalSlider);
if (pControl == NULL)
return NULL;
((CGUISettingsSliderControl *)pControl)->SetText(label);
pSettingControl.reset(new CGUIControlSliderSetting((CGUISettingsSliderControl *)pControl, iControlID, pSetting));
}
}
else if (controlType == "range")
{
if (m_pOriginalSlider != NULL)
pControl = new CGUISettingsSliderControl(*m_pOriginalSlider);
//.........这里部分代码省略.........
示例2: AddSetting
CGUIControl* CGUIWindowSettingsCategory::AddSetting(CSetting *pSetting, float width, int &iControlID)
{
if (pSetting == NULL)
return NULL;
BaseSettingControlPtr pSettingControl;
CGUIControl *pControl = NULL;
// determine the label and any possible indentation in case of sub settings
string label = g_localizeStrings.Get(pSetting->GetLabel());
int parentLevels = 0;
CSetting *parentSetting = m_settings.GetSetting(pSetting->GetParent());
while (parentSetting != NULL)
{
parentLevels++;
parentSetting = m_settings.GetSetting(parentSetting->GetParent());
}
if (parentLevels > 0)
{
// add additional 2 spaces indentation for anything past one level
string indentation;
for (int index = 1; index < parentLevels; index++)
indentation.append(" ");
label = StringUtils::Format(g_localizeStrings.Get(168).c_str(), indentation.c_str(), label.c_str());
}
// create the proper controls
switch (pSetting->GetControl().GetType())
{
case SettingControlTypeCheckmark:
{
pControl = new CGUIRadioButtonControl(*m_pOriginalRadioButton);
if (pControl == NULL)
return NULL;
((CGUIRadioButtonControl *)pControl)->SetLabel(label);
pSettingControl.reset(new CGUIControlRadioButtonSetting((CGUIRadioButtonControl *)pControl, iControlID, pSetting));
break;
}
case SettingControlTypeSpinner:
{
pControl = new CGUISpinControlEx(*m_pOriginalSpin);
if (pControl == NULL)
return NULL;
((CGUISpinControlEx *)pControl)->SetText(label);
pSettingControl.reset(new CGUIControlSpinExSetting((CGUISpinControlEx *)pControl, iControlID, pSetting));
break;
}
case SettingControlTypeEdit:
{
pControl = new CGUIEditControl(*m_pOriginalEdit);
if (pControl == NULL)
return NULL;
((CGUIEditControl *)pControl)->SetLabel(label);
pSettingControl.reset(new CGUIControlEditSetting((CGUIEditControl *)pControl, iControlID, pSetting));
break;
}
case SettingControlTypeList:
{
pControl = new CGUIButtonControl(*m_pOriginalButton);
if (pControl == NULL)
return NULL;
((CGUIButtonControl *)pControl)->SetLabel(label);
pSettingControl.reset(new CGUIControlListSetting((CGUIButtonControl *)pControl, iControlID, pSetting));
break;
}
case SettingControlTypeButton:
{
pControl = new CGUIButtonControl(*m_pOriginalButton);
if (pControl == NULL)
return NULL;
((CGUIButtonControl *)pControl)->SetLabel(label);
pSettingControl.reset(new CGUIControlButtonSetting((CGUIButtonControl *)pControl, iControlID, pSetting));
break;
}
case SettingControlTypeNone:
default:
return NULL;
}
if (pSetting->GetControl().GetDelayed())
pSettingControl->SetDelayed();
return AddSettingControl(pControl, pSettingControl, width, iControlID);
}