![]() |
ManaPlus
|
#include <focushandler.h>
Private Types | |
typedef std::vector< Widget * > | WidgetVector |
typedef WidgetVector::iterator | WidgetIterator |
Private Member Functions | |
void | checkForWindow () const |
Static Private Member Functions | |
static void | distributeFocusLostEvent (const Event &focusEvent) |
static void | distributeFocusGainedEvent (const Event &focusEvent) |
Private Attributes | |
WidgetVector | mWidgets |
Widget * | mFocusedWidget |
Widget * | mModalFocusedWidget |
Widget * | mModalMouseInputFocusedWidget |
Widget * | mDraggedWidget |
Widget * | mLastWidgetWithMouse |
Widget * | mLastWidgetWithModalFocus |
Widget * | mLastWidgetWithModalMouseInputFocus |
Widget * | mLastWidgetPressed |
std::list< Widget * > | mModalStack |
The focus handler. This focus handler does exactly the same as the Guichan focus handler, but keeps a stack of modal widgets to be able to handle multiple modal focus requests.
Definition at line 83 of file focushandler.h.
|
private |
Typedef.
Definition at line 353 of file focushandler.h.
|
private |
Typedef.
Definition at line 348 of file focushandler.h.
FocusHandler::FocusHandler | ( | ) |
Definition at line 78 of file focushandler.cpp.
void FocusHandler::add | ( | Widget *const | widget | ) |
Adds a widget to by handles by the focus handler.
widget | The widget to add. |
Definition at line 537 of file focushandler.cpp.
References mWidgets.
Referenced by Widget::setFocusHandler().
|
private |
Checks to see if the widget tabbed to is in a window, and if it is, it requests the window be moved to the top.
Definition at line 316 of file focushandler.cpp.
References Widget::getParent(), mFocusedWidget, and Widget::requestMoveToTop().
Referenced by tabNext(), and tabPrevious().
|
staticprivate |
Distributes a focus gained event.
focusEvent | the event to distribute. |
Definition at line 337 of file focushandler.cpp.
References Gui::distributeGlobalFocusGainedEvent(), Widget::getFocusListeners(), Event::getSource(), and gui.
Referenced by focusNext(), focusPrevious(), requestFocus(), tabNext(), and tabPrevious().
|
staticprivate |
Distributes a focus lost event.
focusEvent | the event to distribute. |
Definition at line 554 of file focushandler.cpp.
References Widget::getFocusListeners(), and Event::getSource().
Referenced by focusNext(), focusNone(), focusPrevious(), requestFocus(), tabNext(), and tabPrevious().
void FocusHandler::focusNext | ( | ) |
Focuses the next widget added to a conainer. If no widget has focus the first widget gets focus. The order in which the widgets are focused is determined by the order they were added to a container.
Definition at line 427 of file focushandler.cpp.
References CAST_S32, distributeFocusGainedEvent(), distributeFocusLostEvent(), mFocusedWidget, and mWidgets.
void FocusHandler::focusNone | ( | ) |
Focuses nothing. A focus event will also be sent to the focused widget's focus listeners if a widget has focus.
Definition at line 542 of file focushandler.cpp.
References distributeFocusLostEvent(), and mFocusedWidget.
Referenced by ChatWindow::action(), Gui::handleKeyInput(), requestModalFocus(), Widget::setFocusable(), Widget::setVisible(), and Window::widgetHidden().
void FocusHandler::focusPrevious | ( | ) |
Focuses the previous widget added to a contaienr. If no widget has focus the first widget gets focus. The order in which the widgets are focused is determined by the order they were added to a container.
Definition at line 477 of file focushandler.cpp.
References CAST_S32, distributeFocusGainedEvent(), distributeFocusLostEvent(), mFocusedWidget, and mWidgets.
Widget * FocusHandler::getDraggedWidget | ( | ) | const |
Gets the widget being dragged. Used by the Gui class to keep track of the dragged widget.
Definition at line 573 of file focushandler.cpp.
References mDraggedWidget.
Referenced by Gui::handleMouseMoved(), Gui::handleMousePressed(), Gui::handleMouseReleased(), Gui::handleMouseWheelMovedDown(), Gui::handleMouseWheelMovedUp(), and Gui::removeDragged().
Widget * FocusHandler::getFocused | ( | ) | const |
Gets the widget with focus.
Definition at line 412 of file focushandler.cpp.
References mFocusedWidget.
Referenced by Gui::getKeyEventSource(), and Gui::handleKeyInput().
Widget * FocusHandler::getLastWidgetPressed | ( | ) | const |
Gets the last widget pressed. Used by the Gui class to keep track of pressed widgets.
Definition at line 613 of file focushandler.cpp.
References mLastWidgetPressed.
Referenced by Gui::handleMouseReleased().
Widget * FocusHandler::getLastWidgetWithModalFocus | ( | ) | const |
Gets the last widget with modal focus.
Definition at line 593 of file focushandler.cpp.
References mLastWidgetWithModalFocus.
Referenced by Gui::handleModalFocus().
Widget * FocusHandler::getLastWidgetWithModalMouseInputFocus | ( | ) | const |
Gets the last widget with modal mouse input focus.
Definition at line 603 of file focushandler.cpp.
References mLastWidgetWithModalMouseInputFocus.
Referenced by Gui::handleModalMouseInputFocus().
Widget * FocusHandler::getLastWidgetWithMouse | ( | ) | const |
Gets the last widget with the mouse. Used by the Gui class to keep track the last widget with the mouse.
Definition at line 583 of file focushandler.cpp.
References mLastWidgetWithMouse.
Widget * FocusHandler::getModalFocused | ( | ) | const |
Gets the widget with modal focus.
Definition at line 417 of file focushandler.cpp.
References mModalFocusedWidget.
Referenced by Gui::distributeKeyEvent(), Gui::distributeMouseEvent(), Gui::handleModalFocus(), Gui::handleMousePressed(), Widget::isModalFocused(), and InputManager::updateConditionMask().
Widget * FocusHandler::getModalMouseInputFocused | ( | ) | const |
Gets the widget with modal mouse input focus.
Definition at line 422 of file focushandler.cpp.
References mModalMouseInputFocusedWidget.
Referenced by Gui::distributeKeyEvent(), Gui::distributeMouseEvent(), Gui::getMouseEventSource(), Gui::handleModalFocusGained(), Gui::handleModalMouseInputFocus(), Gui::handleMouseMoved(), and Widget::isModalMouseInputFocused().
Checks if a widget is focused.
widget | The widget to check. |
Definition at line 532 of file focushandler.cpp.
References mFocusedWidget.
Referenced by Widget::isFocused(), remove(), and Window::widgetHidden().
void FocusHandler::releaseModalFocus | ( | Widget *const | widget | ) |
Releases modal focus if the widget has modal focus. If the widget doesn't have modal focus no relase will occur.
widget | The widget to release modal focus for. |
Definition at line 108 of file focushandler.cpp.
References mModalFocusedWidget, mModalStack, and requestModalFocus().
Referenced by Widget::releaseModalFocus(), and remove().
void FocusHandler::releaseModalMouseInputFocus | ( | const Widget *const | widget | ) |
Releases modal mouse input focus if the widget has modal mouse input focus. If the widget doesn't have modal mouse input focus no relase will occur.
widget | the widget to release modal mouse input focus for. |
Definition at line 406 of file focushandler.cpp.
References mModalMouseInputFocusedWidget.
Referenced by Widget::releaseModalMouseInputFocus().
void FocusHandler::remove | ( | Widget *const | widget | ) |
Removes a widget from the focus handler.
widget | The widget to remove. |
Definition at line 127 of file focushandler.cpp.
References FOR_EACH, isFocused(), mDraggedWidget, mFocusedWidget, mLastWidgetPressed, mLastWidgetWithModalFocus, mLastWidgetWithModalMouseInputFocus, mLastWidgetWithMouse, mWidgets, and releaseModalFocus().
Referenced by Widget::setFocusHandler().
void FocusHandler::requestFocus | ( | const Widget *const | widget | ) |
Requests focus for a widget. Focus will only be granted to a widget if it's focusable and if no other widget has modal focus. If a widget receives focus a focus event will be sent to the focus listeners of the widget.
widget | The widget to request focus for. |
Definition at line 359 of file focushandler.cpp.
References CAST_U32, distributeFocusGainedEvent(), distributeFocusLostEvent(), mFocusedWidget, and mWidgets.
Referenced by ListBox::refocus(), and Widget::requestFocus().
void FocusHandler::requestModalFocus | ( | Widget *const | widget | ) |
Requests modal focus for a widget. Focus will only be granted to a widget if it's focusable and if no other widget has modal focus.
widget | The widget to request modal focus for. |
Exception | when another widget already has modal focus. |
Definition at line 92 of file focushandler.cpp.
References focusNone(), Widget::isModalFocused(), mFocusedWidget, mModalFocusedWidget, and mModalStack.
Referenced by releaseModalFocus(), and Widget::requestModalFocus().
void FocusHandler::requestModalMouseInputFocus | ( | Widget *const | widget | ) |
Requests modal mouse input focus for a widget. Focus will only be granted to a widget if it's focusable and if no other widget has modal mouse input focus.
Modal mouse input focus means no other widget then the widget with modal mouse input focus will receive mouse input. The widget with modal mouse input focus will also receive mouse input no matter what the mouse input is or where the mouse input occurs.
widget | The widget to focus for modal mouse input focus. |
Exception | when another widget already has modal mouse input focus. |
Definition at line 395 of file focushandler.cpp.
References mModalMouseInputFocusedWidget.
Referenced by Widget::requestModalMouseInputFocus().
void FocusHandler::setDraggedWidget | ( | Widget *const | draggedWidget | ) |
Sets the widget being dragged. Used by the Gui class to keep track of the dragged widget.
draggedWidget | The widget being dragged. |
Definition at line 578 of file focushandler.cpp.
References mDraggedWidget.
Referenced by Gui::handleMousePressed(), Gui::handleMouseReleased(), and Gui::removeDragged().
void FocusHandler::setLastWidgetPressed | ( | Widget *const | lastWidgetPressed | ) |
Sets the last widget pressed. Used by the Gui class to keep track of pressed widgets.
lastWidgetPressed | The last widget pressed. |
Definition at line 618 of file focushandler.cpp.
References mLastWidgetPressed.
Referenced by Gui::handleMousePressed(), and Gui::handleMouseReleased().
void FocusHandler::setLastWidgetWithModalFocus | ( | Widget *const | widget | ) |
Sets the last widget with modal focus.
widget | The last widget with modal focus. |
Definition at line 598 of file focushandler.cpp.
References mLastWidgetWithModalFocus.
Referenced by Gui::handleModalFocus().
void FocusHandler::setLastWidgetWithModalMouseInputFocus | ( | Widget *const | widget | ) |
Sets the last widget with modal mouse input focus.
widget | The last widget with modal mouse input focus. |
Definition at line 608 of file focushandler.cpp.
References mLastWidgetWithModalMouseInputFocus.
Referenced by Gui::handleModalFocusGained(), and Gui::handleModalMouseInputFocus().
void FocusHandler::setLastWidgetWithMouse | ( | Widget *const | lastWidgetWithMouse | ) |
Sets the last widget with the mouse. Used by the Gui class to keep track the last widget with the mouse.
lastWidgetWithMouse | The last widget with the mouse. |
Definition at line 588 of file focushandler.cpp.
References mLastWidgetWithMouse.
void FocusHandler::tabNext | ( | ) |
Focuses the next widget which allows tabbing in unless the current focused Widget disallows tabbing out.
Definition at line 174 of file focushandler.cpp.
References CAST_S32, checkForWindow(), distributeFocusGainedEvent(), distributeFocusLostEvent(), Widget::isFocusable(), Widget::isModalFocused(), Widget::isTabInEnabled(), Widget::isTabOutEnabled(), mFocusedWidget, mModalFocusedWidget, and mWidgets.
Referenced by Gui::handleKeyInput().
void FocusHandler::tabPrevious | ( | ) |
Focuses the previous widget which allows tabbing in unless current focused widget disallows tabbing out.
Definition at line 245 of file focushandler.cpp.
References CAST_S32, checkForWindow(), distributeFocusGainedEvent(), distributeFocusLostEvent(), Widget::isFocusable(), Widget::isModalFocused(), Widget::isTabInEnabled(), Widget::isTabOutEnabled(), mFocusedWidget, mModalFocusedWidget, and mWidgets.
Referenced by Gui::handleKeyInput().
|
private |
Holds the dragged widget. NULL if no widget is being dragged.
Definition at line 382 of file focushandler.h.
Referenced by getDraggedWidget(), remove(), and setDraggedWidget().
|
private |
Holds the focused widget. NULL if no widget has focus.
Definition at line 364 of file focushandler.h.
Referenced by checkForWindow(), focusNext(), focusNone(), focusPrevious(), getFocused(), isFocused(), remove(), requestFocus(), requestModalFocus(), tabNext(), and tabPrevious().
|
private |
Holds the last widget pressed.
Definition at line 402 of file focushandler.h.
Referenced by getLastWidgetPressed(), remove(), and setLastWidgetPressed().
|
private |
Holds the last widget with modal focus.
Definition at line 392 of file focushandler.h.
Referenced by getLastWidgetWithModalFocus(), remove(), and setLastWidgetWithModalFocus().
|
private |
Holds the last widget with modal mouse input focus.
Definition at line 397 of file focushandler.h.
Referenced by getLastWidgetWithModalMouseInputFocus(), remove(), and setLastWidgetWithModalMouseInputFocus().
|
private |
Holds the last widget with the mouse.
Definition at line 387 of file focushandler.h.
Referenced by getLastWidgetWithMouse(), remove(), and setLastWidgetWithMouse().
|
private |
Holds the modal focused widget. NULL if no widget has modal focused.
Definition at line 370 of file focushandler.h.
Referenced by getModalFocused(), releaseModalFocus(), requestModalFocus(), tabNext(), and tabPrevious().
|
private |
Holds the modal mouse input focused widget. NULL if no widget is being dragged.
Definition at line 376 of file focushandler.h.
Referenced by getModalMouseInputFocused(), releaseModalMouseInputFocus(), and requestModalMouseInputFocus().
|
private |
Stack of widgets that have requested modal forcus.
Definition at line 407 of file focushandler.h.
Referenced by releaseModalFocus(), and requestModalFocus().
|
private |
Holds the widgets currently being handled by the focus handler.
Definition at line 359 of file focushandler.h.
Referenced by add(), focusNext(), focusPrevious(), remove(), requestFocus(), tabNext(), and tabPrevious().