Exemplo n.º 1
0
void CDropListBox::OnMouseMove(UINT nFlags, CPoint point) 
{
	//
	// Is mouse within listbox
	CRect rcClient;
	GetClientRect( rcClient );
	if( !rcClient.PtInRect( point ) )
	{
		ReleaseCapture();
		GetParent()->SendMessage( WM_VRC_SETCAPTURE );
	}

	//
	// Set selection item under mouse
	int nPos = point.y / GetItemHeight(0) + GetTopIndex();
	PLIST_ITEM pItem = (PLIST_ITEM)GetItemDataPtr(nPos);
	if( (DWORD)pItem != -1 )
	{
		if( GetCurSel() != nPos && !pItem->bDisabled )
		{
			SetCurSel( nPos );
		}
	}

	//
	// Check if we have autoscrolled
	if( m_nLastTopIdx != GetTopIndex() )
	{
		int nDiff = m_nLastTopIdx - GetTopIndex();
		m_nLastTopIdx = GetTopIndex();

		SCROLLINFO info;
		info.cbSize = sizeof(SCROLLINFO);
		if( m_pScroll->GetScrollInfo( &info, SIF_ALL|SIF_DISABLENOSCROLL ) )
		{
			info.nPos = m_nLastTopIdx;
			m_pScroll->SetScrollInfo( &info );
		}
	}


//	OutputDebugString( "DropListBox MouseMove\n" );

	CListBox::OnMouseMove(nFlags, point);

}
Exemplo n.º 2
0
void CCheckListBox::MouseSelect(UINT nFlags, CPoint point)
{
	int nTopIndex = GetTopIndex();

	if (GetCapture() == this)
	{
		CRect crClient;
		GetClientRect(crClient);
		
		int nIndex = Index(point);
		
		if (nIndex >= 0)
		{
			if (nIndex != m_nCurrent)
			{
				int nItem = m_nCurrent;
				
				while (nItem != nIndex)
				{
					if (nItem < nIndex)
					{
						nItem++;
					}
					else
					{
						nItem--;
					}
					
					Select(nItem, m_fMark, TRUE);
				}

				UpdateWindow();
				
				SetCurSel(nIndex);
				m_nCurrent = nIndex;
				
#ifdef WIN32
				GetParent()->SendMessage(WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(), LBN_SELCHANGE), (LPARAM)GetSafeHwnd());
#else
				GetParent()->SendMessage(WM_COMMAND, GetDlgCtrlID(), MAKELPARAM(GetSafeHwnd(), LBN_SELCHANGE));
#endif
			}
		}
	}
	m_fScrolling = (GetTopIndex() != nTopIndex);
}
Exemplo n.º 3
0
int CDropListBox::GetBottomIndex()
{
	int nTop = GetTopIndex();
	CRect rc;
	GetClientRect( &rc );
	int nVisCount = rc.Height() / GetItemHeight(0);
	return nTop + nVisCount;
}
Exemplo n.º 4
0
BOOL CDomainListBox::SelectAndShowItem( int nSel )
{
	int	nPageCount	=	GetCountPerPage( );

	SelectItem( nSel, TRUE );
	int nTopIndex = GetTopIndex();
	if( LB_ERR != nTopIndex && nTopIndex+nPageCount<nSel )
		SetTopIndex( nSel-nPageCount );
	return TRUE;
}
Exemplo n.º 5
0
void CDropListBox::OnMouseMove(UINT nFlags, CPoint point) 
{
	//
	// Is mouse within listbox
	CRect rcClient;
	GetClientRect( rcClient );
	if( !rcClient.PtInRect( point ) )
	{
		ReleaseCapture();
		GetParent()->SendMessage( WM_VRC_SETCAPTURE );
	}

	//
	// Set selection item under mouse
	int nPos = PointTest(point);
	PLIST_ITEM pItem = (PLIST_ITEM)GetItemDataPtr(nPos);
	if( nPos != LB_ERR && (DWORD)pItem != -1 && pItem != NULL)
	{
		if( GetCurSel() != nPos && !(pItem->state & ACBIS_DISABLED) )
		{
			SetCurSel( nPos );
		}
	}

	//
	// Check if we have auto scrolled
	if( m_nLastTopIdx != GetTopIndex() )
	{
		int nDiff = m_nLastTopIdx - GetTopIndex();
		m_nLastTopIdx = GetTopIndex();

		SCROLLINFO info;
		info.cbSize = sizeof(SCROLLINFO);
		if( m_pDropWnd->GetScrollBarPtr()->GetScrollInfo( &info, SIF_ALL|SIF_DISABLENOSCROLL ) )
		{
			info.nPos = m_nLastTopIdx;
			m_pDropWnd->GetScrollBarPtr()->SetScrollInfo( &info );
		}
	}

	CListBox::OnMouseMove(nFlags, point);
}
Exemplo n.º 6
0
//
/// Refresh the window.
//
void
TCheckList::Update()
{
  int topIndex = GetTopIndex();
  int selIndex = GetSelIndex();
  SendMessage(WM_SETREDRAW, false);
  Invalidate();
  SetTopIndex(topIndex);
  if (selIndex != LB_ERR)
    SetSelIndex(selIndex);
  SendMessage(WM_SETREDRAW, true);
}
Exemplo n.º 7
0
void CEditView::GetCharBoundingRect( int nCol, int nRow, LPRECT prcChar ) const
{
	int nViewCol = m_pBuffer->ConvertBufferColToViewCol( nRow, nCol );
	int cyLine = GetLineHeight();
	prcChar->top = m_rcAll.top + ( nRow - GetTopIndex() ) * cyLine;
	prcChar->bottom = prcChar->top + cyLine;
	int cxChar = GetCharWidth();
	prcChar->left = m_rcAll.left + GetLeftMargin( TRUE, TRUE ) + ( nViewCol - GetLeftIndex() ) * cxChar;
	// for tabs, we want to expand the rect to represent the entire expanded width, not just one char's worth
	int cbChar = m_pBuffer->GetCharSize( nRow, nCol );
	prcChar->right = prcChar->left + cxChar * ( m_pBuffer->ConvertBufferColToViewCol( nRow, nCol + cbChar ) - nViewCol );
}
Exemplo n.º 8
0
int CListCtrlA::CellRectFromPoint(CPoint & point, RECT * cellrect, int * col) const{
	int colnum;

	// Make sure that the ListView is in LVS_REPORT
	if( (GetWindowLong(m_hWnd, GWL_STYLE) & LVS_TYPEMASK) != LVS_REPORT )
		return -1;

	// Get the top and bottom row visible
	int row = GetTopIndex();
	int bottom = row + GetCountPerPage();
	if( bottom > GetItemCount() )
		bottom = GetItemCount();
	
	// Get the number of columns
	CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
	int nColumnCount = pHeader->GetItemCount();

	// Loop through the visible rows
	for( ;row <=bottom;row++)
	{
		// Get bounding rect of item and check whether point falls in it.
		CRect rect;
		GetItemRect( row, &rect, LVIR_BOUNDS );
		if( rect.PtInRect(point) )
		{
			// Now find the column
			for( colnum = 0; colnum < nColumnCount; colnum++ )
			{
				int colwidth = GetColumnWidth(colnum);
				if( point.x >= rect.left 
					&& point.x <= (rect.left + colwidth ) )
				{
					RECT rectClient;
					GetClientRect( &rectClient );
					if( col ) *col = colnum;
					rect.right = rect.left + colwidth;

					// Make sure that the right extent does not exceed
					// the client area
					if( rect.right > rectClient.right ) 
						rect.right = rectClient.right;
					*cellrect = rect;
					return row;
				}
				rect.left += colwidth;
			}
		}
	}
	return -1;
}
Exemplo n.º 9
0
int 
CListCtrlEx::HitTestEx (CPoint& Point, int* pColumn)
{
    int ColumnNum = 0;
    int Row = HitTest (Point, NULL);
    
    if (pColumn)
		*pColumn = 0;

    // Make sure that the ListView is in LVS_REPORT
    if ((GetWindowLong (m_hWnd, GWL_STYLE) & LVS_TYPEMASK) != LVS_REPORT)
		return Row;

    // Get the top and bottom row visible
    Row = GetTopIndex();
    int Bottom = Row + GetCountPerPage();
    if (Bottom > GetItemCount())
	    Bottom = GetItemCount();
    
    // Get the number of columns
    CHeaderCtrl* pHeader = (CHeaderCtrl*) GetDlgItem(0);
    int nColumnCount = pHeader->GetItemCount();

    // Loop through the visible rows
    for(; Row <= Bottom; Row++)
    {
		// Get bounding rect of item and check whether point falls in it.
		CRect Rect;
		GetItemRect (Row, &Rect, LVIR_BOUNDS);
		if (Rect.PtInRect (Point))
		{
			// Now find the column
			for (ColumnNum = 0; ColumnNum < nColumnCount; ColumnNum++)
			{
				int ColWidth = GetColumnWidth (ColumnNum);
				if (Point.x >= Rect.left && Point.x <= (Rect.left + ColWidth))
				{
					if (pColumn)
						*pColumn = ColumnNum;
					return Row;
				}
				Rect.left += ColWidth;
			}
		}
    }
    return -1;
}
Exemplo n.º 10
0
int CListCtrlEx::CellRectFromPoint(CPoint& point, CRect* pRectCell, int* pCol) const
{
    if((::GetWindowLong(m_hWnd, GWL_STYLE) & LVS_TYPEMASK) != LVS_REPORT )
	   return -1;

    int nRow = GetTopIndex();
    int nBottom = nRow + GetCountPerPage();
    if(nBottom > GetItemCount())
		nBottom = GetItemCount();
        
    CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
    int nColumnCount = pHeader->GetItemCount();

    for(; nRow <= nBottom; nRow++)
    {
        CRect rect;
        GetItemRect(nRow, &rect, LVIR_BOUNDS);
        if(rect.PtInRect(point))
        {
			for(int nColumn = 0; nColumn < nColumnCount; nColumn++)
			{
				int nColWidth = GetColumnWidth(nColumn);
				if(point.x >= rect.left && point.x <= (rect.left + nColWidth))
				{
					CRect rectClient;
					GetClientRect(&rectClient);
					if(pCol)
						*pCol = nColumn;
					
					rect.right = rect.left + nColWidth;

					if(rect.right > rectClient.right) 
						rect.right = rectClient.right;
					
					*pRectCell = rect;
					
					return nRow;
				}

				rect.left += nColWidth;
			}
		}
	}

	return -1;
}
Exemplo n.º 11
0
// HitTestEx	- Determine the row index and column index for a point
// Returns	- the row index or -1 if point is not over a row
// point	- point to be tested.
// col		- to hold the column index
int CVarListCtrl::HitTestEx(CPoint &point, int *col) const
{
	int colnum = 0;
	int row = HitTest( point, NULL );
	
	if( col ) *col = 0;

	// Make sure that the ListView is in LVS_REPORT
	if( (GetWindowLong(m_hWnd, GWL_STYLE) & LVS_TYPEMASK) != LVS_REPORT )
		return row;

	// Get the top and bottom row visible
	row = GetTopIndex();
	int bottom = row + GetCountPerPage();
	if( bottom > GetItemCount() )
		bottom = GetItemCount();
	
	// Get the number of columns
	CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
	int nColumnCount = pHeader->GetItemCount();

	// Loop through the visible rows
	for( ;row <=bottom;row++)
	{
		// Get bounding rect of item and check whether point falls in it.
		CRect rect;
		GetItemRect( row, &rect, LVIR_BOUNDS );
		if( rect.PtInRect(point) )
		{
			// Now find the column
			for( colnum = 0; colnum < nColumnCount; colnum++ )
			{
				int colwidth = GetColumnWidth(colnum);
				if( point.x >= rect.left 
					&& point.x <= (rect.left + colwidth ) )
				{
					if( col ) *col = colnum;
					return row;
				}
				rect.left += colwidth;
			}
		}
	}
	return -1;
}
Exemplo n.º 12
0
void SListBox::OnPaint(IRenderTarget * pRT)
{
    SPainter painter;
    BeforePaint(pRT,painter);

    int iFirstVisible = GetTopIndex();
    int nPageItems = (m_rcClient.Height()+m_nItemHei-1)/m_nItemHei+1;

    for(int iItem = iFirstVisible; iItem<GetCount() && iItem <iFirstVisible+nPageItems; iItem++)
    {
        CRect rcItem(0,0,m_rcClient.Width(),m_nItemHei);
        rcItem.OffsetRect(0,m_nItemHei*iItem-m_ptOrigin.y);
        rcItem.OffsetRect(m_rcClient.TopLeft());
        DrawItem(pRT,rcItem,iItem);
    }

    AfterPaint(pRT,painter);
}
Exemplo n.º 13
0
void CDuiListBox::OnPaint(CDCHandle dc)
{
    DuiDCPaint duiDC;
    BeforePaint(dc,duiDC);

    int iFirstVisible = GetTopIndex();
    int nPageItems = (m_rcClient.Height()+m_nItemHei-1)/m_nItemHei+1;

    for(int iItem = iFirstVisible; iItem<GetCount() && iItem <iFirstVisible+nPageItems; iItem++)
    {
        CRect rcItem(0,0,m_rcClient.Width(),m_nItemHei);
        rcItem.OffsetRect(0,m_nItemHei*iItem-m_ptOrigin.y);
        rcItem.OffsetRect(m_rcClient.TopLeft());
        DrawItem(dc,rcItem,iItem);
    }

    AfterPaint(dc,duiDC);
}
Exemplo n.º 14
0
int CMyListCtrl::GetRowFromPoint(CPoint &point, CRect *rcCell, int *nCol) const
{
	int   nColumn, nRow, nBottom, nWidth;
    CRect rcItem, rcClient;

	// ListCtrl이 LVS_REPORT 타입인 지 확인
	if((GetWindowLong(m_hWnd, GWL_STYLE) & LVS_TYPEMASK) != LVS_REPORT) return -1;

	// 눈에 보이는 처음과 끝의 Row 값을 얻는다
	nRow    = GetTopIndex();
	nBottom = nRow + GetCountPerPage();
	if(nBottom > GetItemCount())
		nBottom = GetItemCount();

    // 보이는 Row만큼 루프를 돈다
	for(; nRow <= nBottom ; nRow++)
	{
		GetItemRect(nRow, &rcItem, LVIR_BOUNDS);
		if(rcItem.PtInRect(point))
		{
			// Column을 찾는다
			for(nColumn = 0 ; nColumn < m_nColumnCount ; nColumn++)
			{
				nWidth = GetColumnWidth(nColumn);
				if(point.x >= rcItem.left && 
                   point.x <= (rcItem.left + nWidth))
				{
					GetClientRect(&rcClient);
					if(nCol)
                        *nCol = nColumn;
					rcItem.right = rcItem.left + nWidth;

					// 오른쪽 끝이 클라이언트 영역을 벗어나지 않게
					if(rcItem.right > rcClient.right) 
						rcItem.right = rcClient.right;
					*rcCell = rcItem;
					return nRow;
				}
				rcItem.left += nWidth;
			}
		}
	}
	return -1;
}
	int FilterListCtrl::GetBottomIndex() const
	{
		CRect r;
		GetClientRect(r);

		int nBottomIndex = GetTopIndex() + GetCountPerPage() - 1;

		if (nBottomIndex >= GetItemCount()) {
			nBottomIndex = GetItemCount() - 1;
		} else 
		if (nBottomIndex < GetItemCount()) {
			CRect br;
			GetItemRect(nBottomIndex, br, LVIR_BOUNDS);

			if (br.bottom < r.bottom) nBottomIndex++;
		}

		return(nBottomIndex);
	}
