示例#1
0
//static
void TBRadioCheckBox::UpdateGroupWidgets(TBWidget *new_leader)
{
	assert(new_leader->GetValue() && new_leader->GetGroupID());

	// Find the group root widget.
	TBWidget *group = new_leader;
	while (group && !group->GetIsGroupRoot() && group->GetParent())
		group = group->GetParent();

	for (TBWidget *child = group; child; child = child->GetNextDeep(group))
		if (child != new_leader && child->GetGroupID() == new_leader->GetGroupID())
			child->SetValue(0);
}
void TBTabContainer::SetCurrentPage(int index)
{
	if (index == m_current_page)
		return;
	m_current_page = index;

	// Update the pages visibility and tabs pressed value.
	index = 0;
	TBWidget *page = m_content_root.GetFirstChild();
	TBWidget *tab = m_tab_layout.GetFirstChild();
	for (   ; page && tab; page = page->GetNext(), tab = tab->GetNext(), index++)
	{
		bool active = index == m_current_page;
		page->SetOpacity(active ? 1.0f : 0.0f);
		tab->SetValue(active ? 1 : 0);
	}
}
void TBTabContainer::SetValue(int index)
{
    if (index == m_current_page || !GetNumPages())
		return;

	m_current_page = index;

	// Update the pages visibility and tabs pressed value.
	index = 0;
	TBWidget *page = m_content_root.GetFirstChild();
	TBWidget *tab = m_tab_layout.GetFirstChild();
	for (   ; page && tab; page = page->GetNext(), tab = tab->GetNext(), index++)
	{
		bool active = index == m_current_page;
		page->SetVisibilility(active ? WIDGET_VISIBILITY_VISIBLE : WIDGET_VISIBILITY_INVISIBLE);
		tab->SetValue(active ? 1 : 0);
	}

    TBWidgetEvent ev(EVENT_TYPE_TAB_CHANGED);
    InvokeEvent(ev);
}