HRESULT CGamesList::OnSetCurSel(XUIMessageSetCurSel *pSetCurSelData, BOOL &bHandled ) { int nFocalPoint = 4; if(SETTINGS::getInstance().getGameListVisual() == 0) return S_OK; if(SETTINGS::getInstance().getGameListVisual() == 1) nFocalPoint = 4; else if(SETTINGS::getInstance().getGameListVisual() == 2) nFocalPoint = 3; else nFocalPoint = 4; if(flag == false) { int nFocalInverse = GetVisibleItemCount() - nFocalPoint - 1; int previousItem = GetCurSel(); int currentTopItem = GetTopItem(); int currentItem = pSetCurSelData->iItem; int direction = currentItem - previousItem; int listCount = GetItemCount(); if(direction > 0) { currentTopItem++; if(currentItem > nFocalPoint && currentItem <= listCount - nFocalInverse - 1) { SetTopItem(currentTopItem); pSetCurSelData->iItem = currentTopItem + nFocalPoint; flag = true; } } else { currentTopItem--; if(currentItem >= nFocalPoint && currentItem < listCount - nFocalInverse - 1) { SetTopItem(currentTopItem); pSetCurSelData->iItem = currentTopItem + nFocalPoint; flag = true; } } } else { flag = false; bHandled = true; } return S_OK; }
void ListControl::OnPaint(DibBitmap *pbm) { Rect rcForm; m_pfrm->GetRect(&rcForm); Rect rc; Rect rcScrollPos; GetSubRects(&rc, NULL, NULL, &rcScrollPos); rc.Offset(rcForm.left, rcForm.top); rcScrollPos.Offset(rcForm.left, rcForm.top); Size sizArrow; s_ptbmScrollUpUp->GetSize(&sizArrow); int cliDraw = GetVisibleItemCount(); int cx = rc.Width(); int x = rc.left; int y = rc.top; int xArrow = rc.left + ((cx - sizArrow.cx) / 2); // Walk through the list to the item that should be displayed first ListItem *pli; int ili = 0; for (pli = m_pliFirst; ili < m_iliTop; pli = pli->pliNext, ili++); int cliDrawn = 0; for (; pli != NULL && cliDraw > 0; pli = pli->pliNext, y += m_cyItem, cliDraw--) { DrawItem(pbm, pli, x, y, cx, m_cyItem); cliDrawn++; } bool fNeedsScrollUp = NeedsScrollUpArrow(); bool fNeedsScrollDown = NeedsScrollDownArrow(); if (m_wf & kfLstcScrollPosition) { if (fNeedsScrollUp || fNeedsScrollDown) { pbm->Shadow(rcScrollPos.left, rcScrollPos.top, rcScrollPos.Width(), rcScrollPos.Height()); pbm->Shadow(rcScrollPos.left, rcScrollPos.top, rcScrollPos.Width(), rcScrollPos.Height()); int y1 = rcScrollPos.Height() * m_iliTop / m_cli; int y2 = rcScrollPos.Height() * (m_iliTop + cliDrawn) / m_cli; pbm->Fill(rcScrollPos.left, rcScrollPos.top + y1, rcScrollPos.Width(), y2 - y1, #if 0 m_fPenDown ? GetColor(kiclrWhite) : GetColor(m_iclrScrollPos)); #else GetColor(m_iclrScrollPos)); #endif } } else {
void CHeaderCtrlExt::SetVisible(int nIndex, BOOL bVisible) { CItemData* pData = (CItemData*)GetItemData(nIndex); if(! pData)return; if(pData->m_bVisible != bVisible) { pData->m_bVisible = bVisible; // get total items int nCount = GetItemCount(); // get current item's order int nOrder = IndexToOrder(nIndex); int* piCols = new int[nCount]; ASSERT(piCols); GetOrderArray(piCols, nCount); if(bVisible) { // restore item width ResetItemWidth(nIndex); // move the item to the original position int nTarget; int nVisible = GetVisibleItemCount(); if(nIndex > nVisible - 1)nTarget = nVisible - 1; else nTarget = nIndex; ASSERT(nTarget <= nOrder); for(int i = nOrder;i > nTarget;--i)piCols[i] = piCols[i - 1]; piCols[nTarget] = nIndex; } else { // hide item SetItemWidth(nIndex, 0); } SetOrderArray(nCount, piCols); delete []piCols; } }