From e768add9d172d78bd5deb7e98d228fb50bf8e2c5 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 30 Nov 2013 16:05:16 +0300 Subject: add support for unselectable guitables. --- src/gui/widgets/guitable.cpp | 18 +++++++++++------- src/gui/widgets/guitable.h | 4 ++++ src/gui/widgets/tabs/setup_relations.cpp | 1 + 3 files changed, 16 insertions(+), 7 deletions(-) (limited to 'src/gui/widgets') diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp index 15765763e..9d6eb0926 100644 --- a/src/gui/widgets/guitable.cpp +++ b/src/gui/widgets/guitable.cpp @@ -104,7 +104,8 @@ GuiTable::GuiTable(const Widget2 *const widget, mSelectedColumn(-1), mLinewiseMode(false), mWrappingEnabled(false), - mOpaque(opacity) + mOpaque(opacity), + mSelectable(true) { mBackgroundColor = getThemeColor(Theme::BACKGROUND); @@ -157,11 +158,14 @@ void GuiTable::recomputeDimensions() const int columns_nr = mModel->getColumns(); int width = 0; - if (mSelectedRow >= rows_nr) - mSelectedRow = rows_nr - 1; + if (mSelectable) + { + if (mSelectedRow >= rows_nr) + mSelectedRow = rows_nr - 1; - if (mSelectedColumn >= columns_nr) - mSelectedColumn = columns_nr - 1; + if (mSelectedColumn >= columns_nr) + mSelectedColumn = columns_nr - 1; + } for (int i = 0; i < columns_nr; i++) width += getColumnWidth(i); @@ -204,7 +208,7 @@ int GuiTable::getColumnWidth(const int i) const void GuiTable::setSelectedRow(const int selected) { - if (!mModel) + if (!mModel || !mSelectable) { mSelectedRow = -1; } @@ -457,7 +461,7 @@ void GuiTable::keyPressed(gcn::KeyEvent& keyEvent) // -- MouseListener notifications void GuiTable::mousePressed(gcn::MouseEvent& mouseEvent) { - if (!mModel) + if (!mModel || !mSelectable) return; if (mouseEvent.getButton() == gcn::MouseEvent::LEFT) diff --git a/src/gui/widgets/guitable.h b/src/gui/widgets/guitable.h index 072563715..d41e5589b 100644 --- a/src/gui/widgets/guitable.h +++ b/src/gui/widgets/guitable.h @@ -158,6 +158,9 @@ public: void requestFocus(); + void setSelectable(bool b) + { mSelectable = b; } + protected: /** Frees all action listeners on inner widgets. */ void uninstallActionListeners(); @@ -194,6 +197,7 @@ private: bool mLinewiseMode; bool mWrappingEnabled; bool mOpaque; + bool mSelectable; }; #endif // GUI_WIDGETS_GUITABLE_H diff --git a/src/gui/widgets/tabs/setup_relations.cpp b/src/gui/widgets/tabs/setup_relations.cpp index c1b6cc1ed..8f5802371 100644 --- a/src/gui/widgets/tabs/setup_relations.cpp +++ b/src/gui/widgets/tabs/setup_relations.cpp @@ -270,6 +270,7 @@ Setup_Relations::Setup_Relations(const Widget2 *const widget) : RELATION_CHOICE_COLUMN_WIDTH); mPlayerTitleTable->setBackgroundColor(getThemeColor( Theme::TABLE_BACKGROUND)); + mPlayerTitleTable->setSelectable(false); for (int i = 0; i < COLUMNS_NR; i++) { -- cgit v1.2.3-70-g09d2