diff options
-rw-r--r-- | src/gui/table.cpp | 29 | ||||
-rw-r--r-- | src/gui/widgets/listbox.cpp | 34 | ||||
-rw-r--r-- | src/gui/widgets/resizegrip.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/window.cpp | 6 |
4 files changed, 38 insertions, 33 deletions
diff --git a/src/gui/table.cpp b/src/gui/table.cpp index e98d76e5..5ad3b5e1 100644 --- a/src/gui/table.cpp +++ b/src/gui/table.cpp @@ -19,16 +19,17 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <guichan/actionlistener.hpp> -#include <guichan/graphics.hpp> -#include <guichan/key.hpp> +#include "gui/palette.h" +#include "gui/table.h" +#include "gui/sdlinput.h" -#include "palette.h" -#include "table.h" +#include "configuration.h" -#include "../configuration.h" +#include "utils/dtor.h" -#include "../utils/dtor.h" +#include <guichan/actionlistener.hpp> +#include <guichan/graphics.hpp> +#include <guichan/key.hpp> float GuiTable::mAlpha = 1.0; @@ -377,38 +378,38 @@ void GuiTable::keyPressed(gcn::KeyEvent& keyEvent) { gcn::Key key = keyEvent.getKey(); - if (key.getValue() == gcn::Key::ENTER || key.getValue() == gcn::Key::SPACE) + if (key.getValue() == Key::ENTER || key.getValue() == Key::SPACE) { distributeActionEvent(); keyEvent.consume(); } - else if (key.getValue() == gcn::Key::UP) + else if (key.getValue() == Key::UP) { setSelectedRow(mSelectedRow - 1); keyEvent.consume(); } - else if (key.getValue() == gcn::Key::DOWN) + else if (key.getValue() == Key::DOWN) { setSelectedRow(mSelectedRow + 1); keyEvent.consume(); } - else if (key.getValue() == gcn::Key::LEFT) + else if (key.getValue() == Key::LEFT) { setSelectedColumn(mSelectedColumn - 1); keyEvent.consume(); } - else if (key.getValue() == gcn::Key::RIGHT) + else if (key.getValue() == Key::RIGHT) { setSelectedColumn(mSelectedColumn + 1); keyEvent.consume(); } - else if (key.getValue() == gcn::Key::HOME) + else if (key.getValue() == Key::HOME) { setSelectedRow(0); setSelectedColumn(0); keyEvent.consume(); } - else if (key.getValue() == gcn::Key::END) + else if (key.getValue() == Key::END) { setSelectedRow(mModel->getRows() - 1); setSelectedColumn(mModel->getColumns() - 1); diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index 1271bf77..322ed06d 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -22,6 +22,7 @@ #include "gui/widgets/listbox.h" #include "gui/palette.h" +#include "gui/sdlinput.h" #include "configuration.h" @@ -100,27 +101,34 @@ void ListBox::keyPressed(gcn::KeyEvent& keyEvent) { gcn::Key key = keyEvent.getKey(); - if (key.getValue() == gcn::Key::ENTER || key.getValue() == gcn::Key::SPACE) + if (key.getValue() == Key::ENTER || key.getValue() == Key::SPACE) { distributeActionEvent(); keyEvent.consume(); } - else if (key.getValue() == gcn::Key::UP) + else if (key.getValue() == Key::UP) { - setSelected(mSelected - 1); + if (getSelected() > 0) + setSelected(mSelected - 1); + else if (getSelected() == 0 && mWrappingEnabled) + setSelected(getListModel()->getNumberOfElements() - 1); keyEvent.consume(); } - else if (key.getValue() == gcn::Key::DOWN) + else if (key.getValue() == Key::DOWN) { - setSelected(mSelected + 1); + if (getSelected() < (getListModel()->getNumberOfElements() - 1)) + setSelected(mSelected + 1); + else if (getSelected() == (getListModel()->getNumberOfElements() - 1) && + mWrappingEnabled) + setSelected(0); keyEvent.consume(); } - else if (key.getValue() == gcn::Key::HOME) + else if (key.getValue() == Key::HOME) { setSelected(0); keyEvent.consume(); } - else if (key.getValue() == gcn::Key::END) + else if (key.getValue() == Key::END) { setSelected(getListModel()->getNumberOfElements() - 1); keyEvent.consume(); @@ -131,10 +139,10 @@ void ListBox::mouseWheelMovedUp(gcn::MouseEvent& mouseEvent) { if (isFocused()) { - if (getSelected() > 0 || (getSelected() == 0 && mWrappingEnabled)) - { + if (getSelected() > 0) setSelected(getSelected() - 1); - } + else if (getSelected() == 0 && mWrappingEnabled) + setSelected(getListModel()->getNumberOfElements() - 1); mouseEvent.consume(); } @@ -144,7 +152,11 @@ void ListBox::mouseWheelMovedDown(gcn::MouseEvent& mouseEvent) { if (isFocused()) { - setSelected(getSelected() + 1); + if (getSelected() < (getListModel()->getNumberOfElements() - 1)) + setSelected(getSelected() + 1); + else if (getSelected() == (getListModel()->getNumberOfElements() - 1) && + mWrappingEnabled) + setSelected(0); mouseEvent.consume(); } diff --git a/src/gui/widgets/resizegrip.cpp b/src/gui/widgets/resizegrip.cpp index 8c28c20b..799a1e7f 100644 --- a/src/gui/widgets/resizegrip.cpp +++ b/src/gui/widgets/resizegrip.cpp @@ -54,9 +54,7 @@ ResizeGrip::~ResizeGrip() mInstances--; if (mInstances == 0) - { gripImage->decRef(); - } } void ResizeGrip::draw(gcn::Graphics *graphics) diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index de48dfa2..dde455e6 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -377,9 +377,7 @@ void Window::mouseReleased(gcn::MouseEvent &event) void Window::mouseExited(gcn::MouseEvent &event) { if (mGrip && !mouseResize) - { gui->setCursorType(Gui::CURSOR_POINTER); - } } void Window::mouseMoved(gcn::MouseEvent &event) @@ -435,9 +433,7 @@ void Window::mouseDragged(gcn::MouseEvent &event) std::max(mMinWinHeight, newHeight)); if (mouseResize & TOP) - { newDim.y -= newDim.height - getHeight(); - } } if (mouseResize & (LEFT | RIGHT)) @@ -447,9 +443,7 @@ void Window::mouseDragged(gcn::MouseEvent &event) std::max(mMinWinWidth, newWidth)); if (mouseResize & LEFT) - { newDim.x -= newDim.width - getWidth(); - } } // Keep guichan window inside screen (supports resizing any side) |