ManaPlus
src
gui
widgets
chatinput.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
#ifndef GUI_WIDGETS_CHATINPUT_H
25
#define GUI_WIDGETS_CHATINPUT_H
26
27
#include "
gui/windows/chatwindow.h
"
28
29
#include "
configuration.h
"
30
31
#include "
gui/windows/emotewindow.h
"
32
33
#include "
gui/widgets/textfield.h
"
34
35
#include "
localconsts.h
"
36
40
class
ChatInput
final
:
public
TextField
41
{
42
public
:
43
explicit
ChatInput
(
ChatWindow
*
const
window) :
44
TextField
(window,
std
::string(),
45
LoseFocusOnTab_false
,
nullptr
,
std
::string(), false),
46
mWindow
(window),
47
mFocusGaining
(false)
48
{
49
setVisible
(
Visible_false
);
50
addFocusListener
(
this
);
51
}
52
53
A_DELETE_COPY
(
ChatInput
)
54
55
59
void
focusLost
(const
Event
&event)
override
final
60
{
61
TextField::focusLost
(event);
62
if
(
mFocusGaining
|| !
config
.
getBoolValue
(
"protectChatFocus"
))
63
{
64
processVisible
(
Visible_false
);
65
if
(
chatWindow
!=
nullptr
)
66
chatWindow
->
updateVisibility
();
67
mFocusGaining
=
false
;
68
return
;
69
}
70
mFocusGaining
=
true
;
71
requestFocus
();
72
mFocusGaining
=
false
;
73
}
74
75
void
processVisible
(
const
Visible
n)
76
{
77
if
(
mWindow
==
nullptr
||
isVisible
() == (n ==
Visible_true
))
78
return
;
79
80
if
(n ==
Visible_false
)
81
mFocusGaining
=
true
;
82
setVisible
(n);
83
if
(
config
.
getBoolValue
(
"hideChatInput"
)
84
||
config
.
getBoolValue
(
"showEmotesButton"
))
85
{
86
mWindow
->
adjustTabSize
();
87
}
88
if
(
emoteWindow
!=
nullptr
)
89
{
90
emoteWindow
->
hide
();
91
}
92
}
93
94
void
unprotectFocus
()
95
{
mFocusGaining
=
true
; }
96
97
void
setVisible
(
Visible
visible)
98
{
99
TextField::setVisible
(visible);
100
}
101
102
private
:
103
ChatWindow
*
mWindow
;
104
bool
mFocusGaining
;
105
};
106
107
#endif
// GUI_WIDGETS_CHATINPUT_H
chatWindow
ChatWindow * chatWindow
Definition:
chatwindow.cpp:94
chatwindow.h
ChatInput
Definition:
chatinput.h:41
ChatInput::unprotectFocus
void unprotectFocus()
Definition:
chatinput.h:94
ChatInput::processVisible
void processVisible(const Visible n)
Definition:
chatinput.h:75
ChatInput::setVisible
void setVisible(Visible visible)
Definition:
chatinput.h:97
ChatInput::focusLost
void focusLost(const Event &event)
Definition:
chatinput.h:59
ChatInput::mFocusGaining
bool mFocusGaining
Definition:
chatinput.h:104
ChatInput::ChatInput
ChatInput(ChatWindow *const window)
Definition:
chatinput.h:43
ChatInput::mWindow
ChatWindow * mWindow
Definition:
chatinput.h:103
ChatWindow
Definition:
chatwindow.h:61
ChatWindow::updateVisibility
void updateVisibility()
Definition:
chatwindow.cpp:2118
ChatWindow::adjustTabSize
void adjustTabSize()
Definition:
chatwindow.cpp:281
Configuration::getBoolValue
bool getBoolValue(const std::string &key) const
Definition:
configuration.cpp:597
EmoteWindow::hide
void hide()
Definition:
emotewindow.cpp:181
Event
Definition:
event.h:79
TextField
Definition:
textfield.h:93
TextField::focusLost
void focusLost(const Event &event)
Definition:
textfield.cpp:799
Widget::setVisible
void setVisible(Visible visible)
Definition:
widget.cpp:225
Widget::requestFocus
virtual void requestFocus()
Definition:
widget.cpp:204
Widget::addFocusListener
void addFocusListener(FocusListener *const focusListener)
Definition:
widget.cpp:282
Widget::isVisible
bool isVisible() const
Definition:
widget.h:378
config
Configuration config
Definition:
configuration.cpp:52
configuration.h
emoteWindow
EmoteWindow * emoteWindow
Definition:
emotewindow.cpp:49
emotewindow.h
localconsts.h
override
#define override
Definition:
localconsts.h:47
final
#define final
Definition:
localconsts.h:46
A_DELETE_COPY
#define A_DELETE_COPY(func)
Definition:
localconsts.h:53
nullptr
#define nullptr
Definition:
localconsts.h:45
LoseFocusOnTab_false
const bool LoseFocusOnTab_false
Definition:
losefocusontab.h:30
std
Definition:
mseprimitives.h:398
textfield.h
Visible
bool Visible
Definition:
visible.h:30
Visible_false
const bool Visible_false
Definition:
visible.h:30
Visible_true
const bool Visible_true
Definition:
visible.h:30
Generated on Wed Mar 17 2021 19:19:06 for ManaPlus by
1.9.1