本文整理汇总了C++中CGUIControl::HasID方法的典型用法代码示例。如果您正苦于以下问题:C++ CGUIControl::HasID方法的具体用法?C++ CGUIControl::HasID怎么用?C++ CGUIControl::HasID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGUIControl
的用法示例。
在下文中一共展示了CGUIControl::HasID方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnMessage
bool CGUIControlGroupList::OnMessage(CGUIMessage& message)
{
switch (message.GetMessage() )
{
case GUI_MSG_FOCUSED:
{ // a control has been focused
// scroll if we need to and update our page control
ValidateOffset();
float offset = 0;
for (iControls it = m_children.begin(); it != m_children.end(); ++it)
{
CGUIControl *control = *it;
if (!control->IsVisible())
continue;
if (control->HasID(message.GetControlId()))
{
// find out whether this is the first or last control
if (IsFirstFocusableControl(control))
ScrollTo(0);
else if (IsLastFocusableControl(control))
ScrollTo(m_totalSize - Size());
else if (offset < m_scroller.GetValue())
ScrollTo(offset);
else if (offset + Size(control) > m_scroller.GetValue() + Size())
ScrollTo(offset + Size(control) - Size());
break;
}
offset += Size(control) + m_itemGap;
}
}
break;
case GUI_MSG_SETFOCUS:
{
// we've been asked to focus. We focus the last control if it's on this page,
// else we'll focus the first focusable control from our offset (after verifying it)
ValidateOffset();
// now check the focusControl's offset
float offset = 0;
for (iControls it = m_children.begin(); it != m_children.end(); ++it)
{
CGUIControl *control = *it;
if (!control->IsVisible())
continue;
if (control->HasID(m_focusedControl))
{
if (offset >= m_scroller.GetValue() && offset + Size(control) <= m_scroller.GetValue() + Size())
return CGUIControlGroup::OnMessage(message);
break;
}
offset += Size(control) + m_itemGap;
}
// find the first control on this page
offset = 0;
for (iControls it = m_children.begin(); it != m_children.end(); ++it)
{
CGUIControl *control = *it;
if (!control->IsVisible())
continue;
if (control->CanFocus() && offset >= m_scroller.GetValue() && offset + Size(control) <= m_scroller.GetValue() + Size())
{
m_focusedControl = control->GetID();
break;
}
offset += Size(control) + m_itemGap;
}
}
break;
case GUI_MSG_PAGE_CHANGE:
{
if (message.GetSenderId() == m_pageControl)
{ // it's from our page control
ScrollTo((float)message.GetParam1());
return true;
}
}
break;
}
return CGUIControlGroup::OnMessage(message);
}