Exemplo n.º 16
0
BOOL CDropListBox::Expand(PLIST_ITEM pItem, UINT nCode)
{
	if(pItem == NULL)
	{
		return FALSE;
	}

	BOOL bResult = FALSE;
	if(nCode == LBE_COLLAPSE)
	{
		bResult = Collapse(pItem);
	}
	else if(nCode == LBE_EXPAND)
	{
		bResult = Expand(pItem);
	}
	else if(nCode == LBE_TOGGLE)
	{
		if(pItem->state & ACBIS_COLLAPSED)
		{
			bResult = Expand(pItem);
		}
		else
		{
			bResult = Collapse(pItem);
		}
	}

	if(bResult)
	{
		SCROLLINFO info;
		info.cbSize = sizeof(SCROLLINFO);
		if( m_pDropWnd->GetScrollBarPtr()->GetScrollInfo( &info, SIF_ALL|SIF_DISABLENOSCROLL ) )
		{
			info.nPage = GetBottomIndex() - GetTopIndex();
			info.nMax = GetCount()-1;
			info.nMin = 0;
			m_pDropWnd->GetScrollBarPtr()->SetScrollInfo( &info );
		}
	}
	return bResult;
}
Exemplo n.º 17
0
int CDropListBox::GetBottomIndex()
{
	int nTop = GetTopIndex();
	if(nTop == LB_ERR)
	{
		return LB_ERR;
	}
	CRect rc;
	GetClientRect( &rc );

	int nBottomIndex = LB_ERR;
	//variable height
	if((GetStyle() & LBS_OWNERDRAWVARIABLE) == LBS_OWNERDRAWVARIABLE)
	{
		int i, nHeight, nCount = GetCount(), nTotalHeight = 0;
		for(i = nTop; i < nCount; i++)
		{
			if((nHeight = GetItemHeight(i)) == LB_ERR)
			{
				ASSERT(FALSE);
				break;
			}
			nTotalHeight += nHeight;
			if(nTotalHeight > rc.Height())
			{
				break;
			}
		}
		nBottomIndex = i;
	}
	else
	{
		int nVisCount = rc.Height() / GetItemHeight(0);
		nBottomIndex = nTop + nVisCount;
		if(nBottomIndex > GetCount())
		{
			nBottomIndex = GetCount();
		}
	}
	//AfxTrace(_T("GetBottomIndex=%d\n"), nBottomIndex);
	return nBottomIndex;
}
Exemplo n.º 18
0
void CListCtrlEx::OnPaint()
{
  int i;
  int Top = GetTopIndex();
  int Total = GetItemCount();
  int PerPage = GetCountPerPage();
  int Last = ((Top+PerPage) > Total)? Total : Top+PerPage;
  int Count = m_ProgressList.GetSize();
  CProgressCtrl* pCtrl;
  if ((Last-Top) > Count)
  {
    for (i = Count; i < Last-Top; i++)
    {
      pCtrl = new CProgressCtrl();
      CRect rt(1,1,1,1);
      pCtrl->Create(NULL, rt, this, IDC_PROGRESS_LIST+i);
      m_ProgressList.Add(pCtrl);
    }
  }
  
  CHeaderCtrl* pHeader = GetHeaderCtrl();
  for (i = Top; i < Last; i++)
  {
    CRect ColRt;
    pHeader->GetItemRect(m_ProgressColumn, &ColRt);
    
    CRect rt;
    GetItemRect(i, &rt, LVIR_LABEL);
    rt.top += 1;
    rt.bottom -= 1;
    rt.left += ColRt.left;
    rt.right = rt.left + ColRt.Width() - 4;
    
    pCtrl = m_ProgressList.GetAt(i-Top);
    CString strPercent = GetItemText(i, m_ProgressColumn);
    int nPercent = atoi(strPercent);
    pCtrl->SetPos(nPercent);
    pCtrl->MoveWindow(&rt);
    pCtrl->ShowWindow(SW_SHOWNORMAL);
  }
  CListCtrl::OnPaint();
}
Exemplo n.º 19
0
void CEditableListCtrl::VerifyScrollPos()
{
	int nTopRowVal = GetTopIndex();
	int nBottomVal = nTopRowVal + GetCountPerPage();
	if (m_iRow > nTopRowVal-1 && m_iRow < nBottomVal+1)
		;
	else
	{
		if (m_iRow < nTopRowVal)
		{
			for (int j = 0; j < -m_iRow + nTopRowVal; j++)
				SendMessage(WM_VSCROLL, SB_LINEUP, 0);
		}
		if (m_iRow > nBottomVal)
		{
			for (int j = 0; j < m_iRow - nTopRowVal; j++)
				SendMessage(WM_VSCROLL, SB_LINEDOWN, 0);
		}
	}
}
Exemplo n.º 20
0
void SListBox::RedrawItem(int iItem)
{
    if(!IsVisible(TRUE)) return;

    CRect rcClient;
    GetClientRect(&rcClient);
    int iFirstVisible = GetTopIndex();
    int nPageItems=(rcClient.Height()+m_nItemHei-1)/m_nItemHei+1;

    if(iItem>=iFirstVisible && iItem<GetCount() && iItem<iFirstVisible+nPageItems)
    {
        CRect rcItem(0,0,rcClient.Width(),m_nItemHei);
        rcItem.OffsetRect(0,m_nItemHei*iItem-m_ptOrigin.y);
        rcItem.OffsetRect(rcClient.TopLeft());
        IRenderTarget *pRT=GetRenderTarget(&rcItem,OLEDC_PAINTBKGND);

        SSendMessage(WM_ERASEBKGND,(WPARAM)(HDC)pRT);
        DrawItem(pRT,rcItem,iItem);

        ReleaseRenderTarget(pRT);
    }
}
Exemplo n.º 21
0
int CClickList::HitTestEx(const CPoint &Point, int &Col) const
{
	Col = 0;

    // Make sure that the ListView is in LVS_REPORT
    if (LVS_REPORT != (GetWindowLong(m_hWnd, GWL_STYLE) & LVS_TYPEMASK))
		return HitTest(Point, NULL);

    // Get the top and bottom row visible
    int row = GetTopIndex();
    int bottom = row + GetCountPerPage();
    if (bottom > GetItemCount())
		bottom = GetItemCount();
    
    // Get the number of columns
    CHeaderCtrl *pHeader = const_cast<CClickList *>(this)->GetHeaderCtrl();
	if (NULL == pHeader)
		return -1;

    // Loop through the visible rows
	CRect rect;
	int nColumnCount = pHeader->GetItemCount(), colnum, colwidth;
    for (; row <= bottom; row++) {
		// Get bounding rect of item and check whether point falls in it.
		GetItemRect(row, &rect, LVIR_BOUNDS);

		if (rect.PtInRect(Point)) // Now find the column
			for (colnum = 0; colnum < nColumnCount; colnum++) {
				colwidth = GetColumnWidth(colnum);
				if (Point.x >= rect.left && Point.x <= rect.left + colwidth) {
					Col = colnum;
					return row;
				}
				rect.left += colwidth;
			}
    }

    return -1;
}
Exemplo n.º 22
0
/* Return the item index of the point locate in */
int CDropListBox::PointTest(CPoint point)
{
	int i = GetTopIndex(), nCount = GetCount(), nResult;
	if(i == LB_ERR)
	{
		return LB_ERR;
	}

	CRect rect;
	for(; i < nCount; i++)
	{
		if((nResult = GetItemRect(i, &rect)) == LB_ERR)
		{
			return LB_ERR;
		}
		if(PtInRect(&rect, point))
		{
			return i;
		}
	}
	return LB_ERR;
}
Exemplo n.º 23
0
void CSCWListCtrl::UpdateRowHeight(bool bInvalidate){
  // We need to change WINDOWPOS to trigger MeasureItem 
  // http://www.codeproject.com/Articles/1401/Changing-Row-Height-in-an-owner-drawn-Control
  CRect rc;
  GetWindowRect(&rc);
  WINDOWPOS wp;
  wp.hwnd = m_hWnd;
  wp.cx = rc.Width();
  wp.cy = rc.Height();
  wp.flags = SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER;
  
  //Add LVS_OWNERDRAWFIXED style for generating MeasureItem event
  ModifyStyle(0, LVS_OWNERDRAWFIXED);

  SendMessage(WM_WINDOWPOSCHANGED, 0, (LPARAM)&wp);
  if (bInvalidate)
  {
    Invalidate();
    int idx = GetTopIndex();
    if (idx >=0)
      EnsureVisible(idx, FALSE);
  }
}
int COXAutoListBox::GetItemFromPoint(POINT pt)
{
	CRect rct;
	GetClientRect(&rct);

	
	if (rct.PtInRect(pt))
	{
		int nTop=GetTopIndex();
		
		int nCount=rct.Height()/GetItemHeight(nTop);
		for (int n=nTop;n<nTop+nCount;n++)
		{
			//find  hot item to select
			GetItemRect(n,&rct);
			if (rct.PtInRect(pt))
				return n;
		
		}
	}
	return -1;

}
Exemplo n.º 25
0
BOOL CSchemaCombo::OnClickItem(int nItem, BOOL bDown)
{
	if ( nItem > 0 && GetItemData( nItem ) == 0 )
	{
		if ( bDown )
		{
			int nOldTop = GetTopIndex();
			int nDelta = ( nOldTop != CB_ERR && nItem > nOldTop ) ? ( nItem - nOldTop ) : 0;
			DeleteString( nItem );
			Load( m_sPreDrop, m_nType, CSchema::saMax, FALSE );
			int nCurSel = GetCurSel();
			if ( nCurSel != CB_ERR )
			{
				if ( nCurSel >= nDelta )
				{
					SetTopIndex( nCurSel - nDelta );
				}
				SetCurSel( nCurSel );
			}
		}
		return TRUE;
	}
	return FALSE;
}
Exemplo n.º 26
0
int CPlayerListCtrl::HitTestEx(const CPoint& point, int* col) const
{
    if (col) {
        *col = 0;
    }

    int row = HitTest(CPoint(0, point.y), nullptr);

    if ((GetWindowLongPtr(m_hWnd, GWL_STYLE) & LVS_TYPEMASK) != LVS_REPORT) {
        return row;
    }

    int nColumnCount = ((CHeaderCtrl*)GetDlgItem(0))->GetItemCount();

    for (int top = GetTopIndex(), bottom = GetBottomIndex(); top <= bottom; top++) {
        CRect r;
        GetItemRect(top, &r, LVIR_BOUNDS);

        if (r.top <= point.y && point.y < r.bottom) {
            for (int colnum = 0; colnum < nColumnCount; colnum++) {
                int colwidth = GetColumnWidth(colnum);

                if (point.x >= r.left && point.x <= (r.left + colwidth)) {
                    if (col) {
                        *col = colnum;
                    }
                    return top;
                }

                r.left += colwidth;
            }
        }
    }

    return -1;
}
Exemplo n.º 27
0
// **************************************************************************
// HitTestEx ()
//
// Description:
//	Determine which item or subitem was hit.
//
// Parameters:
//  CPoint		&cPoint		Current locaction of mouse cursor
//	int			*pCol		Gets set to column hit was in.
//
// Returns:
//  int - Row hit was in, or -1 if hit was not on a cell.
// **************************************************************************
int CKListEditCtrl::HitTestEx (CPoint &cPoint, int *pCol)
	{	
	int nCol = 0;
	int nRow = HitTest (cPoint, NULL);		
	int nBottom = 0;
	int cnColumns = 0;
	
	// Initialize returned column number to zero:
	if (pCol) 
		*pCol = 0;

	// Make sure that the ListView is in LVS_REPORT format:
	if ((GetWindowLong (m_hWnd, GWL_STYLE) & LVS_TYPEMASK) != LVS_REPORT)
		return (nRow);	
	
	// Get the top and bottom visible rows:
	nRow = GetTopIndex ();
	nBottom = nRow + GetCountPerPage ();	
	
	// Make sure bottom index is valid:
	if (nBottom > GetItemCount ())
		nBottom = GetItemCount ();		
	
	// Get the number of columns:
	CHeaderCtrl* pHeader = (CHeaderCtrl*) GetDlgItem (0);
	cnColumns = pHeader->GetItemCount ();	

	// Determine which row the hit occurred:
	for (; nRow <= nBottom; nRow++)	
		{
		// Get bounding rect of item:
		CRect rect;
		GetItemRect (nRow, &rect, LVIR_BOUNDS);		
		
		// Check to see if the point falls in bounds of that row:
		if (rect.PtInRect (cPoint))		
			{
			// Hit was in this row.  Now find the column:
			for (nCol = 0; nCol < cnColumns; nCol++)
				{				
				int nColWidth = GetColumnWidth (nCol);				
				
				// If hit is within this column, return:
				if (cPoint.x >= rect.left && cPoint.x <= (rect.left + nColWidth))				
					{					
					if (pCol) 
						*pCol = nCol;

					return (nRow);				
					}				
				
				// Adjust left side of row's rectangle so we will look at 
				// next column ntext time around loop:
				rect.left += nColWidth;			
				}		
			}	
		}

	// If we make it here, then the hit was not on a cell.  Return -1
	// to indicate failure:
	return (-1);
	}
