ManaPlus
src
gui
widgets
radiobutton.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_WIDGETS_RADIOBUTTON_H
68
#define GUI_WIDGETS_RADIOBUTTON_H
69
70
#include "
listeners/keylistener.h
"
71
#include "
listeners/mouselistener.h
"
72
#include "
listeners/widgetlistener.h
"
73
74
#include "
gui/fonts/textchunk.h
"
75
76
#include "
gui/widgets/widget.h
"
77
78
#include "
localconsts.h
"
79
80
class
Skin
;
81
85
class
RadioButton
final
:
public
Widget
,
86
public
MouseListener
,
87
public
KeyListener
,
88
public
WidgetListener
89
90
{
91
public
:
95
RadioButton
(
const
Widget2
*
const
widget,
96
const
std::string &
restrict
caption,
97
const
std::string &
restrict
group,
98
const
bool
marked);
99
100
A_DELETE_COPY
(
RadioButton
)
101
102
105
~RadioButton
()
override
final
;
106
110
void
drawBox
(
Graphics
*
const
graphics)
A_NONNULL
(2);
111
116
void
draw
(
Graphics
*
const
graphics)
override
final
A_NONNULL
(2);
117
118
void
safeDraw
(
Graphics
*
const
graphics)
override
final
A_NONNULL
(2);
119
123
void
mouseEntered
(
MouseEvent
& event)
override
final
;
124
128
void
mouseExited
(
MouseEvent
& event)
override
final
;
129
130
void
keyPressed
(
KeyEvent
& event)
override
final
;
131
132
void
updateAlpha
();
133
134
void
adjustSize
();
135
142
bool
isSelected
()
const
143
{
return
mSelected
; }
144
152
void
setSelected
(
const
bool
selected);
153
160
const
std::string &
getCaption
()
const
161
{
return
mCaption
; }
162
171
void
setCaption
(
const
std::string &caption);
172
173
void
mouseClicked
(
MouseEvent
& event)
override
final
;
174
175
void
mouseDragged
(
MouseEvent
& event)
override
final
;
176
185
void
setGroup
(
const
std::string &group);
186
193
const
std::string &
getGroup
()
const
194
{
return
mGroup
; }
195
196
void
setParent
(
Widget
*widget)
override
final
;
197
198
void
widgetHidden
(
const
Event
&event)
override
final
;
199
200
void
setWindow
(
Widget
*
const
widget)
override
final
;
201
202
private
:
203
static
int
instances
;
204
static
Skin
*
mSkin
;
205
static
float
mAlpha
;
206
210
bool
mSelected
;
211
215
std::string
mCaption
;
216
220
std::string
mGroup
;
221
222
TextChunk
mTextChunk
;
223
227
typedef
std::multimap<std::string, RadioButton *>
GroupMap
;
228
232
typedef
GroupMap::iterator
GroupIterator
;
233
237
static
GroupMap
mGroupMap
;
238
239
int
mPadding
;
240
int
mImagePadding
;
241
int
mImageSize
;
242
int
mSpacing
;
243
int
mTextX
;
244
bool
mHasMouse
;
245
bool
mTextChanged
;
246
};
247
248
#endif
// GUI_WIDGETS_RADIOBUTTON_H
Event
Definition:
event.h:79
Graphics
Definition:
graphics.h:109
KeyEvent
Definition:
keyevent.h:86
KeyListener
Definition:
keylistener.h:80
MouseEvent
Definition:
mouseevent.h:81
MouseListener
Definition:
mouselistener.h:78
RadioButton
Definition:
radiobutton.h:90
RadioButton::setGroup
void setGroup(const std::string &group)
Definition:
radiobutton.cpp:323
RadioButton::RadioButton
RadioButton(const Widget2 *const widget, const std::string &caption, const std::string &group, const bool marked)
Definition:
radiobutton.cpp:90
RadioButton::getGroup
const std::string & getGroup() const
Definition:
radiobutton.h:193
RadioButton::drawBox
void drawBox(Graphics *const graphics)
Definition:
radiobutton.cpp:187
RadioButton::mPadding
int mPadding
Definition:
radiobutton.h:239
RadioButton::mAlpha
static float mAlpha
Definition:
radiobutton.h:205
RadioButton::mTextChunk
TextChunk mTextChunk
Definition:
radiobutton.h:222
RadioButton::safeDraw
void safeDraw(Graphics *const graphics)
Definition:
radiobutton.cpp:257
RadioButton::mouseDragged
void mouseDragged(MouseEvent &event)
Definition:
radiobutton.cpp:318
RadioButton::~RadioButton
~RadioButton()
Definition:
radiobutton.cpp:147
RadioButton::mSkin
static Skin * mSkin
Definition:
radiobutton.h:204
RadioButton::setSelected
void setSelected(const bool selected)
Definition:
radiobutton.cpp:291
RadioButton::getCaption
const std::string & getCaption() const
Definition:
radiobutton.h:160
RadioButton::mSpacing
int mSpacing
Definition:
radiobutton.h:242
RadioButton::mGroup
std::string mGroup
Definition:
radiobutton.h:220
RadioButton::setWindow
void setWindow(Widget *const widget)
Definition:
radiobutton.cpp:366
RadioButton::updateAlpha
void updateAlpha()
Definition:
radiobutton.cpp:166
RadioButton::GroupIterator
GroupMap::iterator GroupIterator
Definition:
radiobutton.h:232
RadioButton::setParent
void setParent(Widget *widget)
Definition:
radiobutton.cpp:353
RadioButton::widgetHidden
void widgetHidden(const Event &event)
Definition:
radiobutton.cpp:360
RadioButton::mImagePadding
int mImagePadding
Definition:
radiobutton.h:240
RadioButton::isSelected
bool isSelected() const
Definition:
radiobutton.h:142
RadioButton::adjustSize
void adjustSize()
Definition:
radiobutton.cpp:283
RadioButton::mTextX
int mTextX
Definition:
radiobutton.h:243
RadioButton::mCaption
std::string mCaption
Definition:
radiobutton.h:215
RadioButton::mGroupMap
static GroupMap mGroupMap
Definition:
radiobutton.h:237
RadioButton::draw
void draw(Graphics *const graphics)
Definition:
radiobutton.cpp:232
RadioButton::mSelected
bool mSelected
Definition:
radiobutton.h:210
RadioButton::mouseClicked
void mouseClicked(MouseEvent &event)
Definition:
radiobutton.cpp:308
RadioButton::mouseEntered
void mouseEntered(MouseEvent &event)
Definition:
radiobutton.cpp:262
RadioButton::mImageSize
int mImageSize
Definition:
radiobutton.h:241
RadioButton::keyPressed
void keyPressed(KeyEvent &event)
Definition:
radiobutton.cpp:272
RadioButton::instances
static int instances
Definition:
radiobutton.h:203
RadioButton::GroupMap
std::multimap< std::string, RadioButton * > GroupMap
Definition:
radiobutton.h:227
RadioButton::mHasMouse
bool mHasMouse
Definition:
radiobutton.h:244
RadioButton::mouseExited
void mouseExited(MouseEvent &event)
Definition:
radiobutton.cpp:267
RadioButton::setCaption
void setCaption(const std::string &caption)
Definition:
radiobutton.cpp:346
RadioButton::mTextChanged
bool mTextChanged
Definition:
radiobutton.h:245
Skin
Definition:
skin.h:37
TextChunk
Definition:
textchunk.h:43
Widget2
Definition:
widget2.h:37
WidgetListener
Definition:
widgetlistener.h:81
Widget
Definition:
widget.h:99
keylistener.h
localconsts.h
restrict
#define restrict
Definition:
localconsts.h:165
A_NONNULL
#define A_NONNULL(...)
Definition:
localconsts.h:168
final
#define final
Definition:
localconsts.h:46
A_DELETE_COPY
#define A_DELETE_COPY(func)
Definition:
localconsts.h:53
mouselistener.h
textchunk.h
widget.h
widgetlistener.h
Generated on Wed Mar 17 2021 19:19:06 for ManaPlus by
1.9.1