diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-03-19 18:17:35 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-03-19 18:17:35 +0300 |
commit | 29183043d599655143633daa9f22f310f97a1b54 (patch) | |
tree | f21a42b818a598a7d666d1060c47efadcfade555 /src | |
parent | 349038b1af02729ef04b546826138b432c8fa92e (diff) | |
download | manaverse-29183043d599655143633daa9f22f310f97a1b54.tar.gz manaverse-29183043d599655143633daa9f22f310f97a1b54.tar.bz2 manaverse-29183043d599655143633daa9f22f310f97a1b54.tar.xz manaverse-29183043d599655143633daa9f22f310f97a1b54.zip |
Improve focushandler.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/focushandler.cpp | 41 | ||||
-rw-r--r-- | src/gui/focushandler.h | 36 |
2 files changed, 38 insertions, 39 deletions
diff --git a/src/gui/focushandler.cpp b/src/gui/focushandler.cpp index 928b3b72e..9424bbf29 100644 --- a/src/gui/focushandler.cpp +++ b/src/gui/focushandler.cpp @@ -87,7 +87,7 @@ FocusHandler::FocusHandler() : { } -void FocusHandler::requestModalFocus(Widget *widget) +void FocusHandler::requestModalFocus(Widget *const widget) { /* If there is another widget with modal focus, remove its modal focus * and put it on the modal widget stack. @@ -103,7 +103,7 @@ void FocusHandler::requestModalFocus(Widget *widget) focusNone(); } -void FocusHandler::releaseModalFocus(Widget *widget) +void FocusHandler::releaseModalFocus(Widget *const widget) { mModalStack.remove(widget); @@ -123,15 +123,14 @@ void FocusHandler::releaseModalFocus(Widget *widget) } } -void FocusHandler::remove(Widget *widget) +void FocusHandler::remove(Widget *const widget) { releaseModalFocus(widget); if (isFocused(widget)) mFocusedWidget = nullptr; - for (WidgetIterator iter = mWidgets.begin(); - iter != mWidgets.end(); ++iter) + FOR_EACH (WidgetIterator, iter, mWidgets) { if ((*iter) == widget) { @@ -354,14 +353,14 @@ void FocusHandler::distributeFocusGainedEvent(const Event &focusEvent) } } -void FocusHandler::requestFocus(Widget* widget) +void FocusHandler::requestFocus(Widget *const widget) { if (!widget || widget == mFocusedWidget) return; int toBeFocusedIndex = -1; for (unsigned int i = 0, sz = static_cast<unsigned int>( - mWidgets.size()); i < sz; ++i) + mWidgets.size()); i < sz; ++i) { if (mWidgets[i] == widget) { @@ -390,7 +389,7 @@ void FocusHandler::requestFocus(Widget* widget) } } -void FocusHandler::requestModalMouseInputFocus(Widget* widget) +void FocusHandler::requestModalMouseInputFocus(Widget *const widget) { if (mModalMouseInputFocusedWidget && mModalMouseInputFocusedWidget != widget) @@ -401,7 +400,7 @@ void FocusHandler::requestModalMouseInputFocus(Widget* widget) mModalMouseInputFocusedWidget = widget; } -void FocusHandler::releaseModalMouseInputFocus(Widget* widget) +void FocusHandler::releaseModalMouseInputFocus(Widget *const widget) { if (mModalMouseInputFocusedWidget == widget) mModalMouseInputFocusedWidget = nullptr; @@ -527,12 +526,12 @@ void FocusHandler::focusPrevious() } } -bool FocusHandler::isFocused(const Widget* widget) const +bool FocusHandler::isFocused(const Widget *const widget) const { return mFocusedWidget == widget; } -void FocusHandler::add(Widget* widget) +void FocusHandler::add(Widget *const widget) { mWidgets.push_back(widget); } @@ -566,52 +565,52 @@ void FocusHandler::distributeFocusLostEvent(const Event& focusEvent) } } -Widget* FocusHandler::getDraggedWidget() +Widget* FocusHandler::getDraggedWidget() const { return mDraggedWidget; } -void FocusHandler::setDraggedWidget(Widget* draggedWidget) +void FocusHandler::setDraggedWidget(Widget *const draggedWidget) { mDraggedWidget = draggedWidget; } -Widget* FocusHandler::getLastWidgetWithMouse() +Widget* FocusHandler::getLastWidgetWithMouse() const { return mLastWidgetWithMouse; } -void FocusHandler::setLastWidgetWithMouse(Widget* lastWidgetWithMouse) +void FocusHandler::setLastWidgetWithMouse(Widget *const lastWidgetWithMouse) { mLastWidgetWithMouse = lastWidgetWithMouse; } -Widget* FocusHandler::getLastWidgetWithModalFocus() +Widget* FocusHandler::getLastWidgetWithModalFocus() const { return mLastWidgetWithModalFocus; } -void FocusHandler::setLastWidgetWithModalFocus(Widget* widget) +void FocusHandler::setLastWidgetWithModalFocus(Widget *const widget) { mLastWidgetWithModalFocus = widget; } -Widget* FocusHandler::getLastWidgetWithModalMouseInputFocus() +Widget* FocusHandler::getLastWidgetWithModalMouseInputFocus() const { return mLastWidgetWithModalMouseInputFocus; } -void FocusHandler::setLastWidgetWithModalMouseInputFocus(Widget* widget) +void FocusHandler::setLastWidgetWithModalMouseInputFocus(Widget *const widget) { mLastWidgetWithModalMouseInputFocus = widget; } -Widget* FocusHandler::getLastWidgetPressed() +Widget* FocusHandler::getLastWidgetPressed() const { return mLastWidgetPressed; } -void FocusHandler::setLastWidgetPressed(Widget* lastWidgetPressed) +void FocusHandler::setLastWidgetPressed(Widget *const lastWidgetPressed) { mLastWidgetPressed = lastWidgetPressed; } diff --git a/src/gui/focushandler.h b/src/gui/focushandler.h index f12819e75..58b317024 100644 --- a/src/gui/focushandler.h +++ b/src/gui/focushandler.h @@ -97,7 +97,7 @@ class FocusHandler final * @param widget The widget to request focus for. * @see isFocused, Widget::requestFocus */ - void requestFocus(Widget* widget); + void requestFocus(Widget *const widget); /** * Requests modal focus for a widget. Focus will only be granted @@ -108,7 +108,7 @@ class FocusHandler final * @throws Exception when another widget already has modal focus. * @see releaseModalFocus, Widget::requestModalFocus */ - void requestModalFocus(Widget* widget); + void requestModalFocus(Widget *const widget); /** * Requests modal mouse input focus for a widget. Focus will only @@ -125,7 +125,7 @@ class FocusHandler final * focus. * @see releaseModalMouseInputFocus, Widget::requestModalMouseInputFocus */ - void requestModalMouseInputFocus(Widget* widget); + void requestModalMouseInputFocus(Widget *const widget); /** * Releases modal focus if the widget has modal focus. @@ -134,7 +134,7 @@ class FocusHandler final * @param widget The widget to release modal focus for. * @see reuqestModalFocus, Widget::releaseModalFocus */ - void releaseModalFocus(Widget* widget); + void releaseModalFocus(Widget *const widget); /** * Releases modal mouse input focus if the widget has modal mouse input @@ -144,7 +144,7 @@ class FocusHandler final * @param widget the widget to release modal mouse input focus for. * @see requestModalMouseInputFocus, Widget::releaseModalMouseInputFocus */ - void releaseModalMouseInputFocus(Widget* widget); + void releaseModalMouseInputFocus(Widget *const widget); /** * Checks if a widget is focused. @@ -153,7 +153,7 @@ class FocusHandler final * @return True if the widget is focused, false otherwise. * @see Widget::isFocused */ - bool isFocused(const Widget* widget) const; + bool isFocused(const Widget *const widget) const; /** * Gets the widget with focus. @@ -204,7 +204,7 @@ class FocusHandler final * @param widget The widget to add. * @see remove */ - void add(Widget* widget); + void add(Widget *const widget); /** * Removes a widget from the focus handler. @@ -212,7 +212,7 @@ class FocusHandler final * @param widget The widget to remove. * @see add */ - void remove(Widget* widget); + void remove(Widget *const widget); /** * Focuses nothing. A focus event will also be sent to the @@ -243,7 +243,7 @@ class FocusHandler final * @return the widget being dragged. * @see setDraggedWidget */ - Widget* getDraggedWidget() A_WARN_UNUSED; + Widget* getDraggedWidget() const A_WARN_UNUSED; /** * Sets the widget being dragged. Used by the Gui class to @@ -252,7 +252,7 @@ class FocusHandler final * @param draggedWidget The widget being dragged. * @see getDraggedWidget */ - void setDraggedWidget(Widget* draggedWidget); + void setDraggedWidget(Widget *const draggedWidget); /** * Gets the last widget with the mouse. Used by the Gui class @@ -261,7 +261,7 @@ class FocusHandler final * @return The last widget with the mouse. * @see setLastWidgetWithMouse */ - Widget* getLastWidgetWithMouse() A_WARN_UNUSED; + Widget* getLastWidgetWithMouse() const A_WARN_UNUSED; /** * Sets the last widget with the mouse. Used by the Gui class @@ -270,7 +270,7 @@ class FocusHandler final * @param lastWidgetWithMouse The last widget with the mouse. * @see getLastWidgetWithMouse */ - void setLastWidgetWithMouse(Widget* lastWidgetWithMouse); + void setLastWidgetWithMouse(Widget *const lastWidgetWithMouse); /** * Gets the last widget with modal focus. @@ -278,7 +278,7 @@ class FocusHandler final * @return The last widget with modal focus. * @see setLastWidgetWithModalFocus */ - Widget* getLastWidgetWithModalFocus() A_WARN_UNUSED; + Widget* getLastWidgetWithModalFocus() const A_WARN_UNUSED; /** * Sets the last widget with modal focus. @@ -286,7 +286,7 @@ class FocusHandler final * @param widget The last widget with modal focus. * @see getLastWidgetWithModalFocus */ - void setLastWidgetWithModalFocus(Widget* widget); + void setLastWidgetWithModalFocus(Widget *const widget); /** * Gets the last widget with modal mouse input focus. @@ -294,7 +294,7 @@ class FocusHandler final * @return The last widget with modal mouse input focus. * @see setLastWidgetWithModalMouseInputFocus */ - Widget* getLastWidgetWithModalMouseInputFocus() A_WARN_UNUSED; + Widget* getLastWidgetWithModalMouseInputFocus() const A_WARN_UNUSED; /** * Sets the last widget with modal mouse input focus. @@ -302,7 +302,7 @@ class FocusHandler final * @param widget The last widget with modal mouse input focus. * @see getLastWidgetWithModalMouseInputFocus */ - void setLastWidgetWithModalMouseInputFocus(Widget* widget); + void setLastWidgetWithModalMouseInputFocus(Widget *const widget); /** * Gets the last widget pressed. Used by the Gui class to keep track @@ -311,7 +311,7 @@ class FocusHandler final * @return The last widget pressed. * @see setLastWidgetPressed */ - Widget* getLastWidgetPressed() A_WARN_UNUSED; + Widget* getLastWidgetPressed() const A_WARN_UNUSED; /** * Sets the last widget pressed. Used by the Gui class to keep track @@ -320,7 +320,7 @@ class FocusHandler final * @param lastWidgetPressed The last widget pressed. * @see getLastWidgetPressed */ - void setLastWidgetPressed(Widget* lastWidgetPressed); + void setLastWidgetPressed(Widget *const lastWidgetPressed); private: /** |