gui/widget/listframe: change previous commit to use setSelectedLine()

This commit is contained in:
martii
2013-07-20 14:26:03 +02:00
committed by [CST] Focus
parent cd310b3ca8
commit e387454ef6

View File

@@ -582,25 +582,11 @@ void CListFrame::scrollPageDown(const int pages)
if( m_nNrOfLines <= 1) return; if( m_nNrOfLines <= 1) return;
if(m_nCurrentPage + pages < m_nNrOfPages) if(m_nCurrentPage + pages < m_nNrOfPages)
{ setSelectedLine(m_nSelectedLine + pages * m_nLinesPerPage);
m_nCurrentPage += pages;
m_nCurrentLine += pages * m_nLinesPerPage;
m_nSelectedLine += pages * m_nLinesPerPage;
if(m_nSelectedLine >= m_nNrOfLines - 1)
m_nSelectedLine = m_nNrOfLines - 1;
}
else if (m_nSelectedLine == m_nNrOfLines - 1) else if (m_nSelectedLine == m_nNrOfLines - 1)
{ setSelectedLine(0);
m_nCurrentPage = 0;
m_nCurrentLine = 0;
m_nSelectedLine = 0;
}
else else
{ setSelectedLine(m_nNrOfLines - 1);
m_nCurrentPage = m_nNrOfPages - 1;
m_nCurrentLine = m_nCurrentPage * m_nLinesPerPage;
m_nSelectedLine = m_nNrOfLines - 1;
}
//TRACE("[CListFrame] m_nCurrentLine: %d, m_nCurrentPage: %d \r\n",m_nCurrentLine,m_nCurrentPage); //TRACE("[CListFrame] m_nCurrentLine: %d, m_nCurrentPage: %d \r\n",m_nCurrentLine,m_nCurrentPage);
refresh(); refresh();
} }
@@ -612,26 +598,12 @@ void CListFrame::scrollPageUp(const int pages)
if( !(m_nMode & SCROLL)) return; if( !(m_nMode & SCROLL)) return;
if( m_nNrOfLines <= 1) return; if( m_nNrOfLines <= 1) return;
if(m_nCurrentPage - pages > -1) if(m_nCurrentPage - pages > 1)
{ setSelectedLine(m_nSelectedLine - pages * m_nLinesPerPage);
m_nCurrentPage -= pages;
m_nCurrentLine -= pages * m_nLinesPerPage;
m_nSelectedLine -= pages * m_nLinesPerPage;
if(m_nSelectedLine < 0)
m_nSelectedLine = 0;
}
else if (m_nSelectedLine == 0) else if (m_nSelectedLine == 0)
{ setSelectedLine(m_nNrOfLines - 1);
m_nCurrentPage = m_nNrOfPages - 1;
m_nCurrentLine = m_nCurrentPage * m_nLinesPerPage;
m_nSelectedLine = m_nNrOfLines - 1;
}
else else
{ setSelectedLine(0);
m_nCurrentPage = 0;
m_nCurrentLine = 0;
m_nSelectedLine = 0;
}
//TRACE("[CListFrame] m_nCurrentLine: %d, m_nCurrentPage: %d \r\n",m_nCurrentLine,m_nCurrentPage); //TRACE("[CListFrame] m_nCurrentLine: %d, m_nCurrentPage: %d \r\n",m_nCurrentLine,m_nCurrentPage);
refresh(); refresh();
} }
@@ -680,8 +652,10 @@ bool CListFrame::setSelectedLine(int selection)
{ {
//TRACE("[CListFrame]->setSelectedLine %d \r\n",selection); //TRACE("[CListFrame]->setSelectedLine %d \r\n",selection);
bool result = false; bool result = false;
if(selection >= 0 && selection < m_nNrOfLines) if (selection < 0)
{ selection = 0;
else if (selection >= m_nNrOfLines)
selection = m_nNrOfLines - 1;
m_nSelectedLine = selection; m_nSelectedLine = selection;
m_nCurrentPage = selection / m_nLinesPerPage; m_nCurrentPage = selection / m_nLinesPerPage;
m_nCurrentLine = m_nCurrentPage * m_nLinesPerPage; m_nCurrentLine = m_nCurrentPage * m_nLinesPerPage;
@@ -689,7 +663,6 @@ bool CListFrame::setSelectedLine(int selection)
refreshScroll(); //NEW refreshScroll(); //NEW
result = true; result = true;
//TRACE(" selected line: %d,%d,%d \r\n",m_nSelectedLine,m_nCurrentPage,m_nCurrentLine); //TRACE(" selected line: %d,%d,%d \r\n",m_nSelectedLine,m_nCurrentPage,m_nCurrentLine);
}
return (result); return (result);
} }