Ejemplo n.º 1
0
void COptionTreeList::CheckVisibleFocus()
{
	// Declare variables
	COptionTreeItem *otiItem;	

	// Validate option
	if (m_otOption == NULL)
	{
		return;
	}
	
	// Get focused item
	otiItem = m_otOption->GetFocusedItem();
	if (otiItem == NULL)
	{
		return;
	}

	// See if item is visible
	if (!m_otOption->IsItemVisible(otiItem))
	{
		// -- Single select
		if (m_otOption->IsSingleSelection())
		{
			otiItem->Select(FALSE);
		}

		// -- Set focus
		m_otOption->SetFocusedItem(NULL);

		// -- Send notify to user
		m_otOption->SendNotify(OT_NOTIFY_SELCHANGE, NULL);

		// -- Force redraw
		Invalidate();

		// -- Update window
		UpdateWindow();
	}
}
Ejemplo n.º 2
0
void COptionTreeList::OnLButtonDblClk(UINT nFlags, CPoint point) 
{
	// Validate option
	if (m_otOption == NULL)
	{
		CWnd::OnLButtonDblClk(nFlags, point);
		return;
	}

	// See if disabled
	if (m_otOption->IsDisableInput() || !m_otOption->IsWindowEnabled())
	{
		CWnd::OnLButtonDblClk(nFlags, point);
		return;
	}

	// Declare variables
	COptionTreeItem *otiItem;
	COptionTreeItem *oliOldFocus;
	CRect rcClient, rcLabel;

	// Send notify to user
	m_otOption->SendNotify(NM_DBLCLK);

	// Get client rect
	GetClientRect(rcClient);

	// Hit test
	if ((otiItem = m_otOption->FindItem(point)) != NULL && otiItem->GetChild())
	{
		switch (m_otOption->HitTest(point))
		{
			case OT_HIT_COLUMN:

				// -- Get largest visible label
				rcLabel = m_otOption->GetLargestVisibleLabel();

				// -- Resize limit
				// -- -- Right
				if (rcLabel.right + OT_SPACE > (rcClient.right - OT_RESIZEBUFFER))
				{
					// -- -- -- Set column
					m_otOption->SetColumn(rcClient.right - OT_RESIZEBUFFER);
				}
				else
				{
					// -- -- -- Set column
					m_otOption->SetColumn(rcLabel.right + OT_SPACE);
				}

				// -- Update move items
				m_otOption->UpdateMoveAllItems();

				// -- Force redraw
				Invalidate();

				// -- Update window
				UpdateWindow();

				break;

			case OT_HIT_ATTRIBUTE:

				if (!otiItem->IsRootLevel())
				{
					break;
				}

			default:
				// -- Get focus item
				oliOldFocus = m_otOption->GetFocusedItem();

				// -- Select items
				m_otOption->SelectItems(NULL, FALSE);

				// -- Set focus item
				m_otOption->SetFocusedItem(otiItem);

				// -- Select
				otiItem->Select();
			
				// -- Send notify to user
				if (otiItem != oliOldFocus)
				{
					m_otOption->SendNotify(OT_NOTIFY_SELCHANGE, otiItem);
				}

			case OT_HIT_EXPAND:

				if (!m_otOption->SendNotify(OT_NOTIFY_ITEMEXPANDING, otiItem))
				{
					// -- Expand
					otiItem->Expand(!otiItem->IsExpanded());

					// -- Update resize
					UpdateResize();

					// -- Force redraw
					Invalidate();

					// -- Update window
					UpdateWindow();

					// -- Check visible
					CheckVisibleFocus();
				}
				break;
		}
	}
	else
	{
		switch (m_otOption->HitTest(point))
		{
			case OT_HIT_COLUMN:

				// -- Get largest visible label
				rcLabel = m_otOption->GetLargestVisibleLabel();

				// -- Resize limit
				// -- -- Right
				if (rcLabel.right + OT_SPACE > (rcClient.right - OT_RESIZEBUFFER))
				{
					// -- -- -- Set column
					m_otOption->SetColumn(rcClient.right - OT_RESIZEBUFFER);
				}
				else
				{
					// -- -- -- Set column
					m_otOption->SetColumn(rcLabel.right + OT_SPACE);
				}

				// -- Update move items
				m_otOption->UpdateMoveAllItems();

				// -- Force redraw
				Invalidate();

				// -- Update window
				UpdateWindow();

				break;
		}
	}

	CWnd::OnLButtonDblClk(nFlags, point);
}
Ejemplo n.º 3
0
void COptionTreeList::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// Validate option
	if (m_otOption == NULL)
	{
		CWnd::OnLButtonDown(nFlags, point);
		return;
	}

	// See if disabled
	if (m_otOption->IsDisableInput() || !m_otOption->IsWindowEnabled())
	{
		CWnd::OnLButtonDown(nFlags, point);
		return;
	}

	// Send notify to user
	m_otOption->SendNotify(NM_CLICK);

	// Declare variables
	long lHit;
	COptionTreeItem *otiItem;
	COptionTreeItem *oliOldFocus;
	CRect rcClient;

	// Get client rectangle
	GetClientRect(rcClient);

	// Set focus to window
	SetFocus();

	// Hit test
	lHit = m_otOption->HitTest(point);
	switch (lHit)
	{
		case OT_HIT_COLUMN:
			
			if (m_otOption->SendNotify(OT_NOTIFY_COLUMNCLICK))
			{
				break;
			}

			// -- Set capture
			m_bColDrag = TRUE;
			SetCapture();

			m_lColumn = m_otOption->GetOrigin().x;

			// -- Force redraw
			Invalidate();

			// -- Update window
			UpdateWindow();

			break;

		case OT_HIT_EXPAND:

			if ((otiItem = m_otOption->FindItem(point)) != NULL)
			{
				if (otiItem->GetChild() && !m_otOption->SendNotify(OT_NOTIFY_ITEMEXPANDING, otiItem))
				{
					// -- Expand
					otiItem->Expand(!otiItem->IsExpanded());

					// -- Update resize
					UpdateResize();

					// -- Force redraw
					Invalidate();

					// -- Update window
					UpdateWindow();

					// -- Check visible
					CheckVisibleFocus();
				}
			}
			break;

		default:

			if ((otiItem = m_otOption->FindItem(point)) != NULL)
			{
				// -- Get old focus
				oliOldFocus = m_otOption->GetFocusedItem();

				// -- Select items
				m_otOption->SelectItems(NULL, FALSE);

				// -- Select
				otiItem->Select();

				// -- Make sure new item
				if (otiItem != oliOldFocus)
				{
					m_otOption->SendNotify(OT_NOTIFY_SELCHANGE, otiItem);
				}

				// -- Send notify
				if (lHit == OT_HIT_ATTRIBUTE && !otiItem->IsRootLevel())
				{
					if (!m_otOption->SendNotify(OT_NOTIFY_PROPCLICK, otiItem) && !otiItem->IsReadOnly())
					{
						otiItem->Activate();
					}
				}

				// -- Set focus item
				m_otOption->SetFocusedItem(otiItem);

				// -- Force redraw
				Invalidate();

				// -- Update window
				UpdateWindow();

			}
			else
			{
				// -- Select items
				m_otOption->SelectItems(NULL, FALSE);

				// -- Set focus item
				m_otOption->SetFocusedItem(NULL);

				// -- Send notify
				m_otOption->SendNotify(OT_NOTIFY_SELCHANGE);

				// -- Force redraw
				Invalidate();

				// -- Update window
				UpdateWindow();
			}
			break;
	}

	CWnd::OnLButtonDown(nFlags, point);
}