ManaPlus
focushandler.h
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2004-2009 The Mana World Development Team
4  * Copyright (C) 2009-2010 The Mana Developers
5  * Copyright (C) 2011-2019 The ManaPlus Developers
6  * Copyright (C) 2019-2021 Andrei Karas
7  *
8  * This file is part of The ManaPlus Client.
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  */
23 
24 /* _______ __ __ __ ______ __ __ _______ __ __
25  * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
26  * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
27  * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
28  * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
29  * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
30  * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
31  *
32  * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
33  *
34  *
35  * Per Larsson a.k.a finalman
36  * Olof Naessén a.k.a jansem/yakslem
37  *
38  * Visit: http://guichan.sourceforge.net
39  *
40  * License: (BSD)
41  * Redistribution and use in source and binary forms, with or without
42  * modification, are permitted provided that the following conditions
43  * are met:
44  * 1. Redistributions of source code must retain the above copyright
45  * notice, this list of conditions and the following disclaimer.
46  * 2. Redistributions in binary form must reproduce the above copyright
47  * notice, this list of conditions and the following disclaimer in
48  * the documentation and/or other materials provided with the
49  * distribution.
50  * 3. Neither the name of Guichan nor the names of its contributors may
51  * be used to endorse or promote products derived from this software
52  * without specific prior written permission.
53  *
54  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
55  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
56  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
57  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
58  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
59  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
60  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
61  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
62  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
63  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
64  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
65  */
66 
67 #ifndef GUI_FOCUSHANDLER_H
68 #define GUI_FOCUSHANDLER_H
69 
70 #include "utils/vector.h"
71 
72 #include <list>
73 
74 #include "localconsts.h"
75 
76 class Event;
77 class Widget;
78 
85 {
86  public:
87  FocusHandler();
88 
90 
91 
100  void requestFocus(const Widget *const widget);
101 
111  void requestModalFocus(Widget *const widget);
112 
128  void requestModalMouseInputFocus(Widget *const widget);
129 
137  void releaseModalFocus(Widget *const widget);
138 
147  void releaseModalMouseInputFocus(const Widget *const widget);
148 
156  bool isFocused(const Widget *const widget) const;
157 
164 
172 
180 
189  void focusNext();
190 
199  void focusPrevious();
200 
207  void add(Widget *const widget);
208 
215  void remove(Widget *const widget);
216 
221  void focusNone();
222 
229  void tabNext();
230 
237  void tabPrevious();
238 
247 
255  void setDraggedWidget(Widget *const draggedWidget);
256 
265 
273  void setLastWidgetWithMouse(Widget *const lastWidgetWithMouse);
274 
282 
289  void setLastWidgetWithModalFocus(Widget *const widget);
290 
298 
305  void setLastWidgetWithModalMouseInputFocus(Widget *const widget);
306 
315 
323  void setLastWidgetPressed(Widget *const lastWidgetPressed);
324 
325  private:
330  void checkForWindow() const;
331 
337  static void distributeFocusLostEvent(const Event& focusEvent);
338 
344  static void distributeFocusGainedEvent(const Event& focusEvent);
345 
349  typedef STD_VECTOR<Widget*> WidgetVector;
350 
354  typedef WidgetVector::iterator WidgetIterator;
355 
361 
366 
372 
378 
384 
389 
394 
399 
404 
408  std::list<Widget*> mModalStack;
409 };
410 
411 #endif // GUI_FOCUSHANDLER_H
Definition: event.h:79
static void distributeFocusGainedEvent(const Event &focusEvent)
void setLastWidgetWithModalFocus(Widget *const widget)
static void distributeFocusLostEvent(const Event &focusEvent)
void add(Widget *const widget)
void checkForWindow() const
void requestModalFocus(Widget *const widget)
Widget * mLastWidgetWithMouse
Definition: focushandler.h:388
void tabPrevious()
Widget * mLastWidgetWithModalFocus
Definition: focushandler.h:393
Widget * getLastWidgetWithModalMouseInputFocus() const
Widget * getModalMouseInputFocused() const
Widget * mFocusedWidget
Definition: focushandler.h:365
Widget * getDraggedWidget() const
Widget * mModalMouseInputFocusedWidget
Definition: focushandler.h:377
void requestModalMouseInputFocus(Widget *const widget)
void requestFocus(const Widget *const widget)
Widget * mModalFocusedWidget
Definition: focushandler.h:371
void setLastWidgetWithMouse(Widget *const lastWidgetWithMouse)
Widget * getFocused() const
void releaseModalMouseInputFocus(const Widget *const widget)
Widget * getLastWidgetPressed() const
Widget * mLastWidgetPressed
Definition: focushandler.h:403
std::list< Widget * > mModalStack
Definition: focushandler.h:408
WidgetVector::iterator WidgetIterator
Definition: focushandler.h:354
void releaseModalFocus(Widget *const widget)
Widget * mDraggedWidget
Definition: focushandler.h:383
Widget * mLastWidgetWithModalMouseInputFocus
Definition: focushandler.h:398
void remove(Widget *const widget)
void focusPrevious()
std::vector< Widget * > WidgetVector
Definition: focushandler.h:349
void setLastWidgetWithModalMouseInputFocus(Widget *const widget)
void setDraggedWidget(Widget *const draggedWidget)
Widget * getLastWidgetWithMouse() const
WidgetVector mWidgets
Definition: focushandler.h:360
Widget * getModalFocused() const
bool isFocused(const Widget *const widget) const
Widget * getLastWidgetWithModalFocus() const
void setLastWidgetPressed(Widget *const lastWidgetPressed)
Definition: widget.h:99
#define A_WARN_UNUSED
Definition: localconsts.h:161
#define final
Definition: localconsts.h:46
#define A_DELETE_COPY(func)
Definition: localconsts.h:53