const FSlateBrush* SDetailCategoryTableRow::GetBackgroundImage() const
{
	if (IsHovered())
	{
		return IsItemExpanded() ? FEditorStyle::GetBrush("DetailsView.CategoryTop_Hovered") : FEditorStyle::GetBrush("DetailsView.CollapsedCategory_Hovered");
	}
	else
	{
		return IsItemExpanded() ? FEditorStyle::GetBrush("DetailsView.CategoryTop") : FEditorStyle::GetBrush("DetailsView.CollapsedCategory");
	}
}
void CDragDropTreeCtrl::OnMouseMove(UINT nFlags, CPoint point)
{
    CTreeCtrl::OnMouseMove(nFlags, point);

    if (m_bDragging && m_pImageList != NULL)
    {
        // Stop the scroll timer if it's running.
        KillTimer(1);

        // Erase the old drag image and draw a new one.
        m_pImageList->DragMove(point);

        // Highlight the drop target if the cursor is over an item.
        HTREEITEM hItem = HighlightDropTarget(point);

        // Modify the cursor to provide visual feedback to the user.
        // Note: It's important to do this AFTER the call to DragMove.
        ::SetCursor(hItem == NULL ?
                    AfxGetApp()->LoadStandardCursor(IDC_NO) :
                    (HCURSOR) ::GetClassLongPtr(m_hWnd, GCLP_HCURSOR));

        // Set a timer if the cursor is at the top or bottom of the window,
        // or if it's over a collapsed item.
        CRect rect;
        GetClientRect(rect);
        int cy = rect.Height();

        if ((point.y >= 0 && point.y <= m_nScrollMargin) ||
            (point.y >= cy - m_nScrollMargin && point.y <= cy) ||
            (hItem != NULL && ItemHasChildren(hItem) &&
            !IsItemExpanded(hItem)))

            SetTimer(1, m_nDelayInterval, NULL);
    }
}
EVisibility SDetailCategoryTableRow::IsSeparatorVisible() const
{
	return bIsInnerCategory || IsItemExpanded() ? EVisibility::Collapsed : EVisibility::Visible;
}
void CDragDropTreeCtrl::OnTimer(UINT_PTR nIDEvent)
{
    CTreeCtrl::OnTimer(nIDEvent);

    // Reset the timer.
    SetTimer(1, m_nScrollInterval, NULL);

    // Get the current cursor position and window height.
    DWORD dwPos = ::GetMessagePos();
    CPoint point(LOWORD(dwPos), HIWORD(dwPos));
    ScreenToClient(&point);

    CRect rect;
    GetClientRect(rect);
    int cy = rect.Height();

    // Scroll the window if the cursor is near the top or bottom.
    if (point.y >= 0 && point.y <= m_nScrollMargin)
    {
        HTREEITEM hFirstVisible = GetFirstVisibleItem();
        m_pImageList->DragShowNolock(FALSE);
        SendMessage(WM_VSCROLL, MAKEWPARAM(SB_LINEUP, 0), NULL);
        m_pImageList->DragShowNolock(TRUE);

        // Kill the timer if the window did not scroll, or redraw the
        // drop target highlight if the window did scroll.
        if (GetFirstVisibleItem() == hFirstVisible)
            KillTimer(1);
        else
        {
            HighlightDropTarget(point);
            return;
        }
    }
    else if (point.y >= cy - m_nScrollMargin && point.y <= cy)
    {
        HTREEITEM hFirstVisible = GetFirstVisibleItem();
        m_pImageList->DragShowNolock(FALSE);
        SendMessage(WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN, 0), NULL);
        m_pImageList->DragShowNolock(TRUE);

        // Kill the timer if the window did not scroll, or redraw the
        // drop target highlight if the window did scroll.
        if (GetFirstVisibleItem() == hFirstVisible)
            KillTimer(1);
        else
        {
            HighlightDropTarget(point);
            return;
        }
    }

    // If the cursor is hovering over a collapsed item, expand the tree.
    UINT nFlags;
    HTREEITEM hItem = HitTest(point, &nFlags);

    if (hItem != NULL && ItemHasChildren(hItem) && !IsItemExpanded(hItem))
    {
        m_pImageList->DragShowNolock(FALSE);
        Expand(hItem, TVE_EXPAND);
        m_pImageList->DragShowNolock(TRUE);
        KillTimer(1);
        return;
    }
}
BOOL CTreePropSheetBase::PreTranslateMessage(MSG* pMsg) 
{
  if( pMsg->hwnd == GetPageTreeControl()->GetSafeHwnd() )
  {
    // If not in skipping empty page mode, keep the standard behavior.
    if( !m_bSkipEmptyPages )
      return CPropertySheet::PreTranslateMessage(pMsg);

    if( pMsg->message == WM_KEYDOWN )
    {
      // Get the current tree item.
      HTREEITEM hCurrentItem = m_pwndPageTree->GetSelectedItem();
      if( NULL == hCurrentItem )
        return TRUE;

      if( pMsg->wParam == VK_UP )
      {
        // Active the previous page according to tree ordering - 
        // skipping empty pages on the way.
        ActivatePreviousPage( hCurrentItem );
   	    return TRUE;
      }
      else if ( pMsg->wParam == VK_DOWN )
      {
        // Active the next page according to tree ordering -
        // skipping empty pages on the way.
        ActivateNextPage( hCurrentItem );
  	    return TRUE;
      }
      else if( pMsg->wParam == VK_LEFT )
      {
        /* Here, we try to mimic the tree keyboard handling by doing 
           one of the two things:the following
           - If the tree item is expanded, collapse it
           - If the tree item is collapse, find a parent item that has a page
             associated with it and select it, collapsing all items along the 
             way. */
        if( IsItemExpanded( hCurrentItem ) )
        {
          // Collapse the item since it is expanded.
          m_pwndPageTree->Expand( hCurrentItem, TVE_COLLAPSE );
        }
        else
        {
          // Already collapsed, search for a candidate for selection.
          HTREEITEM hItem = m_pwndPageTree->GetParentItem( hCurrentItem );
          while( NULL != hItem && !HasValidPropertyPageAssociated( hItem ) )
          {
            // Add item to the stack.
            hItem = m_pwndPageTree->GetParentItem( hItem );
          }
          // If the item points to a valid page, select it and collapse 
          if( NULL != hItem && HasValidPropertyPageAssociated( hItem ) )
          {
            m_pwndPageTree->SelectItem( hItem );
          }
        }
        return TRUE;
      }
      else if( pMsg->wParam == VK_RIGHT )
      {
        /* Here, we try to mimic the tree keyboard handling by doing 
           one of the two things:the following
           - If the tree item is collapsed, expand it
           - If the tree item is expanded, find a child item that has a page
             associated with it and select it, expanding all items along the 
             way. The child has to be a first child in the hierarchy. */
        if( IsItemExpanded( hCurrentItem ) )
        {
          // Already expanded, search for a candidate for selection.
          HTREEITEM hItem = m_pwndPageTree->GetChildItem( hCurrentItem );
          while( NULL != hItem && !HasValidPropertyPageAssociated( hItem ) )
          {
            // Add item to the stack.
            hItem = m_pwndPageTree->GetChildItem( hItem );
          }
          // If the item points to a valid page, select it and collapse 
          if( NULL != hItem && HasValidPropertyPageAssociated( hItem ) )
          {
            m_pwndPageTree->SelectItem( hItem );
          }
        }
        else
        {
          // Expand the item since it is collapsed.
          m_pwndPageTree->Expand( hCurrentItem, TVE_EXPAND );
        }
        return TRUE;
      }
    }
  }
  else if( WM_ENABLE == pMsg->message)
  {
    // Handle WM_ENABLE messages for property pages: Update the property page
    // information map.
    TRACE("");

  }

	return CPropertySheet::PreTranslateMessage(pMsg);
}