/// <summary>Resize window to fit current items</summary> /// <param name="wParam">Ignored.</param> /// <param name="lParam">Ignored.</param> LRESULT SuggestionList::OnVisibleItemsChanged(WPARAM wParam, LPARAM lParam) { // DEBUG: //Console << "SuggestionList::OnVisibleItemsChanged()" << ENDL; CWindowDC dc(this); WindowRect wnd(this); int width = 0; // Measure visible items for (int index = GetTopIndex(), end = min(GetTopIndex()+GetCountPerPage(), (int)Content.size()); index < end; ++index) { auto& item = Content[index]; auto w = dc.GetTextExtent(item.Text.c_str()).cx + dc.GetTextExtent(item.Type.c_str()).cx + 10; width = max(w, width); } // Enforce min/max widths width = max(width, 200); width = min(width, 700); // Adjust for scrollBar auto wndWidth = width + 2*GetSystemMetrics(SM_CXEDGE); if (GetCountPerPage() < (int)Content.size()) wndWidth += GetSystemMetrics(SM_CXVSCROLL); // Resize window + column SetWindowPos(nullptr,-1,-1, wndWidth, wnd.Height(), SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE); SetColumnWidth(0, width); return 0; }
void CGitProgressList::AddItemToList() { int totalcount = GetItemCount(); SetItemCountEx(totalcount+1, LVSICF_NOSCROLL|LVSICF_NOINVALIDATEALL); // make columns width fit if (iFirstResized < 30) { // only resize the columns for the first 30 or so entries. // after that, don't resize them anymore because that's an // expensive function call and the columns will be sized // close enough already. ResizeColumns(); ++iFirstResized; } // Make sure the item is *entirely* visible even if the horizontal // scroll bar is visible. int count = GetCountPerPage(); if (totalcount <= (GetTopIndex() + count + nEnsureVisibleCount + 2)) { ++nEnsureVisibleCount; m_bLastVisible = true; } else { nEnsureVisibleCount = 0; if (IsIconic() == 0) m_bLastVisible = false; } }
BOOL CListCtrlEx::OnEraseBkgnd(CDC* pDC) { // TODO: Add your message handler code here and/or call default CRect rect; CListCtrlEx::GetClientRect(rect); POINT mypoint; CBrush brush0(m_colRow1); CBrush brush1(m_colRow2); int chunk_height=GetCountPerPage(); pDC->FillRect(&rect,&brush1); for (int i=0;i<=chunk_height;i++) { GetItemPosition(i,&mypoint); rect.top=mypoint.y ; GetItemPosition(i+1,&mypoint); rect.bottom =mypoint.y; pDC->FillRect(&rect,i %2 ? &brush1 : &brush0); } brush0.DeleteObject(); brush1.DeleteObject(); //return FALSE; return CListCtrl::OnEraseBkgnd(pDC); }
INT_PTR CQListCtrl::OnToolHitTest(CPoint point, TOOLINFO * pTI) const { CRect rect; GetClientRect(&rect); if(rect.PtInRect(point)) { if(GetItemCount()) { int nTopIndex = GetTopIndex(); int nBottomIndex = nTopIndex + GetCountPerPage(); if(nBottomIndex > GetItemCount()) nBottomIndex = GetItemCount(); for(int nIndex = nTopIndex; nIndex <= nBottomIndex; nIndex++) { GetItemRect(nIndex, rect, LVIR_BOUNDS); if(rect.PtInRect(point)) { pTI->hwnd = m_hWnd; pTI->uId = (UINT)(nIndex+1); pTI->lpszText = LPSTR_TEXTCALLBACK; pTI->rect = rect; return pTI->uId; } } } } return -1; }
void CustomVirtListCtrl<T,L>::RefreshVisibleItems() { if ( m_data.empty() ) return; const long topItemIndex = GetTopItem(); const long range = topItemIndex + GetCountPerPage(); RefreshItems( topItemIndex, LSL::Util::Clamp( range, topItemIndex, (long) m_data.size() -1 ) ); }
/** * dx,dyのドラッグ量に応じて、ドラッグ開始かどうかを判定し、変数を設定する * * ドラッグ開始時は m_bPanDragging, m_bVerticalDragging を設定する */ void CTouchListCtrl::MySetDragFlagWhenMovedPixelOverLimit(int dx, int dy) { // 縦ドラッグ開始判断用オフセット値 #ifndef WINCE // WIN32の場合、半行以上の移動をドラッグとみなす int dyMinLimit = theApp.m_optionMng.GetFontHeight() / 2 + 1 ; #else // // WMの場合、少しの移動でドラッグとみなす // int dyMinLimit = 1; // WMの場合も、半行以上の移動をドラッグとみなす int dyMinLimit = theApp.m_optionMng.GetFontHeight() / 2 + 1 ; #endif if (m_bPanDragging) { // 横ドラッグ中 if( abs( dx ) < m_screenWidth / 3 ){ // マウスを元に戻したら横ドラッグをキャンセル m_bPanDragging = false ; } } else if (m_bVerticalDragging) { // 縦ドラッグ中 } else { // ドラッグ方向が確定していない if( m_bCanSlide && m_bUseHorizontalDragMove && ( abs(dx) > abs(dy) && abs(dx) > m_screenWidth / 3 ) ) { // 横方向の移動量が大きくて移動量が画面の1/3以上の場合] // ドラッグ方向設定 if( dx > 0 ){ m_drPanScrollDirection = PAN_SCROLL_DIRECTION_RIGHT; } else { m_drPanScrollDirection = PAN_SCROLL_DIRECTION_LEFT; } // 横ドラッグ開始 m_bPanDragging = true; } else if (abs(dy) >= dyMinLimit && (!m_bCanSlide || abs(dx) < abs(dy))) { // 縦移動量がドラッグ開始オフセット以上で、 // 「横スライド無効」か、「横スライド有効で縦移動量が横移動量より大きい」場合 if( GetItemCount()-GetCountPerPage() > 0 ) { // 縦スクロール可能ならば // 縦ドラッグ開始 //if (theApp.m_Platforms.WM6_5 || theApp.m_Platforms.WM6_5_1) { // // WM6.5 以降であれば無効 //} else { m_bVerticalDragging = true; if (m_bBlackScrollMode) { m_bFullPageDrawForBlackScrollStart = true; } //} } } } }
void CGridListCtrl::OnPaint() { // Make the gridlines easier to see than default light grey // First let the control do its default drawing. const MSG *pMsg = GetCurrentMessage(); DefWindowProc(pMsg->message, pMsg->wParam, pMsg->lParam); // Draw the lines only for LVS_REPORT mode if ((GetStyle() & LVS_TYPEMASK) == LVS_REPORT) { CClientDC dc(this); CPen NewPen(PS_SOLID, 0, m_RGBLineColour); CPen *pOldPen = dc.SelectObject(&NewPen); // Get the number of columns CHeaderCtrl *pHeader = (CHeaderCtrl *)GetDlgItem(m_HeaderCtrlID); int nColumnCount = pHeader->GetItemCount(); // The bottom of the header corresponds to the top of the line RECT rect; pHeader->GetClientRect(&rect); int top = rect.bottom; // Now get the client rect so we know the line length and when to stop GetClientRect(&rect); // The border of the column is offset by the horz scroll int borderx = 0 - GetScrollPos(SB_HORZ); for (int i = 0; i < nColumnCount; i++) { // Get the next border borderx += GetColumnWidth(pHeader->OrderToIndex(i)); // if next border is outside client area, break out if (borderx >= rect.right) break; // Draw the line. dc.MoveTo(borderx - 1, top); dc.LineTo(borderx - 1, rect.bottom); } // Draw the horizontal grid lines // First get the height if (!GetItemRect(0, &rect, LVIR_BOUNDS)) return; int height = rect.bottom - rect.top; GetClientRect(&rect); int width = rect.right; for (int i = 1; i <= GetCountPerPage(); i++) { dc.MoveTo(0, top + height * i); dc.LineTo(width, top + height * i); } dc.SelectObject(pOldPen); } }
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; }
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; }
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; }
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; }
// 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; }
BOOL CClonePairListCtrl::OnEraseBkgnd(CDC* pDC) { // TODO: Add your message handler code here and/or call default CRect rect; CClonePairListCtrl::GetClientRect(rect); POINT mypoint; CBrush brush0(m_colRow1); CBrush brush1(m_colRow2); int chunk_height=GetCountPerPage(); //pDC->FillRect(&rect,&brush1); int top = 0; int bottom = 0; GetItemPosition(0,&mypoint); top = mypoint.y; GetItemPosition(1,&mypoint); bottom = mypoint.y; int height = bottom - top; for (int i=0;i<=chunk_height;i++) { //GetItemPosition(i,&mypoint); rect.top=top; //mypoint.y ; //GetItemPosition(i+1,&mypoint); rect.bottom = bottom; //mypoint.y; pDC->FillRect(&rect,i %2 ? &brush1 : &brush0); top = bottom; bottom +=height; } brush0.DeleteObject(); brush1.DeleteObject(); return FALSE; }
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); }
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(); }
// Page Up BOOL CDomainListBox::SelectPrior( ) { int nPageCount = GetCountPerPage( ); for( int i=0; i<GetCount(); i++ ) { int nStatus = GetSelected( i ); if( LB_ERR != nStatus && nStatus ) { SelectItem( -1, FALSE ); SelectItem( i-nPageCount < 0 ? 0 : i-nPageCount ); return TRUE; } } if( GetCount() > 0 ) SelectItem( GetCount()-1, TRUE ); return TRUE; }
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); } } }
void CDragVirtualListCtrl::AutoScroll(const CPoint& Cursor) { if (GetItemCount() > GetCountPerPage()) { // if view is scrollable CRect cr, ir, hr; GetClientRect(cr); GetHeaderCtrl()->GetClientRect(hr); cr.top += hr.Height() - 1; // top scroll boundary is bottom of header GetItemRect(0, ir, LVIR_BOUNDS); int Offset = ir.Height() / 2; // vertical scrolling is quantized to lines if (Cursor.y < cr.top) // if cursor is above top boundary m_ScrollDelta = Cursor.y - cr.top - Offset; // start scrolling up else if (Cursor.y >= cr.bottom) // if cursor is below bottom boundary m_ScrollDelta = Cursor.y - cr.bottom + Offset; // start scrolling down else m_ScrollDelta = 0; // stop scrolling } else m_ScrollDelta = 0; if (m_ScrollDelta && !m_ScrollTimer) m_ScrollTimer = SetTimer(TIMER_ID, SCROLL_DELAY, NULL); }
/****************************************************************************** Function Name : OnEraseBkgnd Input(s) : CDC* - The pointer of Client DC Output : BOOL - Nonzero if it erases the background; otherwise 0. Functionality : Member of : CListCtrlEx Friend of : - Author(s) : Venkatanarayana Makam Date Created : 30/03/2011 Modifications : ******************************************************************************/ BOOL CListCtrlEx::OnEraseBkgnd(CDC* pDC) { CRect omClientRect; POINT omItemPos; int nTotalItems = GetCountPerPage(); GetClientRect(omClientRect); for(int i=0;i<nTotalItems+2;i++) { GetItemPosition(i,&omItemPos); omClientRect.top=omItemPos.y ; GetItemPosition(i+1,&omItemPos); omClientRect.bottom =omItemPos.y; CBrush omBrush(i %2 ? m_colRow1 : m_colRow2); pDC->FillRect(&omClientRect, &omBrush); omBrush.DeleteObject(); } //Nonzero if it erases the background; otherwise 0. return TRUE; }
// Page Down BOOL CDomainListBox::SelectNext( ) { int nPageCount = GetCountPerPage( ); for( int i=0; i<GetCount(); i++ ) { int nStatus = GetSelected( i ); if( LB_ERR != nStatus && nStatus ) { SelectItem( -1, FALSE ); int nNewSel = (i+nPageCount >= GetCount() ? GetCount()-1 : i+nPageCount); SelectAndShowItem( nNewSel ); return TRUE; } } if( GetCount() > 0 ) SelectItem( 0, TRUE ); return TRUE; }
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; }
/// <summary>Shrinks to fit.</summary> void SuggestionList::ShrinkToFit() { try { // Check if less than 1 page of items if (GetCountPerPage() > (int)Content.size() && !Content.empty()) { ClientRect wnd(this); CRect rc(0,0,0,0); // Calculate item height if (!GetItemRect(0, &rc, LVIR_LABEL) || !rc.Height()) throw Win32Exception(HERE, L"Unable to retrieve item height"); // Resize SetWindowPos(nullptr,-1,-1, wnd.Width(), rc.Height()*Content.size(), SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE); } } catch (ExceptionBase& e) { Console.Log(HERE, e); } }
void CBOINCListCtrl::DrawProgressBars() { long topItem, numItems, numVisibleItems, i, row; wxRect r, rr; int w = 0, x = 0, xx, yy, ww; int progressColumn = m_pParentView->GetProgressColumn(); #if USE_NATIVE_LISTCONTROL wxClientDC dc(this); m_bProgressBarEventPending = false; #else wxClientDC dc(GetMainWin()); // Available only in wxGenericListCtrl #endif if (progressColumn < 0) { m_iRowsNeedingProgressBars.Clear(); return; } int n = (int)m_iRowsNeedingProgressBars.GetCount(); if (n <= 0) return; wxColour progressColor = wxTheColourDatabase->Find(wxT("LIGHT BLUE")); wxBrush progressBrush(progressColor); numItems = GetItemCount(); if (numItems) { topItem = GetTopItem(); // Doesn't work properly for Mac Native control in wxMac-2.8.7 numVisibleItems = GetCountPerPage(); ++numVisibleItems; if (numItems <= (topItem + numVisibleItems)) numVisibleItems = numItems - topItem; x = 0; for (i=0; i< progressColumn; i++) { x += GetColumnWidth(i); } w = GetColumnWidth(progressColumn); #if USE_NATIVE_LISTCONTROL x -= GetScrollPos(wxHORIZONTAL); #else GetMainWin()->CalcScrolledPosition(x, 0, &x, &yy); #endif wxFont theFont = GetFont(); dc.SetFont(theFont); for (int i=0; i<n; ++i) { row = m_iRowsNeedingProgressBars[i]; if (row < topItem) continue; if (row > (topItem + numVisibleItems -1)) continue; GetItemRect(row, r); #if ! USE_NATIVE_LISTCONTROL r.y = r.y - GetHeaderHeight() - 1; #endif r.x = x; r.width = w; r.Inflate(-1, -2); rr = r; wxString progressString = m_pParentView->GetProgressText(row); dc.GetTextExtent(progressString, &xx, &yy); r.y += (r.height - yy - 1) / 2; // Adapted from ellipis code in wxRendererGeneric::DrawHeaderButtonContents() if (xx > r.width) { int ellipsisWidth; dc.GetTextExtent( wxT("..."), &ellipsisWidth, NULL); if (ellipsisWidth > r.width) { progressString.Clear(); xx = 0; } else { do { progressString.Truncate( progressString.length() - 1 ); dc.GetTextExtent( progressString, &xx, &yy); } while (xx + ellipsisWidth > r.width && progressString.length() ); progressString.append( wxT("...") ); xx += ellipsisWidth; } } dc.SetLogicalFunction(wxCOPY); dc.SetBackgroundMode(wxSOLID); dc.SetPen(progressColor); dc.SetBrush(progressBrush); dc.DrawRectangle( rr ); rr.Inflate(-2, -1); ww = rr.width * m_pParentView->GetProgressValue(row); rr.x += ww; rr.width -= ww; #if 0 // Show background stripes behind progress bars wxListItemAttr* attr = m_pParentView->FireOnListGetItemAttr(row); wxColour bkgd = attr->GetBackgroundColour(); dc.SetPen(bkgd); dc.SetBrush(bkgd); #else dc.SetPen(*wxWHITE_PEN); dc.SetBrush(*wxWHITE_BRUSH); #endif dc.DrawRectangle( rr ); dc.SetPen(*wxBLACK_PEN); dc.SetBackgroundMode(wxTRANSPARENT); if (xx > (r.width - 7)) { dc.DrawText(progressString, r.x, r.y); } else { dc.DrawText(progressString, r.x + (w - 8 - xx), r.y); } } } m_iRowsNeedingProgressBars.Clear(); }
// ************************************************************************** // 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); }
/** * ScrollByMoveY(const int dy) * ドラッグ中の描画処理 * 引数 * dy:マウスのY座標(point.y値、CTouchListCtrlコントロールのローカル座標、絶対値) * 戻り値 * 描画位置が先頭か最後尾になった場合にtrue、そうでない場合にfalseを返す * 関連するメンバ変数 * m_ptDragStart :(I) :ドラッグ開始点 * m_iItemHeight :(I) :アイテム1個当たりの高さ(ピクセル) * m_iDragLine :(I/O) :ドラッグ開始から現在までにスクロールした行数 * m_offsetPixelY :(O) :ピクセル単位スクロールのためのオフセット値 * 機能 * ・ドラッグ開始点(m_ptDragStart.y)からマウスの現在位置(dy)の移動量を基に * 画面に表示するItemの位置を決定し、スクロールして表示する */ bool CTouchListCtrl::ScrollByMoveY(const int dy) { util::StopWatch sw; sw.start(); // 先頭or最後尾フラグ bool bLimitOver = false; // 現時点での表示アイテム先頭位置、オフセットを保存する int iTop = GetTopIndex(); int iOffset = m_offsetPixelY; // Drag開始点からの移動行数を求める int iScrollLine = (( dy - m_ptDragStart.y ) / m_iItemHeight ) ; // ★ if (m_bBlackScrollMode) { // PIXEL単位でスクロールさせる m_offsetPixelY = -(( dy - m_ptDragStart.y ) % m_iItemHeight ); } else { #ifndef WINCE // PIXEL単位でスクロールさせる m_offsetPixelY = -(( dy - m_ptDragStart.y ) % m_iItemHeight ); #else if (theApp.m_optionMng.m_bListScrollByPixelOnMZ3) { // PIXEL単位でスクロールさせる m_offsetPixelY = -(( dy - m_ptDragStart.y ) % m_iItemHeight ); } else { // Item単位でスクロールさせる(WMデフォルト) m_offsetPixelY = 0; } #endif } // 前回の移動行数からの差分だけスクロールする // Scroll()メソッドはピクセル数指定だが、ピクセル指定すると // 1行分の半分くらいで1行移動したりしてマウスの動きと同期が取れないので // 行数×高さで動かす if( abs(iScrollLine - m_iDragLine) > 0 ){ CSize szScroll( 0 , -(( iScrollLine - m_iDragLine ) * m_iItemHeight) ); MZ3_TRACE( L" ScrollByMoveY, Scroll(%5d)\n" , szScroll.cy ); // Win32では独自処理で描画する // WMでは処理が追いつかないので標準処理に任せる // スクロール中の再描画を禁止 #ifndef WINCE LockWindowUpdate(); #endif // スクロール実行 Scroll( szScroll ); // スクロール中の再描画を再開 #ifndef WINCE UnlockWindowUpdate(); #endif } // スクロール後の先頭位置を取得する int iNextTop = GetTopIndex(); // 上端より上または下端より下ならばオフセットを効かせない if( ( iNextTop < 0 ) || ( iNextTop == 0 && m_offsetPixelY < 0) || ( GetItemCount() - GetCountPerPage() == iNextTop && m_offsetPixelY > 0) || ( GetItemCount() - GetCountPerPage() < iNextTop ) ){ m_offsetPixelY = 0; } if( ( iNextTop <= 0 ) || ( GetItemCount() - GetCountPerPage() <= iNextTop ) ){ // 先頭or最後尾フラグ bLimitOver = true; } bool bDoRedraw = false; if( iTop != iNextTop ) { // Item表示位置が変わった // トータル移動行数を蓄積する m_iDragLine += iTop - iNextTop; MZ3_TRACE( L" ScrollByMoveY, DrawBackSurface() req1\n" ); bDoRedraw = true; } else { // Item表示位置は変わらない if (iOffset != m_offsetPixelY) { // オフセットが変わった MZ3_TRACE( L" ScrollByMoveY, DrawBackSurface() req2\n" ); bDoRedraw = true; } } if (bDoRedraw) { if (m_bBlackScrollMode) { // 再描画 DrawBackSurface(); UpdateWindow(); } else { #ifndef WINCE // 再描画 // Win32では独自処理で描画する DrawBackSurface(); UpdateWindow(); #else if (theApp.m_optionMng.m_bListScrollByPixelOnMZ3) { // ピクセル単位スクロールの場合はWMでも独自処理で描画する DrawBackSurface(); UpdateWindow(); } #endif } } // MZ3LOGGER_INFO(util::FormatString(L" ScrollByMoveY elapsed : %dmsec", sw.getElapsedMilliSecUntilNow())); return bLimitOver; }
/** * DrawBackSurface() * 裏画面バッファにリスト項目を描画する */ int CTouchListCtrl::DrawBackSurface( bool bForceDraw /* = true */ ) { MZ3_TRACE( L"DrawBackSurface(%s)\n", bForceDraw ? L"true" : L"false"); if( m_memDC == NULL ){ return 0; } m_dwLastDrawTick = GetTickCount(); // 念のため遅延描画タイマーを停止する MyResetRedrawTimer(); // 背景を塗りつぶす if (m_bBlackScrollMode && (m_bVerticalDragging || m_bAutoScrolling)) { // ★ドラッグ中は背景を再描画しない } else { BITMAP bmp; GetObject(m_memBMP->m_hObject, sizeof(BITMAP), &bmp); HBITMAP hBgBitmap = GetBgBitmapHandle(); if( !theApp.m_optionMng.IsUseBgImage() || hBgBitmap == NULL ) { // 背景画像なしの場合 // m_memDC->FillSolidRect( 0, 0, bmp.bmWidth, bmp.bmHeight, RGB(255,255,255) ); // 暫定的にステータスバーの背景色を利用する m_memDC->SetBkColor(theApp.m_skininfo.getColor("MainStatusBG")); m_memDC->FillSolidRect( 0, 0, bmp.bmWidth, bmp.bmHeight, theApp.m_skininfo.getColor("MainStatusBG")); }else{ // 背景ビットマップの描画 CRect rectViewClient; this->GetClientRect( &rectViewClient ); rectViewClient.OffsetRect( 0 , m_drawStartTopOffset + m_offsetPixelY ); int x = rectViewClient.left; int y = rectViewClient.top; int w = rectViewClient.Width(); int h = rectViewClient.Height() + m_iItemHeight * 2; int offset = 0; if( IsScrollWithBk() ){ offset = ( m_iItemHeight * GetTopIndex() + m_offsetPixelY) % bmp.bmHeight; } util::DrawBitmap( m_memDC->GetSafeHdc(), hBgBitmap, x, y, w, h, 0, 0 + offset ); } MZ3_TRACE( L" Top=%5d,offset=%5d\n" , GetTopIndex() , m_offsetPixelY ); } // 透過モードに設定 m_memDC->SetBkMode(TRANSPARENT); util::StopWatch sw1, sw2; sw1.start(); if (m_bBlackScrollMode && (m_bVerticalDragging || m_bAutoScrolling) && !m_bFullPageDrawForBlackScrollStart) { // ★ドラッグ中はアイテムを再描画しない // 但し、ドラッグ開始時(m_bFullPageDrawForBlackScrollStart==trueの場合)は描画する } else { // フォントを現在のフォントに置き換え CFont* oldFont = (CFont*)m_memDC->SelectObject( GetFont() ); // 画面に収まるItemを順番に描画する // オフセットスクロール用に1行余分に描画する。 int N_OVER_OFFSET_LINES = 1; if (m_bFullPageDrawForBlackScrollStart) { // 裏画面用に上下2画面分、余分に描画する N_OVER_OFFSET_LINES = GetCountPerPage(); } // 裏画面描画範囲初期化 m_yBackSurfaceStart = 65535; m_yBackSurfaceEnd = 0; for (int i=-N_OVER_OFFSET_LINES; i <= GetCountPerPage()+N_OVER_OFFSET_LINES; i++) { int nItem = GetTopIndex() + i; // 範囲を越えたらスルー if (nItem < 0) { continue; } if (nItem >= GetItemCount()) { break; } // バックバッファにアイテムを描画する // 裏画面に3画面分描画する際は背景も描画する DrawItemToBackSurface(nItem, m_bFullPageDrawForBlackScrollStart); } // フォントを元に戻す m_memDC->SelectObject( oldFont ); } sw1.stop(); // 画面に転送する sw2.start(); if (bForceDraw) { // 強制的に描画する CDC* pDC = GetDC(); DrawToScreen(pDC); ReleaseDC(pDC); ValidateRect( &m_viewRect ); } sw2.stop(); // MZ3LOGGER_INFO(util::FormatString(L" DrawBackSurface, elapsed : %dms, %dms", // sw1.getElapsedMilliSecUntilStoped(), // sw2.getElapsedMilliSecUntilStoped() // )); return(1); }
bool CQueueViewBase::RemoveItem(CQueueItem* pItem, bool destroy, bool updateItemCount /*=true*/, bool updateSelections /*=true*/) { if (pItem->GetType() == QueueItemType_File || pItem->GetType() == QueueItemType_Folder) { wxASSERT(m_fileCount > 0); m_fileCount--; m_fileCountChanged = true; } else if (pItem->GetType() == QueueItemType_FolderScan) { wxASSERT(m_folderScanCount > 0); m_folderScanCount--; m_folderScanCountChanged = true; } int index = 0; if (updateSelections) index = GetItemIndex(pItem); CQueueItem* topLevelItem = pItem->GetTopLevelItem(); int count = topLevelItem->GetChildrenCount(true); topLevelItem->RemoveChild(pItem, destroy); bool didRemoveParent; int oldCount = m_itemCount; if (!topLevelItem->GetChild(0)) { std::vector<CServerItem*>::iterator iter; for (iter = m_serverList.begin(); iter != m_serverList.end(); iter++) { if (*iter == topLevelItem) break; } if (iter != m_serverList.end()) m_serverList.erase(iter); UpdateSelections_ItemRangeRemoved(GetItemIndex(topLevelItem), count + 1); delete topLevelItem; m_itemCount -= count + 1; if (updateItemCount) SaveSetItemCount(m_itemCount); didRemoveParent = true; } else { count -= topLevelItem->GetChildrenCount(true); if (updateSelections) UpdateSelections_ItemRangeRemoved(index, count); m_itemCount -= count; if (updateItemCount) SaveSetItemCount(m_itemCount); didRemoveParent = false; } if (updateItemCount) { if (m_fileCountChanged || m_folderScanCountChanged) DisplayNumberQueuedFiles(); if (oldCount > m_itemCount) { bool eraseBackground = GetTopItem() + GetCountPerPage() + 1 >= m_itemCount; RefreshListOnly(eraseBackground); if (eraseBackground) Update(); } } return didRemoveParent; }
void CMusikListCtrl::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxBufferedPaintDC dc(this); MSWDefWindowProc(WM_ERASEBKGND, (WPARAM) (HDC) dc.GetHDC(), 0); MSWDefWindowProc(WM_PAINT, (WPARAM) (HDC) dc.GetHDC(), 0); /* copied from original wxwindows code */ // Reset the device origin since it may have been set dc.SetDeviceOrigin(0, 0); bool drawHRules = ((GetWindowStyle() & wxLC_HRULES) != 0); bool drawVRules = ((GetWindowStyle() & wxLC_VRULES) != 0); if (!drawHRules && !drawVRules) return; if ((GetWindowStyle() & wxLC_REPORT) == 0) return; wxPen pen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT), 1, wxSOLID); dc.SetPen(pen); dc.SetBrush(* wxTRANSPARENT_BRUSH); wxSize clientSize = GetClientSize(); wxRect itemRect; int cy=0; int itemCount = GetItemCount(); int i; if (drawHRules) { long top = GetTopItem(); for (i = top; i < top + GetCountPerPage() + 1; i++) { if (GetItemRect(i, itemRect)) { cy = itemRect.GetTop(); if (i != 0) // Don't draw the first one { dc.DrawLine(0, cy, clientSize.x, cy); } // Draw last line if (i == itemCount - 1) { cy = itemRect.GetBottom(); dc.DrawLine(0, cy, clientSize.x, cy); } } } } i = itemCount - 1; if (drawVRules && (i > -1)) { wxRect firstItemRect; GetItemRect(0, firstItemRect); if (GetItemRect(i, itemRect)) { int col; int x = itemRect.GetX(); for (col = 0; col < GetColumnCount(); col++) { int colWidth = GetColumnWidth(col); x += colWidth ; dc.DrawLine(x-1, firstItemRect.GetY() - 2, x-1, itemRect.GetBottom()); } } } }
BOOL CLogListCtrl::OnEraseBkgnd(CDC* pDC) { int itemCount = GetItemCount(); if (!itemCount) { return CListCtrl::OnEraseBkgnd(pDC); } RECT clientRect; RECT itemRect; int topIndex = GetTopIndex(); int maxItems = GetCountPerPage(); int drawnItems = itemCount < maxItems ? itemCount : maxItems; CRect rcClip; GetClientRect(&clientRect); rcClip = clientRect; GetItemRect(topIndex, &itemRect, LVIR_BOUNDS); clientRect.bottom = itemRect.top; if (m_crWindowTextBk != CLR_NONE) { pDC->FillSolidRect(&clientRect,GetBkColor()); } else { rcClip.top = itemRect.top; } if(topIndex + maxItems >= itemCount) { GetClientRect(&clientRect); GetItemRect(topIndex + drawnItems - 1, &itemRect, LVIR_BOUNDS); clientRect.top = itemRect.bottom; rcClip.bottom = itemRect.bottom; if (m_crWindowTextBk != CLR_NONE) { pDC->FillSolidRect(&clientRect, GetBkColor()); } } if (itemRect.right < clientRect.right) { GetClientRect(&clientRect); clientRect.left = itemRect.right; rcClip.right = itemRect.right; if (m_crWindowTextBk != CLR_NONE) { pDC->FillSolidRect(&clientRect, GetBkColor()); } } if (m_crWindowTextBk == CLR_NONE) { CRect rcClipBox; pDC->GetClipBox(&rcClipBox); rcClipBox.SubtractRect(&rcClipBox, &rcClip); if (!rcClipBox.IsRectEmpty()) { pDC->ExcludeClipRect(&rcClip); CListCtrl::OnEraseBkgnd(pDC); InvalidateRect(&rcClip, FALSE); } } return TRUE; }