diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-03-27 21:41:20 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-03-27 21:41:20 +0300 |
commit | 964ffbb9b6ed5246b14a7d0c0d065f7d38af0912 (patch) | |
tree | edef1b3f31183402e2d0f86ee48c9734c2a03c7e /src/gui/widgets/table.cpp | |
parent | 41ac086fcd38fd472b579a495a8e8e7685ae4722 (diff) | |
download | mv-964ffbb9b6ed5246b14a7d0c0d065f7d38af0912.tar.gz mv-964ffbb9b6ed5246b14a7d0c0d065f7d38af0912.tar.bz2 mv-964ffbb9b6ed5246b14a7d0c0d065f7d38af0912.tar.xz mv-964ffbb9b6ed5246b14a7d0c0d065f7d38af0912.zip |
Fix some warnings and improve code from gcc 4.6 compilation.
Diffstat (limited to 'src/gui/widgets/table.cpp')
-rw-r--r-- | src/gui/widgets/table.cpp | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/src/gui/widgets/table.cpp b/src/gui/widgets/table.cpp index 6011e4ceb..00f41a760 100644 --- a/src/gui/widgets/table.cpp +++ b/src/gui/widgets/table.cpp @@ -301,27 +301,31 @@ void GuiTable::draw(gcn::Graphics* graphics) if (first_row < 0) first_row = 0; - int rows_nr = 1 + (getHeight() / getRowHeight()); // May overestimate + unsigned rows_nr = 1 + (getHeight() / getRowHeight()); // May overestimate // by one. - int max_rows_nr = mModel->getRows() - first_row; // clip if neccessary: + unsigned max_rows_nr; + if (mModel->getRows() < first_row) + max_rows_nr = 0; + else + max_rows_nr = mModel->getRows() - first_row; // clip if neccessary: if (max_rows_nr < rows_nr) rows_nr = max_rows_nr; // Now determine the first and last column // Take the easy way out; these are usually bounded and all visible. - int first_column = 0; - int last_column1 = mModel->getColumns(); + unsigned first_column = 0; + unsigned last_column1 = mModel->getColumns(); // Set up everything for drawing int height = getRowHeight(); int y_offset = first_row * height; - for (int r = first_row; r < first_row + rows_nr; ++r) + for (unsigned r = first_row; r < first_row + rows_nr; ++r) { int x_offset = 0; - for (int c = first_column; c + 1 <= last_column1; ++c) + for (unsigned c = first_column; c + 1 <= last_column1; ++c) { gcn::Widget *widget = mModel->getElementAt(r, c); int width = getColumnWidth(c); @@ -340,18 +344,21 @@ void GuiTable::draw(gcn::Graphics* graphics) graphics->setColor(Theme::getThemeColor(Theme::HIGHLIGHT, static_cast<int>(mAlpha * 255.0f))); - if (mLinewiseMode && r == mSelectedRow && c == 0) - { - graphics->fillRectangle(gcn::Rectangle(0, y_offset, - getWidth(), height)); - } - else if (!mLinewiseMode && - c == mSelectedColumn && r == mSelectedRow) + if (mSelectedRow > 0) { - graphics->fillRectangle(gcn::Rectangle(x_offset, y_offset, - width, height)); + if (mLinewiseMode && r == (unsigned)mSelectedRow && c == 0) + { + graphics->fillRectangle(gcn::Rectangle(0, y_offset, + getWidth(), height)); + } + else if (!mLinewiseMode && mSelectedColumn > 0 + && c == (unsigned)mSelectedColumn + && r == (unsigned)mSelectedRow) + { + graphics->fillRectangle(gcn::Rectangle(x_offset, y_offset, + width, height)); + } } - graphics->pushClipArea(bounds); widget->draw(graphics); graphics->popClipArea(); |