bool OnKey(IInputProvider* pprovider, const KeyState& ks, bool& fForceTranslate) { VerifyScrollPos(); if (ks.bDown) { switch (ks.vk) { case VK_DOWN: NextItem(); SelectionChanged(); return true; case VK_UP: PreviousItem(); SelectionChanged(); return true; case VK_PRIOR: // page up PageUp(); SelectionChanged(); return true; case VK_NEXT: // page down PageDown(); SelectionChanged(); return true; } } return false; }
MouseResult Button( IInputProvider* pprovider, const Point& point, int button, bool bCaptured, bool bInside, bool bDown ) { VerifyScrollPos(); if (button == 0 && bDown) { int nSize = GetSignificantSize(*m_ppainter); int nSignificantMouseDim = (int)(m_bHorizontal ? point.X(): point.Y()); SetSelection(m_plist->GetItem((nSignificantMouseDim + GetScrollPos()) / nSize)); NeedPaint(); SelectionChanged(); if (pprovider->IsDoubleClick()) { m_peventDoubleClick->Trigger(); } else { m_peventSingleClick->Trigger(); } } else if(button == 1 && bDown) { int nSize = GetSignificantSize(*m_ppainter); int nSignificantMouseDim = (int)(m_bHorizontal ? point.X(): point.Y()); SetSelection(m_plist->GetItem((nSignificantMouseDim + GetScrollPos()) / nSize)); NeedPaint(); SelectionChanged(); if (pprovider->IsDoubleClick()) { m_peventDoubleRightClick->Trigger(); } else { m_peventSingleRightClick->Trigger(); } } else if(button == 8 && bDown) { //Imago 8/14/09 mouse wheel NextItem(); SelectionChanged(); } else if(button == 9 && bDown) { PreviousItem(); SelectionChanged(); } return MouseResult(); }
void Paint(Surface* psurface) { VerifyScrollPos(); // // Find the item at the top of the list // int ysize = GetSignificantSize(*m_ppainter); int index = GetScrollPos() / ysize; int y = index * ysize - GetScrollPos(); ItemID pitem = m_plist->GetItem(index); while ( pitem != NULL && y < GetSignificantSize() ) { if (m_bHorizontal) psurface->Offset(WinPoint(y, 0)); else psurface->Offset(WinPoint(0, y)); m_ppainter->Paint( pitem, psurface, pitem == m_pitemSelection, false ); if (m_bHorizontal) psurface->Offset(WinPoint(-y, 0)); else psurface->Offset(WinPoint(0, -y)); y += ysize; pitem = m_plist->GetNext(pitem); } }
BOOL CEditableListCtrl::PreTranslateMessage(MSG* pMsg) { if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_TAB) { CommitEditCtrl(); m_iEditRow = -1; m_iEditCol = -1; if (GetKeyState(VK_SHIFT) & 0x8000) { m_iCol--; if (m_iCol < 1) { m_iCol = MAX_COLS - 1; m_iRow--; while (m_iRow >= 0 && GetItemData(m_iRow) & 1) m_iRow--; if (m_iRow < 0) { m_iCol = 1; m_iRow = 0; // cycle to prev sibling control CWnd* pWnd = GetWindow(GW_HWNDPREV); ASSERT( pWnd ); if (pWnd) { pWnd->SetFocus(); return CListCtrl::PreTranslateMessage(pMsg); } } } } else { m_iCol++; if (m_iCol >= MAX_COLS) { m_iCol = 1; m_iRow++; while (m_iRow < GetItemCount() && GetItemData(m_iRow) & 1) m_iRow++; ResetBottomPosition(); if (m_iRow > GetItemCount() - 1) { m_iRow = GetItemCount() - 1; // cycle to next sibling control CWnd* pWnd = GetNextWindow(); ASSERT( pWnd ); if (pWnd) { pWnd->SetFocus(); return CListCtrl::PreTranslateMessage(pMsg); } } } } VerifyScrollPos(); ResetTopPosition(); ResetBottomPosition(); switch (m_iCol) { case 0: break; case 1: ShowEditCtrl(); break; } return TRUE; } return CListCtrl::PreTranslateMessage(pMsg); }