//static
void TBRadioCheckBox::ToggleGroup(TBWidget *root, TBWidget *toggled)
{
	if (root != toggled && root->GetGroupID() == toggled->GetGroupID())
		root->SetValue(0);
	for (TBWidget *child = root->GetFirstChild(); child; child = child->GetNext())
		ToggleGroup(child, toggled);
}
Exemple #2
0
/// Left-click
void InstanceCtrl::OnLeftClick(wxMouseEvent& event)
{
	SetFocus();
	VisualCoord clickedIndex;
	HitTest(event.GetPosition(), clickedIndex);
	if(clickedIndex.isItem())
	{
		int flags = 0;
		if (event.ControlDown())
			flags |= wxINST_CTRL_DOWN;
		if (event.ShiftDown())
			flags |= wxINST_SHIFT_DOWN;
		if (event.AltDown())
			flags |= wxINST_ALT_DOWN;
			
		EnsureVisible(clickedIndex);
		DoSelection(clickedIndex);
		SetIntendedColumn(clickedIndex);
	}
	else if(clickedIndex.isHeaderTicker())
	{
		ToggleGroup(clickedIndex.groupIndex);
	}
	else ClearSelections();
}
Exemple #3
0
/// Left-double-click
void InstanceCtrl::OnLeftDClick(wxMouseEvent& event)
{
	VisualCoord clickedIndex;
	HitTest(event.GetPosition(), clickedIndex);
	if (clickedIndex.isItem())
	{
		int flags = 0;
		if (event.ControlDown())
			flags |= wxINST_CTRL_DOWN;
		if (event.ShiftDown())
			flags |= wxINST_SHIFT_DOWN;
		if (event.AltDown())
			flags |= wxINST_ALT_DOWN;
			
		InstanceCtrlEvent cmdEvent(
		    wxEVT_COMMAND_INST_ACTIVATE,
		    GetId());
		cmdEvent.SetEventObject(this);
		cmdEvent.SetItemIndex(clickedIndex);
		int clickedID = IDFromIndex(clickedIndex);
		cmdEvent.SetItemID(clickedID);
		cmdEvent.SetFlags(flags);
		cmdEvent.SetPosition(event.GetPosition());
		GetEventHandler()->ProcessEvent(cmdEvent);
	}
	else if(clickedIndex.isHeader())
	{
		ToggleGroup(clickedIndex.groupIndex);
	}
}
Exemple #4
0
BOOL CDXCtrlTreeview::OnLeftButtonDown(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	DWORD dwIndex;
	DWORD dwCurTime;

	if(IsVisible() && HitTest(LOWORD(lParam), HIWORD(lParam)))
	{
		dwIndex = GetClickedIndex(LOWORD(lParam), HIWORD(lParam));
		if(dwIndex != -1 && dwIndex == m_dwSelectedIndex)
			ToggleGroup(dwIndex);
		m_dwSelectedIndex = dwIndex;
		SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(m_dwId, LBN_SELCHANGE), (LPARAM)this);
		m_pManager->Redraw();
		
		
		dwCurTime = GetTickCount();
		if(m_dwLastClickPos == (DWORD)lParam && dwCurTime - m_dwLastClickTime < 1000)
		{
			SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(m_dwId, LBN_DBLCLK), (LPARAM)this);
			m_dwLastClickTime = 0;
		}
		else
			m_dwLastClickTime = dwCurTime;
		m_dwLastClickPos = (DWORD)lParam;
		
		return TRUE;
	}
	return FALSE;
}
void TBRadioCheckBox::SetValue(int value)
{
	if (m_value == value)
		return;
	m_value = value;

	SetState(WIDGET_STATE_SELECTED, value ? true : false);

	Invalidate();
	TBWidgetEvent ev(EVENT_TYPE_CHANGED);
	InvokeEvent(ev);

	if (!value || !GetGroupID())
		return;
	// Toggle all other widgets in the same group. First get a root widget
	// for the search.
	TBWidget *group = this;
	while (group && !group->GetIsGroupRoot())
		group = group->GetParent();
	if (group)
	{
		ToggleGroup(group, this);
	}
}