summaryrefslogtreecommitdiff
path: root/src/gui/table.cpp
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2009-02-04 22:55:59 -0700
committerIra Rice <irarice@gmail.com>2009-02-04 22:55:59 -0700
commitb64fd3b17bcd3f750851f0213eac43d467de8600 (patch)
tree306e1679cf3546684c9cef93661dd40e094cf6ea /src/gui/table.cpp
parenta955833718217fe35442bcde8a43375c91002738 (diff)
downloadmana-b64fd3b17bcd3f750851f0213eac43d467de8600.tar.gz
mana-b64fd3b17bcd3f750851f0213eac43d467de8600.tar.bz2
mana-b64fd3b17bcd3f750851f0213eac43d467de8600.tar.xz
mana-b64fd3b17bcd3f750851f0213eac43d467de8600.zip
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 <irarice@gmail.com>
Diffstat (limited to 'src/gui/table.cpp')
-rw-r--r--src/gui/table.cpp20
1 files 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);
}