本文整理汇总了C++中CGUIControl::AllocResources方法的典型用法代码示例。如果您正苦于以下问题:C++ CGUIControl::AllocResources方法的具体用法?C++ CGUIControl::AllocResources怎么用?C++ CGUIControl::AllocResources使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGUIControl
的用法示例。
在下文中一共展示了CGUIControl::AllocResources方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddSetting
void CGUIDialogVisualisationSettings::AddSetting(VisSetting &setting, float width, int iControlID)
{
CGUIControl *pControl = NULL;
if (setting.type == VisSetting::CHECK)
{
pControl = new CGUIRadioButtonControl(*m_pOriginalRadioButton);
if (!pControl) return ;
((CGUIRadioButtonControl *)pControl)->SetLabel(setting.name);
pControl->SetWidth(width);
((CGUIRadioButtonControl *)pControl)->SetSelected(setting.current == 1);
}
else if (setting.type == VisSetting::SPIN && setting.entry.size() > 0)
{
pControl = new CGUISpinControlEx(*m_pOriginalSpin);
if (!pControl) return ;
pControl->SetWidth(width);
((CGUISpinControlEx *)pControl)->SetText(setting.name);
pControl->SetWidth(width);
for (unsigned int i = 0; i < setting.entry.size(); i++)
((CGUISpinControlEx *)pControl)->AddLabel(setting.entry[i], i);
((CGUISpinControlEx *)pControl)->SetValue(setting.current);
}
if (!pControl) return;
pControl->SetID(iControlID);
pControl->SetVisible(true);
CGUIControlGroupList *group = (CGUIControlGroupList *)GetControl(CONTROL_GROUP_LIST);
if (group)
{
pControl->AllocResources();
group->AddControl(pControl);
}
else
delete pControl;
}
示例2: AllocResources
void CGUIControlGroup::AllocResources()
{
CGUIControl::AllocResources();
for (iControls it = m_children.begin(); it != m_children.end(); ++it)
{
CGUIControl *control = *it;
if (!control->IsDynamicallyAllocated())
control->AllocResources();
}
}
示例3: OnMessage
bool CGUIWindow::OnMessage(CGUIMessage& message)
{
switch ( message.GetMessage() )
{
case GUI_MSG_WINDOW_INIT:
{
CLog::Log(LOGDEBUG, "------ Window Init (%s) ------", GetProperty("xmlfile").c_str());
if (m_dynamicResourceAlloc || !m_bAllocated) AllocResources();
OnInitWindow();
return true;
}
break;
case GUI_MSG_WINDOW_DEINIT:
{
CLog::Log(LOGDEBUG, "------ Window Deinit (%s) ------", GetProperty("xmlfile").c_str());
OnDeinitWindow(message.GetParam1());
// now free the window
if (m_dynamicResourceAlloc) FreeResources();
return true;
}
break;
case GUI_MSG_CLICKED:
{
// a specific control was clicked
CLICK_EVENT clickEvent = m_mapClickEvents[ message.GetSenderId() ];
// determine if there are any handlers for this event
if (clickEvent.HasAHandler())
{
// fire the message to all handlers
clickEvent.Fire(message);
}
break;
}
case GUI_MSG_SELCHANGED:
{
// a selection within a specific control has changed
SELECTED_EVENT selectedEvent = m_mapSelectedEvents[ message.GetSenderId() ];
// determine if there are any handlers for this event
if (selectedEvent.HasAHandler())
{
// fire the message to all handlers
selectedEvent.Fire(message);
}
break;
}
case GUI_MSG_FOCUSED:
{ // a control has been focused
if (HasID(message.GetSenderId()))
{
m_focusedControl = message.GetControlId();
return true;
}
break;
}
case GUI_MSG_LOSTFOCUS:
{
// nothing to do at the window level when we lose focus
return true;
}
case GUI_MSG_MOVE:
{
if (HasID(message.GetSenderId()))
return OnMove(message.GetControlId(), message.GetParam1());
break;
}
case GUI_MSG_SETFOCUS:
{
// CLog::Log(LOGDEBUG,"set focus to control:%i window:%i (%i)\n", message.GetControlId(),message.GetSenderId(), GetID());
if ( message.GetControlId() )
{
// first unfocus the current control
CGUIControl *control = GetFocusedControl();
if (control)
{
CGUIMessage msgLostFocus(GUI_MSG_LOSTFOCUS, GetID(), control->GetID(), message.GetControlId());
control->OnMessage(msgLostFocus);
}
// get the control to focus
CGUIControl* pFocusedControl = GetFirstFocusableControl(message.GetControlId());
if (!pFocusedControl) pFocusedControl = (CGUIControl *)GetControl(message.GetControlId());
// and focus it
if (pFocusedControl)
return pFocusedControl->OnMessage(message);
}
return true;
}
break;
case GUI_MSG_EXCLUSIVE_MOUSE:
{
m_exclusiveMouseControl = message.GetSenderId();
return true;
}
break;
//.........这里部分代码省略.........
示例4: OnMessage
bool CGUIWindow::OnMessage(CGUIMessage& message)
{
switch ( message.GetMessage() )
{
case GUI_MSG_WINDOW_LOAD:
{
Initialize();
return true;
}
break;
case GUI_MSG_WINDOW_INIT:
{
CLog::Log(LOGDEBUG, "------ Window Init (%s) ------", GetProperty("xmlfile").c_str());
if (m_dynamicResourceAlloc || !m_bAllocated) AllocResources(false);
OnInitWindow();
return true;
}
break;
case GUI_MSG_WINDOW_DEINIT:
{
CLog::Log(LOGDEBUG, "------ Window Deinit (%s) ------", GetProperty("xmlfile").c_str());
OnDeinitWindow(message.GetParam1());
// now free the window
if (m_dynamicResourceAlloc) FreeResources();
return true;
}
break;
case GUI_MSG_UNFOCUS_ALL:
{
//unfocus the current focused control in this window
CGUIControl *control = GetFocusedControl();
if(control)
{
//tell focused control that it has lost the focus
CGUIMessage msgLostFocus(GUI_MSG_LOSTFOCUS, GetID(), control->GetID(), control->GetID());
control->OnMessage(msgLostFocus);
CLog::Log(LOGDEBUG, "Unfocus WindowID: %i, ControlID: %i",GetID(), control->GetID());
}
return true;
}
case GUI_MSG_FOCUSED:
{ // a control has been focused
if (HasID(message.GetSenderId()))
{
m_focusedControl = message.GetControlId();
return true;
}
break;
}
case GUI_MSG_LOSTFOCUS:
{
// nothing to do at the window level when we lose focus
return true;
}
case GUI_MSG_MOVE:
{
if (HasID(message.GetSenderId()))
return OnMove(message.GetControlId(), message.GetParam1());
break;
}
case GUI_MSG_SETFOCUS:
{
// CLog::Log(LOGDEBUG,"set focus to control:%i window:%i (%i)\n", message.GetControlId(),message.GetSenderId(), GetID());
if ( message.GetControlId() )
{
// first unfocus the current control
CGUIControl *control = GetFocusedControl();
if (control)
{
CGUIMessage msgLostFocus(GUI_MSG_LOSTFOCUS, GetID(), control->GetID(), message.GetControlId());
control->OnMessage(msgLostFocus);
}
// get the control to focus
CGUIControl* pFocusedControl = GetFirstFocusableControl(message.GetControlId());
if (!pFocusedControl) pFocusedControl = GetControl(message.GetControlId());
// and focus it
if (pFocusedControl)
return pFocusedControl->OnMessage(message);
}
return true;
}
break;
case GUI_MSG_EXCLUSIVE_MOUSE:
{
m_exclusiveMouseControl = message.GetSenderId();
return true;
}
break;
case GUI_MSG_GESTURE_NOTIFY:
{
CAction action(ACTION_GESTURE_NOTIFY, 0, static_cast<float>(message.GetParam1()), static_cast<float>(message.GetParam2()), 0, 0);
EVENT_RESULT result = OnMouseAction(action);
auto res = new int(result);
message.SetPointer(static_cast<void*>(res));
//.........这里部分代码省略.........
示例5: CreateControls
//.........这里部分代码省略.........
{
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();
}
示例6: AddSetting
void CGUIDialogSettings::AddSetting(SettingInfo &setting, float width, int iControlID)
{
CGUIControl *pControl = NULL;
if (setting.type == SettingInfo::BUTTON_DIALOG && m_pOriginalSettingsButton)
{
pControl = new CGUIButtonControl(*m_pOriginalSettingsButton);
if (!pControl) return ;
((CGUIButtonControl *)pControl)->SetLabel(setting.name);
pControl->SetWidth(width);
if (setting.data) ((CGUIButtonControl *)pControl)->SetLabel2(*(CStdString *)setting.data);
}
else if (setting.type == SettingInfo::BUTTON && m_pOriginalSettingsButton)
{
pControl = new CGUIButtonControl(*m_pOriginalSettingsButton);
if (!pControl) return ;
((CGUIButtonControl *)pControl)->SetLabel(setting.name);
if (setting.formatFunction)
((CGUIButtonControl *)pControl)->SetLabel2(setting.formatFunction(*(float *)setting.data, setting.interval));
pControl->SetWidth(width);
}
else if (setting.type == SettingInfo::EDIT && m_pOriginalEdit)
{
pControl = new CGUIEditControl(*m_pOriginalEdit);
if (!pControl) return ;
((CGUIEditControl *)pControl)->SetLabel(setting.name);
pControl->SetWidth(width);
if (setting.data) ((CGUIEditControl *)pControl)->SetLabel2(*(CStdString *)setting.data);
}
else if (setting.type == SettingInfo::EDIT_NUM && m_pOriginalEditNum)
{
pControl = new CGUIEditControl(*m_pOriginalEditNum);
if (!pControl) return ;
((CGUIEditControl *)pControl)->SetLabel(setting.name);
pControl->SetWidth(width);
((CGUIEditControl *)pControl)->SetInputType(CGUIEditControl::INPUT_TYPE_NUMBER, 0);
if (setting.data) {
CStdString strIndex;
strIndex.Format("%i", *(int *)setting.data);
((CGUIEditControl *)pControl)->SetLabel2(strIndex);
}
}
else if (setting.type == SettingInfo::SEPARATOR && m_pOriginalSeparator)
{
pControl = new CGUIImage(*m_pOriginalSeparator);
if (!pControl) return ;
pControl->SetWidth(width);
}
else if (setting.type == SettingInfo::CHECK || setting.type == SettingInfo::CHECK_UCHAR)
{
if (!m_pOriginalRadioButton) return;
pControl = new CGUIRadioButtonControl(*m_pOriginalRadioButton);
if (!pControl) return ;
((CGUIRadioButtonControl *)pControl)->SetLabel(setting.name);
pControl->SetWidth(width);
if (setting.data) ((CGUIRadioButtonControl *)pControl)->SetSelected(*(bool *)setting.data == 1);
}
else if (setting.type == SettingInfo::SPIN && setting.entry.size() > 0 && m_pOriginalSpin)
{
pControl = new CGUISpinControlEx(*m_pOriginalSpin);
if (!pControl) return ;
pControl->SetWidth(width);
((CGUISpinControlEx *)pControl)->SetText(setting.name);
pControl->SetWidth(width);
for (unsigned int i = 0; i < setting.entry.size(); i++)
((CGUISpinControlEx *)pControl)->AddLabel(setting.entry[i].second, setting.entry[i].first);
if (setting.data) ((CGUISpinControlEx *)pControl)->SetValue(*(int *)setting.data);
}
else if (setting.type == SettingInfo::SLIDER)
{
if (!m_pOriginalSlider) return;
pControl = new CGUISettingsSliderControl(*m_pOriginalSlider);
if (!pControl) return ;
pControl->SetWidth(width);
((CGUISettingsSliderControl *)pControl)->SetText(setting.name);
if (setting.formatFunction)
((CGUISettingsSliderControl *)pControl)->SetTextValue(setting.formatFunction(*(float *)setting.data, setting.interval));
((CGUISettingsSliderControl *)pControl)->SetType(SPIN_CONTROL_TYPE_FLOAT);
((CGUISettingsSliderControl *)pControl)->SetFloatRange(setting.min, setting.max);
((CGUISettingsSliderControl *)pControl)->SetFloatInterval(setting.interval);
if (setting.data) ((CGUISettingsSliderControl *)pControl)->SetFloatValue(*(float *)setting.data);
}
if (!pControl) return;
pControl->SetID(iControlID);
pControl->SetVisible(true);
pControl->SetEnabled(setting.enabled);
CGUIControlGroupList *group = (CGUIControlGroupList *)GetControl(CONTROL_GROUP_LIST);
if (group)
{
pControl->AllocResources();
group->AddControl(pControl);
}
else
delete pControl;
}
示例7: CreateControls
//.........这里部分代码省略.........
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();
}