From b64fd3b17bcd3f750851f0213eac43d467de8600 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Wed, 4 Feb 2009 22:55:59 -0700 Subject: Fixed a few table events. One prevented wrapping for tables when you are scrolling through the table upward, while the other didn't check upper bounds for rows and columns to see if the event is in the table, but rather just the lower bounds. Signed-off-by: Ira Rice --- src/gui/table.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/gui/table.cpp b/src/gui/table.cpp index 3bed48d8..674f3891 100644 --- a/src/gui/table.cpp +++ b/src/gui/table.cpp @@ -191,7 +191,7 @@ void GuiTable::setSelectedRow(int selected) } else { - if (selected < 0) + if (selected < 0 && !mWrappingEnabled) { mSelectedRow = -1; } @@ -199,7 +199,8 @@ void GuiTable::setSelectedRow(int selected) { mSelectedRow = 0; } - else if (selected >= mModel->getRows() && !mWrappingEnabled) + else if ((selected >= mModel->getRows() && !mWrappingEnabled) || + (selected < 0 && mWrappingEnabled)) { mSelectedRow = mModel->getRows() - 1; } @@ -218,15 +219,13 @@ void GuiTable::setSelectedColumn(int selected) } else { - if (selected < 0) - { - mSelectedColumn = -1; - } - else if (selected >= mModel->getColumns() && mWrappingEnabled) + if ((selected >= mModel->getColumns() && mWrappingEnabled) || + (selected < 0 && !mWrappingEnabled)) { mSelectedColumn = 0; } - else if (selected >= mModel->getColumns() && !mWrappingEnabled) + else if ((selected >= mModel->getColumns() && !mWrappingEnabled) || + (selected < 0 && mWrappingEnabled)) { mSelectedColumn = mModel->getColumns() - 1; } @@ -445,7 +444,8 @@ void GuiTable::mousePressed(gcn::MouseEvent& mouseEvent) int row = getRowForY(mouseEvent.getY()); int column = getColumnForX(mouseEvent.getX()); - if (row > -1 && column > -1) + if (row > -1 && column > -1 && + row < mModel->getRows() && column < mModel->getColumns()) { mSelectedColumn = column; mSelectedRow = row; @@ -459,7 +459,7 @@ void GuiTable::mouseWheelMovedUp(gcn::MouseEvent& mouseEvent) { if (isFocused()) { - if (getSelectedRow() > 0 ) + if (getSelectedRow() >= 0 ) { setSelectedRow(getSelectedRow() - 1); } -- cgit v1.2.3-70-g09d2