本文整理汇总了C++中Control::CanFocus方法的典型用法代码示例。如果您正苦于以下问题:C++ Control::CanFocus方法的具体用法?C++ Control::CanFocus怎么用?C++ Control::CanFocus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Control
的用法示例。
在下文中一共展示了Control::CanFocus方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Move
void Menu::Move(bool down)
{
Control *find = m_focus;
if (find == NULL)
return;
do {
if (down)
{
find = find->m_next;
if (find == NULL)
find = m_controls;
}
else
{
find = find->m_last;
if (find == NULL)
{
find = m_controls;
while (find->m_next != NULL)
find = find->m_next;
}
}
if (find == m_focus)
{
// Avoid an infinite loop, if we're on the input it must be the only one (or none)
return;
}
} while((!find->CanFocus()) || (!find->Visible()));
m_focus->SetFocus(false);
m_focus = find;
m_focus->SetFocus(true);
Update();
}
示例2: Update
void Menu::Update(void)
{
if (!IsOnScreen(m_focus))
{
int dir = FindInList(m_topView, m_focus);
if (dir == 0)
{
// Item not in list? Suspicious
return;
}
if (dir < 0)
{
// First, move up until view is visible
do
{
do
{
m_topView = m_topView->m_last;
}
while ((m_topView != NULL) && (!m_topView->Visible()));
}
while (!IsOnScreen(m_focus));
// Second, optionally find top label
Control *label = m_topView->m_last;
while ((label != NULL) && ((!label->Visible()) || label->CanFocus()))
label = label->m_last;
if (label != NULL)
{
Control *minTop = m_topView;
m_topView = label;
if (!IsOnScreen(m_focus))
m_topView = minTop;
}
}
else
{
// Simply move down until item visible
do
{
do
{
m_topView = m_topView->m_next;
}
while (!m_topView->Visible());
}
while (!IsOnScreen(m_focus));
}
}
OnPaint(m_destination);
}