Exemplo n.º 28
0
//---------------------------------------------------------------------------
intptr_t TSessionLog::GetBottomIndex() const
{
  return (GetCount() > 0 ? (GetTopIndex() + GetCount() - 1) : -1);
}
Exemplo n.º 29
0
//*****************************************************************************
//
// Function Name: RGridCtrl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
//
// Description:   Message handler for WM_KEYDOWN.
//
// Returns:		   None
//
// Exceptions:	   None
//
//*****************************************************************************
void RGridCtrlBase::OnKeyDown(UINT nChar, UINT, UINT) 
{
	int nCurSel = GetCurSel() ;

	int nRowOffset = 0 ;
	int nColOffset = 0 ;

	int nCurRow = nCurSel / m_nNumCols ;
	int nCurCol = nCurSel % m_nNumCols ;

	switch (nChar)
	{
	case VK_UP:
		nRowOffset = -1;
		break ;

	case VK_DOWN:
		nRowOffset = 1 ;
		break ;

	case VK_LEFT:
		nColOffset = -1 ;
		break ;

	case VK_RIGHT:
		nColOffset = 1 ;
		break ;

	case VK_PRIOR:
		nRowOffset = -m_cxVisibleRows ;
		break ;

	case VK_HOME:
		nRowOffset = -nCurRow ;
		nColOffset = -nCurCol ;
		break ;

	case VK_NEXT:
		nRowOffset = m_cxVisibleRows ;
		break ;

	case VK_END:
		nRowOffset = GetCount() / m_nNumCols - nCurRow ;
		nColOffset = GetCount() % m_nNumCols - nCurCol ;
		break ;

	default:

		// See if we're suppose to send it off to the parent
		if (GetStyle() & LBS_WANTKEYBOARDINPUT)
		{
			VKeyToItem( nChar, GetCurSel() ) ;
		}

		return ;
	}

	if (nCurSel < 0)
	{
		//
		// If there was no previously selected item, default
		// to the first item in the list.
		//

		nCurRow = nCurCol = 0 ;
		nRowOffset = nColOffset = 0 ;
	}
	else
	{
		//
		// Determine the new row and column, making sure to
		// keep them within bounds
		//

		nCurRow += nRowOffset ;
		nCurRow = max( 0, min( nCurRow, GetCount() / m_nNumCols ) ) ;
		
		nCurCol += nColOffset ;
		nCurCol = max( 0, min( nCurCol, m_nNumCols - 1 ) ) ;

		if (nCurRow == GetCount() / m_nNumCols)
		{
			nCurCol = min( nCurCol, GetCount() % m_nNumCols - 1 ) ;
		}
	}

	int nNewSel = nCurRow * m_nNumCols + nCurCol ;

	if (nNewSel != nCurSel)
	{

		if (nCurRow < m_nTopCellRow || nCurRow >= m_nTopCellRow + m_cxVisibleRows ||
			 nCurCol < m_nTopCellCol || nCurCol >= m_nTopCellCol + m_cxVisibleCols)
		{
			SetTopIndex( max( 0, GetTopIndex() + (nNewSel - nCurSel) )) ;
		}

		SetCurSel( nNewSel ) ;

		if (GetStyle() & LBS_NOTIFY)
		{
			GetParent()->PostMessage(WM_COMMAND,
				MAKEWPARAM( GetDlgCtrlID(), LBN_SELCHANGE ), 
				(LPARAM) GetSafeHwnd()) ;
		}
	}
}
Exemplo n.º 30
0
int CResizableComboBox::MakeIntegralHeight(const int height)
{
    int inth = height;  // integral height (result)
    int availh = height;    // available height
    int n = GetCount();

    DWORD dwStyle = GetStyle();

    if (!m_bIntegralHeight || n == 0)
        return inth;

    if (dwStyle & CBS_OWNERDRAWVARIABLE)
    {
        inth = 0;   // try to reach availh by integral steps
        int i = 0;
        // use items below the first visible
        for (i=GetTopIndex(); availh>0 && i<n; i++)
        {
            int h = GetItemHeight(i);
            if (h == CB_ERR)
                break;

            inth += h;
            availh -= h;
        }
        // to fill the remaining height, use items above
        for (i=GetTopIndex()-1; availh>0 && i>=0; i--)
        {
            int h = GetItemHeight(i);
            if (h == CB_ERR)
                break;

            inth += h;
            availh -= h;
        }
        // scroll into view
        SetTopIndex(i);

        if (!m_bClipMaxHeight) // it can be higher than all the items
        {
            // to fill the remaining height, use last item
            int h = GetItemHeight(n-1);
            if (h != CB_ERR)
            {
                inth += availh - availh % h;
            }
        }
    }
    else
    {
        // every item has the same height (take the first)
        int h = GetItemHeight(0);
        if (h != CB_ERR && n != CB_ERR)
        {
            int rows = availh / h;
            // can't be higher than all the items
            if (m_bClipMaxHeight && rows > n)
                rows = n;
            inth = rows * h;
            // scroll into view
            if (n - rows < GetTopIndex())
                SetTopIndex(n-rows);
        }
    }

    return inth;
}